コード例 #1
0
  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;
      }
    }
  }
コード例 #2
0
  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);
  }
  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);
  }