Java Code Examples for com.intellij.util.ui.UIUtil#isUnderIntelliJLaF()

The following examples show how to use com.intellij.util.ui.UIUtil#isUnderIntelliJLaF() . 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: AdvancedSettingsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static int calculateCheckBoxIndent() {
  JCheckBox checkBox = new JCheckBox();
  Icon icon = checkBox.getIcon();
  int indent = 0;
  if (icon == null) {
    icon = UIManager.getIcon("CheckBox.icon");
  }
  if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
    icon = EmptyIcon.create(20, 18);
  }
  if (icon != null) {
    final Insets i = checkBox.getInsets();
    final Rectangle r = checkBox.getBounds();
    final Rectangle r1 = new Rectangle();
    r1.x = i.left;
    r1.y = i.top;
    r1.width = r.width - (i.right + r1.x);
    r1.height = r.height - (i.bottom + r1.y);
    final Rectangle iconRect = new Rectangle();
    SwingUtilities.layoutCompoundLabel(checkBox, checkBox.getFontMetrics(checkBox.getFont()), checkBox.getText(), icon, checkBox.getVerticalAlignment(), checkBox.getHorizontalAlignment(),
                                       checkBox.getVerticalTextPosition(), checkBox.getHorizontalTextPosition(), r1, new Rectangle(), iconRect,
                                       checkBox.getText() == null ? 0 : checkBox.getIconTextGap());
    indent = iconRect.x;
  }
  return indent + checkBox.getIconTextGap();
}
 
Example 2
Source File: WideSelectionTreeUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
  if (myWideSelection && !UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula() && !UIUtil.isUnderIntelliJLaF()) {
    paintSelectedRows(g, ((JTree)c));
  }
  if (myWideSelection) {
    final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
    final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;
    final Rectangle bounds = g.getClipBounds();

    // draw background for the given clip bounds
    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    if (sourceList != null && (Boolean)sourceList) {
      Graphics2D backgroundGraphics = (Graphics2D)g.create();
      backgroundGraphics.setClip(xOffset, bounds.y, containerWidth, bounds.height);
      LIST_BACKGROUND_PAINTER.paintBorder(tree, backgroundGraphics, xOffset, bounds.y, containerWidth, bounds.height);
      backgroundGraphics.dispose();
    }
  }

  super.paint(g, c);
}
 
Example 3
Source File: EditorComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  if (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula()) {
    return super.getPreferredSize();
  }
  if (myEditorField != null) {
    final Dimension preferredSize = new Dimension(myEditorField.getComponent().getPreferredSize());
    JBInsets.addTo(preferredSize, getInsets());
    return preferredSize;
  }

  //final int cbHeight = new JComboBox().getPreferredSize().height; // should be used actually
  return new Dimension(100, UIUtil.fixComboBoxHeight(20));
}
 
Example 4
Source File: InspectorTreeUI.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = getSelectionBackground(tree, true);

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}
 
Example 5
Source File: InspectorTreeUI.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = getSelectionBackground(tree, true);

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}
 
Example 6
Source File: SearchTextField.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected boolean isSearchControlUISupported() {
  return (SystemInfo.isMacOSLeopard && UIUtil.isUnderAquaLookAndFeel()) || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF();
}
 
Example 7
Source File: TreeTableTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected final boolean isWideSelection() {
  return UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF();
}
 
Example 8
Source File: WideSelectionTreeUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean shouldPaintLines() {
  if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
    return false;
  }
  return myForceDontPaintLines || !"None".equals(tree.getClientProperty("JTree.lineStyle"));
}
 
Example 9
Source File: WideSelectionTreeUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = getSelectionBackground(tree, true);

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}
 
Example 10
Source File: LafIconLookup.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static Icon findIcon(@Nonnull String name, boolean selected, boolean focused, boolean enabled, boolean editable, boolean pressed, boolean isThrowErrorIfNotFound) {
  String key = name;
  if (editable) {
    key = name + "Editable";
  }

  if (selected) {
    key = key + "Selected";
  }

  if (pressed) {
    key = key + "Pressed";
  }
  else if (focused) {
    key = key + "Focused";
  }
  else if (!enabled) {
    key = key + "Disabled";
  }

  String dir;
  /*if (UIUtil.isUnderDefaultMacTheme()) {
    dir = (UIUtil.isGraphite() ? "graphite/" : "");
  }
  else*/
  {
   /* if (UIUtil.isUnderWin10LookAndFeel()) {
      dir = "win10/";
    }
    else */
    {
      if (UIUtil.isUnderDarcula()) {
        dir = "darcula/";
      }
      else {
        dir = (UIUtil.isUnderIntelliJLaF() ? "intellij/" : "");
      }
    }
  }
  return findLafIcon(dir + key, LafIconLookup.class, isThrowErrorIfNotFound);
}