Java Code Examples for com.intellij.ide.ui.UISettings

The following examples show how to use com.intellij.ide.ui.UISettings. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: consulo   Source File: LafManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private static void fireUpdate() {

    UISettings.getInstance().fireUISettingsChanged();
    EditorFactory.getInstance().refreshAllEditors();

    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
      FileStatusManager.getInstance(openProject).fileStatusesChanged();
      DaemonCodeAnalyzer.getInstance(openProject).restart();
    }
    for (IdeFrame frame : WindowManagerEx.getInstanceEx().getAllProjectFrames()) {
      if (frame instanceof IdeFrameEx) {
        ((IdeFrameEx)frame).updateView();
      }
    }
    ActionToolbarImpl.updateAllToolbarsImmediately();
  }
 
Example 2
Source Project: consulo-csharp   Source File: CSharpNavBarExtension.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
@RequiredReadAction
public PsiElement adjustElement(PsiElement psiElement)
{
	if(psiElement instanceof CSharpFile)
	{
		if(!UISettings.getInstance().getShowMembersInNavigationBar())
		{
			return psiElement;
		}

		DotNetNamedElement element = CSharpPsiUtilImpl.findSingleElement((CSharpFile) psiElement);
		if(element != null)
		{
			return element;
		}
	}

	if(!UISettings.getInstance().getShowMembersInNavigationBar())
	{
		return psiElement.getContainingFile();
	}

	return super.adjustElement(psiElement);
}
 
Example 3
Source Project: consulo   Source File: DesktopToolWindowPanelImpl.java    License: Apache License 2.0 6 votes vote down vote up
private void updateToolStripesVisibility() {
  boolean oldVisible = myLeftStripe.isVisible();

  final boolean showButtons = !UISettings.getInstance().getHideToolStripes() && !UISettings.getInstance().getPresentationMode();
  boolean visible = showButtons || myStripesOverlayed;
  myLeftStripe.setVisible(visible);
  myRightStripe.setVisible(visible);
  myTopStripe.setVisible(visible);
  myBottomStripe.setVisible(visible);

  boolean overlayed = !showButtons && myStripesOverlayed;

  myLeftStripe.setOverlayed(overlayed);
  myRightStripe.setOverlayed(overlayed);
  myTopStripe.setOverlayed(overlayed);
  myBottomStripe.setOverlayed(overlayed);


  if (oldVisible != visible) {
    revalidate();
    repaint();
  }
}
 
Example 4
void apply() {
  final ThriftConfig config = new ThriftConfig(
    StringUtils.trimToNull(tfThriftCompiler.getText()),
    cbNoWarn.isSelected(),
    cbStrict.isSelected(),
    cbVerbose.isSelected(),
    cbRecurse.isSelected(),
    cbDebug.isSelected(),
    cbAllowNegKeys.isSelected(),
    cbAllow64bitConsts.isSelected()
  );

  plugin.setConfig(config);
  setModified(false);

  UISettings.getInstance().fireUISettingsChanged();
}
 
Example 5
Source Project: consulo   Source File: DaemonTooltipWithActionRenderer.java    License: Apache License 2.0 6 votes vote down vote up
private Font getActionFont() {
  Font toolTipFont = UIUtil.getToolTipFont();
  if (toolTipFont == null || SystemInfo.isWindows) return toolTipFont;

  //if font was changed from default we dont have a good heuristic to customize it
  if (JBUI.Fonts.label() != toolTipFont || UISettings.getInstance().OVERRIDE_NONIDEA_LAF_FONTS) return toolTipFont;

  if (SystemInfo.isMac) {
    return toolTipFont.deriveFont(toolTipFont.getSize() - 1f);
  }

  if (SystemInfo.isLinux) {
    return toolTipFont.deriveFont(toolTipFont.getSize() - 1f);
  }
  return toolTipFont;
}
 
