public void writeExternalUtil(
      @NotNull Element element, @NotNull OptionsAndConfirmations optionsAndConfirmations)
      throws WriteExternalException {
    final Map<String, VcsShowOptionsSettingImpl> options = optionsAndConfirmations.getOptions();
    final Map<String, VcsShowConfirmationOptionImpl> confirmations =
        optionsAndConfirmations.getConfirmations();

    for (VcsShowOptionsSettingImpl setting : options.values()) {
      if (!Registry.is("saving.state.in.new.format.is.allowed", false) || !setting.getValue()) {
        Element settingElement = new Element(OPTIONS_SETTING);
        element.addContent(settingElement);
        settingElement.setAttribute(VALUE_ATTTIBUTE, Boolean.toString(setting.getValue()));
        settingElement.setAttribute(ID_ATTRIBUTE, setting.getDisplayName());
      }
    }

    for (VcsShowConfirmationOptionImpl setting : confirmations.values()) {
      if (!Registry.is("saving.state.in.new.format.is.allowed", false)
          || setting.getValue() != VcsShowConfirmationOption.Value.SHOW_CONFIRMATION) {
        final Element settingElement = new Element(CONFIRMATIONS_SETTING);
        element.addContent(settingElement);
        settingElement.setAttribute(VALUE_ATTTIBUTE, setting.getValue().toString());
        settingElement.setAttribute(ID_ATTRIBUTE, setting.getDisplayName());
      }
    }
  }
  @Override
  public void initComponent() {
    myMode = Registry.get("ide.tooltip.mode");

    myIsEnabled = Registry.get("ide.tooltip.callout");
    myIsEnabled.addListener(
        new RegistryValueListener.Adapter() {
          @Override
          public void afterValueChanged(RegistryValue value) {
            processEnabled();
          }
        },
        ApplicationManager.getApplication());

    Toolkit.getDefaultToolkit()
        .addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);

    ActionManager.getInstance()
        .addAnActionListener(
            new AnActionListener.Adapter() {
              @Override
              public void beforeActionPerformed(
                  AnAction action, DataContext dataContext, AnActionEvent event) {
                hideCurrent(null, action, event);
              }
            },
            ApplicationManager.getApplication());

    processEnabled();
  }
  @Override
  public UIDefaults getDefaults() {
    try {
      final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
      superMethod.setAccessible(true);
      final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());

      final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
      if (SystemInfo.isLinux) {
        if (!Registry.is("darcula.use.native.fonts.on.linux")) {
          Font font = findFont("DejaVu Sans");
          if (font != null) {
            for (Object key : defaults.keySet()) {
              if (key instanceof String && ((String) key).endsWith(".font")) {
                defaults.put(key, new FontUIResource(font.deriveFont(13f)));
              }
            }
          }
        } else if (Arrays.asList("CN", "JP", "KR", "TW")
            .contains(Locale.getDefault().getCountry())) {
          for (Object key : defaults.keySet()) {
            if (key instanceof String && ((String) key).endsWith(".font")) {
              final Font font = defaults.getFont(key);
              if (font != null) {
                defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
              }
            }
          }
        }
      }

      LafManagerImpl.initInputMapDefaults(defaults);
      initIdeaDefaults(defaults);
      patchStyledEditorKit(defaults);
      patchComboBox(metalDefaults, defaults);
      defaults.remove("Spinner.arrowButtonBorder");
      defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
      MetalLookAndFeel.setCurrentTheme(createMetalTheme());
      if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
      }
      if (SystemInfo.isLinux && JBUI.isHiDPI()) {
        applySystemFonts(defaults);
      }
      defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
      return defaults;
    } catch (Exception e) {
      log(e);
    }
    return super.getDefaults();
  }
