Search in sources :

Example 6 with TreeCellRenderer

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);
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) TreePath(javax.swing.tree.TreePath)

Example 7 with TreeCellRenderer

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)));
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) TableViewModel(com.intellij.util.ui.TableViewModel) TableView(com.intellij.ui.table.TableView) TreeTableView(com.intellij.ui.dualView.TreeTableView)

Example 8 with TreeCellRenderer

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));
        }
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Color(java.awt.Color) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) UIResource(javax.swing.plaf.UIResource)

Example 9 with TreeCellRenderer

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);
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 10 with TreeCellRenderer

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();
            }
        });
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) ComponentEvent(java.awt.event.ComponentEvent) DetailsComponent(com.intellij.openapi.ui.DetailsComponent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

TreeCellRenderer (javax.swing.tree.TreeCellRenderer)14 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)7 TreePath (javax.swing.tree.TreePath)4 ComponentAdapter (java.awt.event.ComponentAdapter)2 ComponentEvent (java.awt.event.ComponentEvent)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 CompilerOptionInfo (com.intellij.flex.model.bc.CompilerOptionInfo)1 ValueSource (com.intellij.flex.model.bc.ValueSource)1 DetailsComponent (com.intellij.openapi.ui.DetailsComponent)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 TreeTableView (com.intellij.ui.dualView.TreeTableView)1 TableView (com.intellij.ui.table.TableView)1 TableViewModel (com.intellij.util.ui.TableViewModel)1 Color (java.awt.Color)1 Insets (java.awt.Insets)1 Rectangle (java.awt.Rectangle)1 Enumeration (java.util.Enumeration)1 UIResource (javax.swing.plaf.UIResource)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeCellEditor (javax.swing.tree.DefaultTreeCellEditor)1