answer = 2; // We should delete this link.
}
switch (answer) {
case 1:
// Assign new file.
FileListEntryEditor flEditor = new FileListEntryEditor
(panel.frame(), flEntry, false, true, panel.metaData());
flEditor.setVisible(true, true);
break;
case 2:
// Clear field:
tableModel.removeEntry(j);
deleted = true; // Make sure we don't investigate this link further.
j--; // Step back in the iteration, because we removed an entry.
break;
case 3:
// Clear field:
tableModel.removeEntry(j);
deleted = true; // Make sure we don't investigate this link further.
j--; // Step back in the iteration, because we removed an entry.
removeAllBroken = true; // Notify for further cases.
break;
case 4:
// Cancel
break mainLoop;
}
brokenLinks++;
}
// Unless we deleted this link, see if its file type is recognized:
if (!deleted && (flEntry.getType() instanceof UnknownExternalFileType)) {
String[] options = new String[]
{Globals.lang("Define '%0'", flEntry.getType().getName()),
Globals.lang("Change file type"), Globals.lang("Cancel")};
String defOption = options[0];
int answer = JOptionPane.showOptionDialog(panel.frame(), Globals.lang("One or more file links are of the type '%0', which is undefined. What do you want to do?",
flEntry.getType().getName()),
Globals.lang("Undefined file type"), JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, defOption);
if (answer == JOptionPane.CANCEL_OPTION) {
// User doesn't want to handle this unknown link type.
}
else if (answer == JOptionPane.YES_OPTION) {
// User wants to define the new file type. Show the dialog:
ExternalFileType newType = new ExternalFileType(flEntry.getType().getName(), "", "", "", "new");
ExternalFileTypeEntryEditor editor = new ExternalFileTypeEntryEditor(panel.frame(), newType);
editor.setVisible(true);
if (editor.okPressed()) {
// Get the old list of types, add this one, and update the list in prefs:
java.util.List<ExternalFileType> fileTypes = new ArrayList<ExternalFileType>();
ExternalFileType[] oldTypes = Globals.prefs.getExternalFileTypeSelection();
for (int k = 0; k < oldTypes.length; k++) {
fileTypes.add(oldTypes[k]);
}
fileTypes.add(newType);
Collections.sort(fileTypes);
Globals.prefs.setExternalFileTypes(fileTypes);
panel.mainTable.repaint();
}
}
else {
// User wants to change the type of this link.
// First get a model of all file links for this entry:
FileListEntryEditor editor = new FileListEntryEditor
(panel.frame(), flEntry, false, true, panel.metaData());
editor.setVisible(true, false);
}
}
}
if (!tableModel.getStringRepresentation().equals(old)) {