protected void addIdentifierActionPerformed(
      DomainSortableTable identifierTable, ResourcesComponents model) {
    ArchDescComponentIdentifiers newArchDescComponentIdentifier;
    DomainEditor dialog =
        new DomainEditor(
            ArchDescComponentIdentifiers.class,
            editorField.getParentEditor(),
            "Add Identifier",
            new ArchDescComponentIdentifiersFields());
    dialog.setNavigationButtonListeners((ActionListener) editorField.getParentEditor());
    dialog.setNewRecord(true);

    boolean done = false;
    int returnStatus;
    while (!done) {
      newArchDescComponentIdentifier = new ArchDescComponentIdentifiers(model);
      dialog.setModel(newArchDescComponentIdentifier, null);
      returnStatus = dialog.showDialog();

      if (returnStatus == JOptionPane.OK_OPTION) {
        model.addArchDescComponentIdentifier(newArchDescComponentIdentifier);
        identifierTable.updateCollection(model.getArchDescComponentIdentifiers());
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        model.addArchDescComponentIdentifier(newArchDescComponentIdentifier);
        identifierTable.updateCollection(model.getArchDescComponentIdentifiers());
      } else {
        done = true;
      }
    }
  }
  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;
      }
    }
  }
Пример #3
0
 private DomainEditor assignCallingTableAndModel(
     DomainEditor domainEditor, JTable callingTable, DomainObject callingDomainModel) {
   try {
     domainEditor.setCallingTable(callingTable);
   } catch (UnsupportedTableModelException e) {
     new ErrorDialog(domainEditor, "Unsupported table model", e).showDialog();
   }
   domainEditor.setCallingModel(callingDomainModel);
   return domainEditor;
 }
 private void dateTableMouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     try {
       DomainEditor domainEditor =
           new DomainEditor(
               ArchDescriptionDates.class,
               editorField.getParentEditor(),
               "Dates",
               new ArchDescriptionDatesFields());
       domainEditor.setCallingTable(dateTable);
       domainEditor.setNavigationButtonListeners(domainEditor);
       editRelatedRecord(dateTable, ArchDescriptionDates.class, true, domainEditor);
     } catch (UnsupportedTableModelException e1) {
       new ErrorDialog("Error creating editor for Dates", e1).showDialog();
     }
   }
 }
  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;
   }
 }
Пример #7
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);
  }
