Java Code Examples for com.intellij.ide.ui.UISettings#getInstance()

The following examples show how to use com.intellij.ide.ui.UISettings#getInstance() . 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 File: ShowNavBarAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e){
  final DataContext context = e.getDataContext();
  final Project project = context.getData(CommonDataKeys.PROJECT);
  if (project != null) {
    UISettings uiSettings = UISettings.getInstance();
    if (uiSettings.SHOW_NAVIGATION_BAR && !uiSettings.PRESENTATION_MODE){
      new SelectInNavBarTarget(project).select(null, false);
    } else {
      final Component component = context.getData(PlatformDataKeys.CONTEXT_COMPONENT);
      if (!isInsideNavBar(component)) {
        final Editor editor = context.getData(PlatformDataKeys.EDITOR);
        final NavBarPanel toolbarPanel = new NavBarPanel(project, false);
        toolbarPanel.showHint(editor, context);
      }
    }
  }
}
 
Example 2
Source File: LafManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void patchLafFonts(UIDefaults uiDefaults) {
  //if (JBUI.isHiDPI()) {
  //  HashMap<Object, Font> newFonts = new HashMap<Object, Font>();
  //  for (Object key : uiDefaults.keySet().toArray()) {
  //    Object val = uiDefaults.get(key);
  //    if (val instanceof Font) {
  //      newFonts.put(key, JBFont.create((Font)val));
  //    }
  //  }
  //  for (Map.Entry<Object, Font> entry : newFonts.entrySet()) {
  //    uiDefaults.put(entry.getKey(), entry.getValue());
  //  }
  //} else
  UISettings uiSettings = UISettings.getInstance();
  if (uiSettings.OVERRIDE_NONIDEA_LAF_FONTS) {
    storeOriginalFontDefaults(uiDefaults);
    JBUI.setUserScaleFactor(uiSettings.FONT_SIZE / UIUtil.DEF_SYSTEM_FONT_SIZE);
    initFontDefaults(uiDefaults, UIUtil.getFontWithFallback(uiSettings.FONT_FACE, Font.PLAIN, uiSettings.getFontSize()));
  }
  else {
    restoreOriginalFontDefaults(uiDefaults);
  }
}
 
Example 3
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e){
  UISettings settings = UISettings.getInstance();
  Project project = e.getProject();

  setPresentationMode(project, !settings.PRESENTATION_MODE);
}
 
Example 4
Source File: NavBarBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Insets getBorderInsets(final Component c) {
  if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) {
    if (NavBarRootPaneExtension.runToolbarExists()) {
      return new JBInsets(1, 0, 1, 4);
    }

    return new JBInsets(0, 0, 0, 4);
  }

  return new JBInsets(1, 0, 0, 4);
}
 
Example 5
Source File: TabsAlphabeticalModeSwitcher.java    From consulo with 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 6
Source File: ToolWindowLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public List<String> getVisibleIdsOn(@Nonnull ToolWindowAnchor anchor, @Nonnull ToolWindowManager manager) {
  List<String> ids = new ArrayList<>();
  for (WindowInfoImpl each : getAllInfos(anchor)) {
    final ToolWindow window = manager.getToolWindow(each.getId());
    if (window == null) continue;
    if (window.isAvailable() || UISettings.getInstance().ALWAYS_SHOW_WINDOW_BUTTONS) {
      ids.add(each.getId());
    }
  }
  return ids;
}
 
Example 7
Source File: EditorTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void setupEditorFont(final EditorEx editor) {
  if (myInheritSwingFont) {
    ((DesktopEditorImpl)editor).setUseEditorAntialiasing(false);
    editor.getColorsScheme().setEditorFontName(getFont().getFontName());
    editor.getColorsScheme().setEditorFontSize(getFont().getSize());
    return;
  }
  UISettings settings = UISettings.getInstance();
  if (settings.PRESENTATION_MODE) editor.setFontSize(settings.PRESENTATION_MODE_FONT_SIZE);
}
 
