com.intellij.ui.SimpleColoredComponent Java Examples

The following examples show how to use com.intellij.ui.SimpleColoredComponent. 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 otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode)node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon(false));
    SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0,0,0,0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example #2
Source File: VirtualFileCellRenderer.java    From intellij-reference-diagram with Apache License 2.0 6 votes vote down vote up
public static void render(SimpleColoredComponent renderer, FileFQNReference ref, Project project) {
    VirtualFile virtualFile = ref.getPsiElement().getContainingFile().getVirtualFile();
    PsiJavaFile psiFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile);
    int style = SimpleTextAttributes.STYLE_PLAIN;
    Color color = SimpleTextAttributes.LINK_BOLD_ATTRIBUTES.getFgColor();
    Icon icon = getIcon(virtualFile);
    String comment = null;
    if (!virtualFile.isValid()) style |= SimpleTextAttributes.STYLE_STRIKEOUT;
    boolean fileHidden = isFileHidden(virtualFile);
    if (fileHidden) {
        color = HIDDEN;
    } ;
    renderer.setIcon(!fileHidden || icon == null ? icon : getTransparentIcon(icon));
    SimpleTextAttributes attributes = new SimpleTextAttributes(style, color);
    renderer.append(psiFile.getPackageName() + "." + psiFile.getName(), attributes);
    renderer.append(" " + ref.toUsageString(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, SimpleTextAttributes.GRAY_ATTRIBUTES.getFgColor()));
    if (comment != null) renderer.append(comment, attributes);
}
 
Example #3
Source File: UnknownFileTypeDiffRequest.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public JComponent getComponent(@Nonnull final DiffContext context) {
  final SimpleColoredComponent label = new SimpleColoredComponent();
  label.setTextAlign(SwingConstants.CENTER);
  label.append("Can't show diff for unknown file type. ",
               new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
  if (myFileName != null) {
    label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
      @Override
      public void run() {
        FileType type = FileTypeChooser.associateFileType(myFileName);
        if (type != null) onSuccess(context);
      }
    });
    LinkMouseListenerBase.installSingleTagOn(label);
  }
  return JBUI.Panels.simplePanel(label).withBorder(JBUI.Borders.empty(5));
}
 
Example #4
Source File: ShowUsagesTableCellRenderer.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode) node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon(false));
    SimpleTextAttributes attributes =
        deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0, 0, 0, 0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example #5
Source File: HotfixGroupElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
public HotfixGroupElement(final String name, final Object data, final VirtualFile file, final Consumer<HotfixGate> hotfix,
                          final String fixDescription, final MutableErrorTreeView view) {
  super(name, data, file);
  myHotfix = hotfix;
  myFixDescription = fixDescription;
  myView = view;
  myLeftTreeCellRenderer = new CustomizeColoredTreeCellRenderer() {
    public void customizeCellRenderer(SimpleColoredComponent renderer,
                                      JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      renderer.setIcon(AllIcons.General.Error);

      final String[] text = getText();
      final String errorText = ((text != null) && (text.length > 0)) ? text[0] : "";
      renderer.append("Error: " + errorText, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  };
  myRightTreeCellRenderer = new MyRightRenderer();
}
 
Example #6
Source File: SpeedSearchUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #7
Source File: SpeedSearchUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void appendColoredFragmentForMatcher(@Nonnull String text,
                                                   SimpleColoredComponent component,
                                                   @Nonnull final SimpleTextAttributes attributes,
                                                   Matcher matcher,
                                                   Color selectedBg,
                                                   boolean selected) {
  if (!(matcher instanceof MinusculeMatcher) || (Registry.is("ide.highlight.match.in.selected.only") && !selected)) {
    component.append(text, attributes);
    return;
  }

  final Iterable<TextRange> iterable = ((MinusculeMatcher)matcher).matchingFragments(text);
  if (iterable != null) {
    final Color fg = attributes.getFgColor();
    final int style = attributes.getStyle();
    final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg);
    final SimpleTextAttributes highlighted = new SimpleTextAttributes(selectedBg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH);
    appendColoredFragments(component, text, iterable, plain, highlighted);
  }
  else {
    component.append(text, attributes);
  }
}
 
Example #8
Source File: RectanglePainter.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void paint(@Nonnull Graphics2D g2, @Nonnull String text, int paddingX, int paddingY, @Nonnull Color color) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
  g2.setFont(getLabelFont());
  g2.setStroke(new BasicStroke(1.5f));

  FontMetrics fontMetrics = g2.getFontMetrics();
  int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X;
  int height = fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;

  g2.setColor(color);
  if (mySquare) {
    g2.fillRect(paddingX, paddingY, width, height);
  }
  else {
    g2.fill(new RoundRectangle2D.Double(paddingX, paddingY, width, height, LABEL_ARC, LABEL_ARC));
  }

  g2.setColor(JBColor.BLACK);
  int x = paddingX + TEXT_PADDING_X;
  int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
  g2.drawString(text, x, y);

  config.restore();
}
 
