Search in sources :

Example 1 with TreeTableNode

use of org.jdesktop.swingx.treetable.TreeTableNode in project platform by lsfusion.

the class GroupingDialog method createExpandButtons.

private void createExpandButtons() {
    expandButtonsPanel.removeAll();
    expandButtonsPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final List<JButton> buttons = new ArrayList<>();
    for (int i = 0; i <= treeTable.getLevelCount() - 1; i++) {
        JButton button = new JButton("" + i);
        if (i == 0) {
            button.setText("-");
            button.setToolTipText(getString("form.queries.grouping.collapse.all"));
        } else {
            button.setToolTipText(getString("form.queries.grouping.expand.level") + " " + i);
        }
        buttons.add(button);
        button.setMargin(new Insets(0, 0, 0, 0));
        button.setBorder(new LineBorder(Color.BLACK));
        button.setBackground(Color.WHITE);
        button.setContentAreaFilled(false);
        button.setOpaque(true);
        button.setFocusable(false);
        Dimension buttonSize = new Dimension(getIntUISize(14), getIntUISize(14));
        button.setFont(button.getFont().deriveFont(button.getFont().getStyle(), getUIFontSize(8)));
        button.setMaximumSize(buttonSize);
        button.setPreferredSize(buttonSize);
        button.addActionListener(new ActionListener() {

            Integer value;

            public void actionPerformed(ActionEvent e) {
                JButton source = (JButton) e.getSource();
                value = buttons.indexOf(source);
                expand(null, treeTable.getRoot());
            }

            private void expand(Object[] parents, TreeTableNode node) {
                if (parents == null || (Integer) node.getUserObject() <= value) {
                    TreePath pathToExpand;
                    Object[] newParents;
                    if (parents != null) {
                        pathToExpand = new TreePath(BaseUtils.add(parents, node));
                        newParents = BaseUtils.add(parents, node);
                    } else {
                        pathToExpand = new TreePath(node);
                        newParents = new Object[] { node };
                    }
                    treeTable.expandPath(pathToExpand);
                    for (int i = 0; i < node.getChildCount(); i++) {
                        expand(newParents, node.getChildAt(i));
                    }
                } else {
                    treeTable.collapsePath(new TreePath(BaseUtils.add(parents, node)));
                }
            }
        });
        expandButtonsPanel.add(button);
    }
    expandButtonsPanel.revalidate();
    expandButtonsPanel.repaint();
    if (expandButtonsPanel.getComponentCount() != 0) {
        // разворачиваем всё дерево
        ((JButton) expandButtonsPanel.getComponents()[expandButtonsPanel.getComponentCount() - 1]).doClick();
    }
}
Also used : TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode) MutableTreeTableNode(org.jdesktop.swingx.treetable.MutableTreeTableNode) LineBorder(javax.swing.border.LineBorder) TreePath(javax.swing.tree.TreePath)

Example 2 with TreeTableNode

use of org.jdesktop.swingx.treetable.TreeTableNode in project ganttproject by bardsoftware.

the class TreeTableContainer method expandAll.

private void expandAll(TreePath root) {
    getTree().expandPath(root);
    TreeTableNode node = (TreeTableNode) root.getLastPathComponent();
    for (int i = 0; i < node.getChildCount(); i++) {
        expandAll(root.pathByAddingChild(node.getChildAt(i)));
    }
}
Also used : DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode) TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode) MutableTreeTableNode(org.jdesktop.swingx.treetable.MutableTreeTableNode)

Example 3 with TreeTableNode

use of org.jdesktop.swingx.treetable.TreeTableNode in project ganttproject by bardsoftware.

the class TreeTableContainer method collapseAll.

private void collapseAll(TreePath root) {
    TreeTableNode node = (TreeTableNode) root.getLastPathComponent();
    for (int i = 0; i < node.getChildCount(); i++) {
        collapseAll(root.pathByAddingChild(node.getChildAt(i)));
    }
    getTree().collapsePath(root);
}
Also used : DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode) TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode) MutableTreeTableNode(org.jdesktop.swingx.treetable.MutableTreeTableNode)

Example 4 with TreeTableNode

use of org.jdesktop.swingx.treetable.TreeTableNode in project ganttproject by bardsoftware.

the class TreeUtil method getNextSibling.

static TreeTableNode getNextSibling(TreeTableNode node) {
    TreeTableNode parent = node.getParent();
    int idxNext = getNextSibling(parent, node);
    return idxNext == -1 ? null : parent.getChildAt(idxNext);
}
Also used : MutableTreeTableNode(org.jdesktop.swingx.treetable.MutableTreeTableNode) TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode)

Example 5 with TreeTableNode

use of org.jdesktop.swingx.treetable.TreeTableNode in project ganttproject by bardsoftware.

the class TreeUtil method getPrevSibling.

static TreeTableNode getPrevSibling(TreeTableNode node) {
    TreeTableNode parent = node.getParent();
    int idxPrev = getPrevSibling(parent, node);
    return idxPrev == -1 ? null : parent.getChildAt(idxPrev);
}
Also used : MutableTreeTableNode(org.jdesktop.swingx.treetable.MutableTreeTableNode) TreeTableNode(org.jdesktop.swingx.treetable.TreeTableNode)

Aggregations

TreeTableNode (org.jdesktop.swingx.treetable.TreeTableNode)9 DefaultMutableTreeTableNode (org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)5 MutableTreeTableNode (org.jdesktop.swingx.treetable.MutableTreeTableNode)5 TreePath (javax.swing.tree.TreePath)3 OpNode (com.evolveum.midpoint.schema.traces.OpNode)2 Node (com.evolveum.midpoint.studio.ui.trace.entry.Node)2 LineBorder (javax.swing.border.LineBorder)1 AssignmentNode (net.sourceforge.ganttproject.resource.AssignmentNode)1 Task (net.sourceforge.ganttproject.task.Task)1