Example 6
Source Project: consulo   Source File: PluginsTableRenderer.java    License: Apache License 2.0 6 votes vote down vote up
public PluginsTableRenderer(PluginDescriptor pluginDescriptor, boolean availableRender) {
  myPluginDescriptor = pluginDescriptor;

  final Font smallFont;
  if (SystemInfo.isMac) {
    smallFont = UIUtil.getLabelFont(UIUtil.FontSize.MINI);
  }
  else {
    smallFont = UIUtil.getLabelFont().deriveFont(Math.max(UISettings.getInstance().getFontSize() - JBUI.scale(3), JBUI.scaleFontSize(10)));
  }
  myName.setFont(UIUtil.getLabelFont().deriveFont(UISettings.getInstance().getFontSize()));
  myStatus.setFont(smallFont);
  myCategory.setFont(smallFont);
  myDownloads.setFont(smallFont);
  myStatus.setText("");
  myCategory.setText("");
  myLastUpdated.setFont(smallFont);
  if (!availableRender || !(pluginDescriptor instanceof PluginNode)) {
    myPanel.remove(myRightPanel);
  }

  myPanel.setBorder(UIUtil.isJreHiDPI(myPanel) ? JBUI.Borders.empty(4, 3) : JBUI.Borders.empty(2, 3));
}
 
Example 7
@Override
@RequiredReadAction
public PsiElement getLeafElement(@Nonnull DataContext dataContext) {
  if (UISettings.getInstance().getShowMembersInNavigationBar()) {
    PsiFile psiFile = dataContext.getData(CommonDataKeys.PSI_FILE);
    Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
    if (psiFile == null || editor == null) return null;
    PsiElement psiElement = psiFile.findElementAt(editor.getCaretModel().getOffset());
    if (psiElement != null && psiElement.getLanguage() == getLanguage()) {
      StructureViewModel model = buildStructureViewModel(psiFile, editor);
      if (model != null) {
        Object currentEditorElement = model.getCurrentEditorElement();
        if (currentEditorElement instanceof PsiElement) {
          return ((PsiElement)currentEditorElement).getOriginalElement();
        }
      }
    }
  }
  return null;
}
 
Example 8
Source Project: consulo   Source File: IJSwingUtilities.java    License: Apache License 2.0 6 votes vote down vote up
public static void moveMousePointerOn(Component component) {
  if (component != null && component.isShowing()) {
    UISettings settings = ApplicationManager.getApplication() == null ? null : UISettings.getInstance();
    if (settings != null && settings.MOVE_MOUSE_ON_DEFAULT_BUTTON) {
      Point point = component.getLocationOnScreen();
      int dx = component.getWidth() / 2;
      int dy = component.getHeight() / 2;
      try {
        new Robot().mouseMove(point.x + dx, point.y + dy);
      }
      catch (AWTException ignored) {
        // robot is not available
      }
    }
  }
}
 
Example 9
Source Project: consulo   Source File: DesktopFloatingDecorator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final void show() {
  setFocusableWindowState(myInfo.isActive());

  super.show();
  final UISettings uiSettings = UISettings.getInstance();
  if (uiSettings.ENABLE_ALPHA_MODE) {
    final WindowManagerEx windowManager = WindowManagerEx.getInstanceEx();
    windowManager.setAlphaModeEnabled(this, true);
    if (myInfo.isActive()) {
      windowManager.setAlphaModeRatio(this, 0.0f);
    }
    else {
      windowManager.setAlphaModeRatio(this, uiSettings.ALPHA_MODE_RATIO);
    }
  }
  paint(getGraphics()); // This prevents annoying flick

  setFocusableWindowState(true);

  uiSettings.addUISettingsListener(myUISettingsListener, myDelayAlarm);
}
 
Example 10
Source Project: consulo   Source File: CodeCompletionPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void apply() {

    CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

    codeInsightSettings.COMPLETION_CASE_SENSITIVE = getCaseSensitiveValue();

    codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = myCbSelectByChars.isSelected();
    codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION = myCbOnCodeCompletion.isSelected();
    codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = myCbOnSmartTypeCompletion.isSelected();
    codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = myCbShowFullParameterSignatures.isSelected();

    codeInsightSettings.AUTO_POPUP_PARAMETER_INFO = myCbParameterInfoPopup.isSelected();
    codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP = myCbAutocompletion.isSelected();
    codeInsightSettings.AUTO_POPUP_JAVADOC_INFO = myCbAutopopupJavaDoc.isSelected();

    codeInsightSettings.PARAMETER_INFO_DELAY = getIntegerValue(myParameterInfoDelayField.getText(), 0);
    codeInsightSettings.JAVADOC_INFO_DELAY = getIntegerValue(myAutopopupJavaDocField.getText(), 0);

    UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = myCbSorting.isSelected();

    final Project project = DataManager.getInstance().getDataContext(myPanel).getData(CommonDataKeys.PROJECT);
    if (project != null){
      DaemonCodeAnalyzer.getInstance(project).settingsChanged();
    }
  }
 
