void onEdit() { DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel(); TreePath path = m_tree.getSelectionPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); Organization org = (Organization) node.getUserObject(); OrganizationEditorDlg dlg = null; if (parent == model.getRoot()) dlg = new OrganizationEditorDlg( pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, null, org); else dlg = new OrganizationEditorDlg( pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, (DefaultMutableTreeNode) node.getParent(), org); dlg.setVisible(true); if (dlg.getResponse() == JOptionPane.OK_OPTION) { node.setUserObject(dlg.getOrganization()); model.nodeChanged(node); } }
public void update() { if (myFileSystemTree != null) { myFileSystemTree.updateTree(); final DefaultTreeModel model = (DefaultTreeModel) myTree.getModel(); final int visibleRowCount = myTree.getVisibleRowCount(); for (int row = 0; row < visibleRowCount; row++) { final TreePath pathForRow = myTree.getPathForRow(row); if (pathForRow != null) { final TreeNode node = (TreeNode) pathForRow.getLastPathComponent(); if (node != null) { model.nodeChanged(node); } } } } }