Java Code Examples for com.intellij.ui.SimpleTextAttributes#REGULAR_ATTRIBUTES

The following examples show how to use com.intellij.ui.SimpleTextAttributes#REGULAR_ATTRIBUTES . 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: RoutePathChunk.java    From railways with MIT License 6 votes vote down vote up
@Override
public SimpleTextAttributes getTextAttrs() {
    switch(getType()) {
        case RoutePathChunk.PARAMETER:
            return isHighlighted() ? RailwaysColors.PARAM_TOKEN_HL_ATTR :
                    RailwaysColors.PARAM_TOKEN_ATTR;

        case RoutePathChunk.OPTIONAL:
            return isHighlighted() ? RailwaysColors.OPTIONAL_TOKEN_HL_ATTR :
                    RailwaysColors.OPTIONAL_TOKEN_ATTR;

        default:
            return isHighlighted() ? RailwaysColors.REGULAR_HL_ATTR :
                    SimpleTextAttributes.REGULAR_ATTRIBUTES;
    }
}
 
Example 2
Source File: OrderEntryAppearanceServiceImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static CellAppearanceEx formatRelativePath(@Nonnull final ContentFolder folder, @Nonnull final Image icon) {
  LightFilePointer folderFile = new LightFilePointer(folder.getUrl());
  VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(folder.getContentEntry().getUrl());
  if (file == null) return FileAppearanceService.getInstance().forInvalidUrl(folderFile.getPresentableUrl());

  String contentPath = file.getPath();
  String relativePath;
  SimpleTextAttributes textAttributes;
  VirtualFile folderFileFile = folderFile.getFile();
  if (folderFileFile == null) {
    String absolutePath = folderFile.getPresentableUrl();
    relativePath = absolutePath.startsWith(contentPath) ? absolutePath.substring(contentPath.length()) : absolutePath;
    textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
  }
  else {
    relativePath = VfsUtilCore.getRelativePath(folderFileFile, file, File.separatorChar);
    textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }

  relativePath = StringUtil.isEmpty(relativePath) ? "." + File.separatorChar : relativePath;
  return new SimpleTextCellAppearance(relativePath, icon, textAttributes);
}
 
