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 onDelete() {
    TreePath path = m_tree.getSelectionPath();
    if (path != null) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      Object[] options = {"Yes", "No"};
      int choise =
          JOptionPane.showOptionDialog(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(),
              "Are you sure deleting this " + node + " ?",
              "Confirm",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[1]);

      if (choise == JOptionPane.YES_OPTION) {
        try {
          deleteNodeParent(node);
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
        }
      }
    }
  }
Ejemplo n.º 3
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)));
    }
  }