Beispiel #1
0
 /**
  * Constructor.
  *
  * @param title the title of this wizard dialog.
  * @param password the actual password.
  */
 public PasswordsDialog(java.lang.String title, java.lang.String password) {
   super(elv.util.Util.getMainFrame(), title, true);
   this.password = password;
   try {
     initComponents();
     java.awt.Dimension windowSize = elv.util.Util.getMainFrame().getSize();
     java.awt.Point windowLocation = elv.util.Util.getMainFrame().getLocation();
     java.awt.Dimension dialogSize = getSize();
     java.awt.Point dialogLocation =
         new java.awt.Point(
             windowLocation.x + (windowSize.width - dialogSize.width) / 2,
             windowLocation.y + (windowSize.height - dialogSize.height) / 2);
     setLocation(
         (dialogLocation.x >= 0 ? dialogLocation.x : 0),
         (dialogLocation.y >= 0 ? dialogLocation.y : 0));
   } catch (java.lang.Exception exc) {
     elv.util.Error.showErrorMessage(this, exc);
   }
 }
Beispiel #2
0
 /** Method for Remove button action. */
 private void removeButtonActionPerformed(
     java.awt.event.ActionEvent evt) // GEN-FIRST:event_removeButtonActionPerformed
     { // GEN-HEADEREND:event_removeButtonActionPerformed
   try {
     javax.swing.tree.TreePath[] removedPaths = diagnosisesTree.getSelectionPaths();
     if (removedPaths != null) {
       javax.swing.tree.DefaultTreeModel treeModel =
           (javax.swing.tree.DefaultTreeModel) diagnosisesTree.getModel();
       javax.swing.tree.DefaultMutableTreeNode rootNode =
           (javax.swing.tree.DefaultMutableTreeNode) diagnosisesTree.getModel().getRoot();
       javax.swing.tree.DefaultMutableTreeNode node;
       javax.swing.tree.TreeNode[] parentNodes;
       elv.util.parameters.Diagnosis diagnosis;
       for (int i = 0; i < removedPaths.length; i++) {
         node = (javax.swing.tree.DefaultMutableTreeNode) removedPaths[i].getLastPathComponent();
         if (!node.isRoot()) {
           if (!isNodeAncestor(node, removedPaths, i)) {
             setChanged(true);
             elv.util.Util.getMainFrame().setChanged(true);
             treeModel.removeNodeFromParent(node);
             for (java.util.Enumeration e = node.preorderEnumeration(); e.hasMoreElements(); ) {
               node = (javax.swing.tree.DefaultMutableTreeNode) e.nextElement();
               diagnosis = (elv.util.parameters.Diagnosis) node.getUserObject();
               diagnosises.remove(diagnosis);
             }
           }
         }
       }
       node = rootNode;
       java.util.Enumeration e = node.preorderEnumeration();
       node = (javax.swing.tree.DefaultMutableTreeNode) e.nextElement();
       while (e.hasMoreElements()) {
         node = (javax.swing.tree.DefaultMutableTreeNode) e.nextElement();
         diagnosis = (elv.util.parameters.Diagnosis) node.getUserObject();
         parentNodes = node.getPath();
         for (int j = 1; j < parentNodes.length; j++) {
           node = (javax.swing.tree.DefaultMutableTreeNode) parentNodes[j];
           java.lang.String level = Integer.toString(node.getParent().getIndex(node) + 1);
           if (j == 1) {
             diagnosis.setParagraph(level);
           } else {
             diagnosis.setParagraph(diagnosis.getParagraph() + "." + level);
           }
         }
       }
     }
     setEnabled(isEnabled);
   } catch (java.lang.Exception exc) {
     elv.util.Error.showErrorMessage(this, exc);
   }
 } // GEN-LAST:event_removeButtonActionPerformed