Example #4
0
  @Override
  public JComponent createComponent() {
    myComponent = new MyPanel();

    mySplitter = new JBSplitter(false, .15f);
    mySplitter.setSplitterProportionKey("ProjectStructure.TopLevelElements");
    mySplitter.setHonorComponentsMinimumSize(true);
    if (Registry.is("ide.new.project.settings")) {
      mySplitter.setOnePixelMode();
    }

    initSidePanel();

    final JPanel left =
        new JPanel(new BorderLayout()) {
          @Override
          public Dimension getMinimumSize() {
            final Dimension original = super.getMinimumSize();
            return new Dimension(Math.max(original.width, 100), original.height);
          }
        };

    final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
    toolbarGroup.add(new BackAction(myComponent));
    toolbarGroup.add(new ForwardAction(myComponent));
    final ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarGroup, true);
    toolbar.setTargetComponent(myComponent);
    myToolbarComponent = toolbar.getComponent();
    if (Registry.is("ide.new.project.settings")) {
      left.setBackground(UIUtil.getSidePanelColor());
    } else {
      left.add(myToolbarComponent, BorderLayout.NORTH);
    }
    left.add(mySidePanel, BorderLayout.CENTER);

    mySplitter.setFirstComponent(left);
    mySplitter.setSecondComponent(myDetails);

    myComponent.add(mySplitter, BorderLayout.CENTER);
    myErrorsComponent = new ConfigurationErrorsComponent(myProject);
    if (!Registry.is("ide.new.project.settings")) {
      myComponent.add(myErrorsComponent, BorderLayout.SOUTH);
    }

    myUiInitialized = true;

    return myComponent;
  }
  private void hideCurrentNow(boolean animationEnabled) {
    if (myCurrentTipUi != null) {
      myCurrentTipUi.setAnimationEnabled(animationEnabled);
      myCurrentTipUi.hide();
      myCurrentTooltip.onHidden();
      myShowDelay = false;
      myAlarm.addRequest(
          new Runnable() {
            @Override
            public void run() {
              myShowDelay = true;
            }
          },
          Registry.intValue("ide.tooltip.reshowDelay"));
    }

    myShowRequest = null;
    myCurrentTooltip = null;
    myCurrentTipUi = null;
    myCurrentComponent = null;
    myQueuedComponent = null;
    myQueuedTooltip = null;
    myCurrentEvent = null;
    myCurrentTipIsCentered = false;
    myX = -1;
    myY = -1;
  }
 protected void doRun(
     @NotNull final ExecutionEnvironment environment, @NotNull final Runnable startRunnable) {
   Boolean allowSkipRun = environment.getUserData(EXECUTION_SKIP_RUN);
   if (allowSkipRun != null && allowSkipRun) {
     environment
         .getProject()
         .getMessageBus()
         .syncPublisher(EXECUTION_TOPIC)
         .processNotStarted(environment.getExecutor().getId(), environment);
   } else {
     // important! Do not use DumbService.smartInvokeLater here because it depends on modality
     // state
     // and execution of startRunnable could be skipped if modality state check fails
     //noinspection SSBasedInspection
     SwingUtilities.invokeLater(
         () -> {
           if (!myProject.isDisposed()) {
             if (!Registry.is("dumb.aware.run.configurations")) {
               DumbService.getInstance(myProject).runWhenSmart(startRunnable);
             } else {
               try {
                 DumbService.getInstance(myProject).setAlternativeResolveEnabled(true);
                 startRunnable.run();
               } catch (IndexNotReadyException ignored) {
                 ExecutionUtil.handleExecutionError(
                     environment,
                     new ExecutionException("cannot start while indexing is in progress."));
               } finally {
                 DumbService.getInstance(myProject).setAlternativeResolveEnabled(false);
               }
             }
           }
         });
   }
 }
  @Override
  public void reset() {
    initComponent();
    UISettings settings = UISettings.getInstance();

    myComponent.myFontCombo.setSelectedItem(settings.FONT_FACE);

    // todo migrate
    // myComponent.myAntialiasingCheckBox.setSelected(settings.ANTIALIASING_IN_IDE);
    // myComponent.myLCDRenderingScopeCombo.setSelectedItem(settings.LCD_RENDERING_SCOPE);

    myComponent.myAntialiasingInIDE.setSelectedItem(settings.IDE_AA_TYPE);
    myComponent.myAntialiasingInEditor.setSelectedItem(settings.EDITOR_AA_TYPE);

    myComponent.myFontSizeCombo.setSelectedItem(Integer.toString(settings.FONT_SIZE));
    myComponent.myPresentationModeFontSize.setSelectedItem(
        Integer.toString(settings.PRESENTATION_MODE_FONT_SIZE));
    myComponent.myAnimateWindowsCheckBox.setSelected(settings.ANIMATE_WINDOWS);
    myComponent.myWindowShortcutsCheckBox.setSelected(settings.SHOW_TOOL_WINDOW_NUMBERS);
    myComponent.myShowToolStripesCheckBox.setSelected(!settings.HIDE_TOOL_STRIPES);
    myComponent.myCbDisplayIconsInMenu.setSelected(settings.SHOW_ICONS_IN_MENUS);
    myComponent.myShowMemoryIndicatorCheckBox.setSelected(settings.SHOW_MEMORY_INDICATOR);
    myComponent.myAllowMergeButtons.setSelected(settings.ALLOW_MERGE_BUTTONS);
    myComponent.myCycleScrollingCheckBox.setSelected(settings.CYCLE_SCROLLING);

    myComponent.myHideIconsInQuickNavigation.setSelected(settings.SHOW_ICONS_IN_QUICK_NAVIGATION);
    myComponent.myMoveMouseOnDefaultButtonCheckBox.setSelected(
        settings.MOVE_MOUSE_ON_DEFAULT_BUTTON);
    myComponent.myHideNavigationPopupsCheckBox.setSelected(settings.HIDE_NAVIGATION_ON_FOCUS_LOSS);
    myComponent.myAltDNDCheckBox.setSelected(settings.DND_WITH_PRESSED_ALT_ONLY);
    myComponent.myLafComboBox.setSelectedItem(LafManager.getInstance().getCurrentLookAndFeel());
    myComponent.myOverrideLAFFonts.setSelected(settings.OVERRIDE_NONIDEA_LAF_FONTS);
    myComponent.myDisableMnemonics.setSelected(settings.DISABLE_MNEMONICS);
    myComponent.myUseSmallLabelsOnTabs.setSelected(settings.USE_SMALL_LABELS_ON_TABS);
    myComponent.myWidescreenLayoutCheckBox.setSelected(settings.WIDESCREEN_SUPPORT);
    myComponent.myLeftLayoutCheckBox.setSelected(settings.LEFT_HORIZONTAL_SPLIT);
    myComponent.myRightLayoutCheckBox.setSelected(settings.RIGHT_HORIZONTAL_SPLIT);
    myComponent.myNavigateToPreviewCheckBox.setSelected(settings.NAVIGATE_TO_PREVIEW);
    myComponent.myNavigateToPreviewCheckBox.setVisible(false); // disabled for a while
    myComponent.myColorBlindnessPanel.setColorBlindness(settings.COLOR_BLINDNESS);
    myComponent.myDisableMnemonicInControlsCheckBox.setSelected(
        settings.DISABLE_MNEMONICS_IN_CONTROLS);

    boolean alphaModeEnabled = WindowManagerEx.getInstanceEx().isAlphaModeSupported();
    if (alphaModeEnabled) {
      myComponent.myEnableAlphaModeCheckBox.setSelected(settings.ENABLE_ALPHA_MODE);
    } else {
      myComponent.myEnableAlphaModeCheckBox.setSelected(false);
    }
    myComponent.myEnableAlphaModeCheckBox.setEnabled(alphaModeEnabled);
    myComponent.myAlphaModeDelayTextField.setText(Integer.toString(settings.ALPHA_MODE_DELAY));
    myComponent.myAlphaModeDelayTextField.setEnabled(
        alphaModeEnabled && settings.ENABLE_ALPHA_MODE);
    int ratio = (int) (settings.ALPHA_MODE_RATIO * 100f);
    myComponent.myAlphaModeRatioSlider.setValue(ratio);
    myComponent.myAlphaModeRatioSlider.setToolTipText(ratio + "%");
    myComponent.myAlphaModeRatioSlider.setEnabled(alphaModeEnabled && settings.ENABLE_ALPHA_MODE);
    myComponent.myInitialTooltipDelaySlider.setValue(Registry.intValue("ide.tooltip.initialDelay"));
    myComponent.updateCombo();
  }
  @Override
  public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) {
    if (!Registry.is("vcs.showConsole")) {
      return;
    }
    if (StringUtil.isEmptyOrSpaces(message)) {
      return;
    }

    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              @Override
              public void run() {
                // for default and disposed projects the ContentManager is not available.
                if (myProject.isDisposed() || myProject.isDefault()) return;
                final ContentManager contentManager = getContentManager();
                if (contentManager == null) {
                  myPendingOutput.add(Pair.create(message, attributes));
                } else {
                  getOrCreateConsoleContent(contentManager);
                  myEditorAdapter.appendString(message, attributes);
                }
              }
            },
            ModalityState.defaultModalityState());
  }
  @Override
  public String getEventMessage(LocatableEvent event) {
    final Location location = event.location();
    String sourceName;
    try {
      sourceName = location.sourceName();
    } catch (AbsentInformationException e) {
      sourceName = getFileName();
    }

    final boolean printFullTrace = Registry.is("debugger.breakpoint.message.full.trace");

    StringBuilder builder = new StringBuilder();
    if (printFullTrace) {
      builder.append(
          DebuggerBundle.message(
              "status.line.breakpoint.reached.full.trace",
              DebuggerUtilsEx.getLocationMethodQName(location)));
      try {
        final List<StackFrame> frames = event.thread().frames();
        renderTrace(frames, builder);
      } catch (IncompatibleThreadStateException e) {
        builder.append("Stacktrace not available: ").append(e.getMessage());
      }
    } else {
      builder.append(
          DebuggerBundle.message(
              "status.line.breakpoint.reached",
              DebuggerUtilsEx.getLocationMethodQName(location),
              sourceName,
              getLineIndex() + 1));
    }
    return builder.toString();
  }
  public void addProgress(@NotNull ProgressIndicatorEx original, @NotNull TaskInfo info) {
    synchronized (myOriginals) {
      final boolean veryFirst = !hasProgressIndicators();

      myOriginals.add(original);
      myInfos.add(info);

      final InlineProgressIndicator expanded = createInlineDelegate(info, original, false);
      final InlineProgressIndicator compact = createInlineDelegate(info, original, true);

      myPopup.addIndicator(expanded);
      myProgressIcon.resume();

      if (veryFirst && !myPopup.isShowing()) {
        buildInInlineIndicator(compact);
      } else {
        buildInProcessCount();
        if (myInfos.size() > 1 && Registry.is("ide.windowSystem.autoShowProcessPopup")) {
          openProcessPopup(false);
        }
      }

      runQuery();
    }
  }
  static CharFilter.Result getLookupAction(final char charTyped, final LookupImpl lookup) {
    final CharFilter.Result filtersDecision = getFiltersDecision(charTyped, lookup);
    if (!Registry.is("ide.completion.allow.finishing.by.chars")
        && filtersDecision == CharFilter.Result.SELECT_ITEM_AND_FINISH_LOOKUP) {
      return CharFilter.Result.HIDE_LOOKUP;
    }

    final LookupElement currentItem = lookup.getCurrentItem();
    if (currentItem != null && charTyped != ' ') {
      String postfix = lookup.getAdditionalPrefix() + charTyped;
      final PrefixMatcher matcher = lookup.itemMatcher(currentItem);
      for (String lookupString : currentItem.getAllLookupStrings()) {
        if (lookupString.startsWith(matcher.getPrefix() + postfix)) {
          return CharFilter.Result.ADD_TO_PREFIX;
        }
      }
    }

    if (filtersDecision != null) {
      return filtersDecision;
    }
    throw new AssertionError(
        "Typed char not handler by char filter: c="
            + charTyped
            + "; prefix="
            + currentItem
            + "; filters="
            + Arrays.toString(getFilters()));
  }
 @Override
 public final void setOkBadge(Project project, boolean visible) {
   if (!isAppActive() && Registry.is("ide.appIcon.badge")) {
     _setTextBadge(getIdeFrame(project), null);
     _setOkBadge(getIdeFrame(project), visible);
   }
 }
 @Override
 public final void setErrorBadge(Project project, String text) {
   if (!isAppActive() && Registry.is("ide.appIcon.badge")) {
     _setOkBadge(getIdeFrame(project), false);
     _setTextBadge(getIdeFrame(project), text);
   }
 }
  public static boolean isTooltipRequest(KeyEvent keyEvent) {
    if (ourTooltipKeysProperty == null) {
      ourTooltipKeysProperty = Registry.get("ide.forcedShowTooltip");
      ourTooltipKeysProperty.addListener(
          new RegistryValueListener.Adapter() {
            @Override
            public void afterValueChanged(RegistryValue value) {
              updateTooltipRequestKey(value);
            }
          },
          Disposer.get("ui"));

      updateTooltipRequestKey(ourTooltipKeysProperty);
    }

    if (keyEvent.getID() != KeyEvent.KEY_PRESSED) return false;

    for (Integer each : ourTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) == 0) return false;
    }

    for (Integer each : ourOtherTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) > 0) return false;
    }

    final int code = keyEvent.getKeyCode();

    return code == KeyEvent.VK_META
        || code == KeyEvent.VK_CONTROL
        || code == KeyEvent.VK_SHIFT
        || code == KeyEvent.VK_ALT;
  }
 private void queueUpdateByProblem() {
   if (Registry.is("projectView.showHierarchyErrors")) {
     if (myTreeBuilder != null) {
       myTreeBuilder.queueUpdate();
     }
   }
 }
  private static void makeVariableFinalIfNeeded(
      InsertionContext context, @Nullable PsiReferenceExpression ref) {
    if (!Registry.is("java.completion.make.outer.variables.final")
        || ref == null
        || PsiUtil.isLanguageLevel8OrHigher(ref)
        || JspPsiUtil.isInJspFile(ref)) {
      return;
    }

    PsiElement target = ref.resolve();
    if (target instanceof PsiLocalVariable || target instanceof PsiParameter) {
      PsiClass placeClass =
          PsiTreeUtil.findElementOfClassAtOffset(
              context.getFile(), context.getTailOffset() - 1, PsiClass.class, false);
      if (placeClass != null
          && !PsiTreeUtil.isAncestor(placeClass, target, true)
          && !HighlightControlFlowUtil.isReassigned(
              (PsiVariable) target,
              new HashMap<PsiElement, Collection<ControlFlowUtil.VariableInfo>>())) {
        PsiModifierList modifierList = ((PsiVariable) target).getModifierList();
        if (modifierList != null) {
          modifierList.setModifierProperty(PsiModifier.FINAL, true);
        }
      }
    }
  }
  @NotNull
  public static String buildStringToFindForIndicesFromRegExp(
      @NotNull String stringToFind, @NotNull Project project) {
    if (!Registry.is("idea.regexp.search.uses.indices")) return "";

    final AccessToken accessToken = ReadAction.start();
    try {
      final List<PsiElement> topLevelRegExpChars = getTopLevelRegExpChars("a", project);
      if (topLevelRegExpChars.size() != 1) return "";

      // leave only top level regExpChars
      return StringUtil.join(
          getTopLevelRegExpChars(stringToFind, project),
          new Function<PsiElement, String>() {
            final Class regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();

            @Override
            public String fun(PsiElement element) {
              return regExpCharPsiClass.isInstance(element) ? element.getText() : " ";
            }
          },
          "");
    } finally {
      accessToken.finish();
    }
  }
  private boolean updateLookup() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (isOutdated() || !shouldShowLookup()) return false;

    boolean justShown = false;
    if (!myLookup.isShown()) {
      if (hideAutopopupIfMeaningless()) {
        return false;
      }

      if (Registry.is("dump.threads.on.empty.lookup")
          && myLookup.isCalculating()
          && myLookup.getItems().isEmpty()) {
        PerformanceWatcher.getInstance().dumpThreads(true);
      }

      if (StringUtil.isEmpty(myLookup.getAdvertisementText()) && !isAutopopupCompletion()) {
        final String text = DefaultCompletionContributor.getDefaultAdvertisementText(myParameters);
        if (text != null) {
          myLookup.setAdvertisementText(text);
        }
      }

      if (!myLookup.showLookup()) {
        return false;
      }
      justShown = true;
    }
    myLookup.refreshUi(true, justShown);
    hideAutopopupIfMeaningless();
    if (justShown) {
      myLookup.ensureSelectionVisible();
    }
    return true;
  }
 public static String applyMiddleMatching(String prefix) {
   if (Registry.is("ide.completion.middle.matching")
       && !prefix.isEmpty()
       && !ourForceStartMatching) {
     return "*" + StringUtil.replace(prefix, ".", ". ").trim();
   }
   return prefix;
 }
 @Override
 public final boolean hideProgress(Project project, Object processId) {
   if (Registry.is("ide.appIcon.progress")) {
     return _hideProgress(getIdeFrame(project), processId);
   } else {
     return false;
   }
 }
 private static int getScrollAmount(Component c, MouseWheelEvent me, JScrollBar scrollBar) {
   final int scrollBarWidth = scrollBar.getWidth();
   final int ratio =
       Registry.is("ide.smart.horizontal.scrolling") && scrollBarWidth > 0
           ? Math.max((int) Math.pow(c.getWidth() / scrollBarWidth, 2), 10)
           : 10; // do annoying scrolling faster if smart scrolling is on
   return me.getUnitsToScroll() * scrollBar.getUnitIncrement() * ratio;
 }
 @Override
 public boolean isIgnored(VirtualFile vf) {
   if (Registry.is("ide.hide.excluded.files")) {
     return myExcludedIndex.isExcludedFile(vf);
   } else {
     return myExcludedIndex.isUnderIgnored(vf);
   }
 }
