com.intellij.ui.ColoredTreeCellRenderer Java Examples

The following examples show how to use com.intellij.ui.ColoredTreeCellRenderer. 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: BlazeCoverageProjectViewClassDecorator.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {
  PsiFile file = getPsiFileForJavaClass(node.getPsiElement());
  if (file == null) {
    return;
  }
  CoverageDataManager manager = getCoverageDataManager();
  CoverageSuitesBundle currentSuite = manager.getCurrentSuitesBundle();
  Project project = file.getProject();
  BlazeCoverageAnnotator annotator = getAnnotator(project, currentSuite);
  if (annotator == null) {
    return;
  }
  String string = annotator.getFileCoverageInformationString(file, currentSuite, manager);
  if (string != null) {
    appendCoverageInfo(cellRenderer, string);
  }
}
 
Example #2
Source File: ExtensionTreeCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  if (value instanceof ExtensionCheckedTreeNode) {
    ExtensionCheckedTreeNode extensionCheckedTreeNode = (ExtensionCheckedTreeNode)value;

    final ModuleExtensionProviderEP providerEP = extensionCheckedTreeNode.getProviderEP();
    if (providerEP == null) {
      return;
    }

    ColoredTreeCellRenderer textRenderer = getTextRenderer();

    boolean enabled = extensionCheckedTreeNode.isEnabled();
    textRenderer.setIcon(enabled ? providerEP.getIcon() : ImageEffects.transparent(providerEP.getIcon()));
    if (enabled) {
      textRenderer.append(providerEP.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
    else {
      textRenderer.append(providerEP.getName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
}
 
Example #3
Source File: BreakpointsFavoriteListProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void customizeRenderer(ColoredTreeCellRenderer renderer,
                              JTree tree,
                              @Nonnull Object value,
                              boolean selected,
                              boolean expanded,
                              boolean leaf,
                              int row,
                              boolean hasFocus) {
  renderer.clear();
  renderer.setIcon(AllIcons.Debugger.Db_set_breakpoint);
  if (value instanceof BreakpointItem) {
    BreakpointItem breakpointItem = (BreakpointItem)value;
    breakpointItem.setupGenericRenderer(renderer, true);
  }
  else if (value instanceof XBreakpointGroup) {
    renderer.append(((XBreakpointGroup)value).getName());
    renderer.setIcon(((XBreakpointGroup)value).getIcon(expanded));
  }
  else if (value instanceof XBreakpointGroupingRule) {
    renderer.append(((XBreakpointGroupingRule)value).getPresentableName());
  }
  else {
    renderer.append(String.valueOf(value));
  }
}
 
Example #4
Source File: BreakpointsTreeCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void customizeRenderer(Project project,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      ColoredTreeCellRenderer renderer) {
  if (value instanceof BreakpointItemNode) {
    BreakpointItemNode node = (BreakpointItemNode)value;
    BreakpointItem breakpoint = node.getBreakpointItem();
    breakpoint.setupRenderer(renderer, project, selected);
  }
  else if (value instanceof BreakpointsGroupNode) {
    XBreakpointGroup group = ((BreakpointsGroupNode)value).getGroup();
    renderer.setIcon(group.getIcon(expanded));
    renderer.append(group.getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
  }
}
 
Example #5
Source File: CoverageProjectViewDirectoryNodeDecorator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {
  final PsiElement element = node.getPsiElement();
  if (element == null || !element.isValid()) {
    return;
  }

  final CoverageDataManager manager = getCoverageDataManager();
  final CoverageSuitesBundle currentSuite = manager.getCurrentSuitesBundle();
  final CoverageAnnotator coverageAnnotator = currentSuite != null ? currentSuite.getAnnotator(element.getProject()) : null;
  if (coverageAnnotator == null) {
    // N/A
    return;
  }

  if (element instanceof PsiDirectory) {
    final String informationString = coverageAnnotator.getDirCoverageInformationString((PsiDirectory) element, currentSuite, manager);
    if (informationString != null) {
      appendCoverageInfo(cellRenderer, informationString);
    }
  }
}
 
Example #6
Source File: MethodNodeBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void customizeRenderer(ColoredTreeCellRenderer renderer) {
  if (myMethod == null) return;
  int flags = Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS;
  renderer.setIcon(IconDescriptorUpdaters.getIcon(myMethod, flags));

  customizeRendererText(renderer);
}
 
Example #7
Source File: AbstractFavoritesListProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void customizeRenderer(ColoredTreeCellRenderer renderer,
                              JTree tree,
                              @Nonnull Object value,
                              boolean selected,
                              boolean expanded,
                              boolean leaf,
                              int row,
                              boolean hasFocus) {
}
 
Example #8
Source File: FavoritesListProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
void customizeRenderer(ColoredTreeCellRenderer renderer,
JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus);
 
Example #9
Source File: BookmarksFavoriteListProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void customizeRenderer(ColoredTreeCellRenderer renderer,
                              JTree tree,
                              @Nonnull Object value,
                              boolean selected,
                              boolean expanded,
                              boolean leaf,
                              int row,
                              boolean hasFocus) {
  renderer.clear();
  renderer.setIcon(Bookmark.getDefaultIcon());
  if (value instanceof Bookmark) {
    Bookmark bookmark = (Bookmark)value;
    BookmarkItem.setupRenderer(renderer, myProject, bookmark, selected);
    if (renderer.getIcon() != null) {
      RowIcon icon = new RowIcon(3, RowIcon.Alignment.CENTER);
      icon.setIcon(TargetAWT.to(bookmark.getIcon()), 0);
      icon.setIcon(JBUI.scale(EmptyIcon.create(1)), 1);
      icon.setIcon(renderer.getIcon(), 2);
      renderer.setIcon(icon);
    }
    else {
      renderer.setIcon(bookmark.getIcon());
    }
  }
  else {
    renderer.append(getListName(myProject));
  }
}
 
Example #10
Source File: VcsLinkedTextComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void render(@Nonnull ColoredTreeCellRenderer renderer) {
  boolean isActive = mySelected || myUnderlined;
  SimpleTextAttributes linkTextAttributes = isActive ? SimpleTextAttributes.LINK_ATTRIBUTES : SimpleTextAttributes.SYNTHETIC_ATTRIBUTES;
  isActive = isActive || !myTransparent;
  SimpleTextAttributes wrappedTextAttributes = PushLogTreeUtil
    .addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isActive);
  if (!StringUtil.isEmptyOrSpaces(myTextBefore)) {
    renderer.append(myTextBefore, wrappedTextAttributes);
    renderer.append(" ");
  }
  if (!StringUtil.isEmptyOrSpaces(myHandledLink)) {
    renderer.append(myHandledLink, PushLogTreeUtil.addTransparencyIfNeeded(linkTextAttributes, isActive), this);
  }
  renderer.append(myTextAfter, wrappedTextAttributes);
}
 
Example #11
Source File: RepositoryNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void render(@Nonnull ColoredTreeCellRenderer renderer, @javax.annotation.Nullable String syncEditingText) {
  int repoFixedWidth = 120;
  SimpleTextAttributes repositoryDetailsTextAttributes = PushLogTreeUtil
          .addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isChecked());

  renderer.append(getRepoName(renderer, repoFixedWidth), repositoryDetailsTextAttributes);
  renderer.appendTextPadding(repoFixedWidth);
  renderer.append(myRepositoryPanel.getSourceName(), repositoryDetailsTextAttributes);
  renderer.append(myRepositoryPanel.getArrow(), repositoryDetailsTextAttributes);
  PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel();
  pushTargetPanel.render(renderer, renderer.getTree().isPathSelected(TreeUtil.getPathFromRoot(this)), isChecked(), syncEditingText);
}
 
Example #12
Source File: CommitNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void render(@Nonnull ColoredTreeCellRenderer renderer) {
  renderer.append("   ");
  TreeNode parent = getParent();
  new IssueLinkRenderer(myProject, renderer).appendTextWithLinks(getUserObject().getSubject(), PushLogTreeUtil
    .addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES,
                             !(parent instanceof RepositoryNode) || ((RepositoryNode)parent).isChecked()));
}
 
Example #13
Source File: TextWithLinkNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void render(@Nonnull ColoredTreeCellRenderer renderer) {
  renderer.append("   ");
  myLinkedText.setSelected(renderer.getTree().isPathSelected(TreeUtil.getPathFromRoot(this)));
  TreeNode parent = getParent();
  if (parent instanceof RepositoryNode) {
    myLinkedText.setTransparent(!((RepositoryNode)parent).isChecked());
  }
  myLinkedText.render(renderer);
}
 
Example #14
Source File: SingleRepositoryNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void render(@Nonnull ColoredTreeCellRenderer renderer) {
  renderer.append(" ");
  renderer.append(myRepositoryPanel.getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  renderer.append(myRepositoryPanel.getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel();
  pushTargetPanel.render(renderer, renderer.getTree().isPathSelected(TreeUtil.getPathFromRoot(this)), true, null);
}
 
Example #15
Source File: P4ChangeListDecorator.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Override
public void decorateChangeList(LocalChangeList changeList, ColoredTreeCellRenderer cellRenderer, boolean selected, boolean expanded, boolean hasFocus) {
    if (isProjectInvalid()) {
        return;
    }
    CacheComponent cache = CacheComponent.getInstance(project);
    ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project);
    Pair<IdeChangelistMap, IdeFileMap>
            openedCache = cache.getServerOpenedCache();
    try {
        Collection<P4ChangelistId> p4Changes = openedCache.first.getP4ChangesFor(changeList);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Change " + changeList + " has p4 changes " + p4Changes);
        }
        if (p4Changes.isEmpty()) {
            // Early exit
            return;
        }
        ChangelistConnectionInfo info = new ChangelistConnectionInfo(p4Changes.size());
        for (P4ChangelistId p4Change: p4Changes) {
            if (registry != null && registry.isOnline(p4Change.getClientServerRef())) {
                info.addOnline(p4Change);
            } else {
                info.addOffline(p4Change);
            }
        }
        decorateInfo(info, cellRenderer);
    } catch (InterruptedException e) {
        InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>(new VcsInterruptedException(e)));
    }
}
 
Example #16
Source File: RedisKeyValueDescriptor.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.setIcon(this.icon);
    if (this.keyType != null) {
        cellRenderer.append(this.keyType.name(), StyleAttributesProvider.getIndexAttribute());
        cellRenderer.append(" ");
    }
    cellRenderer.append(getFormattedKey(), StyleAttributesProvider.getKeyValueAttribute());
}
 
