Refine search
@Override public void actionPerformed(ActionEvent e) { if (checkBoxTree.getSelectionPath() != null) { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) checkBoxTree.getSelectionPath().getLastPathComponent(); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) selectedNode.getParent(); if (parentNode != null) { DefaultMutableTreeNode immediateSiblingNode = directionUp ? (DefaultMutableTreeNode) parentNode.getChildBefore(selectedNode) : (DefaultMutableTreeNode) parentNode.getChildAfter(selectedNode); if (immediateSiblingNode != null) { parentNode.insert(immediateSiblingNode, parentNode.getIndex(selectedNode)); ((DefaultTreeModel) checkBoxTree.getModel()).nodeStructureChanged(parentNode); checkBoxTree.setSelectionPath(new TreePath(selectedNode.getPath())); } } } } }
TreeNode[] path = node.getPath(); TreePath tp = new TreePath(path); CheckedNode cn = new CheckedNode(false, node.getChildCount() > 0, false); nodesCheckingState.put(tp, cn); DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; Object obj = node.getUserObject(); TreePath tp = new TreePath(node.getPath()); CheckedNode cn = nodesCheckingState.get(tp); if (cn == null) {
protected void init() { // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("XChart Example Charts"); createNodes(top); tree = new JTree(top); // Create a tree that allows one selection at a time. tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes. tree.addTreeSelectionListener(this); // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create Chart Panel tabbedPane = new JTabbedPane(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } // select first leaf DefaultMutableTreeNode firstLeaf = top.getFirstLeaf(); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); // Add the scroll panes to a split pane. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(tabbedPane); Dimension minimumSize = new Dimension(130, 160); treeView.setMinimumSize(minimumSize); splitPane.setPreferredSize(new Dimension(700, 700)); // Add the split pane to this panel. add(splitPane); }
@Override public void execute() { if (MediatorGui.treeDatabase() == null) { LOGGER.error("Unexpected unregistered MediatorGui.treeDatabase() in "+ this.getClass()); } // Tree model, update the tree (refresh, add node, etc) DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel(); // First node in tree DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); // Loop into the list of databases for (Database database: this.databases) { // Create a node model with the database element AbstractNodeModel newTreeNodeModel = new NodeModelDatabase(database); // Create the node DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel); // Save the node MediatorGui.frame().getTreeNodeModels().put(database, newNode); // Add the node to the tree root.add(newNode); } // Refresh the tree treeModel.reload(root); // Open the root node MediatorGui.treeDatabase().expandPath(new TreePath(root.getPath())); MediatorGui.treeDatabase().setRootVisible(false); }
@Override public void selectAstNode(AstNode astNode) { if (astNode != null) { try { astSelectionEventDisabled = true; DefaultMutableTreeNode treeNode = getAstTreeNodeWithGivenUserObject((DefaultMutableTreeNode) astTree.getModel().getRoot(), astNode); astTree.getSelectionModel().addSelectionPath(new TreePath(treeNode.getPath())); } finally { astSelectionEventDisabled = false; } } }
@Override public void selectAstNode(AstNode astNode) { if (astNode != null) { try { astSelectionEventDisabled = true; DefaultMutableTreeNode treeNode = getAstTreeNodeWithGivenUserObject((DefaultMutableTreeNode) astTree.getModel().getRoot(), astNode); astTree.getSelectionModel().addSelectionPath(new TreePath(treeNode.getPath())); } finally { astSelectionEventDisabled = false; } } }
private void onWindowClosing() { JTree tre = _dialog.treFiles; tre.isCollapsed(new TreePath(_recentFilesNode.getPath())); Preferences.userRoot().putBoolean(PREF_KEY_RECENT_FILES_EXPANDED, tre.isExpanded(new TreePath(_recentFilesNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_FAVOURITE_FILES_EXPANDED, tre.isExpanded(new TreePath(_favouriteFilesNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_RECENT_ALIAS_FILES_EXPANDED, tre.isExpanded(new TreePath(_recentFilesForAliasNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_FAVOURITE_ALIAS_FILES_EXPANDED, tre.isExpanded(new TreePath(_favouriteFilesForAliasNode.getPath()))); }
private void onWindowClosing() { JTree tre = _dialog.treFiles; tre.isCollapsed(new TreePath(_recentFilesNode.getPath())); Preferences.userRoot().putBoolean(PREF_KEY_RECENT_FILES_EXPANDED, tre.isExpanded(new TreePath(_recentFilesNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_FAVOURITE_FILES_EXPANDED, tre.isExpanded(new TreePath(_favouriteFilesNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_RECENT_ALIAS_FILES_EXPANDED, tre.isExpanded(new TreePath(_recentFilesForAliasNode.getPath()))); Preferences.userRoot().putBoolean(PREF_KEY_FAVOURITE_ALIAS_FILES_EXPANDED, tre.isExpanded(new TreePath(_favouriteFilesForAliasNode.getPath()))); }
public TreePanel(DefaultMutableTreeNode root, ControlPanel pcp, boolean isMainPanel, Point location) { this.root=root; this.pcp=pcp; this.isMainPanel = isMainPanel; defaultLocation = location; rootPath=new TreePath(root.getPath()); title = (String)root.getUserObject(); buildTreePanel(); pcp.registerPanel(this); }