/** Method for ok action. */ private void okAction() { try { java.lang.String oldPassword = java.lang.String.valueOf(oldPasswordField.getPassword()); java.lang.String newPassword = java.lang.String.valueOf(newPasswordField.getPassword()); java.lang.String confirmedPassword = java.lang.String.valueOf(confirmedPasswordField.getPassword()); if (!password.equals(oldPassword)) { javax.swing.JOptionPane.showMessageDialog( this, elv.util.Util.translate(elv.util.Util.OLD_STATEMENT), new elv.util.State(elv.util.State.ERROR).toString(), javax.swing.JOptionPane.ERROR_MESSAGE); oldPasswordField.setText(null); oldPasswordField.requestFocusInWindow(); newPasswordField.setText(null); confirmedPasswordField.setText(null); } else if (!newPassword.equals(confirmedPassword)) { javax.swing.JOptionPane.showMessageDialog( this, elv.util.Util.translate(elv.util.Util.CONFIRMED_STATEMENT), new elv.util.State(elv.util.State.ERROR).toString(), javax.swing.JOptionPane.ERROR_MESSAGE); oldPasswordField.setText(null); oldPasswordField.requestFocusInWindow(); newPasswordField.setText(null); confirmedPasswordField.setText(null); } else { password = newPassword; setVisible(false); dispose(); } } catch (java.lang.Exception exc) { elv.util.Error.showErrorMessage(this, exc); } }
/** Implemented method from interface <CODE>java.util.TimerTask</CODE>. */ public void run() { try { // Set and store properties. elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()) .setValue(new elv.util.State(elv.util.State.EXECUTED)); elv.util.Property.get(elv.task.Task.STARTED_NAME, task.getProperties()) .setValue(new java.util.Date()); elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties()).setValue(null); task.storeProperties(); // Execute. for (elv.task.executables.Executable iteratorExecutable : task.getExecutables()) { iteratorExecutable.execute(this); if (!isExecuted) { break; } } timer.cancel(); // Set and store properties. if (isExecuted()) { elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()) .setValue(new elv.util.State(elv.util.State.DONE)); } else { elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()) .setValue(new elv.util.State(elv.util.State.STOPPED)); } elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties()) .setValue(new java.util.Date()); task.storeProperties(); } catch (java.lang.Exception exc) { elv.util.Error.setExecutionError(task, exc); try { elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()) .setValue(new elv.util.State(elv.util.State.ERROR)); elv.util.Property.get(elv.task.Task.STOPPED_NAME, task.getProperties()) .setValue(new java.util.Date()); task.storeProperties(); } catch (java.lang.Exception ex) { elv.util.Error.logServerError(ex); } } isExecuted = false; }
/** 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
/** * Method for state change. * @param evt a <CODE>java.beans.PropertyChangeEvent</>code object. */ private void stateChange(java.beans.PropertyChangeEvent evt) { try { boolean previousIsEnabled = isEnabled; elv.util.State state = (elv.util.State) evt.getNewValue(); isEnabled = (!(task.getContainer() instanceof elv.task.Archive) && (state.equals(new elv.util.State(elv.util.State.UNDEFINED)) || state.equals(new elv.util.State(elv.util.State.DEFINED)) || state.equals(new elv.util.State(elv.util.State.SCHEDULED)))); if (isEnabled != previousIsEnabled) { setEnabled(isEnabled); } } catch (java.lang.Exception exc) { elv.util.Error.showErrorMessage(this, exc); } }
/** Constructor. */ public DiagnosisesTreeModel() { super(new javax.swing.tree.DefaultMutableTreeNode()); try { javax.swing.tree.DefaultMutableTreeNode nodeLevels[] = new javax.swing.tree.DefaultMutableTreeNode[10]; nodeLevels[0] = new javax.swing.tree.DefaultMutableTreeNode(parameterType.TITLE); javax.swing.tree.DefaultMutableTreeNode node = null; 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]); } catch (java.lang.Exception exc) { elv.util.Error.showErrorMessage(DiagnosisesPanel.this, exc); } }
/** * 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); } }
/** Implemented method from <CODE>elv.util.Saveable</CODE>. */ public void save() { if (isChanged()) { try { elv.util.client.ClientStub.storeParameters( task.getPropertyFolderPath() + elv.util.Util.getFS() + parameterType.getFile(), diagnosises); if (task != null) { elv.util.Property.get(elv.task.Task.MODIFIED_NAME, task.getProperties()) .setValue(new java.util.Date()); java.lang.String pathName = task.getPropertyFolderPath() + elv.util.Util.getFS() + task.getPropertyFile(); elv.util.client.ClientStub.storeProperties(pathName, task.getProperties()); // Fire property change for reload the task properties. task.getChangeSupport().firePropertyChange(elv.task.Task.MODIFIED_NAME, null, state); } setChanged(false); } catch (java.lang.Exception exc) { elv.util.Error.showErrorMessage(this, exc); } } }
/** * Constructor. * * @param diagnosises a vector of diagnosises. * @param parameterType the type of diagnosises. * @param cloneableTask the task with the cloneable diagnosises. */ public DiagnosisesPanel( elv.task.Task task, elv.util.parameters.Diagnosis parameterType, elv.task.Task cloneableTask) { this.task = task; this.parameterType = parameterType; try { state = (elv.util.State) elv.util.Property.get(elv.task.Task.STATE_NAME, task.getProperties()).getValue(); isEnabled = (!(task.getContainer() instanceof elv.task.Archive) && (state.equals(new elv.util.State(elv.util.State.UNDEFINED)) || state.equals(new elv.util.State(elv.util.State.DEFINED)) || state.equals(new elv.util.State(elv.util.State.SCHEDULED)))); if (state.equals(new elv.util.State(elv.util.State.UNDEFINED))) { diagnosises = new java.util.Vector<elv.util.parameters.Diagnosis>(); if (cloneableTask != null) { elv.util.State cloneState = (elv.util.State) elv.util.Property.get(elv.task.Task.STATE_NAME, cloneableTask.getProperties()) .getValue(); if (!cloneState.equals(new elv.util.State(elv.util.State.UNDEFINED))) { if (cloneableTask.getContainer() instanceof elv.task.Archive) { java.lang.String name = cloneableTask.getName() + elv.util.Util.ZIP_SEPARATOR + cloneableTask.PROPERTY_FOLDER + elv.util.Util.ZIP_SEPARATOR + parameterType.getFile(); diagnosises = elv.util.client.ClientStub.loadParameters( cloneableTask.getContainer().getFolderPath(), name, parameterType); } else { diagnosises = elv.util.client.ClientStub.loadParameters( cloneableTask.getPropertyFolderPath(), parameterType.getFile(), parameterType); } } } } else { if (task.getContainer() instanceof elv.task.Archive) { java.lang.String name = task.getName() + elv.util.Util.ZIP_SEPARATOR + task.PROPERTY_FOLDER + elv.util.Util.ZIP_SEPARATOR + parameterType.getFile(); diagnosises = elv.util.client.ClientStub.loadParameters( task.getContainer().getFolderPath(), name, parameterType); } else { diagnosises = elv.util.client.ClientStub.loadParameters( task.getPropertyFolderPath(), parameterType.getFile(), parameterType); } } // Set state change support. task.getChangeSupport() .addPropertyChangeListener( elv.util.State.TITLE, new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { stateChange(evt); } }); initComponents(); setEnabled(isEnabled); } catch (java.lang.Exception exc) { elv.util.Error.showErrorMessage(this, exc); } }
/** 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