Example #9
Source File: LinkMouseListenerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void installSingleTagOn(@Nonnull SimpleColoredComponent component) {
  new LinkMouseListenerBase<Consumer<MouseEvent>>() {
    @Nullable
    @Override
    protected Consumer<MouseEvent> getTagAt(@Nonnull MouseEvent e) {
      //noinspection unchecked
      return (Consumer<MouseEvent>)((SimpleColoredComponent)e.getSource()).getFragmentTagAt(e.getX());
    }

    @Override
    protected void handleTagClick(@Nullable Consumer<MouseEvent> tag, @Nonnull MouseEvent event) {
      if (tag != null) {
        tag.consume(event);
      }
    }
  }.installOn(component);
}
 
Example #10
Source File: FixedHotfixGroupElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
public FixedHotfixGroupElement(String name, Object data, VirtualFile file) {
  super(name, data, file);
  myCustomizeColoredTreeCellRenderer = new CustomizeColoredTreeCellRenderer() {
    public void customizeCellRenderer(SimpleColoredComponent renderer,
                                      JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      renderer.setIcon(AllIcons.General.Information);
      renderer.append("Fixed: ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      final String[] text = getText();
      final String checkedText = ((text != null) && (text.length > 0)) ? text[0] : "";
      renderer.append(checkedText, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  };
}
 
Example #11
Source File: SetValueInplaceEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private SetValueInplaceEditor(final XValueNodeImpl node, @Nonnull final String nodeName) {
  super(node, "setValue");
  myValueNode = node;
  myModifier = myValueNode.getValueContainer().getModifier();

  SimpleColoredComponent nameLabel = new SimpleColoredComponent();
  nameLabel.getIpad().right = 0;
  nameLabel.getIpad().left = 0;
  nameLabel.setIcon(myNode.getIcon());
  nameLabel.append(nodeName, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
  XValuePresentation presentation = node.getValuePresentation();
  if (presentation != null) {
    XValuePresentationUtil.appendSeparator(nameLabel, presentation.getSeparator());
  }
  myNameOffset = nameLabel.getPreferredSize().width;
  myEditorPanel = JBUI.Panels.simplePanel(myExpressionEditor.getComponent());
}
 
Example #12
Source File: ShowUsagesTableCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode)node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon());
    SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0,0,0,0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example #13
Source File: AbstractFindUsagesDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  JPanel panel = new JPanel(new GridBagLayout());
  GridBagConstraints gbConstraints = new GridBagConstraints();

  gbConstraints.insets = new Insets(0, 0, UIUtil.DEFAULT_VGAP, 0);
  gbConstraints.fill = GridBagConstraints.NONE;
  gbConstraints.weightx = 1;
  gbConstraints.weighty = 1;
  gbConstraints.anchor = GridBagConstraints.WEST;
  final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
  coloredComponent.setIpad(new Insets(0,0,0,0));
  coloredComponent.setMyBorder(null);
  configureLabelComponent(coloredComponent);
  panel.add(coloredComponent, gbConstraints);

  return panel;
}
 
Example #14
Source File: RunAnythingHelpItem.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void parseAndApplyStyleToParameters(@Nonnull SimpleColoredComponent component, @Nonnull String placeholder) {
  int lt = StringUtil.indexOf(placeholder, "<");
  if (lt == -1) {
    component.append(placeholder);
    return;
  }

  int gt = StringUtil.indexOf(placeholder, ">", lt);
  //appends leading
  component.append(gt > -1 ? placeholder.substring(0, lt) : placeholder);
  while (lt > -1 && gt > -1) {
    component.append(placeholder.substring(lt, gt + 1), SimpleTextAttributes.GRAY_ATTRIBUTES);

    lt = StringUtil.indexOf(placeholder, "<", gt);
    if (lt == -1) {
      component.append(placeholder.substring(gt + 1));
      break;
    }

    component.append(placeholder.substring(gt + 1, lt));
    gt = StringUtil.indexOf(placeholder, ">", lt);
  }
}
 
Example #15
Source File: RunAnythingItemBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Component createComponent(@Nullable String pattern, boolean isSelected, boolean hasFocus) {
  Component oldComponent = createComponent(isSelected);
  if (oldComponent != null) {
    return oldComponent;
  }

  JPanel component = new JPanel(new BorderLayout());
  Color background = UIUtil.getListBackground(isSelected, true);
  component.setBackground(background);

  SimpleColoredComponent textComponent = new SimpleColoredComponent();
  SpeedSearchUtil
          .appendColoredFragmentForMatcher(StringUtil.notNullize(getCommand()), textComponent, REGULAR_ATTRIBUTES, RunAnythingGroup.RUN_ANYTHING_MATCHER_BUILDER.fun(pattern).build(), background,
                                           isSelected);
  component.add(textComponent, BorderLayout.WEST);
  textComponent.appendTextPadding(20);
  setupIcon(textComponent, myIcon);
  addDescription(component, isSelected);

  return component;
}
 
Example #16
Source File: InspectionListCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.setOpaque(true);

  final Color bg = sel ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
  final Color fg = sel ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
  panel.setBackground(bg);
  panel.setForeground(fg);

  SimpleTextAttributes attr = sel ? SELECTED : PLAIN;
  if (value instanceof InspectionToolWrapper) {
    final InspectionToolWrapper toolWrapper = (InspectionToolWrapper)value;
    final SimpleColoredComponent c = new SimpleColoredComponent();
    SpeedSearchUtil.appendColoredFragmentForMatcher("  " + toolWrapper.getDisplayName(), c, attr, myMatcher, bg, sel);
    panel.add(c, BorderLayout.WEST);

    final SimpleColoredComponent group = new SimpleColoredComponent();
    SpeedSearchUtil.appendColoredFragmentForMatcher(toolWrapper.getGroupDisplayName() + "  ", group, attr, myMatcher, bg, sel);
    final JPanel right = new JPanel(new BorderLayout());
    right.setBackground(bg);
    right.setForeground(fg);
    right.add(group, BorderLayout.CENTER);
    final JLabel icon = new JLabel(TargetAWT.to(getIcon(toolWrapper)));
    icon.setBackground(bg);
    icon.setForeground(fg);
    right.add(icon, BorderLayout.EAST);
    panel.add(right, BorderLayout.EAST);
  }
  else {
    // E.g. "..." item
    return super.getListCellRendererComponent(list, value, index, sel, focus);
  }

  return panel;
}
 
