Java Code Examples for com.intellij.util.ui.UIUtil#getTreeTextBackground()
The following examples show how to use
com.intellij.util.ui.UIUtil#getTreeTextBackground() .
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: 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 6
Source File: TreeExpandableItemsHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void doPaintTooltipImage(final Component rComponent, final Rectangle cellBounds, final Graphics2D g, Integer key) { final boolean opaque = rComponent.isOpaque(); if (rComponent instanceof JComponent) { ((JComponent)rComponent).setOpaque(true); } if (myComponent.isRowSelected(key)) { rComponent.setBackground(UIUtil.getTreeSelectionBackground(myComponent.hasFocus())); } else { Color bg = UIUtil.getTreeTextBackground(); if (myComponent instanceof Tree && ((Tree)myComponent).isFileColorsEnabled()) { final Color color = ((Tree)myComponent).getFileColorForPath(myComponent.getPathForRow(key)); if (color != null) { bg = color; } } rComponent.setBackground(bg); } super.doPaintTooltipImage(rComponent, cellBounds, g, key); if (rComponent instanceof JComponent) { ((JComponent)rComponent).setOpaque(opaque); } }
Example 7
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 8
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 9
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 10
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() } }