return false;
}
else if (answer == JOptionPane.YES_OPTION) {
// User wants to define the new file type. Show the dialog:
ExternalFileType newType = new ExternalFileType(fileType.getName(), "", "", "", "new");
ExternalFileTypeEntryEditor editor = new ExternalFileTypeEntryEditor(frame, newType);
editor.setVisible(true);
if (editor.okPressed()) {
// Get the old list of types, add this one, and update the list in prefs:
List<ExternalFileType> fileTypes = new ArrayList<ExternalFileType>();
ExternalFileType[] oldTypes = Globals.prefs.getExternalFileTypeSelection();
for (int i = 0; i < oldTypes.length; i++) {
fileTypes.add(oldTypes[i]);
}
fileTypes.add(newType);
Collections.sort(fileTypes);
Globals.prefs.setExternalFileTypes(fileTypes);
// Finally, open the file:
return openExternalFileAnyFormat(metaData, link, newType);
} else {
// Cancelled:
frame.output(cancelMessage);
return false;
}
}
else {
// User wants to change the type of this link.
// First get a model of all file links for this entry:
FileListTableModel tModel = new FileListTableModel();
String oldValue = entry.getField(GUIGlobals.FILE_FIELD);
tModel.setContent(oldValue);
FileListEntry flEntry = null;
// Then find which one we are looking at:
for (int i=0; i<tModel.getRowCount(); i++) {
FileListEntry iEntry = tModel.getEntry(i);
if (iEntry.getLink().equals(link)) {
flEntry = iEntry;
break;
}
}
if (flEntry == null) {
// This shouldn't happen, so I'm not sure what to put in here:
throw new RuntimeException("Could not find the file list entry "+link+" in "+entry.toString());
}
FileListEntryEditor editor = new FileListEntryEditor(frame, flEntry, false, true, metaData);
editor.setVisible(true, false);
if (editor.okPressed()) {
// Store the changes and add an undo edit:
String newValue = tModel.getStringRepresentation();
UndoableFieldChange ce = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD,
oldValue, newValue);
entry.setField(GUIGlobals.FILE_FIELD, newValue);