Example #17
Source File: RunAnythingHelpItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Component createComponent(@Nullable String pattern, boolean isSelected, boolean hasFocus) {
  JPanel component = (JPanel)super.createComponent(pattern, isSelected, hasFocus);

  SimpleColoredComponent simpleColoredComponent = new SimpleColoredComponent();
  parseAndApplyStyleToParameters(simpleColoredComponent, myPlaceholder);
  appendDescription(simpleColoredComponent, myDescription, UIUtil.getListForeground(isSelected, true));
  setupIcon(simpleColoredComponent, myIcon);

  component.add(simpleColoredComponent, BorderLayout.WEST);

  return component;
}
 
Example #18
Source File: RunAnythingItemBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addDescription(@Nonnull JPanel panel, boolean isSelected) {
  String description = getDescription();
  if (description == null) {
    return;
  }

  SimpleColoredComponent descriptionComponent = new SimpleColoredComponent();
  descriptionComponent.append(description, getDescriptionAttributes(isSelected));
  descriptionComponent.setTextAlign(SwingConstants.RIGHT);
  panel.add(descriptionComponent, BorderLayout.CENTER);
}
 
Example #19
Source File: RunAnythingItemBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static void appendDescription(@Nonnull SimpleColoredComponent component, @Nullable String description, @Nonnull Color foreground) {
  if (description != null) {
    SimpleTextAttributes smallAttributes = new SimpleTextAttributes(STYLE_SMALLER, foreground);
    component.append(StringUtil.shortenTextWithEllipsis(description, 40, 0), smallAttributes);
    component.appendTextPadding(660, SwingConstants.RIGHT);
  }
}
 
