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 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); }