Example 11
Source Project: consulo   Source File: EditorHistoryManager.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
EditorHistoryManager(@Nonnull Project project) {
  myProject = project;

  MessageBusConnection connection = project.getMessageBus().connect();

  connection.subscribe(UISettingsListener.TOPIC, new UISettingsListener() {
    @Override
    public void uiSettingsChanged(UISettings uiSettings) {
      trimToSize();
    }
  });

  connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() {
    @Override
    public void beforeFileClosed(@Nonnull FileEditorManager source, @Nonnull VirtualFile file) {
      updateHistoryEntry(file, false);
    }
  });
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyEditorManagerListener());
}
 
Example 12
Source Project: consulo   Source File: DesktopFloatingDecorator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void uiSettingsChanged(final UISettings uiSettings) {
  LOG.assertTrue(isDisplayable());
  LOG.assertTrue(isShowing());
  final WindowManagerEx windowManager = WindowManagerEx.getInstanceEx();
  myDelayAlarm.cancelAllRequests();
  if (uiSettings.ENABLE_ALPHA_MODE) {
    if (!myInfo.isActive()) {
      windowManager.setAlphaModeEnabled(DesktopFloatingDecorator.this, true);
      windowManager.setAlphaModeRatio(DesktopFloatingDecorator.this, uiSettings.ALPHA_MODE_RATIO);
    }
  }
  else {
    windowManager.setAlphaModeEnabled(DesktopFloatingDecorator.this, false);
  }
}
 
Example 13
Source Project: consulo   Source File: DesktopToolWindowPanelImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private Pair<BufferedImage, Reference<BufferedImage>> getImage(@Nullable Reference<BufferedImage> imageRef) {
  LOG.assertTrue(UISettings.getInstance().getAnimateWindows());
  Window awtWindow = TargetAWT.to(myIdeFrame.getWindow());
  BufferedImage image = SoftReference.dereference(imageRef);
  if (image == null || image.getWidth(null) < getWidth() || image.getHeight(null) < getHeight()) {
    final int width = Math.max(Math.max(1, getWidth()), awtWindow.getWidth());
    final int height = Math.max(Math.max(1, getHeight()), awtWindow.getHeight());
    if (SystemInfo.isWindows) {
      image = awtWindow.getGraphicsConfiguration().createCompatibleImage(width, height);
    }
    else {
      // Under Linux we have found that images created by createCompatibleImage(),
      // createVolatileImage(), etc extremely slow for rendering. TrueColor buffered image
      // is MUCH faster.
      // On Mac we create a retina-compatible image

      image = UIUtil.createImage(getGraphics(), width, height, BufferedImage.TYPE_INT_RGB);
    }
    imageRef = new SoftReference<>(image);
  }
  return Pair.create(image, imageRef);
}
 
Example 14
Source Project: consulo   Source File: MenuItemPresentationFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processPresentation(Presentation presentation) {
  if (!UISettings.getInstance().SHOW_ICONS_IN_MENUS || myForceHide) {
    presentation.setIcon(null);
    presentation.setDisabledIcon(null);
    presentation.setHoveredIcon(null);
    presentation.putClientProperty(HIDE_ICON, Boolean.TRUE);
  }
}
 
Example 15
Source Project: consulo   Source File: ActivateNavigationBarAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  if (project != null && UISettings.getInstance().SHOW_NAVIGATION_BAR){
    final JFrame frame = WindowManagerEx.getInstance().getFrame(project);
    final IdeRootPane ideRootPane = ((IdeRootPane)frame.getRootPane());
    final NavBarPanel navBarPanel = (NavBarPanel)ideRootPane.findByName(NavBarRootPaneExtension.NAV_BAR).getComponent();
    navBarPanel.rebuildAndSelectTail(true);
  }
}
 
Example 16
Source Project: idea-gitignore   Source File: OuterIgnoreWrapper.java    License: MIT License 5 votes vote down vote up
/** Updates tabbedPanel policy depending on UISettings#getScrollTabLayoutInEditor() settings. */
private void updateTabbedPanelPolicy() {
    if (UISettings.getInstance().getScrollTabLayoutInEditor()) {
        tabbedPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    } else {
        tabbedPanel.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
    }
}
 