Example #20
Source File: BaseTextCommentCellAppearance.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void customize(@Nonnull final SimpleColoredComponent component) {
  component.setIcon(getIcon());
  component.append(getPrimaryText(), myTextAttributes);
  final String secondaryText = getSecondaryText();
  if (!StringUtil.isEmptyOrSpaces(secondaryText)) {
    component.append(" (" + secondaryText + ")", myCommentAttributes);
  }
}
 
Example #21
Source File: AnalyzeSizeToolWindowTest.java    From size-analyzer with Apache License 2.0 5 votes vote down vote up
@Test
public void selectingCategoryNodeChangesCategoryPanel() {
  JPanel toolPanel = toolWindow.getContent();
  Component[] components = toolPanel.getComponents();
  OnePixelSplitter splitter = (OnePixelSplitter) components[0];
  JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent();
  JViewport leftView = leftPane.getViewport();
  Tree suggestionTree = (Tree) leftView.getView();

  assertThat(suggestionTree.getSelectionCount()).isEqualTo(0);

  TreePath webPPath = getTreePathWithString(suggestionTree, webPCategoryData.toString());
  suggestionTree.addSelectionPath(webPPath);
  JPanel rightPane = (JPanel) splitter.getSecondComponent();

  assertThat(suggestionTree.getSelectionCount()).isEqualTo(1);
  for (Component component : rightPane.getComponents()) {
    if (component instanceof SimpleColoredComponent) {
      assertThat(component.toString()).contains(webPCategoryData.toString());
      assertThat(component.toString()).contains("Estimated savings: 29.30 KB");
    } else if (component instanceof JPanel) {
      Component[] suggestionPanelComponents = ((JPanel) component).getComponents();
      assertThat(suggestionPanelComponents).hasLength(1);
      for (Component linkLabel : suggestionPanelComponents) {
        assertThat(((LinkLabel<?>) linkLabel).getText()).isEqualTo(SuggestionDataFactory.issueTypeNodeNames.get(IssueType.WEBP));
      }
    }
  }
}
 
Example #22
Source File: ChooseLibrariesDialogBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected LibraryDescriptor(final Project project, final NodeDescriptor parentDescriptor, final Library element) {
  super(project, parentDescriptor, element);
  final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance().forLibrary(project, element, false);
  final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
  appearance.customize(coloredComponent);
  final PresentationData templatePresentation = getTemplatePresentation();
  templatePresentation.setIcon(TargetAWT.from(coloredComponent.getIcon()));
  templatePresentation.addText(notEmpty(appearance.getText()), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
 
Example #23
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
  if (plainView) {
    renderer.setIcon(getIcon());
  }
  final SimpleTextAttributes attributes = myBreakpoint.isEnabled() ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES;
  renderer.append(StringUtil.notNullize(getDisplayText()), attributes);
  String description = getUserDescription();
  if (!StringUtil.isEmpty(description)) {
    renderer.append(" (" + description + ")", SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES);
  }
}
 
Example #24
Source File: CSharpMemberChooseObject.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
public void renderTreeNode(SimpleColoredComponent component, JTree tree)
{
	component.setIcon(IconDescriptorUpdaters.getIcon(myDeclaration, Iconable.ICON_FLAG_VISIBILITY));
	component.append(getPresentationText());
}
 
Example #25
Source File: ArrangementStandardSettingsManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private int parseWidth(@Nonnull ArrangementSettingsToken token, @Nonnull SimpleColoredComponent renderer) {
  renderer.clear();
  final String value = getPresentationValue(token);
  renderer.append(value, SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(token, true)));
  int result = renderer.getPreferredSize().width;

  renderer.clear();
  renderer.append(value, SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(token, false)));
  return Math.max(result, renderer.getPreferredSize().width);
}
 
