private void addNonPreferredNameButtonActionPerformed() {
    Names namesModel = (Names) this.getModel();
    NonPreferredNames newNonPreferredName;
    DomainEditor dialogNonPreferredNames = null;
    try {
      dialogNonPreferredNames =
          DomainEditorFactory.getInstance()
              .createDomainEditorWithParent(NonPreferredNames.class, this.getParentEditor(), false);
    } catch (DomainEditorCreationException e) {
      new ErrorDialog(getParentEditor(), "Error creating editor for NonPreferredNames", e)
          .showDialog();
    }
    dialogNonPreferredNames.setNewRecord(true);

    int returnStatus;
    Boolean done = false;
    while (!done) {
      newNonPreferredName = new NonPreferredNames(namesModel);
      newNonPreferredName.setNameType(namesModel.getNameType());
      dialogNonPreferredNames.setModel(newNonPreferredName, null);
      returnStatus = dialogNonPreferredNames.showDialog();
      if (returnStatus == JOptionPane.OK_OPTION) {
        namesModel.addNonPreferredName(newNonPreferredName);
        nonPreferredNamesTable.getEventList().add(newNonPreferredName);
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        namesModel.addNonPreferredName(newNonPreferredName);
        nonPreferredNamesTable.getEventList().add(newNonPreferredName);
      } else {
        done = true;
      }
    }
  }
  private void addNote(String whereString) {

    Names namesModel = (Names) super.getModel();
    NameContactNotes newNote;
    DomainEditor dialog = null;
    try {
      dialog =
          DomainEditorFactory.getInstance()
              .createDomainEditorWithParent(NameContactNotes.class, this.getParentEditor(), false);
    } catch (DomainEditorCreationException e) {
      new ErrorDialog(getParentEditor(), "Error creating editor for NameContactNotes", e)
          .showDialog();
    }
    dialog.setNewRecord(true);
    Boolean done = false;
    int sequenceNumber = 0;
    Boolean first = true;
    int returnStatus;

    while (!done) {
      newNote = new NameContactNotes(namesModel);
      if (first) {
        sequenceNumber =
            SequencedObjectsUtils.determineSequenceOfNewItem(whereString, nameContactNotesTable);
        first = false;
      } else {
        sequenceNumber++;
      }
      newNote.setSequenceNumber(sequenceNumber);
      dialog.setModel(newNote, null);
      returnStatus = dialog.showDialog();
      if (returnStatus == javax.swing.JOptionPane.OK_OPTION) {
        namesModel.addNameContactNote(newNote);
        nameContactNotesTable.getEventList().add(newNote);
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        namesModel.addNameContactNote(newNote);
        nameContactNotesTable.getEventList().add(newNote);
      } else {
        done = true;
      }
    }
    dialog.setNewRecord(false);
  }
 protected int editRelatedRecord(
     DomainGlazedListTable table, Class clazz, Boolean buffered, DomainEditor domainEditor) {
   int selectedRow = table.getSelectedRow();
   if (selectedRow != -1) {
     DomainObject domainObject = table.getSortedList().get(selectedRow);
     if (domainEditor == null) {
       try {
         domainEditor =
             DomainEditorFactory.getInstance()
                 .createDomainEditorWithParent(clazz, editorField.getParentEditor(), false);
         domainEditor.setCallingTable(table);
       } catch (UnsupportedTableModelException e1) {
         new ErrorDialog(
                 editorField.getParentEditor(),
                 "Error creating editor for " + clazz.getSimpleName(),
                 e1)
             .showDialog();
       } catch (DomainEditorCreationException e) {
         new ErrorDialog(
                 editorField.getParentEditor(),
                 "Error creating editor for " + clazz.getSimpleName(),
                 e)
             .showDialog();
       }
     }
     domainEditor.setBuffered(buffered);
     domainEditor.setSelectedRow(selectedRow);
     domainEditor.setNavigationButtons();
     domainEditor.setModel(domainObject, null);
     int returnValue = domainEditor.showDialog();
     if (domainEditor.getBuffered()) {
       if (returnValue == JOptionPane.CANCEL_OPTION) {
         domainEditor.editorFields.cancelEdit();
       } else {
         domainEditor.editorFields.acceptEdit();
         ApplicationFrame.getInstance()
             .setRecordDirty(); // ok an edit was made, so set the record dirty
       }
     }
     return returnValue;
   } else {
     return JOptionPane.CANCEL_OPTION;
   }
 }
