Ejemplo n.º 1
0
  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);
    }
  }
Ejemplo n.º 2
0
  void onAdd() {
    DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
    TreePath path = m_tree.getSelectionPath();
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    OrganizationEditorDlg dlg = null;

    if (node == model.getRoot())
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, null);
    else
      dlg =
          new OrganizationEditorDlg(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(), m_conn, m_sessionid, node);
    dlg.setVisible(true);

    if (dlg.getResponse() == JOptionPane.OK_OPTION) {
      Organization org = new Organization(dlg.getOrganization(), dlg.getOrganization().getCode());
      DefaultMutableTreeNode child = new DefaultMutableTreeNode(org);
      model.insertNodeInto(child, node, node.getChildCount());
      m_tree.scrollPathToVisible(new TreePath(model.getPathToRoot(child)));
    }
  }