use of javax.swing.tree.TreeCellRenderer in project intellij-community by JetBrains.
the class TreeExpandableItemsHandler method getCellRendererAndBounds.
@Override
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
int rowIndex = key.intValue();
TreePath path = myComponent.getPathForRow(rowIndex);
if (path == null)
return null;
Rectangle bounds = myComponent.getPathBounds(path);
if (bounds == null)
return null;
TreeCellRenderer renderer = myComponent.getCellRenderer();
if (renderer == null)
return null;
Object node = path.getLastPathComponent();
Component rendererComponent = renderer.getTreeCellRendererComponent(myComponent, node, myComponent.isRowSelected(rowIndex), myComponent.isExpanded(rowIndex), myComponent.getModel().isLeaf(node), rowIndex, myComponent.hasFocus());
return Pair.create(rendererComponent, bounds);
}
use of javax.swing.tree.TreeCellRenderer in project intellij-community by JetBrains.
the class FileHistoryPanelImpl method setupDualView.
private void setupDualView(@NotNull DefaultActionGroup group) {
myDualView.setShowGrid(true);
PopupHandler.installPopupHandler(myDualView.getTreeView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
PopupHandler.installPopupHandler(myDualView.getFlatView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myDualView, true);
});
myDualView.addListSelectionListener(e -> updateMessage());
myDualView.setRootVisible(false);
myDualView.expandAll();
final TreeCellRenderer defaultCellRenderer = myDualView.getTree().getCellRenderer();
final Getter<VcsHistorySession> sessionGetter = () -> myHistorySession;
myDualView.setTreeCellRenderer(new MyTreeCellRenderer(defaultCellRenderer, sessionGetter));
myDualView.setCellWrapper(new MyCellWrapper(sessionGetter));
myDualView.installDoubleClickHandler(new MyDiffAction());
final TableView flatView = myDualView.getFlatView();
TableViewModel sortableModel = flatView.getTableViewModel();
sortableModel.setSortable(true);
final RowSorter<? extends TableModel> rowSorter = flatView.getRowSorter();
if (rowSorter != null) {
rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(0, SortOrder.DESCENDING)));
}
}
use of javax.swing.tree.TreeCellRenderer in project jdk8u_jdk by JetBrains.
the class SynthTreeUI method configureRenderer.
private void configureRenderer(SynthContext context) {
TreeCellRenderer renderer = tree.getCellRenderer();
if (renderer instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer r = (DefaultTreeCellRenderer) renderer;
SynthStyle style = context.getStyle();
context.setComponentState(ENABLED | SELECTED);
Color color = r.getTextSelectionColor();
if (color == null || (color instanceof UIResource)) {
r.setTextSelectionColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
}
color = r.getBackgroundSelectionColor();
if (color == null || (color instanceof UIResource)) {
r.setBackgroundSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
}
context.setComponentState(ENABLED);
color = r.getTextNonSelectionColor();
if (color == null || color instanceof UIResource) {
r.setTextNonSelectionColor(style.getColorForState(context, ColorType.TEXT_FOREGROUND));
}
color = r.getBackgroundNonSelectionColor();
if (color == null || color instanceof UIResource) {
r.setBackgroundNonSelectionColor(style.getColorForState(context, ColorType.TEXT_BACKGROUND));
}
}
}
use of javax.swing.tree.TreeCellRenderer in project groovy by apache.
the class ClosureRenderer method render.
private Component render() {
if (children.isEmpty() || defaultRenderer) {
defaultRenderer = true;
children.clear();
if (table != null) {
TableCellRenderer tcr;
if (tableHeader) {
tcr = table.getTableHeader().getDefaultRenderer();
} else {
tcr = table.getDefaultRenderer(table.getColumnClass(column));
}
children.add(tcr.getTableCellRendererComponent(table, value, selected, focused, row, column));
} else if (tree != null) {
TreeCellRenderer tcr;
tcr = new DefaultTreeCellRenderer();
children.add(tcr.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focused));
} else if (list != null) {
ListCellRenderer lcr = (ListCellRenderer) UIManager.get("List.cellRenderer");
if (lcr == null) {
lcr = new DefaultListCellRenderer();
}
children.add(lcr.getListCellRendererComponent(list, value, row, selected, focused));
}
}
Object o = update.call();
if (o instanceof Component) {
return (Component) o;
} else {
return (Component) children.get(0);
}
}
use of javax.swing.tree.TreeCellRenderer in project intellij-community by JetBrains.
the class FacetStructureConfigurable method initTree.
@Override
protected void initTree() {
super.initTree();
if (!myTreeWasInitialized) {
myTreeWasInitialized = true;
final FacetsTreeCellRenderer separatorRenderer = new FacetsTreeCellRenderer();
final TreeCellRenderer oldRenderer = myTree.getCellRenderer();
myTree.setCellRenderer(new TreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof MyNode && ((MyNode) value).getConfigurable() instanceof FrameworkDetectionConfigurable) {
return separatorRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
return oldRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
});
myTree.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
revalidateTree();
}
@Override
public void componentMoved(ComponentEvent e) {
revalidateTree();
}
@Override
public void componentShown(ComponentEvent e) {
revalidateTree();
}
});
}
}
Aggregations