Example 17
Source Project: consulo   Source File: TabsAlphabeticalModeSwitcher.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  super.update(e);
  final int place = UISettings.getInstance().EDITOR_TAB_PLACEMENT;
  e.getPresentation().setEnabled(UISettings.getInstance().SCROLL_TAB_LAYOUT_IN_EDITOR
                                 || place == SwingConstants.LEFT
                                 || place == SwingConstants.RIGHT);
}
 
Example 18
Source Project: consulo   Source File: WindowStateServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private <T> T getFor(Object object, @Nonnull String key, @Nonnull Class<T> type) {
  if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) return null;
  if (UISettings.getInstance().getPresentationMode()) key += ".inPresentationMode"; // separate key for the presentation mode
  GraphicsConfiguration configuration = getConfiguration(object);
  synchronized (myStateMap) {
    CachedState state = myStateMap.get(getAbsoluteKey(configuration, key));
    if (isVisible(state)) return state.get(type, null);

    state = myStateMap.get(key);
    return state == null ? null : state.get(type, state.myScreen == null ? null : getScreenRectangle(configuration));
  }
}
 
Example 19
Source Project: consulo   Source File: FileEditorManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testTabLimit() throws Exception {

    int limit = UISettings.getInstance().EDITOR_TAB_LIMIT;
    try {
      UISettings.getInstance().EDITOR_TAB_LIMIT = 2;
      openFiles(STRING);
      // note that foo.xml is pinned
      assertOpenFiles("foo.xml", "3.txt");
    }
    finally {
      UISettings.getInstance().EDITOR_TAB_LIMIT = limit;
    }
  }
 
Example 20
@Override
@RequiredReadAction
public boolean processChildren(Object object, Object rootElement, Processor<Object> processor) {
  if (UISettings.getInstance().getShowMembersInNavigationBar()) {
    if (object instanceof PsiElement) {
      if (((PsiElement)object).getLanguage() == getLanguage()) {
        StructureViewModel model = buildStructureViewModel(((PsiElement)object).getContainingFile(), null);
        if (model != null) {
          return processStructureViewChildren(model.getRoot(), object, processor);
        }
      }
    }
  }
  return super.processChildren(object, rootElement, processor);
}
 
Example 21
Source Project: consulo   Source File: ActionToolbarImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void paintComponent(final Graphics g) {
  if (getParent() == null) return;

  int gap = JBUIScale.scale(2);
  int center = JBUIScale.scale(3);
  int offset;
  if (myOrientation == SwingConstants.HORIZONTAL) {
    offset = ActionToolbarImpl.this.getHeight() - getMaxButtonHeight() - 1;
  }
  else {
    offset = ActionToolbarImpl.this.getWidth() - getMaxButtonWidth() - 1;
  }

  g.setColor(JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground());
  if (myOrientation == SwingConstants.HORIZONTAL) {
    int y2 = ActionToolbarImpl.this.getHeight() - gap * 2 - offset;
    LinePainter2D.paint((Graphics2D)g, center, gap, center, y2);

    if (myText != null) {
      FontMetrics fontMetrics = getFontMetrics(getFont());
      int top = (getHeight() - fontMetrics.getHeight()) / 2;
      UISettings.setupAntialiasing(g);
      g.setColor(JBColor.foreground());
      g.drawString(myText, gap * 2 + center + gap, top + fontMetrics.getAscent());
    }
  }
  else {
    LinePainter2D.paint((Graphics2D)g, gap, center, ActionToolbarImpl.this.getWidth() - gap * 2 - offset, center);
  }
}
 
Example 22
Source Project: consulo   Source File: OptionsEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void uiSettingsChanged(UISettings source) {
  mySearchWrapper.setBorder(JBUI.Borders.empty(10, 5));

  mySearch.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor));
  mySearchWrapper.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor));
  myLeftSide.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor));
}
 
Example 23
Source Project: consulo   Source File: TogglePresentationModeAction.java    License: Apache License 2.0 5 votes vote down vote up
public static void setPresentationMode(final Project project, final boolean inPresentation) {
  final UISettings settings = UISettings.getInstance();
  settings.PRESENTATION_MODE = inPresentation;

  final boolean layoutStored = storeToolWindows(project);

  tweakUIDefaults(settings, inPresentation);

  ActionCallback callback = project == null ? ActionCallback.DONE : tweakFrameFullScreen(project, inPresentation);
  callback.doWhenProcessed(() -> {
    tweakEditorAndFireUpdateUI(settings, inPresentation);

    restoreToolWindows(project, layoutStored, inPresentation);
  });
}
 