Beispiel #3
0
  /** Method for Add button action. */
  private void addButtonActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_addButtonActionPerformed
      { // GEN-HEADEREND:event_addButtonActionPerformed
    try {
      javax.swing.JTree allDiagnosisesTree = new javax.swing.JTree();
      allDiagnosisesTree.setRootVisible(false);
      allDiagnosisesTree.setShowsRootHandles(true);
      allDiagnosisesTree.setCellRenderer(new elv.util.Util.DefaultTreeCellRenderer());
      allDiagnosisesTree.setModel(
          new javax.swing.tree.DefaultTreeModel(new javax.swing.tree.DefaultMutableTreeNode()) {

            /** Overridden constructor. */
            {
              javax.swing.tree.DefaultMutableTreeNode nodeLevels[] =
                  new javax.swing.tree.DefaultMutableTreeNode[10];
              javax.swing.tree.DefaultMutableTreeNode node = null;
              nodeLevels[0] =
                  new javax.swing.tree.DefaultMutableTreeNode(parameterType.getDefault());
              java.util.Vector<elv.util.parameters.Diagnosis> diagnosises =
                  parameterType.getAllDiagnosises();
              for (elv.util.parameters.Diagnosis iteratorDiagnosis : diagnosises) {
                node = new javax.swing.tree.DefaultMutableTreeNode(iteratorDiagnosis);
                nodeLevels[iteratorDiagnosis.getParagraphLevel()] = node;
                nodeLevels[iteratorDiagnosis.getParagraphLevel() - 1].add(node);
              }
              setRoot(nodeLevels[0]);
            }
          });
      javax.swing.JScrollPane allDiagnosisesScrollPane = new javax.swing.JScrollPane();
      allDiagnosisesScrollPane.setViewportView(allDiagnosisesTree);
      int returnOption =
          elv.util.Option.okCancel(allDiagnosisesScrollPane, parameterType.getTitle());
      if (returnOption == javax.swing.JOptionPane.OK_OPTION
          && allDiagnosisesTree.getSelectionPaths() != null) {
        javax.swing.tree.DefaultTreeModel treeModel =
            (javax.swing.tree.DefaultTreeModel) diagnosisesTree.getModel();
        javax.swing.tree.DefaultMutableTreeNode rootNode =
            (javax.swing.tree.DefaultMutableTreeNode) diagnosisesTree.getModel().getRoot();
        javax.swing.tree.DefaultMutableTreeNode node;
        javax.swing.tree.TreeNode[] parentNodes;
        elv.util.parameters.Diagnosis diagnosis;
        for (int i = 0; i < allDiagnosisesTree.getSelectionPaths().length; i++) {
          node =
              (javax.swing.tree.DefaultMutableTreeNode)
                  allDiagnosisesTree.getSelectionPaths()[i].getLastPathComponent();
          if (!isNodeChild(node, rootNode)) {
            setChanged(true);
            elv.util.Util.getMainFrame().setChanged(true);
            treeModel.insertNodeInto(node, rootNode, rootNode.getChildCount());
            if (i == 0) {
              diagnosisesTree.scrollPathToVisible(new javax.swing.tree.TreePath(node.getPath()));
            }
            for (java.util.Enumeration e = node.preorderEnumeration(); e.hasMoreElements(); ) {
              node = (javax.swing.tree.DefaultMutableTreeNode) e.nextElement();
              diagnosis = (elv.util.parameters.Diagnosis) node.getUserObject();
              parentNodes = node.getPath();
              for (int j = 1; j < parentNodes.length; j++) {
                node = (javax.swing.tree.DefaultMutableTreeNode) parentNodes[j];
                java.lang.String level = Integer.toString(node.getParent().getIndex(node) + 1);
                if (j == 1) {
                  diagnosis.setParagraph(level);
                } else {
                  diagnosis.setParagraph(diagnosis.getParagraph() + "." + level);
                }
              }
              diagnosises.add(diagnosis);
            }
          }
        }
      }
    } catch (java.lang.Exception exc) {
      elv.util.Error.showErrorMessage(this, exc);
    }
  } // GEN-LAST:event_addButtonActionPerformed