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);
  }
  /**
   * Sets the model for this editor.
   *
   * @param model the model to be used
   */
  public final void setModel(final DomainObject model, InfiniteProgressPanel progressPanel) {
    super.setModel(model, progressPanel);

    Names namesModel = (Names) model;
    resourcesTable.updateCollection(namesModel.getResources());
    accessionsTable.updateCollection(namesModel.getAccessions());
    digitalObjectsTable.updateCollection(namesModel.getDigitalObjects());
    nameContactNotesTable.updateCollection(namesModel.getRelatedCollection(NameContactNotes.class));
    nonPreferredNamesTable.updateCollection(
        namesModel.getRelatedCollection(NonPreferredNames.class));

    setPluginModel(); // update any plugins with this new domain object
  }