Example 3
Source File: MessageTreeNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static MessageTreeNode createInfoMessage(XDebuggerTree tree, @Nonnull String message, @Nullable HyperlinkListener hyperlinkListener) {
  Matcher matcher = MessageTreeNodeWithLinks.HREF_PATTERN.matcher(message);
  if (hyperlinkListener == null || !matcher.find()) {
    return new MessageTreeNode(tree, null, message, SimpleTextAttributes.REGULAR_ATTRIBUTES, XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
  }

  List<Object> objects = new ArrayList<Object>();
  int prev = 0;
  do {
    if (matcher.start() != prev) {
      objects.add(message.substring(prev, matcher.start()));
    }
    objects.add(new HyperlinkListenerDelegator(matcher.group(2), matcher.group(1), hyperlinkListener));
    prev = matcher.end();
  }
  while (matcher.find());

  if (prev < message.length()) {
    objects.add(message.substring(prev));
  }
  return new MessageTreeNodeWithLinks(tree, objects);
}
 
Example 4
Source File: DartElementPresentationUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderElement(@NotNull Element element, @NotNull OutlineTreeCellRenderer renderer, boolean nameInBold) {
  final SimpleTextAttributes attributes =
    nameInBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;

  renderer.appendSearch(element.getName(), attributes);

  if (!StringUtil.isEmpty(element.getTypeParameters())) {
    renderer.appendSearch(element.getTypeParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getParameters())) {
    renderer.appendSearch(element.getParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getReturnType())) {
    renderer.append(" ");
    renderer.append(DartPresentableUtil.RIGHT_ARROW);
    renderer.append(" ");
    renderer.appendSearch(element.getReturnType(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
 
Example 5
Source File: DartElementPresentationUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderElement(@NotNull Element element, @NotNull OutlineTreeCellRenderer renderer, boolean nameInBold) {
  final SimpleTextAttributes attributes =
    nameInBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;

  renderer.appendSearch(element.getName(), attributes);

  if (!StringUtil.isEmpty(element.getTypeParameters())) {
    renderer.appendSearch(element.getTypeParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getParameters())) {
    renderer.appendSearch(element.getParameters(), attributes);
  }
  if (!StringUtil.isEmpty(element.getReturnType())) {
    renderer.append(" ");
    renderer.append(DartPresentableUtil.RIGHT_ARROW);
    renderer.append(" ");
    renderer.appendSearch(element.getReturnType(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
 
Example 6
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public SimpleTextAttributes style(@Nullable FlutterLogEntry entry, int attributes) {
  if (showColors && entry != null) {
    final FlutterLog.Level level = FlutterLog.Level.forValue(entry.getLevel());
    return getTextAttributesByLogLevel(level);
  }
  return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
 
Example 7
Source File: OrderEntryAppearanceServiceImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@SuppressWarnings("unchecked")
public CellAppearanceEx forOrderEntry(@Nonnull OrderEntry orderEntry) {
  OrderEntryType<?> type = orderEntry.getType();
  OrderEntryTypeEditor editor = OrderEntryTypeEditor.FACTORY.getByKey(type);
  if(editor != null) {
    return editor.getCellAppearance(orderEntry);
  }
  return new SimpleTextCellAppearance(orderEntry.getPresentableName(), null, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
Example 8
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final int count = stats.getValue(metric);

    final JBLabel label = new JBLabel(Integer.toString(count));
    panel.add(Box.createHorizontalGlue());
    panel.add(label);
    panel.add(Box.createHorizontalStrut(8));

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 9
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public SimpleTextAttributes style(@Nullable FlutterLogEntry entry, int attributes) {
  if (showColors && entry != null) {
    final FlutterLog.Level level = FlutterLog.Level.forValue(entry.getLevel());
    return getTextAttributesByLogLevel(level);
  }
  return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
 
Example 10
Source File: RouteActionChunk.java    From railways with MIT License 5 votes vote down vote up
@Override
public SimpleTextAttributes getTextAttrs() {
    SimpleTextAttributes textAttrs;

    if (getType() == RouteActionChunk.ACTION)
        textAttrs = isHighlighted() ?
                RailwaysColors.METHOD_HL_ATTR : RailwaysColors.METHOD_ATTR;
    else
        textAttrs = isHighlighted() ?
            RailwaysColors.REGULAR_HL_ATTR : SimpleTextAttributes.REGULAR_ATTRIBUTES;

    return textAttrs;
}
 
Example 11
Source File: NodeRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation,
                                                           @Nonnull EditorColorsScheme colorsScheme)
{
  if (presentation instanceof ColoredItemPresentation) {
    final TextAttributesKey textAttributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
    if (textAttributesKey == null) return SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final TextAttributes textAttributes = colorsScheme.getAttributes(textAttributesKey);
    return textAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.fromTextAttributes(textAttributes);
  }
  return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
 
Example 12
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BorderLayout());

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    final Location location = stats.getLocation();
    final String path = location.path;
    final String filename = PathUtil.getFileName(path);
    append(filename, attributes);

    final JBLabel label = new JBLabel(filename);
    label.setHorizontalAlignment(SwingConstants.RIGHT);
    panel.add(Box.createHorizontalGlue());
    panel.add(label, BorderLayout.CENTER);

    final JBLabel lineLabel = new JBLabel(":" + location.line);
    panel.add(lineLabel, BorderLayout.EAST);

    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
      lineLabel.setForeground(table.getSelectionForeground());
    }
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 13
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  if (value == null) return panel;
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

  if (value instanceof SlidingWindowStatsSummary) {
    final SlidingWindowStatsSummary stats = (SlidingWindowStatsSummary)value;
    final SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;

    final JBLabel label = new JBLabel(stats.getLocation().name);
    if (isSelected) {
      label.setForeground(table.getSelectionForeground());
    }
    final int count = stats.getValue(PerfMetric.lastFrame);
    label.setIcon(getIconForCount(idle ? 0 : count, true));
    panel.add(Box.createHorizontalStrut(16));
    panel.add(label);
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example 14
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 15
Source File: OrderEntryTypeEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
default CellAppearanceEx getCellAppearance(@Nonnull T orderEntry) {
  return new SimpleTextCellAppearance(orderEntry.getPresentableName(), null, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
Example 16
Source File: ColoredNodeDecorationUi.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
SimpleTextAttributes getNameAttributes() {
  return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
 
Example 17
Source File: NavBarItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NavBarItem(NavBarPanel panel, Object object, int idx, Disposable parent, boolean inPopup) {
  myPanel = panel;
  myUI = panel.getNavBarUI();
  myObject = object == null ? null : TreeAnchorizer.getService().createAnchor(object);
  myIndex = idx;
  isPopupElement = idx == -1;

  if (object != null) {
    NavBarPresentation presentation = myPanel.getPresentation();
    myText = presentation.getPresentableText(object, inPopup);
    myIcon = presentation.getIcon(object);
    myAttributes = presentation.getTextAttributes(object, false);
  }
  else {
    myText = "Sample";
    myIcon = AllIcons.Nodes.Folder;
    myAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }

  Disposer.register(parent == null ? panel : parent, this);

  setOpaque(false);
  setIpad(myUI.getElementIpad(isPopupElement));

  if (!isPopupElement) {
    setMyBorder(null);
    setBorder(null);
    setPaintFocusBorder(false);
    setIconOpaque(false);
    if (myPanel.allowNavItemsFocus()) {
      // Take ownership of Tab/Shift-Tab navigation (to move focus out of nav bar panel), as
      // navigation between items is handled by the Left/Right cursor keys. This is similar
      // to the behavior a JRadioButton contained inside a GroupBox.
      setFocusTraversalKeysEnabled(false);
      setFocusable(true);
      addKeyListener(new KeyHandler());
      addFocusListener(new FocusHandler());
    }
  }
  else {
    setIconOpaque(true);
    setFocusBorderAroundIcon(true);
  }

  update();
}
 
Example 18
Source File: SimpleTextCellAppearance.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static SimpleTextCellAppearance regular(@Nonnull final String text, @Nullable final Image icon) {
  return new SimpleTextCellAppearance(text, icon, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
Example 19
Source File: CertificateTreeBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void update(PresentationData presentation) {
  CertificateWrapper wrapper = getElement();
  SimpleTextAttributes attr = wrapper.isValid() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : STRIKEOUT_ATTRIBUTES;
  presentation.addText(wrapper.getSubjectField(COMMON_NAME), attr);
}
 
Example 20
Source File: MessageTreeNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static MessageTreeNode createMessageNode(XDebuggerTree tree, XDebuggerTreeNode parent, String message, @Nullable Image icon) {
  return new MessageTreeNode(tree, parent, message, SimpleTextAttributes.REGULAR_ATTRIBUTES, icon);
}