Example 24
Source Project: consulo   Source File: JBEditorTabs.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected SingleRowLayout createSingleRowLayout() {
  if (!UISettings.getInstance().HIDE_TABS_IF_NEED && supportsCompression()) {
    return new CompressibleSingleRowLayout(this);
  }
  else {
    return new ScrollableSingleRowLayout(this);
  }
}
 
Example 25
Source Project: consulo   Source File: ToggleBreadcrumbsAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setSelected(@Nonnull AnActionEvent event, boolean selected) {
  Editor editor = findEditor(event);
  if (editor != null && BreadcrumbsForceShownSettings.setForcedShown(selected, editor)) {
    UISettings.getInstance().fireUISettingsChanged();
  }
}
 
Example 26
Source Project: consulo   Source File: ScrollSettings.java    License: Apache License 2.0 5 votes vote down vote up
static boolean isEligibleFor(Component component) {
  if (component == null || !component.isShowing()) return false;

  Application application = getApplication();
  if (application == null || application.isUnitTestMode()) return false;
  if (PowerSaveMode.isEnabled()) return false;
  if (RemoteDesktopService.isRemoteSession()) return false;

  UISettings settings = UISettings.getInstanceOrNull();
  return settings != null && settings.SMOOTH_SCROLLING;
}
 
Example 27
Source Project: consulo   Source File: DialogUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void setTextWithMnemonic(@Nonnull AbstractButton button, String text, char mn) {
  if (text != null) {
    final StringBuilder realText = new StringBuilder();
    char mnemonic = '\0';
    int index = -1;
    for (int i = 0; i < text.length(); i++) {
      final char ch = text.charAt(i);
      if (ch != mn) {
        realText.append(ch);
      }
      else if (i + 1 < text.length()) {
        mnemonic = text.charAt(i + 1);
        index = realText.length();
      }
    }
    if (mnemonic != '\0') {
      button.setText(realText.toString());
      if (UISettings.getShadowInstance().getDisableMnemonicsInControls()) {
        button.setMnemonic(0);
        button.setDisplayedMnemonicIndex(-1);
        button.setFocusable(true);
      }
      else {
        button.setMnemonic(mnemonic);
        button.setDisplayedMnemonicIndex(index);
      }
    }
  }
}
 
Example 28
Source Project: consulo   Source File: RunAnythingPopupUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void installScrollingActions() {
  RunAnythingScrollingUtil.installActions(myResultsList, (JTextField)TargetAWT.to(getField()), () -> {
    myIsItemSelected = true;
    mySearchField.setValue(myLastInputText);
    clearSelection();
  }, UISettings.getInstance().getCycleScrolling());

  super.installScrollingActions();
}
 
Example 29
Source Project: consulo   Source File: IdeDocumentHistoryImpl.java    License: Apache License 2.0 5 votes vote down vote up
public static void appendTimestamp(@Nonnull Project project, @Nonnull SimpleColoredComponent component, @Nonnull VirtualFile file) {
  if (!UISettings.getInstance().getShowInplaceComments()) {
    return;
  }

  try {
    Long timestamp = getInstance(project).getRecentFilesTimestamps().get(file.getPath());
    if (timestamp != null) {
      component.append(" ").append(DateFormatUtil.formatPrettyDateTime(timestamp), SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES);
    }
  }
  catch (IOException e) {
    LOG.info("Cannot get a timestamp from a persistent hash map", e);
  }
}
 
Example 30
Source Project: consulo   Source File: UniqueNameEditorTabTitleProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getEditorTabTitle(@Nonnull Project project, @Nonnull VirtualFile file) {
  UISettings uiSettings = UISettings.getInstanceOrNull();
  if (uiSettings == null || !uiSettings.getShowDirectoryForNonUniqueFilenames() || DumbService.isDumb(project)) {
    return null;
  }

  // Even though this is a 'tab title provider' it is used also when tabs are not shown, namely for building IDE frame title.
  String uniqueName = uiSettings.getEditorTabPlacement() == UISettings.TABS_NONE
                      ? UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file)
                      : UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePathWithinOpenedFileEditors(project, file);
  uniqueName = getEditorTabText(uniqueName, File.separator, uiSettings.getHideKnownExtensionInTabs());
  return uniqueName.equals(file.getName()) ? null : uniqueName;
}