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

The following examples show how to use com.intellij.util.ui.UIUtil#getInactiveTextColor() . 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: BlazeTargetFilter.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private TextAttributes getHighlightAttributes() {
  if (highlightMatches) {
    // normal link highlighting, when we don't expect too many targets in the output
    return null;
  }
  // avoid a sea of blue in sync output: just add a grey underline to navigable targets
  return new TextAttributes(
      UIUtil.getActiveTextColor(),
      null,
      UIUtil.getInactiveTextColor(),
      EffectType.LINE_UNDERSCORE,
      Font.PLAIN);
}
 
Example 2
Source File: TextPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintComponent(final Graphics g) {
  String s = getText();
  int panelWidth = getWidth();
  int panelHeight = getHeight();
  Color background = getBackground();
  if (background != null && isOpaque()) {
    g.setColor(background);
    g.fillRect(0, 0, panelWidth, panelHeight);
  }
  if (s == null) return;

  Graphics2D g2 = (Graphics2D)g;
  g2.setFont(getFont());
  UISettings.setupAntialiasing(g);

  Rectangle bounds = new Rectangle(panelWidth, panelHeight);
  int x = getTextX(g2);
  int maxWidth = panelWidth - x - getInsets().right;
  FontMetrics fm = g.getFontMetrics();
  int textWidth = fm.stringWidth(s);
  if (textWidth > maxWidth) {
    s = truncateText(s, bounds, fm, new Rectangle(), new Rectangle(), maxWidth);
  }

  int y = UIUtil.getStringY(s, bounds, g2);
  Color foreground = isEnabled() ? getForeground() : UIUtil.getInactiveTextColor();
  g2.setColor(foreground);
  g2.drawString(s, x, y);
}
 
Example 3
Source File: ProjectStructureElementRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@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: RunAnythingItemBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static SimpleTextAttributes getDescriptionAttributes(boolean isSelected) {
  return new SimpleTextAttributes(STYLE_PLAIN, isSelected ? UIUtil.getListSelectionForeground(true) : UIUtil.getInactiveTextColor());
}
 
Example 5
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public Color getForeground(boolean selected, boolean focused, boolean inactive) {
  return (selected && focused) ? UIUtil.getListSelectionForeground() : inactive ? UIUtil.getInactiveTextColor() : null;
}
 
Example 6
Source File: GotoActionModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static Color defaultActionForeground(boolean isSelected, boolean hasFocus, @Nullable Presentation presentation) {
  if (isSelected) return UIUtil.getListSelectionForeground(hasFocus);
  if (presentation != null && !presentation.isEnabledAndVisible()) return UIUtil.getInactiveTextColor();
  return UIUtil.getListForeground();
}