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

The following examples show how to use com.intellij.util.ui.UIUtil#isFullRowSelectionLAF() . 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: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void doPaintIcon(@NotNull Graphics2D g, @NotNull Icon icon, int offset) {
  final Container parent = getParent();
  Color iconBackgroundColor = null;
  if ((isOpaque() || isIconOpaque()) && !isTransparentIconBackground()) {
    if (parent != null && !myFocusBorderAroundIcon && !UIUtil.isFullRowSelectionLAF()) {
      iconBackgroundColor = parent.getBackground();
    }
    else {
      iconBackgroundColor = getBackground();
    }
  }

  if (iconBackgroundColor != null) {
    g.setColor(iconBackgroundColor);
    g.fillRect(offset, 0, icon.getIconWidth() + myIpad.left + myIconTextGap, getHeight());
  }

  paintIcon(g, icon, offset + myIpad.left);
}
 
Example 2
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void doPaintIcon(@NotNull Graphics2D g, @NotNull Icon icon, int offset) {
  final Container parent = getParent();
  Color iconBackgroundColor = null;
  if ((isOpaque() || isIconOpaque()) && !isTransparentIconBackground()) {
    if (parent != null && !myFocusBorderAroundIcon && !UIUtil.isFullRowSelectionLAF()) {
      iconBackgroundColor = parent.getBackground();
    }
    else {
      iconBackgroundColor = getBackground();
    }
  }

  if (iconBackgroundColor != null) {
    g.setColor(iconBackgroundColor);
    g.fillRect(offset, 0, icon.getIconWidth() + myIpad.left + myIconTextGap, getHeight());
  }

  paintIcon(g, icon, offset + myIpad.left);
}
 
Example 3
Source File: SimpleColoredComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void doPaintIcon(@Nonnull Graphics2D g, @Nonnull Icon icon, int offset) {
  final Container parent = getParent();
  Color iconBackgroundColor = null;
  if ((isOpaque() || isIconOpaque()) && !isTransparentIconBackground()) {
    if (parent != null && !myFocusBorderAroundIcon && !UIUtil.isFullRowSelectionLAF()) {
      iconBackgroundColor = parent.getBackground();
    }
    else {
      iconBackgroundColor = getBackground();
    }
  }

  if (iconBackgroundColor != null) {
    g.setColor(iconBackgroundColor);
    g.fillRect(offset, 0, icon.getIconWidth() + myIpad.left + myIconTextGap, getHeight());
  }

  paintIcon(g, icon, offset + myIpad.left);
}
 
Example 4
Source File: NewErrorTreeEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
  myPanel.removeAll();
  myPanel.add(myLeft.getTreeCellRendererComponent(tree, value, false, expanded, leaf, row, true), BorderLayout.WEST);
  myPanel.add(myRight.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row), BorderLayout.EAST);

  if (UIUtil.isFullRowSelectionLAF()) {
    myPanel.setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    if (selected) {
      myPanel.setBackground(UIUtil.getTreeSelectionBackground());
    }
  }
  else if (selected) {
    myPanel.setBackground(UIUtil.getTreeSelectionBackground());
  }
  else {
    myPanel.setBackground(null);
  }

  if (value instanceof LoadingNode) {
    myPanel.setForeground(JBColor.GRAY);
  }
  else {
    myPanel.setForeground(tree.getForeground());
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected ||
      tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    myPanel.setOpaque(false);
  }
  return myPanel;
}
 
Example 5
Source File: InspectorColoredTreeCellRenderer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public final Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus) {
  myTree = tree;

  clear();

  myFocusedCalculated = false;

  // We paint background if and only if tree path is selected and tree has focus.
  // If path is selected and tree is not focused then we just paint focused border.
  if (UIUtil.isFullRowSelectionLAF()) {
    setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (WideSelectionTreeUI.isWideSelection(tree)) {
    setPaintFocusBorder(false);
    if (selected) {
      setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
    }
  }
  else if (selected) {
    setPaintFocusBorder(true);
    if (isFocused()) {
      setBackground(UIUtil.getTreeSelectionBackground());
    }
    else {
      setBackground(null);
    }
  }
  else {
    setBackground(null);
  }

  if (value instanceof LoadingNode) {
    setForeground(JBColor.GRAY);
  }
  else {
    setForeground(tree.getForeground());
    setIcon(null);
  }

  super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree


  if (tree.getUI() instanceof InspectorTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) {
    setMyBorder(null);
    setIpad(JBUI.insets(0, 2));
  }

  customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus);

  return this;
}
 
Example 6
Source File: InspectorColoredTreeCellRenderer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public final Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus) {
  myTree = tree;

  clear();

  myFocusedCalculated = false;

  // We paint background if and only if tree path is selected and tree has focus.
  // If path is selected and tree is not focused then we just paint focused border.
  if (UIUtil.isFullRowSelectionLAF()) {
    setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (WideSelectionTreeUI.isWideSelection(tree)) {
    setPaintFocusBorder(false);
    if (selected) {
      setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
    }
  }
  else if (selected) {
    setPaintFocusBorder(true);
    if (isFocused()) {
      setBackground(UIUtil.getTreeSelectionBackground());
    }
    else {
      setBackground(null);
    }
  }
  else {
    setBackground(null);
  }

  if (value instanceof LoadingNode) {
    setForeground(JBColor.GRAY);
  }
  else {
    setForeground(tree.getForeground());
    setIcon(null);
  }

  super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree


  if (tree.getUI() instanceof InspectorTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) {
    setMyBorder(null);
    setIpad(JBUI.insets(0, 2));
  }

  customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus);

  return this;
}
 
Example 7
Source File: ColoredTreeCellRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@RequiredUIAccess
public final Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus){
  myTree = tree;

  clear();

  mySelected = selected;
  myFocusedCalculated = false;

  // We paint background if and only if tree path is selected and tree has focus.
  // If path is selected and tree is not focused then we just paint focused border.
  if (UIUtil.isFullRowSelectionLAF()) {
    setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
  }
  else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    setPaintFocusBorder(false);
    if (selected) {
      setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
    }
  }
  else if (selected) {
    setPaintFocusBorder(true);
    if (isFocused()) {
      setBackground(UIUtil.getTreeSelectionBackground());
    }
    else {
      setBackground(null);
    }
  }
  else {
    setBackground(null);
  }

  if (value instanceof LoadingNode) {
    setForeground(JBColor.GRAY);
    setIcon(LOADING_NODE_ICON);
  }
  else {
    setForeground(tree.getForeground());
    setIcon(null);
  }

  if (UIUtil.isUnderGTKLookAndFeel()){
    super.setOpaque(false);  // avoid nasty background
    super.setIconOpaque(false);
  }
  else if (UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus) {
    super.setOpaque(false);  // avoid erasing Nimbus focus frame
    super.setIconOpaque(false);
  }
  else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    super.setOpaque(false);  // avoid erasing Nimbus focus frame
    super.setIconOpaque(false);
  }
  else {
    super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree
  }

  if (tree.getUI() instanceof WideSelectionTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) {
    setMyBorder(null);
    setIpad(new Insets(0, 2,  0, 2));
  }

  customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus);

  return this;
}