Example #17
Source File: RedisValueDescriptor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
@Override
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.append(getFormattedKey(), StyleAttributesProvider.getIndexAttribute());
}
 
Example #18
Source File: SyncStatusNodeDecorator.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {}
 
Example #19
Source File: Unity3dProjectViewNodeDecorator.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer)
{

}
 
Example #20
Source File: ProjectViewDecorator.java    From GitToolBox with Apache License 2.0 4 votes vote down vote up
@Override
public void decorate(PackageDependenciesNode packageDependenciesNode,
                     ColoredTreeCellRenderer coloredTreeCellRenderer) {
  log.debug("Decorate package dependencies");
}
 
Example #21
Source File: MongoKeyValueDescriptor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.append(getFormattedKey(), StyleAttributesProvider.getKeyValueAttribute());
}
 
Example #22
Source File: ChangesBrowserNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void appendCount(@Nonnull ColoredTreeCellRenderer renderer) {
  renderer.append(getCountText(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
 
Example #23
Source File: MongoValueDescriptor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.append(getFormattedKey(), StyleAttributesProvider.getIndexAttribute());
}
 
Example #24
Source File: BreakpointItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setupRenderer(ColoredTreeCellRenderer renderer, Project project, boolean selected) {
  boolean plainView = renderer.getTree().getClientProperty("plainView") != null;
  setupGenericRenderer(renderer, plainView);
}
 
Example #25
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setupRenderer(ColoredTreeCellRenderer renderer, Project project, boolean selected) {
  setupGenericRenderer(renderer, false);
}
 
Example #26
Source File: RepositoryWithBranchPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RepositoryWithBranchPanel(@Nonnull final Project project, @Nonnull String repoName,
                                 @Nonnull String sourceName, @Nonnull PushTargetPanel<T> destPushTargetPanelComponent) {
  super();
  setLayout(new BorderLayout());
  myRepositoryCheckbox = new JBCheckBox();
  myRepositoryCheckbox.setFocusable(false);
  myRepositoryCheckbox.setOpaque(false);
  myRepositoryCheckbox.setBorder(null);
  myRepositoryCheckbox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(@Nonnull ActionEvent e) {
      fireOnSelectionChange(myRepositoryCheckbox.isSelected());
    }
  });
  myRepositoryLabel = new JLabel(repoName);
  myLocalBranch = new JBLabel(sourceName);
  myArrowLabel = new JLabel(" " + UIUtil.rightArrow() + " ");
  myDestPushTargetPanelComponent = destPushTargetPanelComponent;
  myTextRenderer = new ColoredTreeCellRenderer() {
    @RequiredUIAccess
    @Override
    public void customizeCellRenderer(@Nonnull JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {

    }
  };
  myTextRenderer.setOpaque(false);
  layoutComponents();

  setInputVerifier(new InputVerifier() {
    @Override
    public boolean verify(JComponent input) {
      ValidationInfo error = myDestPushTargetPanelComponent.verify();
      if (error != null) {
        //noinspection ConstantConditions
        PopupUtil.showBalloonForComponent(error.component, error.message, MessageType.WARNING, false, project);
      }
      return error == null;
    }
  });

  JCheckBox emptyBorderCheckBox = new JCheckBox();
  emptyBorderCheckBox.setBorder(null);
}
 
Example #27
Source File: RepositoryNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private String getRepoName(@Nonnull ColoredTreeCellRenderer renderer, int maxWidth) {
  String name = myRepositoryPanel.getRepositoryName();
  return GraphicsUtil.stringWidth(name, renderer.getFont()) > maxWidth - UIUtil.DEFAULT_HGAP ? name + "  " : name;
}
 
Example #28
Source File: CouchbaseKeyValueDescriptor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.append(getFormattedKey(), StyleAttributesProvider.getKeyValueAttribute());
}
 
Example #29
Source File: RepositoryNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void render(@Nonnull ColoredTreeCellRenderer renderer) {
  render(renderer, null);
}
 
Example #30
Source File: FragmentedKeyNodeDescriptor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
@Override
public void renderNode(ColoredTreeCellRenderer cellRenderer) {
    cellRenderer.append(keyFragment, keyAttribute);
    cellRenderer.setIcon(AllIcons.Nodes.Advice);
}