Ejemplo n.º 4
0
  public void createDomainEditors() {
    ApplicationFrame mainFrame = ApplicationFrame.getInstance();
    DomainTableWorkSurface worksurface;

    // Subjects
    DomainEditor subjectEditor = this.putDialog(Subjects.class, new SubjectEditor(mainFrame));
    subjectEditor.setMainHeaderColorAndTextByClass();
    subjectEditor.setIncludeSaveButton(true);
    this.putSearchDialog(Subjects.class, mainFrame);
    worksurface = mainFrame.getWorkSurface(Subjects.class);
    subjectEditor.setWorkSurface(worksurface);
    subjectEditor.setNavigationButtonListeners(worksurface);

    // Names
    DomainEditor namesEditor =
        this.putDialog(Names.class, new NameEditor(mainFrame, new NameFields()));
    namesEditor.setMainHeaderColorAndTextByClass();
    namesEditor.setIncludeSaveButton(true);
    this.putSearchDialog(Names.class, mainFrame);
    worksurface = mainFrame.getWorkSurface(Names.class);
    namesEditor.setWorkSurface(worksurface);
    namesEditor.setNavigationButtonListeners(worksurface);

    // constants
    DomainEditor constantsEditor =
        new DomainEditor(Constants.class, mainFrame, new ConstantsFields());
    constantsEditor.hidePrintAndNavigationButtons();
    DomainEditorFactory.getInstance()
        .putDialogAndSetListenerToSelf(Constants.class, constantsEditor);

    // Accessions
    DomainEditor accessionEditor =
        DomainEditorFactory.getInstance()
            .putDialog(Accessions.class, new AccessionEditor(mainFrame));
    accessionEditor.setMainHeaderColorAndTextByClass();
    accessionEditor.setIncludeSaveButton(true);
    this.putSearchDialog(Accessions.class, mainFrame);
    worksurface = mainFrame.getWorkSurface(Accessions.class);
    accessionEditor.setWorkSurface(worksurface);
    accessionEditor.setNavigationButtonListeners(worksurface);

    // Resources
    DomainEditor resourceEditor =
        DomainEditorFactory.getInstance().putDialog(Resources.class, new ResourceEditor(mainFrame));
    resourceEditor.setMainHeaderColorAndTextByClass();
    resourceEditor.setIncludeSaveButton(true);
    this.putSearchDialog(Resources.class, mainFrame);
    worksurface = mainFrame.getWorkSurface(Resources.class);
    resourceEditor.setWorkSurface(worksurface);
    resourceEditor.setNavigationButtonListeners(worksurface);

    // Digital Object Editor
    DomainEditor digitalObjectEditor =
        DomainEditorFactory.getInstance()
            .putDialog(DigitalObjects.class, new DigitalObjectEditor(mainFrame));
    digitalObjectEditor.setMainHeaderColorAndTextByClass();
    digitalObjectEditor.setIncludeSaveButton(true);
    this.putSearchDialog(DigitalObjects.class, mainFrame);
    worksurface = mainFrame.getWorkSurface(DigitalObjects.class);
    digitalObjectEditor.setWorkSurface(worksurface);
    digitalObjectEditor.setNavigationButtonListeners(worksurface);
  }
  private void addInstanceButtonActionPerformed() {
    //		ArchDescription archDescriptionModel = (ArchDescription) super.getModel();
    ArchDescriptionInstances newInstance = null;
    Vector<String> possibilities =
        LookupListUtils.getLookupListValues(LookupListUtils.LIST_NAME_INSTANCE_TYPES);
    ImageIcon icon = null;
    try {
      // add a special entry for digital object link to the possibilities vector
      possibilities.add(ArchDescriptionInstances.DIGITAL_OBJECT_INSTANCE_LINK);
      Collections.sort(possibilities);

      dialogInstances =
          (ArchDescriptionInstancesEditor)
              DomainEditorFactory.getInstance()
                  .createDomainEditorWithParent(
                      ArchDescriptionInstances.class, getParentEditor(), getInstancesTable());
    } catch (DomainEditorCreationException e) {
      new ErrorDialog(getParentEditor(), "Error creating editor for ArchDescriptionInstances", e)
          .showDialog();
    }

    dialogInstances.setNewRecord(true);

    int returnStatus;
    Boolean done = false;
    while (!done) {
      defaultInstanceType =
          (String)
              JOptionPane.showInputDialog(
                  getParentEditor(),
                  "What type of instance would you like to create",
                  "",
                  JOptionPane.PLAIN_MESSAGE,
                  icon,
                  possibilities.toArray(),
                  defaultInstanceType);
      System.out.println("adding new instance");
      if ((defaultInstanceType != null) && (defaultInstanceType.length() > 0)) {
        if (defaultInstanceType.equalsIgnoreCase(
            ArchDescriptionInstances.DIGITAL_OBJECT_INSTANCE)) {
          System.out.println("adding new digital instance");
          newInstance = new ArchDescriptionDigitalInstances(resourceComponentModel);
          addDatesToNewDigitalInstance(
              (ArchDescriptionDigitalInstances) newInstance, resourceComponentModel);
        } else if (defaultInstanceType.equalsIgnoreCase(
            ArchDescriptionInstances.DIGITAL_OBJECT_INSTANCE_LINK)) {
          // add a digital object link or links instead
          addDigitalInstanceLink((Resources) editorField.getModel());
          return;
        } else {
          newInstance = new ArchDescriptionAnalogInstances(resourceComponentModel);
        }

        newInstance.setInstanceType(defaultInstanceType);

        // see whether to use a plugin
        if (usePluginDomainEditor(true, newInstance, getInstancesTable())) {
          return;
        }

        dialogInstances.setModel(newInstance, null);
        //				dialogInstances.setResourceInfo((Resources) editorField.getModel());
        returnStatus = dialogInstances.showDialog();
        if (returnStatus == JOptionPane.OK_OPTION) {
          dialogInstances.commitChangesToCurrentRecord();
          resourceComponentModel.addInstance(newInstance);
          getInstancesTable().getEventList().add(newInstance);
          findLocationForInstance(newInstance);
          ApplicationFrame.getInstance().setRecordDirty(); // set the record dirty
          done = true;
        } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
          dialogInstances.commitChangesToCurrentRecord();
          resourceComponentModel.addInstance(newInstance);
          getInstancesTable().getEventList().add(newInstance);
          findLocationForInstance(newInstance);
          ApplicationFrame.getInstance().setRecordDirty(); // set the record dirty
        } else {
          done = true;
        }
      } else {
        done = true;
      }
    }
    dialogInstances.setNewRecord(false);
  }