From 39dbf77152eeb50074353457eaada7664bd754ca Mon Sep 17 00:00:00 2001
From: Siedlerchr
Date: Sun, 1 May 2016 20:14:49 +0200
Subject: [PATCH] WIP: Refactor Open and Save Dialogs NewFileDialogs will be
renamed when the work is done Reworked BrowseAction, added Enum for file
extensions
Use a more factory like pattern to create fileDialogs
Avoids unnecessary constructor overloads
Reworked FileExtensions to accept mutiple Extensions for one description
Added OverwriteExistingFile in JFileChooser
Refactored rest of the dialogs
Removed obsolte keys
Remove comment
---
.../external/ExternalFileTypeEditor.java | 11 +-
.../external/ExternalFileTypeEntryEditor.java | 50 ++---
.../sf/jabref/external/MoveFileAction.java | 52 ++---
.../java/net/sf/jabref/gui/BasePanel.java | 19 +-
.../java/net/sf/jabref/gui/FileDialogs.java | 209 ------------------
.../net/sf/jabref/gui/FileExtensions.java | 61 +++++
.../sf/jabref/gui/FileListEntryEditor.java | 95 ++++----
.../net/sf/jabref/gui/NewFileDialogs.java | 161 ++++++++++++++
.../net/sf/jabref/gui/OpenFileFilter.java | 98 --------
.../sf/jabref/gui/actions/BrowseAction.java | 61 ++---
.../jabref/gui/auximport/FromAuxDialog.java | 53 ++---
.../gui/exporter/CustomExportDialog.java | 59 +++--
.../gui/exporter/SaveDatabaseAction.java | 67 +++---
.../gui/journals/ManageJournalsPanel.java | 79 ++-----
.../gui/openoffice/StyleSelectDialog.java | 4 +-
.../gui/plaintextimport/TextInputDialog.java | 58 +++--
.../gui/preftabs/PreferencesDialog.java | 54 ++---
.../NewProtectedTermsFileDialog.java | 6 +-
.../protectedterms/ProtectedTermsDialog.java | 6 +-
.../jabref/importer/AppendDatabaseAction.java | 28 +--
.../importer/ImportCustomizationDialog.java | 67 +++---
.../sf/jabref/importer/ImportMenuItem.java | 18 +-
.../jabref/importer/OpenDatabaseAction.java | 66 +++---
.../jabref/logic/integrity/ISSNChecker.java | 1 +
src/main/resources/l10n/JabRef_da.properties | 3 -
src/main/resources/l10n/JabRef_de.properties | 3 -
src/main/resources/l10n/JabRef_en.properties | 6 -
src/main/resources/l10n/JabRef_es.properties | 3 -
src/main/resources/l10n/JabRef_fa.properties | 3 -
src/main/resources/l10n/JabRef_fr.properties | 3 -
src/main/resources/l10n/JabRef_in.properties | 3 -
src/main/resources/l10n/JabRef_it.properties | 3 -
src/main/resources/l10n/JabRef_ja.properties | 3 -
src/main/resources/l10n/JabRef_nl.properties | 3 -
src/main/resources/l10n/JabRef_no.properties | 3 -
.../resources/l10n/JabRef_pt_BR.properties | 3 -
src/main/resources/l10n/JabRef_ru.properties | 3 -
src/main/resources/l10n/JabRef_sv.properties | 3 -
src/main/resources/l10n/JabRef_tr.properties | 3 -
src/main/resources/l10n/JabRef_vi.properties | 3 -
src/main/resources/l10n/JabRef_zh.properties | 3 -
41 files changed, 611 insertions(+), 826 deletions(-)
delete mode 100644 src/main/java/net/sf/jabref/gui/FileDialogs.java
create mode 100644 src/main/java/net/sf/jabref/gui/FileExtensions.java
create mode 100644 src/main/java/net/sf/jabref/gui/NewFileDialogs.java
delete mode 100644 src/main/java/net/sf/jabref/gui/OpenFileFilter.java
diff --git a/src/main/java/net/sf/jabref/external/ExternalFileTypeEditor.java b/src/main/java/net/sf/jabref/external/ExternalFileTypeEditor.java
index 374b1778bca..8f2ca3deff2 100644
--- a/src/main/java/net/sf/jabref/external/ExternalFileTypeEditor.java
+++ b/src/main/java/net/sf/jabref/external/ExternalFileTypeEditor.java
@@ -21,6 +21,7 @@
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -58,6 +59,7 @@
* Editor for external file types.
*/
public class ExternalFileTypeEditor extends JDialog {
+
private JFrame frame;
private JDialog dialog;
private List fileTypes;
@@ -111,6 +113,7 @@ private void init() {
dispose();
});
Action cancelAction = new AbstractAction() {
+
@Override
public void actionPerformed(ActionEvent e) {
dispose();
@@ -134,9 +137,10 @@ public void actionPerformed(ActionEvent e) {
//}
});
- add.addActionListener(e -> {
+ add.addActionListener(e -> {
// Generate a new file type:
- ExternalFileType type = new ExternalFileType("", "", "", "", "new", IconTheme.JabRefIcon.FILE.getSmallIcon());
+ ExternalFileType type = new ExternalFileType("", "", "", "", "new",
+ IconTheme.JabRefIcon.FILE.getSmallIcon());
// Show the file type editor:
getEditor(type).setVisible(true);
if (entryEditor.okPressed()) {
@@ -246,6 +250,7 @@ public static AbstractAction getAction(JDialog dialog) {
return new EditExternalFileTypesAction(dialog);
}
+
class EditListener implements ActionListener {
@Override
@@ -276,6 +281,7 @@ public Component getTableCellRendererComponent(JTable tab, Object value, boolean
}
private class FileTypeTableModel extends AbstractTableModel {
+
@Override
public int getColumnCount() {
return 5;
@@ -354,6 +360,7 @@ public void mouseReleased(MouseEvent e) {
}
public static class EditExternalFileTypesAction extends MnemonicAwareAction {
+
private JabRefFrame frame;
private JDialog dialog;
private ExternalFileTypeEditor editor;
diff --git a/src/main/java/net/sf/jabref/external/ExternalFileTypeEntryEditor.java b/src/main/java/net/sf/jabref/external/ExternalFileTypeEntryEditor.java
index b584e79ea44..15f16c397b8 100644
--- a/src/main/java/net/sf/jabref/external/ExternalFileTypeEntryEditor.java
+++ b/src/main/java/net/sf/jabref/external/ExternalFileTypeEntryEditor.java
@@ -17,16 +17,13 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.Collections;
+import java.nio.file.Path;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
-import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -35,9 +32,10 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+
import net.sf.jabref.Globals;
-import net.sf.jabref.gui.FileDialogs;
import net.sf.jabref.gui.IconTheme;
+import net.sf.jabref.gui.NewFileDialogs;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;
@@ -89,8 +87,8 @@ private void init(ExternalFileType inEntry) {
bg.add(other);
FormBuilder builder = FormBuilder.create();
- builder.layout(new FormLayout
- ("left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p"));
+ builder.layout(new FormLayout("left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref",
+ "p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p"));
builder.add(Localization.lang("Icon")).xy(1, 1);
builder.add(icon).xy(3, 1);
builder.add(Localization.lang("Name")).xy(1, 3);
@@ -128,6 +126,7 @@ private void init(ExternalFileType inEntry) {
ok.addActionListener(e -> {
okPressed = true;
+
storeSettings(ExternalFileTypeEntryEditor.this.entry);
diag.dispose();
@@ -177,8 +176,7 @@ public void changedUpdate(DocumentEvent documentEvent) {
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
diag.pack();
- BrowseListener browse = new BrowseListener(application);
- browseBut.addActionListener(browse);
+ browseBut.addActionListener(browsePressed);
if (dParent == null) {
diag.setLocationRelativeTo(fParent);
@@ -248,31 +246,19 @@ public boolean okPressed() {
}
- static class BrowseListener implements ActionListener {
-
- private final JTextField comp;
+ ActionListener browsePressed = e -> {
+ String appDir = application.getText().trim();
+ if (appDir.isEmpty()) {
+ appDir = Globals.prefs.get(JabRefPreferences.FILE_WORKING_DIRECTORY);
+ }
+ Path applicationDir = new NewFileDialogs(fParent, appDir).getSelectedFile();
- public BrowseListener(JTextField comp) {
- this.comp = comp;
+ if (applicationDir.getParent() != null) {
+ Globals.prefs.put(JabRefPreferences.FILE_WORKING_DIRECTORY, applicationDir.getParent().toString());
}
+ application.setText(applicationDir.toString());
+
+ };
- @Override
- public void actionPerformed(ActionEvent e) {
- File initial = new File(comp.getText().trim());
- if (comp.getText().trim().isEmpty()) {
- // Nothing in the field. Go to the last file dir used:
- initial = new File(Globals.prefs.get(JabRefPreferences.FILE_WORKING_DIRECTORY));
- }
- String chosen = FileDialogs.getNewFile(null, initial, Collections.emptyList(),
- JFileChooser.OPEN_DIALOG, false);
- if (chosen != null) {
- File newFile = new File(chosen);
- // Store the directory for next time:
- Globals.prefs.put(JabRefPreferences.FILE_WORKING_DIRECTORY, newFile.getParent());
- comp.setText(newFile.getPath());
- comp.requestFocus();
- }
- }
- }
}
diff --git a/src/main/java/net/sf/jabref/external/MoveFileAction.java b/src/main/java/net/sf/jabref/external/MoveFileAction.java
index b4bc662daa2..e808a54b156 100644
--- a/src/main/java/net/sf/jabref/external/MoveFileAction.java
+++ b/src/main/java/net/sf/jabref/external/MoveFileAction.java
@@ -18,18 +18,17 @@
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
+import java.nio.file.Files;
import java.util.List;
import java.util.Locale;
import javax.swing.AbstractAction;
-import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import net.sf.jabref.Globals;
-import net.sf.jabref.gui.FileDialogs;
import net.sf.jabref.gui.FileListEntry;
import net.sf.jabref.gui.JabRefFrame;
+import net.sf.jabref.gui.NewFileDialogs;
import net.sf.jabref.gui.entryeditor.EntryEditor;
import net.sf.jabref.gui.fieldeditors.FileListEditor;
import net.sf.jabref.gui.util.component.CheckBoxMessage;
@@ -44,6 +43,7 @@
* Action for moving or renaming a file that is linked to from an entry in JabRef.
*/
public class MoveFileAction extends AbstractAction {
+
private static final Log LOGGER = LogFactory.getLog(MoveFileAction.class);
private final JabRefFrame frame;
@@ -54,6 +54,7 @@ public class MoveFileAction extends AbstractAction {
private static final String MOVE_RENAME = Localization.lang("Move/Rename file");
+
public MoveFileAction(JabRefFrame frame, EntryEditor eEditor, FileListEditor editor, boolean toFileDir) {
this.frame = frame;
this.eEditor = eEditor;
@@ -89,7 +90,8 @@ public void actionPerformed(ActionEvent event) {
}
}
if (found < 0) {
- JOptionPane.showMessageDialog(frame, Localization.lang("File_directory_is_not_set_or_does_not_exist!"), MOVE_RENAME, JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(frame, Localization.lang("File_directory_is_not_set_or_does_not_exist!"),
+ MOVE_RENAME, JOptionPane.ERROR_MESSAGE);
return;
}
File file = new File(ln);
@@ -123,8 +125,7 @@ public void actionPerformed(ActionEvent event) {
answer = JOptionPane.showConfirmDialog(frame, Localization.lang("Move file to file directory?"),
MOVE_RENAME, JOptionPane.YES_NO_OPTION);
} else {
- answer = JOptionPane.showConfirmDialog(frame, cbm, MOVE_RENAME,
- JOptionPane.YES_NO_OPTION);
+ answer = JOptionPane.showConfirmDialog(frame, cbm, MOVE_RENAME, JOptionPane.YES_NO_OPTION);
}
if (answer != JOptionPane.YES_OPTION) {
return;
@@ -143,23 +144,16 @@ public void actionPerformed(ActionEvent event) {
}
chosenFile = sb.toString();
} else {
- chosenFile = FileDialogs.getNewFile(frame, file, Collections.singletonList(extension),
- JFileChooser.SAVE_DIALOG, false);
+ System.out.println("Entry extension " + extension);
+ chosenFile = new NewFileDialogs(frame, file.getPath()).saveNewFile().toString();
+
+
}
- if (chosenFile == null) {
+ if (chosenFile.isEmpty()) {
return; // canceled
}
newFile = new File(chosenFile);
- // Check if the file already exists:
- if (newFile.exists() && (JOptionPane.showConfirmDialog(frame,
- Localization.lang("'%0' exists. Overwrite file?", newFile.getName()), MOVE_RENAME,
- JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) {
- if (toFileDir) {
- return;
- } else {
- repeat = true;
- }
- }
+
}
if (!newFile.equals(file)) {
@@ -170,29 +164,29 @@ public void actionPerformed(ActionEvent event) {
}
if (success) {
// Remove the original file:
- if (!file.delete()) {
- LOGGER.info("Cannot delete original file");
- }
+ Files.deleteIfExists(file.toPath());
+
// Relativise path, if possible.
String canPath = new File(dirs.get(found)).getCanonicalPath();
if (newFile.getCanonicalPath().startsWith(canPath)) {
- if ((newFile.getCanonicalPath().length() > canPath.length()) &&
- (newFile.getCanonicalPath().charAt(canPath.length()) == File.separatorChar)) {
+ if ((newFile.getCanonicalPath().length() > canPath.length())
+ && (newFile.getCanonicalPath().charAt(canPath.length()) == File.separatorChar)) {
String newLink = newFile.getCanonicalPath().substring(1 + canPath.length());
- editor.getTableModel().setEntry(selected, new FileListEntry(entry.description, newLink, entry.type));
+ editor.getTableModel().setEntry(selected,
+ new FileListEntry(entry.description, newLink, entry.type));
} else {
String newLink = newFile.getCanonicalPath().substring(canPath.length());
- editor.getTableModel().setEntry(selected, new FileListEntry(entry.description, newLink, entry.type));
+ editor.getTableModel().setEntry(selected,
+ new FileListEntry(entry.description, newLink, entry.type));
}
} else {
String newLink = newFile.getCanonicalPath();
- editor.getTableModel().setEntry(selected, new FileListEntry(entry.description, newLink, entry.type));
+ editor.getTableModel().setEntry(selected,
+ new FileListEntry(entry.description, newLink, entry.type));
}
eEditor.updateField(editor);
- //JOptionPane.showMessageDialog(frame, Globals.lang("File moved"),
- // Globals.lang("Move/Rename file"), JOptionPane.INFORMATION_MESSAGE);
frame.output(Localization.lang("File moved"));
} else {
JOptionPane.showMessageDialog(frame, Localization.lang("Move file failed"), MOVE_RENAME,
diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java
index 45a80c32dbf..6acbfed709b 100644
--- a/src/main/java/net/sf/jabref/gui/BasePanel.java
+++ b/src/main/java/net/sf/jabref/gui/BasePanel.java
@@ -29,6 +29,7 @@
import java.io.StringReader;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -44,7 +45,6 @@
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
-import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
@@ -2366,21 +2366,26 @@ public SaveSelectedAction(SavePreferences.DatabaseSaveType saveType) {
@Override
public void action() throws SaveException {
- String chosenFile = FileDialogs.getNewFile(frame,
- new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.singletonList(".bib"),
- JFileChooser.SAVE_DIALOG, false);
- if (chosenFile != null) {
+ // String chosenFile = FileDialogs.getNewFile(frame,
+ // new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.singletonList(".bib"),
+ // JFileChooser.SAVE_DIALOG, false);
+
+ Path chosenFile = new NewFileDialogs(frame).withExtension(FileExtensions.BIBTEX_DB).saveNewFile();
+ File expFile = chosenFile.toFile();
+ /* if (chosenFile != null) {
File expFile = new File(chosenFile);
if (!expFile.exists() || (JOptionPane.showConfirmDialog(frame,
Localization.lang("'%0' exists. Overwrite file?", expFile.getName()),
Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) {
+ */
saveDatabase(expFile, true, Globals.prefs.getDefaultEncoding(), saveType);
frame.getFileHistory().newFile(expFile.getPath());
frame.output(Localization.lang("Saved selected to '%0'.", expFile.getPath()));
}
}
- }
- }
+
+
+
private static class SearchAndOpenFile {
diff --git a/src/main/java/net/sf/jabref/gui/FileDialogs.java b/src/main/java/net/sf/jabref/gui/FileDialogs.java
deleted file mode 100644
index 0a050e0b890..00000000000
--- a/src/main/java/net/sf/jabref/gui/FileDialogs.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/* Copyright (C) 2003-2015 JabRef contributors.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-package net.sf.jabref.gui;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-import javax.swing.JComponent;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-
-import net.sf.jabref.Globals;
-import net.sf.jabref.logic.util.OS;
-import net.sf.jabref.preferences.JabRefPreferences;
-
-public class FileDialogs {
-
- /**
- * Will return the names of multiple files selected in the given directory
- * and the given extensions.
- *
- * Will return an empty String array if no entry is found.
- *
- * @param owner
- * @param directory
- * @param extensions
- * @param updateWorkingdirectory
- * @return an array of selected file paths, or an empty array if no selection is made.
- */
- public static List getMultipleFiles(JFrame owner, File directory, List extensions,
- boolean updateWorkingdirectory) {
-
- Objects.requireNonNull(extensions);
-
- OpenFileFilter off;
- if (extensions.isEmpty()) {
- off = new OpenFileFilter();
- } else {
- off = new OpenFileFilter(extensions);
- }
-
- Object files = FileDialogs.getNewFileImpl(owner, directory, extensions, null, off, JFileChooser.OPEN_DIALOG,
- updateWorkingdirectory, false, true, null);
-
- if (files instanceof String[]) {
- return Arrays.asList((String[]) files);
- }
- // Fix for:
- // http://sourceforge.net/tracker/index.php?func=detail&aid=1538769&group_id=92314&atid=600306
- if (files != null) {
- return Collections.singletonList((String) files);
- }
- return Collections.emptyList();
- }
-
- public static String getNewFile(JFrame owner, File directory, List extensions, int dialogType, boolean updateWorkingDirectory) {
- return FileDialogs.getNewFile(owner, directory, extensions, null, dialogType, updateWorkingDirectory, false, null);
- }
-
- public static String getNewFile(JFrame owner, File directory, List extensions, int dialogType, boolean updateWorkingDirectory, JComponent accessory) {
- return FileDialogs.getNewFile(owner, directory, extensions, null, dialogType, updateWorkingDirectory, false, accessory);
- }
-
- public static String getNewFile(JFrame owner, File directory, List extensions, String description, int dialogType, boolean updateWorkingDirectory) {
- return FileDialogs.getNewFile(owner, directory, extensions, description, dialogType, updateWorkingDirectory, false, null);
- }
-
- public static String getNewDir(JFrame owner, File directory, List extensions, int dialogType, boolean updateWorkingDirectory) {
- return FileDialogs.getNewFile(owner, directory, extensions, null, dialogType, updateWorkingDirectory, true, null);
- }
-
- public static String getNewDir(JFrame owner, File directory, List extensions, String description, int dialogType, boolean updateWorkingDirectory) {
- return FileDialogs.getNewFile(owner, directory, extensions, description, dialogType, updateWorkingDirectory, true, null);
- }
-
- private static String getNewFile(JFrame owner, File directory, List extensions, String description, int dialogType, boolean updateWorkingDirectory, boolean dirOnly, JComponent accessory) {
-
- OpenFileFilter off;
-
- if (extensions.isEmpty()) {
- off = new OpenFileFilter();
- } else {
- off = new OpenFileFilter(extensions);
- }
-
- return (String) FileDialogs.getNewFileImpl(owner, directory, extensions, description, off, dialogType, updateWorkingDirectory, dirOnly, false, accessory);
- }
-
- private static Object getNewFileImpl(JFrame owner, File directory, List extensions, String description,
- OpenFileFilter off, int dialogType, boolean updateWorkingDirectory, boolean dirOnly,
- boolean multipleSelection, JComponent accessory) {
-
- // Added the !dirOnly condition below as a workaround to the native file dialog
- // not supporting directory selection:
- if (!dirOnly && OS.OS_X) {
- return FileDialogs.getNewFileForMac(owner, directory, dialogType, updateWorkingDirectory);
- }
-
- JFileChooser fc;
- try {
- fc = new JFileChooser(directory);//JabRefFileChooser(directory);
- if (accessory != null) {
- fc.setAccessory(accessory);
- }
- } catch (InternalError errl) {
- // This try/catch clause was added because a user reported an
- // InternalError getting thrown on WinNT, presumably because of a
- // bug in JGoodies Windows PLAF. This clause can be removed if the
- // bug is fixed, but for now we just resort to the native file
- // dialog, using the same method as is always used on Mac:
- return FileDialogs.getNewFileForMac(owner, directory, dialogType, updateWorkingDirectory);
- }
-
- if (dirOnly) {
- fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- }
-
- fc.setMultiSelectionEnabled(multipleSelection);
-
- fc.addChoosableFileFilter(off);
- fc.setDialogType(dialogType);
- int dialogResult;
- if (dialogType == JFileChooser.OPEN_DIALOG) {
- dialogResult = fc.showOpenDialog(owner);
- } else if (dialogType == JFileChooser.SAVE_DIALOG) {
- dialogResult = fc.showSaveDialog(owner);
- } else {
- dialogResult = fc.showDialog(owner, description);
- }
-
- // the getSelectedFile method returns a valid fileselection
- // (if something is selected) indepentently from dialog return status
- if (dialogResult != JFileChooser.APPROVE_OPTION) {
- return null;
- }
-
- // okay button
- File selectedFile = fc.getSelectedFile();
- if (selectedFile == null) { // cancel
- return null;
- }
-
- // If this is a save dialog, and the user has not chosen "All files" as
- // filter
- // we enforce the given extension. But only if extension is not null.
- if ((!extensions.isEmpty()) && (dialogType == JFileChooser.SAVE_DIALOG) && (fc.getFileFilter() == off) && !off.accept(selectedFile)) {
-
- // add the first extension if there are multiple extensions
- selectedFile = new File(selectedFile.getPath() + extensions.get(0));
- }
-
- if (updateWorkingDirectory) {
- Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, selectedFile.getPath());
- }
-
- if (multipleSelection) {
- File[] files = fc.getSelectedFiles();
- String[] filenames = new String[files.length];
- for (int i = 0; i < files.length; i++) {
- filenames[i] = files[i].getAbsolutePath();
- }
- return filenames;
- } else {
- return selectedFile.getAbsolutePath();
- }
- }
-
- private static String getNewFileForMac(JFrame owner, File directory, int dialogType,
- boolean updateWorkingDirectory) {
-
- java.awt.FileDialog fc = new java.awt.FileDialog(owner);
-
- if (directory != null) {
- fc.setDirectory(directory.getParent());
- }
- if (dialogType == JFileChooser.OPEN_DIALOG) {
- fc.setMode(java.awt.FileDialog.LOAD);
- } else {
- fc.setMode(java.awt.FileDialog.SAVE);
- }
-
- fc.setVisible(true);
-
- if (fc.getFile() == null) {
- return null;
- } else {
- if (updateWorkingDirectory) {
- Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, fc.getDirectory() + fc.getFile());
- }
- return fc.getDirectory() + fc.getFile();
- }
- }
-}
diff --git a/src/main/java/net/sf/jabref/gui/FileExtensions.java b/src/main/java/net/sf/jabref/gui/FileExtensions.java
new file mode 100644
index 00000000000..d5338e762c7
--- /dev/null
+++ b/src/main/java/net/sf/jabref/gui/FileExtensions.java
@@ -0,0 +1,61 @@
+package net.sf.jabref.gui;
+
+public enum FileExtensions {
+
+ //importannt: No dot before the extension!
+ BIBTEX_DB(
+ "BibTeX Database", "bib"),
+ BIBTEXML(
+ "BibTexMl, bibx"),
+ AUX(
+ "Aux file", "aux"),
+ SILVER_PLATTERN(
+ "SilverPlatter", "dat"),
+ PUBMED(
+ "Pubmed file", "fcgi"),
+ RIS(
+ "Ris file ", "ris"),
+ ENDNOTE(
+ "Endnote/Refer file", "ref"),
+
+ JSTYLE(
+ "Style file", "jstyle"),
+ LAYOUT(
+ "Custom Layout File", "layout"),
+ XML(
+ "XML file", "xml"),
+ TERMS(
+ "Protected TERMS file", "terms"),
+ TXT(
+ "Plain text file", "txt"),
+ CLASS(
+ "Class file", "class"),
+ JAR(
+ "Jar file", "jar"),
+ ZIP(
+ "Zip file", "zip");
+
+
+ private final String[] extension;
+ private final String description;
+
+
+ private FileExtensions(String description, String... extension) {
+ this.extension = extension;
+ this.description = description;
+ }
+
+ //Array because a) is varags and b) gets passed as varags parameter to FileExtensionNameFilter
+ public String[] getExtensions() {
+ return extension;
+ }
+
+ public String getDescription() {
+
+ return description;
+ }
+
+ public String getFirstExtensionWithDot() {
+ return "." + extension[0].trim();
+ }
+}
diff --git a/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java b/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java
index 7d6ebfb45d5..892248141cd 100644
--- a/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java
+++ b/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
@@ -37,13 +36,10 @@
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -89,19 +85,24 @@ public class FileListEntryEditor {
private ConfirmCloseFileListEntryEditor externalConfirm;
private FileListEntry entry;
- private final BibDatabaseContext databaseContext;
+ //Do not make this variable final, as then the lambda action listener will fail on compiöe
+ private BibDatabaseContext databaseContext;
private boolean okPressed;
private boolean okDisabledExternally;
private boolean openBrowseWhenShown;
private boolean dontOpenBrowseUntilDisposed;
+ //Do not make this variable final, as then the lambda action listener will fail on compile
+ private JabRefFrame frame;
+
private static final Pattern REMOTE_LINK_PATTERN = Pattern.compile("[a-z]+://.*");
- public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar,
- boolean showOpenButton, BibDatabaseContext databaseContext) {
+ public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton,
+ BibDatabaseContext databaseContext) {
this.entry = entry;
this.databaseContext = databaseContext;
+ this.frame = frame;
ActionListener okAction = e -> {
// If OK button is disabled, ignore this event:
@@ -127,27 +128,28 @@ public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showP
}
});
- FormBuilder builder = FormBuilder.create().layout(new FormLayout
- ("left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p"));
+ FormBuilder builder = FormBuilder.create().layout(new FormLayout(
+ "left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p"));
builder.add(Localization.lang("Link")).xy(1, 1);
builder.add(link).xy(3, 1);
- final BrowseListener browse = new BrowseListener(frame, link);
+ //final BrowseListener browse = new BrowseListener(frame, link); //TODO: Maybe use browse action
+
final JButton browseBut = new JButton(Localization.lang("Browse"));
- browseBut.addActionListener(browse);
+ browseBut.addActionListener(browsePressed);
builder.add(browseBut).xy(5, 1);
JButton open = new JButton(Localization.lang("Open"));
if (showOpenButton) {
builder.add(open).xy(7, 1);
}
builder.add(Localization.lang("Description")).xy(1, 3);
- builder.add(description).xyw(3,3,3);
+ builder.add(description).xyw(3, 3, 3);
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
builder.add(Localization.lang("File type")).xy(1, 5);
builder.add(types).xyw(3, 5, 3);
if (showProgressBar) {
builder.appendRows("2dlu, p");
- builder.add(downloadLabel).xy(1,7);
- builder.add(prog).xyw(3,7,3);
+ builder.add(downloadLabel).xy(1, 7);
+ builder.add(prog).xyw(3, 7, 3);
}
ButtonBarBuilder bb = new ButtonBarBuilder();
@@ -167,6 +169,7 @@ public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showP
open.addActionListener(e -> openFile());
AbstractAction cancelAction = new AbstractAction() {
+
@Override
public void actionPerformed(ActionEvent e) {
diag.dispose();
@@ -199,6 +202,8 @@ public void changedUpdate(DocumentEvent documentEvent) {
});
+ System.out.println("LInk field " + link.getText());
+
diag = new JDialog(frame, Localization.lang("Save file"), true);
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
@@ -210,7 +215,8 @@ public void changedUpdate(DocumentEvent documentEvent) {
public void windowActivated(WindowEvent event) {
if (openBrowseWhenShown && !dontOpenBrowseUntilDisposed) {
dontOpenBrowseUntilDisposed = true;
- SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, "")));
+ System.out.println("Window activated ");
+ // SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, "")));
}
}
@@ -288,8 +294,7 @@ public boolean isVisible() {
private void setValues(FileListEntry entry) {
description.setText(entry.description);
link.setText(entry.link);
- //if (link.getText().length() > 0)
- // checkExtension();
+
Collection list = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
types.setModel(new DefaultComboBoxModel<>(list.toArray(new ExternalFileType[list.size()])));
@@ -345,41 +350,29 @@ public boolean okPressed() {
}
- class BrowseListener implements ActionListener {
- private final JFrame parent;
- private final JTextField comp;
-
- public BrowseListener(JFrame parent, JTextField comp) {
- this.parent = parent;
- this.comp = comp;
+ ActionListener browsePressed = e -> {
+ String filePath = link.getText().trim();
+ Optional file = FileUtil.expandFilename(this.databaseContext, filePath);
+ String workingDir;
+ // no file set yet or found
+ if (file.isPresent()) {
+ workingDir = file.get().getPath();
+ } else {
+ workingDir = Globals.prefs.get(JabRefPreferences.FILE_WORKING_DIRECTORY);
}
+ String selection = new NewFileDialogs(this.frame, workingDir).getSelectedFile().toString();
- @Override
- public void actionPerformed(ActionEvent e) {
- String filePath = comp.getText().trim();
- Optional file = FileUtil.expandFilename(databaseContext, filePath);
- File workingDir;
- // no file set yet or found
- if (file.isPresent()) {
- workingDir = new File(file.get().getParent());
- } else {
- workingDir = new File(Globals.prefs.get(JabRefPreferences.FILE_WORKING_DIRECTORY));
- }
- String selection = FileDialogs.getNewFile(parent, workingDir, Collections.emptyList(),
- JFileChooser.OPEN_DIALOG, false);
- if (selection != null) {
- File newFile = new File(selection);
- // Store the directory for next time:
- Globals.prefs.put(JabRefPreferences.FILE_WORKING_DIRECTORY, newFile.getParent());
-
- // If the file is below the file directory, make the path relative:
- List fileDirs = databaseContext.getFileDirectory();
- newFile = FileUtil.shortenFileName(newFile, fileDirs);
-
- comp.setText(newFile.getPath());
- comp.requestFocus();
- }
- }
- }
+ if (selection != null) {
+ File newFile = new File(selection);
+ // Store the directory for next time:
+ Globals.prefs.put(JabRefPreferences.FILE_WORKING_DIRECTORY, newFile.getPath());
+
+ // If the file is below the file directory, make the path relative:
+ List fileDirs = this.databaseContext.getFileDirectory();
+ newFile = FileUtil.shortenFileName(newFile, fileDirs);
+ link.setText(newFile.getPath());
+ link.requestFocus();
+ }
+ };
}
diff --git a/src/main/java/net/sf/jabref/gui/NewFileDialogs.java b/src/main/java/net/sf/jabref/gui/NewFileDialogs.java
new file mode 100644
index 00000000000..2302a23b3ae
--- /dev/null
+++ b/src/main/java/net/sf/jabref/gui/NewFileDialogs.java
@@ -0,0 +1,161 @@
+package net.sf.jabref.gui;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import net.sf.jabref.Globals;
+import net.sf.jabref.preferences.JabRefPreferences;
+
+/**
+ * WIP: Will replaced the FileDialogs class
+ *
+ *
+ */
+public class NewFileDialogs {
+
+ /**
+ * Custom confirmation dialog
+ * http://stackoverflow.com/a/3729157
+ */
+ private final JFileChooser fileChooser = new JFileChooser() {
+
+ @Override
+ public void approveSelection() {
+ File f = getSelectedFile();
+ if (f.exists() && (getDialogType() == SAVE_DIALOG)) {
+ int result = JOptionPane.showConfirmDialog(this, "The file exists, overwrite?", "Existing file",
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ switch (result) {
+ case JOptionPane.YES_OPTION:
+ super.approveSelection();
+ return;
+ case JOptionPane.NO_OPTION:
+ return;
+ case JOptionPane.CLOSED_OPTION:
+ return;
+ case JOptionPane.CANCEL_OPTION:
+ cancelSelection();
+ return;
+ }
+ }
+ super.approveSelection();
+ }
+ };
+
+ private final JFrame parent;
+ private final String directory;
+ private FileNameExtensionFilter extFilter;
+ private Set extensions = EnumSet.noneOf(FileExtensions.class);
+
+
+ public NewFileDialogs(JFrame owner) {
+ this(owner, getWorkingDir());
+ }
+
+ public NewFileDialogs(JFrame owner, String dir) {
+ this.parent = owner;
+ this.directory = dir;
+ System.out.println("DIR in Constructor" + Paths.get(dir));
+ fileChooser.setCurrentDirectory(Paths.get(dir).toFile());
+ }
+
+ private void saveFileDialog() {
+ fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
+ }
+
+ private void openFileDialog() {
+ fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
+
+ }
+
+ public NewFileDialogs dirsOnly() {
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ return this;
+ }
+
+ public NewFileDialogs withExtension(FileExtensions singleExt) {
+ withExtension(EnumSet.of(singleExt));
+ return this;
+ }
+
+ public NewFileDialogs withExtension(Set fileExtensions) {
+ this.extensions = fileExtensions;
+
+ for (FileExtensions ext : fileExtensions) {
+ extFilter = new FileNameExtensionFilter(ext.getDescription(), ext.getExtensions());
+ fileChooser.addChoosableFileFilter(extFilter);
+
+ }
+
+ return this;
+ }
+
+ public NewFileDialogs updateWorkingDirectory() {
+ updateWorkingDirectorySetting(this.directory);
+ return this;
+ }
+
+ public List getMultipleFileNames() {
+ openFileDialog();
+ fileChooser.setMultiSelectionEnabled(true);
+
+ if (showDialogAndIsAccepted()) {
+ List files = Arrays.stream(fileChooser.getSelectedFiles()).map(f -> f.toString())
+ .collect(Collectors.toList());
+
+ return files;
+ }
+
+ return Collections.emptyList();
+
+ }
+
+ public Path getSelectedFile() {
+ openFileDialog();
+ if (showDialogAndIsAccepted()) {
+ return fileChooser.getSelectedFile().toPath();
+ }
+ return Paths.get("");
+ }
+
+ public Path saveNewFile() {
+ saveFileDialog();
+ if (showDialogAndIsAccepted()) {
+ File f = fileChooser.getSelectedFile();
+ if (!extensions.isEmpty() && !fileChooser.accept(f)) {
+
+ System.out.println("Exts " + extensions);
+
+ return new File(f.getPath() + extensions.iterator().next().getFirstExtensionWithDot()).toPath();
+ }
+ return f.toPath();
+ }
+ return Paths.get("");
+ }
+
+ private boolean showDialogAndIsAccepted() {
+ return fileChooser.showDialog(parent, null) == JFileChooser.APPROVE_OPTION;
+ }
+
+ private static String getWorkingDir() {
+ return Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY);
+ }
+
+ private static void updateWorkingDirectorySetting(String dir) {
+ Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, dir);
+
+ }
+
+}
diff --git a/src/main/java/net/sf/jabref/gui/OpenFileFilter.java b/src/main/java/net/sf/jabref/gui/OpenFileFilter.java
deleted file mode 100644
index c5a8fbb9150..00000000000
--- a/src/main/java/net/sf/jabref/gui/OpenFileFilter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (C) 2003-2015 JabRef contributors.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-package net.sf.jabref.gui;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class OpenFileFilter extends javax.swing.filechooser.FileFilter implements FilenameFilter {
-
- private final Set extSet = new HashSet<>();
- private final String desc;
-
-
- public OpenFileFilter(List extensions) {
- StringBuilder buf = new StringBuilder();
- int numExt = extensions.size();
-
- if (numExt > 0) {
- buf.append('*');
- buf.append(extensions.get(0));
-
- extSet.add(extensions.get(0));
- }
-
- for (int curExt = 1; curExt < numExt; curExt++) {
- buf.append(", *");
- buf.append(extensions.get(curExt));
-
- extSet.add(extensions.get(curExt));
- }
-
- desc = buf.toString();
- }
-
- public OpenFileFilter() {
- this(Arrays.asList(
- ".bib",
- ".dat", // silverplatter ending
- ".txt", // windows puts ".txt" extensions and for scifinder
- ".ris",
- ".ref", // refer/endnote format
- ".fcgi", // default for pubmed
- ".bibx", // default for BibTeXML
- ".xml"
- ));
- }
-
- @Override
- public boolean accept(File file) {
- if (file.isDirectory()) {
- return true;
- }
-
- return accept(file.getName());
- }
-
- private boolean accept(String filename) {
-
- String lowerCaseFileName = filename.toLowerCase();
- int dotPos = lowerCaseFileName.lastIndexOf('.');
-
- if (dotPos == -1) {
- return false;
- }
-
- int dotDotPos = lowerCaseFileName.lastIndexOf('.', dotPos - 1); // for dot.dot extensions
-
- return extSet.contains(lowerCaseFileName.substring(dotPos)) ||
- ((dotDotPos >= 0) && extSet.contains(lowerCaseFileName.substring(dotDotPos)));
- }
-
- @Override
- public String getDescription() {
- return desc;
- }
-
- @Override
- public boolean accept(File dir, String name) {
- return accept(new File(dir.getPath() + name));
- }
-}
diff --git a/src/main/java/net/sf/jabref/gui/actions/BrowseAction.java b/src/main/java/net/sf/jabref/gui/actions/BrowseAction.java
index 88f5757e662..62a7eef955f 100644
--- a/src/main/java/net/sf/jabref/gui/actions/BrowseAction.java
+++ b/src/main/java/net/sf/jabref/gui/actions/BrowseAction.java
@@ -18,56 +18,57 @@
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.Collections;
-import java.util.List;
+import java.util.EnumSet;
+import java.util.Set;
import javax.swing.AbstractAction;
-import javax.swing.JComponent;
-import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;
-import net.sf.jabref.gui.FileDialogs;
-import net.sf.jabref.gui.util.FocusRequester;
+import net.sf.jabref.gui.FileExtensions;
+import net.sf.jabref.gui.NewFileDialogs;
import net.sf.jabref.logic.l10n.Localization;
-
/**
* Action used to produce a "Browse" button for one of the text fields.
*/
public final class BrowseAction extends AbstractAction {
+
private final JFrame frame;
private final JTextField comp;
- private final boolean dir;
- private final JComponent focusTarget;
- private final List extension;
+ private final boolean dirsOnly;
+ private final Set extensions;
+
public static BrowseAction buildForDir(JFrame frame, JTextField tc) {
- return new BrowseAction(frame, tc, true, null, Collections.emptyList());
+ return new BrowseAction(frame, tc, true, Collections.emptySet());
}
public static BrowseAction buildForDir(JTextField tc) {
- return new BrowseAction(null, tc, true, null, Collections.emptyList());
+ return new BrowseAction(null, tc, true, Collections.emptySet());
}
public static BrowseAction buildForFile(JTextField tc) {
- return new BrowseAction(null, tc, false, null, Collections.emptyList());
+
+ return new BrowseAction(null, tc, false, Collections.emptySet());
}
- public static BrowseAction buildForFile(JTextField tc, JComponent focusTarget, List extension) {
- return new BrowseAction(null, tc, false, focusTarget, extension);
-}
+ public static BrowseAction buildForFile(JTextField tc, FileExtensions extensions) {
- public static BrowseAction buildForDir(JTextField tc, JComponent focusTarget) {
- return new BrowseAction(null, tc, true, focusTarget, null);
+ return new BrowseAction(null, tc, false, EnumSet.of(extensions));
}
- private BrowseAction(JFrame frame, JTextField tc, boolean dir, JComponent focusTarget, List extension) {
+ public static BrowseAction buildForFile(JTextField tc, Set extensions) {
+ return new BrowseAction(null, tc, false, extensions);
+ }
+
+
+ private BrowseAction(JFrame frame, JTextField tc, boolean dirsOnly, Set extensions) {
super(Localization.lang("Browse"));
this.frame = frame;
- this.dir = dir;
+ this.dirsOnly = dirsOnly;
this.comp = tc;
- this.focusTarget = focusTarget;
- this.extension = extension;
+ this.extensions = extensions;
}
@Override
@@ -77,19 +78,21 @@ public void actionPerformed(ActionEvent e) {
if (chosen != null) {
File newFile = new File(chosen);
comp.setText(newFile.getPath());
- if (focusTarget != null) {
- new FocusRequester(focusTarget);
- }
+
}
}
private String askUser() {
- if (dir) {
- return FileDialogs.getNewDir(frame, new File(comp.getText()), extension,
- JFileChooser.OPEN_DIALOG, false);
+ if (dirsOnly) {
+ String file = new NewFileDialogs(frame, comp.getText()).dirsOnly().withExtension(extensions)
+ .getSelectedFile().toString();
+ System.out.println("Browse Action DIR " + file);
+ return file;
} else {
- return FileDialogs.getNewFile(frame, new File(comp.getText()), extension,
- JFileChooser.OPEN_DIALOG, false);
+ String file = new NewFileDialogs(frame, comp.getText()).withExtension(extensions).getSelectedFile()
+ .toString();
+ System.out.println("Browse Action file " + file);
+ return file;
}
}
}
diff --git a/src/main/java/net/sf/jabref/gui/auximport/FromAuxDialog.java b/src/main/java/net/sf/jabref/gui/auximport/FromAuxDialog.java
index 809fbbf4c3b..a00264be8be 100644
--- a/src/main/java/net/sf/jabref/gui/auximport/FromAuxDialog.java
+++ b/src/main/java/net/sf/jabref/gui/auximport/FromAuxDialog.java
@@ -38,8 +38,6 @@
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
-import java.io.File;
-import java.util.Collections;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
@@ -49,7 +47,6 @@
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
-import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
@@ -60,8 +57,9 @@
import net.sf.jabref.Globals;
import net.sf.jabref.gui.BasePanel;
-import net.sf.jabref.gui.FileDialogs;
+import net.sf.jabref.gui.FileExtensions;
import net.sf.jabref.gui.JabRefFrame;
+import net.sf.jabref.gui.actions.BrowseAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.logic.auxparser.AuxParser;
import net.sf.jabref.logic.auxparser.AuxParserResult;
@@ -73,6 +71,7 @@
import com.jgoodies.forms.layout.FormLayout;
public class FromAuxDialog extends JDialog {
+
private final JPanel statusPanel = new JPanel();
private final JPanel buttons = new JPanel();
private final JButton generateButton = new JButton();
@@ -95,8 +94,7 @@ public class FromAuxDialog extends JDialog {
private final JabRefFrame parentFrame;
- public FromAuxDialog(JabRefFrame frame, String title, boolean modal,
- JTabbedPane viewedDBs) {
+ public FromAuxDialog(JabRefFrame frame, String title, boolean modal, JTabbedPane viewedDBs) {
super(frame, title, modal);
parentTabbedPane = viewedDBs;
@@ -141,9 +139,11 @@ private void jbInit() {
this.setTitle(Localization.lang("AUX file import"));
JLabel desc = new JLabel("" + Localization.lang("AUX file import") + "
"
+ Localization.lang("This feature generates a new database based on which entries "
- + "are needed in an existing LaTeX document.") + "
"
- + "" + Localization.lang("You need to select one of your open databases from which to choose "
- + "entries, as well as the AUX file produced by LaTeX when compiling your document.") + "
");
+ + "are needed in an existing LaTeX document.")
+ + "
" + ""
+ + Localization.lang("You need to select one of your open databases from which to choose "
+ + "entries, as well as the AUX file produced by LaTeX when compiling your document.")
+ + "