Ejemplo n.º 1
0
 /**
  * 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);
   }
 }
Ejemplo n.º 2
0
  /**
   * 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);
    }
  }