Example 8
Source File: MenuItemPresentationFactory.java    From consulo with 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 9
Source File: TogglePresentationModeAction.java    From consulo with 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 10
Source File: IdeNotificationArea.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
private void applyIconToStatusAndToolWindow(Project project, Image icon) {
  if (UISettings.getInstance().HIDE_TOOL_STRIPES || UISettings.getInstance().PRESENTATION_MODE) {
    myLabel.setVisible(true);
    myLabel.setImage(icon);
  }
  else {
    ToolWindow eventLog = EventLog.getEventLog(project);
    if (eventLog != null) {
      eventLog.setIcon(icon);
    }
    myLabel.setVisible(false);
  }
}
 
Example 11
Source File: AbstractColorsScheme.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Font getFont(EditorFontType key) {
  if (UISettings.getInstance().PRESENTATION_MODE) {
    final Font font = myFonts.get(key);
    return new Font(font.getName(), font.getStyle(), UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
  }
  return myFonts.get(key);
}
 
Example 12
Source File: TabLabel.java    From consulo with Apache License 2.0 4 votes vote down vote up
private SimpleColoredComponent createLabel(final JBTabsImpl tabs) {
  SimpleColoredComponent label = new SimpleColoredComponent() {
    @Override
    protected boolean shouldDrawMacShadow() {
      return SystemInfo.isMac || UIUtil.isUnderDarcula();
    }

    @Override
    protected boolean shouldDrawDimmed() {
      return myTabs.getSelectedInfo() != myInfo || myTabs.useBoldLabels();
    }

    @Override
    public Font getFont() {
      if (isFontSet() || !myTabs.useSmallLabels()) {
        return super.getFont();
      }
      return UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
    }

    @Override
    protected void doPaint(Graphics2D g) {
      if (UISettings.getInstance().HIDE_TABS_IF_NEED ||
          tabs.getTabsPosition() == JBTabsPosition.left ||
          tabs.getTabsPosition() == JBTabsPosition.right) {
        super.doPaint(g);
        return;
      }
      Rectangle clip = getVisibleRect();
      if (getPreferredSize().width <= clip.width) {
        super.doPaint(g);
        return;
      }
      int dimSize = 30;
      int dimStep = 2;
      Composite oldComposite = g.getComposite();
      Shape oldClip = g.getClip();
      try {
        g.setClip(clip.x, clip.y, Math.max(0, clip.width - dimSize), clip.height);
        super.doPaint(g);

        for (int x = clip.x + clip.width - dimSize; x < clip.x + clip.width; x += dimStep) {
          g.setClip(x, clip.y, dimStep, clip.height);
          g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                                                    1 - ((float)x - (clip.x + clip.width - dimSize)) / dimSize));
          super.doPaint(g);
        }
      }
      finally {
        g.setComposite(oldComposite);
        g.setClip(oldClip);
      }
    }
  };
  label.setOpaque(false);
  label.setBorder(null);
  label.setIconTextGap(tabs.isEditorTabs()
                       ? (!UISettings.getInstance().HIDE_TABS_IF_NEED ? JBUI.scale(4) : JBUI.scale(2))
                       : new JLabel().getIconTextGap());
  label.setIconOpaque(false);
  label.setIpad(JBUI.emptyInsets());

  return label;
}
 
Example 13
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  boolean selected = UISettings.getInstance().PRESENTATION_MODE;
  e.getPresentation().setText(selected ? "Exit Presentation Mode" : "Enter Presentation Mode");
}
 
Example 14
Source File: ViewToolWindowButtonsAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setSelected(AnActionEvent event,boolean state) {
  UISettings uiSettings = UISettings.getInstance();
  uiSettings.HIDE_TOOL_STRIPES=!state;
  uiSettings.fireUISettingsChanged();
}
 
Example 15
Source File: IdeMenuBar.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void updateMnemonicsVisibility() {
  final boolean enabled = !UISettings.getInstance().DISABLE_MNEMONICS;
  for (int i = 0; i < getMenuCount(); i++) {
    ((ActionMenu)getMenu(i)).setMnemonicEnabled(enabled);
  }
}
 
Example 16
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isCycleScrolling() {
  return myCycleScrolling == null ? UISettings.getInstance().CYCLE_SCROLLING : myCycleScrolling.booleanValue();
}
 
Example 17
Source File: SelectInNavBarTarget.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean canSelect(final PsiFileSystemItem file) {
  return UISettings.getInstance().SHOW_NAVIGATION_BAR;
}
 
