Java Code Examples for com.intellij.ui.SimpleTextAttributes#derive()
The following examples show how to use
com.intellij.ui.SimpleTextAttributes#derive() .
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: ShowUsagesTableCellRenderer.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
private static SimpleTextAttributes deriveAttributesWithColor(SimpleTextAttributes attributes, Color fileBgColor) { if (fileBgColor != null) { attributes = attributes.derive(-1, null, fileBgColor, null); } return attributes; }
Example 2
Source File: ChangeNodeDecorator.java From consulo with Apache License 2.0 | 4 votes |
public SimpleTextAttributes derive(final SimpleTextAttributes attributes) { return attributes.derive(myFontStyle, attributes.getFgColor(), attributes.getBgColor(), attributes.getWaveColor()); }
Example 3
Source File: ProjectStructureElementRenderer.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof MasterDetailsComponent.MyNode) { final MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode)value; final NamedConfigurable namedConfigurable = node.getConfigurable(); if (namedConfigurable == null) { return; } final String displayName = node.getDisplayName(); final Image icon = namedConfigurable.getIcon(expanded); setIcon(icon); setToolTipText(null); setFont(UIUtil.getTreeFont()); SimpleTextAttributes textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES; if (node.isDisplayInBold()) { textAttributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES; } else if (namedConfigurable instanceof ProjectStructureElementConfigurable) { final ProjectStructureElement projectStructureElement = ((ProjectStructureElementConfigurable)namedConfigurable).getProjectStructureElement(); if (projectStructureElement != null) { final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext == null ? null : myContext.getDaemonAnalyzer(); final ProjectStructureProblemsHolderImpl problemsHolder = daemonAnalyzer == null ? null : daemonAnalyzer.getProblemsHolder(projectStructureElement); if (problemsHolder != null && problemsHolder.containsProblems()) { final boolean isUnused = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.UNUSED); final boolean haveWarnings = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.WARNING); final boolean haveErrors = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.ERROR); Color foreground = isUnused ? UIUtil.getInactiveTextColor() : null; final int style = haveWarnings || haveErrors ? SimpleTextAttributes.STYLE_WAVED : -1; final Color waveColor = haveErrors ? JBColor.RED : haveWarnings ? JBColor.GRAY : null; textAttributes = textAttributes.derive(style, foreground, null, waveColor); setToolTipText(problemsHolder.composeTooltipMessage()); } append(displayName, textAttributes); String description = projectStructureElement.getDescription(); if (description != null) { append(" (" + description + ")", SimpleTextAttributes.GRAY_ATTRIBUTES, false); } return; } } append(displayName, textAttributes); } }
Example 4
Source File: FocusDebugger.java From consulo with Apache License 2.0 | 4 votes |
private SimpleTextAttributes maybeGrayOut(SimpleTextAttributes attr, boolean greyOut) { return greyOut ? attr.derive(attr.getStyle(), Color.gray, attr.getBgColor(), attr.getWaveColor()) : attr; }
Example 5
Source File: ShowUsagesTableCellRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Component textComponentSpanningWholeRow(@Nonnull SimpleColoredComponent chunks, Color panelBackground, Color panelForeground, final int column, @Nonnull final JTable table, int row) { final SimpleColoredComponent component = new SimpleColoredComponent() { @Override protected void doPaint(Graphics2D g) { int offset = 0; int i = 0; final TableColumnModel columnModel = table.getColumnModel(); while (i < column) { offset += columnModel.getColumn(i).getWidth(); i++; } g.translate(-offset, 0); //if (column == columnModel.getColumnCount()-1) { //} setSize(getWidth()+offset, getHeight()); // should increase the column width so that selection background will be visible even after offset translation super.doPaint(g); g.translate(+offset, 0); } @Nonnull @Override public Dimension getPreferredSize() { //return super.getPreferredSize(); return column == table.getColumnModel().getColumnCount()-1 ? super.getPreferredSize() : new Dimension(0,0); // it should span the whole row, so we can't return any specific value here, // because otherwise it would be used in the "max width" calculation in com.intellij.find.actions.ShowUsagesAction.calcMaxWidth } }; component.setIpad(new Insets(0,0,0,0)); component.setBorder(null); component.setBackground(panelBackground); component.setForeground(panelForeground); for (SimpleColoredComponent.ColoredIterator iterator = chunks.iterator(); iterator.hasNext(); ) { iterator.next(); String fragment = iterator.getFragment(); SimpleTextAttributes attributes = iterator.getTextAttributes(); attributes = attributes.derive(attributes.getStyle(), panelForeground, panelBackground, attributes.getWaveColor()); component.append(fragment, attributes); } return component; }
Example 6
Source File: ShowUsagesTableCellRenderer.java From consulo with Apache License 2.0 | 4 votes |
private static SimpleTextAttributes deriveAttributesWithColor(SimpleTextAttributes attributes, Color fileBgColor) { if (fileBgColor != null) { attributes = attributes.derive(-1,null, fileBgColor,null); } return attributes; }
Example 7
Source File: ShowUsagesTableCellRenderer.java From otto-intellij-plugin with Apache License 2.0 | 4 votes |
private static SimpleTextAttributes deriveAttributesWithColor(SimpleTextAttributes attributes, Color fileBgColor) { if (fileBgColor != null) { attributes = attributes.derive(-1,null, fileBgColor,null); } return attributes; }