Example #26
Source File: ArrangementStandardSettingsManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ArrangementStandardSettingsManager(@Nonnull ArrangementStandardSettingsAware delegate,
                                          @Nonnull ArrangementColorsProvider colorsProvider,
                                          @Nonnull Collection<StdArrangementRuleAliasToken> aliases)
{
  myDelegate = delegate;
  myColorsProvider = colorsProvider;
  myMutexes = delegate.getMutexes();
  myDefaultSettings = delegate.getDefaultSettings();

  SimpleColoredComponent renderer = new SimpleColoredComponent();
  myGroupingTokens = delegate.getSupportedGroupingTokens();
  if (myGroupingTokens != null) {
    parseWidths(myGroupingTokens, renderer);
    buildWeights(myGroupingTokens);
  }

  myMatchingTokens = delegate.getSupportedMatchingTokens();
  if (myMatchingTokens != null) {
    parseWidths(myMatchingTokens, renderer);
    buildWeights(myMatchingTokens);
  }

  final Set<ArrangementSettingsToken> aliasTokens = ContainerUtil.newHashSet();
  aliasTokens.addAll(aliases);

  myRuleAliases = aliases;
  myRuleAliasMutex = aliasTokens;
  if (!myRuleAliases.isEmpty()) {
    myRuleAliasToken = new CompositeArrangementSettingsToken(StdArrangementTokens.General.ALIAS, aliasTokens);
  }
}
 
Example #27
Source File: CustomizeColoredTreeCellRendererReplacement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public final void customizeCellRenderer(SimpleColoredComponent renderer,
                                        JTree tree,
                                        Object value,
                                        boolean selected,
                                        boolean expanded,
                                        boolean leaf,
                                        int row,
                                        boolean hasFocus) {
}
 
Example #28
Source File: HotfixGroupElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void customizeCellRenderer(SimpleColoredComponent renderer,
                                  JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  renderer.append(" ");
  if (myInProgress) {
    renderer.append("fixing...", SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES);
  } else {
    renderer.append("Fix: " + myFixDescription, SimpleTextAttributes.LINK_BOLD_ATTRIBUTES, myRunner);
  }
}
 
Example #29
Source File: ErrorViewStructure.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MyNavigatableWithDataElement(final Project project,
                                     @Nonnull ErrorTreeElementKind kind,
                                     GroupingElement parent,
                                     String[] message,
                                     @Nonnull final VirtualFile vf,
                                     String exportText,
                                     String rendererTextPrefix) {
  super(kind, parent, message, new OpenFileDescriptor(project, vf, -1, -1), exportText, rendererTextPrefix);
  myVf = vf;
  myCustomizeColoredTreeCellRenderer = new CustomizeColoredTreeCellRenderer() {
    @Override
    public void customizeCellRenderer(SimpleColoredComponent renderer,
                                      JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      final Icon icon = TargetAWT.to(myVf.getFileType().getIcon());
      renderer.setIcon(icon);
      final String[] messages = getText();
      final String text = messages == null || messages.length == 0 ? vf.getPath() : messages[0];
      renderer.append(text);
    }
  };
}
 
Example #30
Source File: RemoteStatusChangeNodeDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void decorate(Change change, SimpleColoredComponent component, boolean isShowFlatten) {
  final boolean state = myRemoteRevisionsCache.isUpToDate(change);
  if (myListState != null) myListState.report(myIdx, state);
  if (!state) {
    component.append(" ");
    component.append(VcsBundle.message("change.nodetitle.change.is.outdated"), SimpleTextAttributes.ERROR_ATTRIBUTES);
  }
}