Example #23
0
 public static void setFilter(ImageFilter filter) {
   if (!Registry.is("color.blindness.icon.filter")) {
     filter = null;
   }
   if (IMAGE_FILTER != filter) {
     IMAGE_FILTER = filter;
     clearCache();
   }
 }
Example #24
0
  protected JComponent createTestTreeView() {
    myTreeView = new SMTRunnerTestTreeView();

    myTreeView.setLargeModel(true);
    myTreeView.attachToModel(this);
    myTreeView.setTestResultsViewer(this);
    if (Registry.is("tests.view.old.statistics.panel")) {
      addTestsTreeSelectionListener(
          new TreeSelectionListener() {
            @Override
            public void valueChanged(TreeSelectionEvent e) {
              AbstractTestProxy selectedTest = getTreeView().getSelectedTest();
              if (selectedTest instanceof SMTestProxy) {
                myStatisticsPane.selectProxy(((SMTestProxy) selectedTest), this, false);
              }
            }
          });
    }

    final SMTRunnerTreeStructure structure = new SMTRunnerTreeStructure(myProject, myTestsRootNode);
    myTreeBuilder = new SMTRunnerTreeBuilder(myTreeView, structure);
    myTreeBuilder.setTestsComparator(TestConsoleProperties.SORT_ALPHABETICALLY.value(myProperties));
    Disposer.register(this, myTreeBuilder);

    myAnimator = new TestsProgressAnimator(myTreeBuilder);

    TrackRunningTestUtil.installStopListeners(
        myTreeView,
        myProperties,
        new Pass<AbstractTestProxy>() {
          @Override
          public void pass(AbstractTestProxy testProxy) {
            if (testProxy == null) return;
            // drill to the first leaf
            while (!testProxy.isLeaf()) {
              final List<? extends AbstractTestProxy> children = testProxy.getChildren();
              if (!children.isEmpty()) {
                final AbstractTestProxy firstChild = children.get(0);
                if (firstChild != null) {
                  testProxy = firstChild;
                  continue;
                }
              }
              break;
            }

            // pretend the selection on the first leaf
            // so if test would be run, tracking would be restarted
            myLastSelected = testProxy;
          }
        });

    // TODO always hide root node
    // myTreeView.setRootVisible(false);
    myUpdateQueue = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
    return myTreeView;
  }
 @Override
 public ContentManager getContentManager() {
   if (myContentManager == null && Registry.is("vcs.merge.toolwindows")) {
     final ToolWindow changes =
         ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS);
     myContentManager = changes == null ? null : changes.getContentManager();
   }
   return myContentManager;
 }