Пример #8
0
  public DomainEditor createDomainEditorWithParent(
      final Class clazz, final JDialog parent, boolean useParentAsEventListener)
      throws DomainEditorCreationException {

    DomainEditor domainEditor = null;
    if (clazz == BibItems.class) {
      domainEditor =
          new DomainEditor(BibItems.class, parent, "Bibliographic Items", new BibItemsFields());

    } else if (clazz == ChronologyItems.class) {
      domainEditor = new DomainEditor(ChronologyItems.class, parent, new ChronologyItemsFields());

    } else if (clazz == IndexItems.class) {
      domainEditor =
          new DomainEditor(IndexItems.class, parent, "Index Items", new IndexItemsFields());

    } else if (clazz == ListOrderedItems.class) {
      domainEditor =
          new DomainEditor(
              ListOrderedItems.class, parent, "List Items", new ListOrderedItemsFields());

    } else if (clazz == ListDefinitionItems.class) {
      domainEditor =
          new DomainEditor(
              ListDefinitionItems.class, parent, "List Items", new ListDefinitionItemsFields());

    } else if (clazz == Subjects.class) {
      domainEditor = new DomainEditor(Subjects.class, parent, new SubjectFields());

    } else if (clazz == AccessionsLocations.class) {
      domainEditor =
          new DomainEditor(AccessionsLocations.class, parent, new AccessionsLocationsFields());

    } else if (clazz == Names.class) {
      domainEditor = new NameEditor(parent, new NameFields());

    } else if (clazz == NameContactNotes.class) {
      domainEditor = new DomainEditor(NameContactNotes.class, parent, new NameContactNoteFields());

    } else if (clazz == NonPreferredNames.class) {
      domainEditor = new NonPreferredNameEditor(parent);

    } else if (clazz == Users.class) {
      domainEditor = new UserEditor(parent);

    } else if (clazz == LookupList.class) {
      domainEditor = new DomainEditor(LookupList.class, parent, new LookupListFields());

    } else if (clazz == RDEScreen.class) {
      domainEditor = new DomainEditor(RDEScreen.class, parent, new RDEScreenFields());

    } else if (clazz == ArchDescriptionRepeatingData.class) {
      domainEditor = new ArchDescriptionRepeatingDataEditor(parent);

    } else if (clazz == ArchDescriptionNames.class) {
      domainEditor =
          new DomainEditor(
              ArchDescriptionNames.class, parent, "dummy text", new ArchDescriptionNamesFields());

    } else if (clazz == RepositoryNotesDefaultValues.class) {
      domainEditor =
          new DomainEditor(
              RepositoryNotesDefaultValues.class, parent, new RepositoryNotesDefaultValuesFields());

    } else if (clazz == RepositoryNotes.class) {
      domainEditor = new DomainEditor(RepositoryNotes.class, parent, new RepositoryNoteFields());

    } else if (clazz == RepositoryStatistics.class) {
      domainEditor =
          new DomainEditor(RepositoryStatistics.class, parent, new RepositoryStatisticsFields());

    } else if (clazz == DefaultValues.class) {
      domainEditor = new DomainEditor(DefaultValues.class, parent, new DefaultValuesFields());

    } else if (clazz == Deaccessions.class) {
      domainEditor = new DomainEditor(Deaccessions.class, parent, new DeaccessionsFields());
      Class parentModelClass = ((DomainEditor) parent).getModel().getClass();
      domainEditor.setMainHeaderColorAndTextByClass(clazz, parentModelClass);

    } else if (clazz == Events.class) {
      domainEditor = new DomainEditor(Events.class, parent, new EventsFields());

    } else if (clazz == RDEScreenPanels.class) {
      domainEditor = new DomainEditor(RDEScreenPanels.class, parent, new RDEScreenPanelFields());

    } else if (clazz == NotesEtcTypes.class) {
      domainEditor = new DomainEditor(NotesEtcTypes.class, parent, new NotesEtcTypesFields());

    } else if (clazz == Locations.class) {
      domainEditor = new LocationEditor(parent);

    } else if (clazz == Repositories.class) {
      domainEditor = new RepositoryEditor(parent);

    } else if (clazz == Constants.class) {
      domainEditor = new DomainEditor(Constants.class, parent, new ConstantsFields());

    } else if (clazz == ArchDescriptionInstances.class) {
      domainEditor = new ArchDescriptionInstancesEditor(parent);

    } else if (clazz == ArchDescriptionRepeatingData.class) {
      domainEditor = new ArchDescriptionRepeatingDataEditor(parent);

    } else if (clazz == FileVersions.class) {
      domainEditor = new FileVersionsEditor(parent);

    } else if (clazz == DatabaseTables.class) {
      domainEditor = new DatabaseTableEditor(parent);
      if (!ApplicationFrame.getInstance()
          .getCurrentUserName()
          .equalsIgnoreCase(Users.USERNAME_DEVELOPER)) {
        ((DatabaseTableEditor) domainEditor).hideAddRemoveButtons();
      }

    } else if (clazz == DatabaseFields.class) {
      domainEditor = new DatabaseFieldsEditor(parent);

    } else if (clazz == Assessments.class) {
      domainEditor = new DomainEditor(Assessments.class, parent, new AssessmentsFields());
    }

    if (domainEditor == null) {
      return null;
    } else if (useParentAsEventListener) {
      if (parent instanceof ActionListener) {
        domainEditor.setNavigationButtonListeners((ActionListener) parent);
        return domainEditor;
      } else {
        throw new DomainEditorCreationException(parent + " is not an action listener");
      }
    } else {
      domainEditor.setNavigationButtonListeners(domainEditor);
      return domainEditor;
    }
  }
Пример #9
0
 private void setListenersToSelf(DomainEditor dialog) {
   dialog.setNavigationButtonListeners(dialog);
 }
Пример #10
0
 private DomainEditor putDialog(
     final Class clazz, final DomainEditor dialog, ActionListener listener) {
   dialog.setNavigationButtonListeners(listener);
   return putDialog(clazz, dialog);
 }