}
// If something was found, entriesChanged it:
if (!editor.getText().equals("") && !editor.getText().equals(old)) {
// Store an undo edit:
//System.out.println("Setting: "+sel[i].getCiteKey()+" "+editor.getText());
ce.addEdit(new UndoableFieldChange(sel[i], fieldName, old, editor.getText()));
sel[i].setField(fieldName, editor.getText());
entriesChanged++;
}
}
}
//System.out.println("Done setting");
// The following loop checks all external links that are already set.
if (checkExisting) {
mainLoop:
for (int i = 0; i < sel.length; i++) {
panel.frame().setProgressBarValue(progress++);
final String old = sel[i].getField(fieldName);
// Check if a extension is set:
if ((old != null) && !old.equals("")) {
// Get an absolute path representation:
File file = Util.expandFilename(old, new String[]{dir, "."});
if ((file == null) || !file.exists()) {
int answer =
JOptionPane.showOptionDialog(panel.frame(),
Globals.lang("<HTML>Could not find file '%0'<BR>linked from entry '%1'</HTML>",
new String[]{old, sel[i].getCiteKey()}),
Globals.lang("Broken link"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, brokenLinkOptions, brokenLinkOptions[0]);
switch (answer) {
case 1:
// Assign new file.
AttachFileDialog afd = new AttachFileDialog(panel.frame(),
panel.metaData(), sel[i], fieldName);
Util.placeDialog(afd, panel.frame());
afd.setVisible(true);
if (!afd.cancelled()) {
ce.addEdit(new UndoableFieldChange(sel[i], fieldName, old, afd.getValue()));
sel[i].setField(fieldName, afd.getValue());
entriesChanged++;
}
break;
case 2:
// Clear field
ce.addEdit(new UndoableFieldChange(sel[i], fieldName, old, null));
sel[i].setField(fieldName, null);
entriesChanged++;
break;
case 3:
// Cancel