Example 18
Source File: CopyPasteManagerEx.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void deleteAfterAllowedMaximum() {
  int max = UISettings.getInstance().MAX_CLIPBOARD_CONTENTS;
  for (int i = myData.size() - 1; i >= max; i--) {
    myData.remove(i);
  }
}
 
Example 19
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void updateTabBorder() {
  if (!myProject.isOpen()) return;

  ToolWindowManagerEx mgr = (ToolWindowManagerEx)ToolWindowManager.getInstance(myProject);

  String[] ids = mgr.getToolWindowIds();

  Insets border = JBUI.emptyInsets();

  UISettings uiSettings = UISettings.getInstance();

  List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP);
  List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM);
  List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT);
  List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT);

  if (!uiSettings.getHideToolStripes() && !uiSettings.getPresentationMode()) {
    border.top = !topIds.isEmpty() ? 1 : 0;
    border.bottom = !bottom.isEmpty() ? 1 : 0;
    border.left = !leftIds.isEmpty() ? 1 : 0;
    border.right = !rightIds.isEmpty() ? 1 : 0;
  }

  for (String each : ids) {
    ToolWindow eachWnd = mgr.getToolWindow(each);
    if (eachWnd == null || !eachWnd.isAvailable()) continue;

    if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) {
      ToolWindowAnchor eachAnchor = eachWnd.getAnchor();
      if (eachAnchor == ToolWindowAnchor.TOP) {
        border.top = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.BOTTOM) {
        border.bottom = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.LEFT) {
        border.left = 0;
      }
      else if (eachAnchor == ToolWindowAnchor.RIGHT) {
        border.right = 0;
      }
    }
  }

  myTabs.getPresentation().setPaintBorder(border.top, border.left, border.right, border.bottom).setTabSidePaintBorder(5);
}
 
Example 20
Source File: ActionsTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  final boolean showIcons = UISettings.getInstance().SHOW_ICONS_IN_MENUS;
  Keymap originalKeymap = myKeymap != null ? myKeymap.getParent() : null;
  Icon icon = null;
  String text;
  boolean bound = false;

  if (value instanceof DefaultMutableTreeNode) {
    Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
    boolean changed;
    if (userObject instanceof Group) {
      Group group = (Group)userObject;
      text = group.getName();

      changed = originalKeymap != null && isGroupChanged(group, originalKeymap, myKeymap);
      icon = group.getIcon();
      if (icon == null){
        icon = CLOSE_ICON;
      }
    }
    else if (userObject instanceof String) {
      String actionId = (String)userObject;
      bound = myShowBoundActions && ((KeymapImpl)myKeymap).isActionBound(actionId);
      AnAction action = ActionManager.getInstance().getActionOrStub(actionId);
      if (action != null) {
        text = action.getTemplatePresentation().getText();
        if (text == null || text.length() == 0) { //fill dynamic presentation gaps
          text = actionId;
        }
        Icon actionIcon = action.getTemplatePresentation().getIcon();
        if (actionIcon != null) {
          icon = actionIcon;
        }
      }
      else {
        text = actionId;
      }
      changed = originalKeymap != null && isActionChanged(actionId, originalKeymap, myKeymap);
    }
    else if (userObject instanceof QuickList) {
      QuickList list = (QuickList)userObject;
      icon = AllIcons.Actions.QuickList;
      text = list.getDisplayName();

      changed = originalKeymap != null && isActionChanged(list.getActionId(), originalKeymap, myKeymap);
    }
    else if (userObject instanceof AnSeparator) {
      // TODO[vova,anton]: beautify
      changed = false;
      text = "-------------";
    }
    else {
      throw new IllegalArgumentException("unknown userObject: " + userObject);
    }

    if (showIcons) {
      setIcon(ActionsTree.getEvenIcon(icon));
    }

    Color foreground;
    if (selected) {
      foreground = UIUtil.getTreeSelectionForeground();
    }
    else {
      if (changed) {
        foreground = JBColor.BLUE;
      }
      else {
        foreground = UIUtil.getTreeForeground();
      }

      if (bound) {
        foreground = JBColor.MAGENTA;
      }
    }
    SearchUtil.appendFragments(myFilter, text, Font.PLAIN, foreground,
                               selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(), this);
  }
}