public void customizeCellRenderer( final ColoredTreeCellRenderer targetRenderer, CheckedTreeNode node, boolean selected, final boolean checked, boolean expanded, boolean leaf, boolean hasFocus) { targetRenderer.setIcon(PlatformIcons.PACKAGE_ICON); final String displayName; final CheckedTreeNode parent = (CheckedTreeNode) node.getParent(); if (parent != null && parent.getUserObject() instanceof PackageDescriptor) { final String parentPackageInTree = ((PackageDescriptor) parent.getUserObject()).getPackageName() + "."; displayName = myPackageName.startsWith(parentPackageInTree) ? myPackageName.substring(parentPackageInTree.length()) : myPackageName; } else { displayName = myPackageName; } targetRenderer.append( displayName, checked ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES); }
protected void customizeCellRenderer( final ColoredTreeCellRenderer targetRenderer, CheckedTreeNode node, boolean selected, final boolean checked, boolean expanded, boolean leaf, boolean hasFocus) { targetRenderer.setIcon(getDisplayIcon()); targetRenderer.append( getDisplayString(), checked ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES); }
@Override public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { invalidate(); final VirtualFile file = getFile(value); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; if (file == null) { if (value instanceof DefaultMutableTreeNode) { final Object uo = node.getUserObject(); if (uo instanceof String) { myColoredRenderer.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus); return myColoredRenderer; } } return myEmpty; } myCheckbox.setVisible(true); final TreeNodeState state = mySelectionManager.getState(node); myCheckbox.setEnabled( TreeNodeState.CLEAR.equals(state) || TreeNodeState.SELECTED.equals(state)); myCheckbox.setSelected(!TreeNodeState.CLEAR.equals(state)); myCheckbox.setOpaque(false); myCheckbox.setBackground(null); setBackground(null); myTextRenderer.getListCellRendererComponent(myFictive, file, 0, selected, hasFocus); revalidate(); return this; }