Java Code Examples for com.intellij.util.ui.UIUtil#getTreeSelectionBackground()
The following examples show how to use
com.intellij.util.ui.UIUtil#getTreeSelectionBackground() .
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: DiagnosticsTreeCellRenderer.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent, @NotNull String text, @NotNull SimpleTextAttributes attributes, boolean selected, @NotNull MultiIconSimpleColoredComponent simpleColoredComponent) { final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); if (speedSearch != null) { final Iterable<TextRange> fragments = speedSearch.matchingFragments(text); if (fragments != null) { final Color fg = attributes.getFgColor(); final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted); return; } } simpleColoredComponent.append(text, attributes); }
Example 2
Source File: DiagnosticsTreeCellRenderer.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent, @NotNull String text, @NotNull SimpleTextAttributes attributes, boolean selected, @NotNull MultiIconSimpleColoredComponent simpleColoredComponent) { final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); if (speedSearch != null) { final Iterable<TextRange> fragments = speedSearch.matchingFragments(text); if (fragments != null) { final Color fg = attributes.getFgColor(); final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted); return; } } simpleColoredComponent.append(text, attributes); }
Example 3
Source File: SpeedSearchUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void appendFragmentsForSpeedSearch(@Nonnull JComponent speedSearchEnabledComponent, @Nonnull String text, @Nonnull SimpleTextAttributes attributes, boolean selected, @Nonnull SimpleColoredComponent simpleColoredComponent) { final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); if (speedSearch != null) { final Iterable<TextRange> fragments = speedSearch.matchingFragments(text); if (fragments != null) { final Color fg = attributes.getFgColor(); final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted); return; } } simpleColoredComponent.append(text, attributes); }
Example 4
Source File: IgnoredSettingsPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (UIUtil.isUnderGTKLookAndFeel()) { final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); UIUtil.changeBackGround(this, background); } IgnoredFileBean bean = (IgnoredFileBean)value; final String path = bean.getPath(); if (path != null) { if (path.endsWith("/")) { append(VcsBundle.message("ignored.configure.item.directory", path), SimpleTextAttributes.REGULAR_ATTRIBUTES); } else { append(VcsBundle.message("ignored.configure.item.file", path), SimpleTextAttributes.REGULAR_ATTRIBUTES); } } else if (bean.getMask() != null) { append(VcsBundle.message("ignored.configure.item.mask", bean.getMask()), SimpleTextAttributes.REGULAR_ATTRIBUTES); } }
Example 5
Source File: InspectorTreeUI.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private static Color getSelectionBackground(@NotNull JTree tree, boolean checkProperty) { Object property = tree.getClientProperty(TREE_TABLE_TREE_KEY); if (property instanceof JTable) { return ((JTable)property).getSelectionBackground(); } boolean selection = tree.hasFocus(); if (!selection && checkProperty) { selection = Boolean.TRUE.equals(property); } return UIUtil.getTreeSelectionBackground(selection); }
Example 6
Source File: InspectorTreeUI.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private static Color getSelectionBackground(@NotNull JTree tree, boolean checkProperty) { Object property = tree.getClientProperty(TREE_TABLE_TREE_KEY); if (property instanceof JTable) { return ((JTable)property).getSelectionBackground(); } boolean selection = tree.hasFocus(); if (!selection && checkProperty) { selection = Boolean.TRUE.equals(property); } return UIUtil.getTreeSelectionBackground(selection); }
Example 7
Source File: TemplateTreeRenderer.java From idea-gitignore with MIT License | 5 votes |
/** * Renders checkbox tree cell filled with @{link TemplateTreeNode} data. * * @param tree current working tree * @param value template data * @param selected node is selected * @param expanded node is expanded * @param leaf node is a leaf * @param row node is a row * @param hasFocus node has focus */ public void customizeRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { if (!(value instanceof TemplateTreeNode)) { return; } TemplateTreeNode node = (TemplateTreeNode) value; final Color background = selected ? UIUtil.getTreeSelectionBackground(true) : UIUtil.getTreeBackground(); UIUtil.changeBackGround(this, background); Color foreground = selected ? UIUtil.getTreeSelectionForeground(true) : node.getTemplate() == null ? PlatformColors.BLUE : UIUtil.getTreeForeground(); int style = SimpleTextAttributes.STYLE_PLAIN; String text = "", hint = ""; if (node.getTemplate() != null) { // template leaf text = node.getTemplate().getName(); } else if (node.getContainer() != null) { // container group hint = IgnoreBundle.message("template.container." + node.getContainer().toString().toLowerCase()); getCheckbox().setVisible(false); } SearchUtil.appendFragments(getFilter(), text, style, foreground, background, getTextRenderer()); getTextRenderer().append(hint, selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, foreground) : SimpleTextAttributes.GRAYED_ATTRIBUTES ); setForeground(foreground); }
Example 8
Source File: CheckboxTreeNoPolicy.java From consulo with Apache License 2.0 | 5 votes |
@Override @RequiredUIAccess public final Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { invalidate(); if (value instanceof CheckedTreeNode) { CheckedTreeNode node = (CheckedTreeNode)value; NodeState state = getNodeStatus(node); myCheckbox.setVisible(true); myCheckbox.setSelected(state != NodeState.CLEAR); myCheckbox.setEnabled(node.isEnabled() && state != NodeState.PARTIAL); myCheckbox.setOpaque(false); myCheckbox.setBackground(null); setBackground(null); } else { myCheckbox.setVisible(false); } myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (UIUtil.isUnderGTKLookAndFeel()) { final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); UIUtil.changeBackGround(this, background); } else if (UIUtil.isUnderNimbusLookAndFeel()) { UIUtil.changeBackGround(this, UIUtil.TRANSPARENT_COLOR); } customizeRenderer(tree, value, selected, expanded, leaf, row, hasFocus); revalidate(); return this; }
Example 9
Source File: XDebuggerFramesList.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void customizeCellRenderer(@Nonnull final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) { // Fix GTK background if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); UIUtil.changeBackGround(this, background); } if (value == null) { append(XDebuggerBundle.message("stack.frame.loading.text"), SimpleTextAttributes.GRAY_ATTRIBUTES); return; } if (value instanceof String) { append((String)value, SimpleTextAttributes.ERROR_ATTRIBUTES); return; } XStackFrame stackFrame = (XStackFrame)value; if (!selected) { Color c = getFrameBgColor(stackFrame); if (c != null) { setBackground(c); } } stackFrame.customizePresentation(this); }
Example 10
Source File: IntentionSettingsTree.java From consulo with Apache License 2.0 | 5 votes |
private void initTree() { myTree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true) { @Override public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (!(value instanceof CheckedTreeNode)) return; CheckedTreeNode node = (CheckedTreeNode)value; SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES; final String text = getNodeText(node); final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); UIUtil.changeBackGround(this, background); if (text != null) { SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null, text, attributes.getStyle(), attributes.getFgColor(), background, getTextRenderer()); } } }, new CheckedTreeNode(null)); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); Object userObject = ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject(); selectionChanged(userObject); } }); myFilter = new MyFilterComponent(); myComponent = new JPanel(new BorderLayout()); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree, true); myComponent.add(myFilter, BorderLayout.NORTH); myComponent.add(scrollPane, BorderLayout.CENTER); myFilter.reset(); }
Example 11
Source File: WideSelectionTreeUI.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static Color getSelectionBackground(@Nonnull JTree tree, boolean checkProperty) { Object property = tree.getClientProperty(TREE_TABLE_TREE_KEY); if (property instanceof JTable) { return ((JTable)property).getSelectionBackground(); } boolean selection = tree.hasFocus(); if (!selection && checkProperty) { selection = Boolean.TRUE.equals(property); } return UIUtil.getTreeSelectionBackground(selection); }
Example 12
Source File: GroupedElementsRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Override protected Color getSelectionBackground() { return UIUtil.getTreeSelectionBackground(); }
Example 13
Source File: SpeedSearchUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void applySpeedSearchHighlighting(@Nonnull JComponent speedSearchEnabledComponent, @Nonnull SimpleColoredComponent coloredComponent, boolean mainTextOnly, boolean selected) { SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); // The bad thing is that SpeedSearch model is decoupled from UI presentation so we don't know the real matched text. // Our best guess is to get strgin from the ColoredComponent. We can only provide main-text-only option. Iterable<TextRange> ranges = speedSearch == null ? null : speedSearch.matchingFragments(coloredComponent.getCharSequence(mainTextOnly).toString()); Iterator<TextRange> rangesIterator = ranges != null ? ranges.iterator() : null; if (rangesIterator == null || !rangesIterator.hasNext()) return; Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); SimpleColoredComponent.ColoredIterator coloredIterator = coloredComponent.iterator(); TextRange range = rangesIterator.next(); main: while (coloredIterator.hasNext()) { coloredIterator.next(); int offset = coloredIterator.getOffset(); int endOffset = coloredIterator.getEndOffset(); if (!range.intersectsStrict(offset, endOffset)) continue; SimpleTextAttributes attributes = coloredIterator.getTextAttributes(); SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, attributes.getFgColor(), null, attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH); if (range.getStartOffset() > offset) { offset = coloredIterator.split(range.getStartOffset() - offset, attributes); } do { if (range.getEndOffset() <= endOffset) { offset = coloredIterator.split(range.getEndOffset() - offset, highlighted); if (rangesIterator.hasNext()) { range = rangesIterator.next(); } else { break main; } } else { coloredIterator.split(endOffset - offset, highlighted); continue main; } } while (range.intersectsStrict(offset, endOffset)); } }
Example 14
Source File: MultilineTreeCellRenderer.java From consulo with Apache License 2.0 | 4 votes |
public void paint(Graphics g) { int height = getHeight(); int width = getWidth(); int borderX = myLabelInsets.left - 1; int borderY = myLabelInsets.top - 1; int borderW = width - borderX - myLabelInsets.right + 2; int borderH = height - borderY - myLabelInsets.bottom + 1; if (myIcon != null) { int verticalIconPosition = (height - myIcon.getIconHeight())/2; myIcon.paintIcon(this, g, 0, verticalIconPosition); borderX += myIcon.getIconWidth(); borderW -= myIcon.getIconWidth(); } Color bgColor; Color fgColor; if (mySelected && myHasFocus){ bgColor = UIUtil.getTreeSelectionBackground(); fgColor = UIUtil.getTreeSelectionForeground(); } else{ bgColor = UIUtil.getTreeTextBackground(); fgColor = getForeground(); } // fill background if (!(myTree.getUI() instanceof WideSelectionTreeUI) || !((WideSelectionTreeUI)myTree.getUI()).isWideSelection()) { g.setColor(bgColor); g.fillRect(borderX, borderY, borderW, borderH); // draw border if (mySelected) { g.setColor(UIUtil.getTreeSelectionBorderColor()); UIUtil.drawDottedRectangle(g, borderX, borderY, borderX + borderW - 1, borderY + borderH - 1); } } // paint text recalculateWraps(); if (myTooSmall) { // TODO ??? return; } int fontHeight = getCurrFontMetrics().getHeight(); int currBaseLine = getCurrFontMetrics().getAscent(); currBaseLine += myTextInsets.top; g.setFont(getFont()); g.setColor(fgColor); UISettings.setupAntialiasing(g); if (!StringUtil.isEmpty(myPrefix)) { g.drawString(myPrefix, myTextInsets.left - myPrefixWidth + 1, currBaseLine); } for (int i = 0; i < myWraps.size(); i++) { String currLine = (String)myWraps.get(i); g.drawString(currLine, myTextInsets.left, currBaseLine); currBaseLine += fontHeight; // first is getCurrFontMetrics().getAscent() } }
Example 15
Source File: UiInspectorAction.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void customizeCellRenderer(@Nonnull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground(); Color background = selected ? UIUtil.getTreeSelectionBackground() : null; if (value instanceof HierarchyTree.ComponentNode) { HierarchyTree.ComponentNode componentNode = (HierarchyTree.ComponentNode)value; Component component = componentNode.getComponent(); if (!selected) { if (!component.isVisible()) { foreground = JBColor.GRAY; } else if (component.getWidth() == 0 || component.getHeight() == 0) { foreground = new JBColor(new Color(128, 10, 0), JBColor.BLUE); } else if (component.getPreferredSize() != null && (component.getSize().width < component.getPreferredSize().width || component.getSize().height < component.getPreferredSize().height)) { foreground = JBColor.BLUE; } if (myInitialSelection == componentNode.getComponent()) { background = new Color(31, 128, 8, 58); } } append(getComponentName(component)); append(": " + RectangleRenderer.toString(component.getBounds()), SimpleTextAttributes.GRAYED_ATTRIBUTES); if (component.isOpaque()) { append(", opaque", SimpleTextAttributes.GRAYED_ATTRIBUTES); } if (component.isDoubleBuffered()) { append(", double-buffered", SimpleTextAttributes.GRAYED_ATTRIBUTES); } componentNode.setText(toString()); setIcon(createColorIcon(component.getForeground(), component.getBackground())); } if (value instanceof HierarchyTree.ClickInfoNode) { append(value.toString()); setIcon(AllIcons.Ide.Rating); } setForeground(foreground); setBackground(background); SpeedSearchUtil.applySpeedSearchHighlighting(tree, this, false, selected); }