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();
}
}
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)));
}
}
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);
}
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);
}
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);
}
Aggregations