Example #26
0
  private void selectAndNotify(
      @Nullable final AbstractTestProxy testProxy, @Nullable Runnable onDone) {
    selectWithoutNotify(testProxy, onDone);

    // Is used by Statistic tab to differ use selection in tree
    // from manual selection from API (e.g. test runner events)
    if (Registry.is("tests.view.old.statistics.panel")) {
      showStatisticsForSelectedProxy(testProxy, false);
    }
  }
  /** Invoked via reflection. */
  LafManagerImpl() {
    myListenerList = new EventListenerList();

    List<UIManager.LookAndFeelInfo> lafList = ContainerUtil.newArrayList();

    if (SystemInfo.isMac) {
      if (Registry.is("ide.mac.yosemite.laf")
          && isIntelliJLafEnabled()
          && SystemInfo.isJavaVersionAtLeast("1.8")) {
        lafList.add(new UIManager.LookAndFeelInfo("Default", IntelliJLaf.class.getName()));
      } else {
        lafList.add(
            new UIManager.LookAndFeelInfo("Default", UIManager.getSystemLookAndFeelClassName()));
      }
    } else {
      if (isIntelliJLafEnabled()) {
        lafList.add(new IntelliJLookAndFeelInfo());
      } else {
        lafList.add(new IdeaLookAndFeelInfo());
      }
      for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        String name = laf.getName();
        if (!"Metal".equalsIgnoreCase(name)
            && !"CDE/Motif".equalsIgnoreCase(name)
            && !"Nimbus".equalsIgnoreCase(name)
            && !"Windows Classic".equalsIgnoreCase(name)
            && !name.startsWith("JGoodies")) {
          lafList.add(laf);
        }
      }
    }

    lafList.add(new DarculaLookAndFeelInfo());

    myLaFs = lafList.toArray(new UIManager.LookAndFeelInfo[lafList.size()]);

    if (!SystemInfo.isMac) {
      // do not sort LaFs on mac - the order is determined as Default, Darcula.
      // when we leave only system LaFs on other OSes, the order also should be determined as
      // Default, Darcula

      Arrays.sort(
          myLaFs,
          new Comparator<UIManager.LookAndFeelInfo>() {
            @Override
            public int compare(UIManager.LookAndFeelInfo obj1, UIManager.LookAndFeelInfo obj2) {
              String name1 = obj1.getName();
              String name2 = obj2.getName();
              return name1.compareToIgnoreCase(name2);
            }
          });
    }

    myCurrentLaf = getDefaultLaf();
  }
    public static ImageDescList create(
        @NotNull String file,
        @Nullable Class cls,
        boolean dark,
        boolean retina,
        boolean allowFloatScaling) {
      ImageDescList vars = new ImageDescList();
      if (retina || dark) {
        final String name = FileUtil.getNameWithoutExtension(file);
        final String ext = FileUtilRt.getExtension(file);

        float scale = calcScaleFactor(allowFloatScaling);

        // TODO: allow SVG images to freely scale on Retina

        if (Registry.is("ide.svg.icon") && dark) {
          vars.add(
              new ImageDesc(
                  name + "_dark.svg", cls, UIUtil.isRetina() ? 2f : scale, ImageDesc.Type.SVG));
        }

        if (Registry.is("ide.svg.icon")) {
          vars.add(
              new ImageDesc(
                  name + ".svg", cls, UIUtil.isRetina() ? 2f : scale, ImageDesc.Type.SVG));
        }

        if (dark && retina) {
          vars.add(new ImageDesc(name + "@2x_dark." + ext, cls, 2f, ImageDesc.Type.PNG));
        }

        if (dark) {
          vars.add(new ImageDesc(name + "_dark." + ext, cls, 1f, ImageDesc.Type.PNG));
        }

        if (retina) {
          vars.add(new ImageDesc(name + "@2x." + ext, cls, 2f, ImageDesc.Type.PNG));
        }
      }
      vars.add(new ImageDesc(file, cls, 1f, ImageDesc.Type.PNG, true));
      return vars;
    }
 static void warn(Configurable configurable, String action, long time) {
   if (ApplicationManager.getApplication().isDispatchThread()) {
     time = System.currentTimeMillis() - time;
     int threshold = Registry.intValue("ide.settings.configurable.loading.threshold", 0);
     if (0 < threshold && threshold < time) {
       String name = configurable.getDisplayName();
       String id = ConfigurableVisitor.ByID.getID(configurable);
       LOG.warn(String.valueOf(time) + " ms to " + action + " '" + name + "' id=" + id);
     }
   }
 }
 private void paintTextEffect(
     Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType) {
   int xStart = (int) xFrom;
   int xEnd = (int) xTo;
   g.setColor(effectColor);
   if (effectType == EffectType.LINE_UNDERSCORE) {
     UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
   } else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
     int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
     g.fillRect(xStart, y, xEnd - xStart, height);
   } else if (effectType == EffectType.STRIKEOUT) {
     int y1 = y - myView.getCharHeight() / 2;
     UIUtil.drawLine(g, xStart, y1, xEnd, y1);
   } else if (effectType == EffectType.WAVE_UNDERSCORE) {
     UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
   } else if (effectType == EffectType.BOLD_DOTTED_LINE) {
     UIUtil.drawBoldDottedLine(
         g,
         xStart,
         xEnd,
         SystemInfo.isMac ? y : y + 1,
         myEditor.getBackgroundColor(),
         g.getColor(),
         false);
   }
 }