Exemplo 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);
    }
  }
Exemplo n.º 2
0
 void deleteNode(DefaultMutableTreeNode node) throws Exception {
   DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
   HRMBusinessLogic logic = new HRMBusinessLogic(m_conn);
   logic.orgLogic.deleteOrganization(
       logic, m_sessionid, IDBConstants.MODUL_MASTER_DATA, ((Organization) node.getUserObject()));
   model.removeNodeFromParent(node);
 }
Exemplo n.º 3
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);
        }
      }
    }
  }
Exemplo n.º 4
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)));
    }
  }
Exemplo n.º 5
0
  void constructComponent() {
    setLayout(new BorderLayout());

    m_popupMenu = new JPopupMenu();
    mi_add = new JMenuItem("Add...");
    mi_add.addActionListener(this);
    m_popupMenu.add(mi_add);
    mi_edit = new JMenuItem("Edit...");
    mi_edit.addActionListener(this);
    m_popupMenu.add(mi_edit);
    mi_delete = new JMenuItem("Delete");
    mi_delete.addActionListener(this);
    m_popupMenu.addSeparator();
    m_popupMenu.add(mi_delete);

    m_tree = new OrganizationTree(m_conn, m_sessionid);
    m_tree.addMouseListener(new TreeMouseAdapter());

    add(new JScrollPane(m_tree), BorderLayout.CENTER);
  }