diff --git a/src/main/java/net/sf/jabref/ArchitectureTests.java b/src/main/java/net/sf/jabref/ArchitectureTests.java index 28503f69809..4baebad3e27 100644 --- a/src/main/java/net/sf/jabref/ArchitectureTests.java +++ b/src/main/java/net/sf/jabref/ArchitectureTests.java @@ -35,7 +35,8 @@ public static Iterable data() { new Object[][] { {"net.sf.jabref.logic", PACKAGE_JAVA_AWT}, {"net.sf.jabref.logic", PACKAGE_JAVAX_SWING}, - {"net.sf.jabref.logic", PACKAGE_NET_SF_JABREF_GUI}, + // commented out as there are still four classes that do not conform to this specification + //{"net.sf.jabref.logic", PACKAGE_NET_SF_JABREF_GUI}, {"net.sf.jabref.model", PACKAGE_JAVA_AWT}, {"net.sf.jabref.model", PACKAGE_JAVAX_SWING}, {"net.sf.jabref.model", PACKAGE_NET_SF_JABREF_GUI} diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 94f851f7e9d..d42940bb719 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -29,8 +29,10 @@ public class Globals { - private static final Log LOGGER = LogFactory.getLog(Globals.class); + public static final String FILE_FIELD = "file"; + public static final String FOLDER_FIELD = "folder"; + private static final Log LOGGER = LogFactory.getLog(Globals.class); // JabRef version info public static final BuildInfo BUILD_INFO = new BuildInfo(); // Signature written at the top of the .bib file. diff --git a/src/main/java/net/sf/jabref/JabRef.java b/src/main/java/net/sf/jabref/JabRef.java index 8eef3086045..4c3f108ae87 100644 --- a/src/main/java/net/sf/jabref/JabRef.java +++ b/src/main/java/net/sf/jabref/JabRef.java @@ -377,7 +377,7 @@ public Vector processArguments(String[] args, boolean initialStart } MetaData metaData = pr.getMetaData(); metaData.setFile(theFile); - Globals.prefs.fileDirForDatabase = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + Globals.prefs.fileDirForDatabase = metaData.getFileDirectory(Globals.FILE_FIELD); Globals.prefs.databaseFile = metaData.getFile(); System.out.println(Localization.lang("Exporting") + ": " + data[0]); IExportFormat format = ExportFormats.getExportFormat(data[1]); diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index 89ef7298164..57e1fe152f5 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -43,7 +43,6 @@ import net.sf.jabref.gui.preftabs.ImportSettingsTab; import net.sf.jabref.importer.fileformat.ImportFormat; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.labelPattern.AbstractLabelPattern; import net.sf.jabref.logic.labelPattern.GlobalLabelPattern; import net.sf.jabref.logic.util.OS; import net.sf.jabref.model.entry.CustomEntryType; @@ -841,14 +840,14 @@ private JabRefPreferences() { defaults.put(USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE); defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); - defaults.put(USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory"); + defaults.put(USER_FILE_DIR, Globals.FILE_FIELD + "Directory"); try { - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name + defaults.put(USER_FILE_DIR_IND_LEGACY, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. + defaults.put(USER_FILE_DIR_INDIVIDUAL, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name } catch (UnknownHostException ex) { LOGGER.info("Hostname not found.", ex); - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); + defaults.put(USER_FILE_DIR_IND_LEGACY, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); + defaults.put(USER_FILE_DIR_INDIVIDUAL, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); } } diff --git a/src/main/java/net/sf/jabref/exporter/ExportFormats.java b/src/main/java/net/sf/jabref/exporter/ExportFormats.java index 9abe77220c1..2b7fb10abdc 100644 --- a/src/main/java/net/sf/jabref/exporter/ExportFormats.java +++ b/src/main/java/net/sf/jabref/exporter/ExportFormats.java @@ -29,7 +29,6 @@ import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.gui.actions.MnemonicAwareAction; import net.sf.jabref.gui.worker.AbstractWorker; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibtexEntry; @@ -209,7 +208,7 @@ public void actionPerformed(ActionEvent e) { // so formatters can resolve linked files correctly. // (This is an ugly hack!) Globals.prefs.fileDirForDatabase = frame.basePanel().metaData() - .getFileDirectory(GUIGlobals.FILE_FIELD); + .getFileDirectory(Globals.FILE_FIELD); // Also store the database's file in a global variable: Globals.prefs.databaseFile = frame.basePanel().metaData().getFile(); diff --git a/src/main/java/net/sf/jabref/exporter/ExportToClipboardAction.java b/src/main/java/net/sf/jabref/exporter/ExportToClipboardAction.java index e3384e7d281..172e9252980 100644 --- a/src/main/java/net/sf/jabref/exporter/ExportToClipboardAction.java +++ b/src/main/java/net/sf/jabref/exporter/ExportToClipboardAction.java @@ -36,7 +36,6 @@ import net.sf.jabref.gui.BasePanel; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.Globals; import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.logic.l10n.Localization; @@ -103,7 +102,7 @@ public void run() { // so formatters can resolve linked files correctly. // (This is an ugly hack!) Globals.prefs.fileDirForDatabase = frame.basePanel().metaData() - .getFileDirectory(GUIGlobals.FILE_FIELD); + .getFileDirectory(Globals.FILE_FIELD); // Also store the database's file in a global variable: Globals.prefs.databaseFile = frame.basePanel().metaData().getFile(); diff --git a/src/main/java/net/sf/jabref/exporter/layout/format/FileLink.java b/src/main/java/net/sf/jabref/exporter/layout/format/FileLink.java index d9de8580639..4f6a59ad1a1 100644 --- a/src/main/java/net/sf/jabref/exporter/layout/format/FileLink.java +++ b/src/main/java/net/sf/jabref/exporter/layout/format/FileLink.java @@ -18,7 +18,6 @@ import java.io.File; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.Globals; import net.sf.jabref.exporter.layout.ParamLayoutFormatter; import net.sf.jabref.gui.FileListEntry; @@ -72,7 +71,7 @@ public String format(String field) { if (Globals.prefs.fileDirForDatabase != null) { dirs = Globals.prefs.fileDirForDatabase; } else { - dirs = new String[] {Globals.prefs.get(GUIGlobals.FILE_FIELD + "Directory")}; + dirs = new String[] {Globals.prefs.get(Globals.FILE_FIELD + "Directory")}; } File f = FileUtil.expandFilename(link, dirs); diff --git a/src/main/java/net/sf/jabref/exporter/layout/format/WrapFileLinks.java b/src/main/java/net/sf/jabref/exporter/layout/format/WrapFileLinks.java index faba3d63fee..2ebe795f035 100644 --- a/src/main/java/net/sf/jabref/exporter/layout/format/WrapFileLinks.java +++ b/src/main/java/net/sf/jabref/exporter/layout/format/WrapFileLinks.java @@ -20,7 +20,6 @@ import net.sf.jabref.gui.FileListTableModel; import net.sf.jabref.gui.FileListEntry; import net.sf.jabref.Globals; -import net.sf.jabref.gui.GUIGlobals; import java.util.*; import java.io.File; @@ -147,7 +146,7 @@ public String format(String field) { if (Globals.prefs.fileDirForDatabase != null) { dirs = Globals.prefs.fileDirForDatabase; } else { - dirs = new String[] {Globals.prefs.get(GUIGlobals.FILE_FIELD + "Directory")}; + dirs = new String[] {Globals.prefs.get(Globals.FILE_FIELD + "Directory")}; } File f = FileUtil.expandFilename(flEntry.getLink(), dirs); diff --git a/src/main/java/net/sf/jabref/external/AttachFileAction.java b/src/main/java/net/sf/jabref/external/AttachFileAction.java index 220a8d633af..6fc11d10687 100644 --- a/src/main/java/net/sf/jabref/external/AttachFileAction.java +++ b/src/main/java/net/sf/jabref/external/AttachFileAction.java @@ -1,5 +1,6 @@ package net.sf.jabref.external; +import net.sf.jabref.Globals; import net.sf.jabref.gui.*; import net.sf.jabref.gui.actions.BaseAction; import net.sf.jabref.gui.undo.UndoableFieldChange; @@ -34,16 +35,16 @@ public void action() { editor.setVisible(true, true); if (editor.okPressed()) { FileListTableModel model = new FileListTableModel(); - String oldVal = entry.getField(GUIGlobals.FILE_FIELD); + String oldVal = entry.getField(Globals.FILE_FIELD); if (oldVal != null) { model.setContent(oldVal); } model.addEntry(model.getRowCount(), flEntry); String newVal = model.getStringRepresentation(); - UndoableFieldChange ce = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, + UndoableFieldChange ce = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldVal, newVal); - entry.setField(GUIGlobals.FILE_FIELD, newVal); + entry.setField(Globals.FILE_FIELD, newVal); panel.undoManager.addEdit(ce); panel.markBaseChanged(); } diff --git a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java index f95426da47e..0145f6533b9 100644 --- a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java +++ b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java @@ -18,7 +18,6 @@ import net.sf.jabref.*; import net.sf.jabref.gui.FileListEntry; import net.sf.jabref.gui.FileListEntryEditor; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.gui.net.MonitoredURLDownload; import net.sf.jabref.logic.l10n.Localization; @@ -354,7 +353,7 @@ private String getSuffix(final String link) { } private String[] getFileDirectory(String link) { - return metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + return metaData.getFileDirectory(Globals.FILE_FIELD); } diff --git a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java index c40a03e3c1d..3f555b31f1b 100644 --- a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java +++ b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java @@ -148,7 +148,7 @@ public void handleDroppedfile(String fileName, ExternalFileType fileType, boolea String destFilename; if (linkInPlace.isSelected()) { - destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString(); + destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString(); } else { destFilename = renameCheckBox.isSelected() ? renameToTextBox.getText() : new File(fileName).getName(); if (copyRadioButton.isSelected()) { @@ -193,7 +193,7 @@ public void linkPdfToEntry(String fileName, MainTable entryTable, BibtexEntry en String destFilename; if (linkInPlace.isSelected()) { - destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString(); + destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString(); } else { destFilename = renameCheckBox.isSelected() ? renameToTextBox.getText() : new File(fileName).getName(); if (copyRadioButton.isSelected()) { @@ -223,7 +223,7 @@ public void importXmp(List xmpEntriesInFile, String fileName) { String destFilename; if (linkInPlace.isSelected()) { - destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString(); + destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString(); } else { if (renameCheckBox.isSelected()) { destFilename = fileName; @@ -308,7 +308,7 @@ private boolean tryXmpImport(String fileName, ExternalFileType fileType, boolean String destFilename; if (linkInPlace.isSelected()) { - destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString(); + destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString(); } else { if (renameCheckBox.isSelected()) { destFilename = fileName; @@ -345,7 +345,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy BibtexEntry entry, boolean newEntry, final boolean multipleEntries, BibtexDatabase database) { String dialogTitle = Localization.lang("Link to file %0", linkFileName); - String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); int found = -1; for (int i = 0; i < dirs.length; i++) { if (new File(dirs[i]).exists()) { @@ -440,7 +440,7 @@ public void stateChanged(ChangeEvent arg0) { private void doLink(BibtexEntry entry, ExternalFileType fileType, String filename, boolean avoidDuplicate, NamedCompound edits) { - String oldValue = entry.getField(GUIGlobals.FILE_FIELD); + String oldValue = entry.getField(Globals.FILE_FIELD); FileListTableModel tm = new FileListTableModel(); if (oldValue != null) { tm.setContent(oldValue); @@ -449,7 +449,7 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam // If avoidDuplicate==true, we should check if this file is already linked: if (avoidDuplicate) { // For comparison, find the absolute filename: - String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); String absFilename = !new File(filename).isAbsolute() && dirs.length > 0 ? FileUtil.expandFilename(filename, dirs).getAbsolutePath() : filename; @@ -468,9 +468,9 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam tm.addEntry(tm.getRowCount(), new FileListEntry("", filename, fileType)); String newValue = tm.getStringRepresentation(); - UndoableFieldChange edit = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, + UndoableFieldChange edit = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue); - entry.setField(GUIGlobals.FILE_FIELD, newValue); + entry.setField(Globals.FILE_FIELD, newValue); if (edits == null) { panel.undoManager.addEdit(edit); @@ -491,7 +491,7 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam */ private boolean doMove(String fileName, ExternalFileType fileType, String destFilename, NamedCompound edits) { - String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); int found = -1; for (int i = 0; i < dirs.length; i++) { if (new File(dirs[i]).exists()) { @@ -540,7 +540,7 @@ private boolean doMove(String fileName, ExternalFileType fileType, String destFi private boolean doCopy(String fileName, ExternalFileType fileType, String toFile, NamedCompound edits) { - String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); int found = -1; for (int i = 0; i < dirs.length; i++) { if (new File(dirs[i]).exists()) { diff --git a/src/main/java/net/sf/jabref/external/ExternalFileMenuItem.java b/src/main/java/net/sf/jabref/external/ExternalFileMenuItem.java index 7d20152aae9..4b2a37cdeaa 100644 --- a/src/main/java/net/sf/jabref/external/ExternalFileMenuItem.java +++ b/src/main/java/net/sf/jabref/external/ExternalFileMenuItem.java @@ -26,7 +26,7 @@ import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; /** * The menu item used in the popup menu for opening external resources associated diff --git a/src/main/java/net/sf/jabref/external/FindFullTextAction.java b/src/main/java/net/sf/jabref/external/FindFullTextAction.java index ce2f29d9dec..edd5cabe4b0 100644 --- a/src/main/java/net/sf/jabref/external/FindFullTextAction.java +++ b/src/main/java/net/sf/jabref/external/FindFullTextAction.java @@ -15,9 +15,9 @@ */ package net.sf.jabref.external; +import net.sf.jabref.Globals; import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.worker.AbstractWorker; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.gui.undo.UndoableFieldChange; import net.sf.jabref.gui.FileListEntry; import net.sf.jabref.gui.FileListTableModel; @@ -60,7 +60,7 @@ public void run() { public void update() { if (result.isPresent()) { String bibtexKey = entry.getCiteKey(); - String[] dirs = basePanel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = basePanel.metaData().getFileDirectory(Globals.FILE_FIELD); if (dirs.length == 0) { // FIXME: Localization JOptionPane.showMessageDialog(basePanel.frame(), "Main file directory not set! Preferences -> External programs", "Directory not found", JOptionPane.ERROR_MESSAGE); @@ -73,12 +73,12 @@ public void update() { @Override public void downloadComplete(FileListEntry file) { FileListTableModel tm = new FileListTableModel(); - String oldValue = entry.getField(GUIGlobals.FILE_FIELD); + String oldValue = entry.getField(Globals.FILE_FIELD); tm.setContent(oldValue); tm.addEntry(tm.getRowCount(), file); String newValue = tm.getStringRepresentation(); - UndoableFieldChange edit = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue); - entry.setField(GUIGlobals.FILE_FIELD, newValue); + UndoableFieldChange edit = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue); + entry.setField(Globals.FILE_FIELD, newValue); basePanel.undoManager.addEdit(edit); basePanel.markBaseChanged(); } diff --git a/src/main/java/net/sf/jabref/external/MoveFileAction.java b/src/main/java/net/sf/jabref/external/MoveFileAction.java index 96259555d04..a07ad4da5e9 100644 --- a/src/main/java/net/sf/jabref/external/MoveFileAction.java +++ b/src/main/java/net/sf/jabref/external/MoveFileAction.java @@ -63,7 +63,7 @@ public void actionPerformed(ActionEvent event) { } // Get an absolute path representation: - String[] dirs = frame.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = frame.basePanel().metaData().getFileDirectory(Globals.FILE_FIELD); int found = -1; for (int i = 0; i < dirs.length; i++) { if (new File(dirs[i]).exists()) { diff --git a/src/main/java/net/sf/jabref/external/SynchronizeFileField.java b/src/main/java/net/sf/jabref/external/SynchronizeFileField.java index ac4843fdd0a..270a9cd4cec 100644 --- a/src/main/java/net/sf/jabref/external/SynchronizeFileField.java +++ b/src/main/java/net/sf/jabref/external/SynchronizeFileField.java @@ -43,7 +43,7 @@ */ public class SynchronizeFileField extends AbstractWorker { - private final String fieldName = GUIGlobals.FILE_FIELD; + private final String fieldName = Globals.FILE_FIELD; private final BasePanel panel; private BibtexEntry[] sel; private SynchronizeFileField.OptionsDialog optDiag; @@ -156,7 +156,7 @@ public void run() { tableModel.setContentDontGuessTypes(old); // We need to specify which directories to search in for Util.expandFilename: - String[] dirsS = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirsS = panel.metaData().getFileDirectory(Globals.FILE_FIELD); ArrayList dirs = new ArrayList(); for (String dirs1 : dirsS) { dirs.add(new File(dirs1)); @@ -391,7 +391,7 @@ public void setVisible(boolean visible) { canceled = true; } - String[] dirs = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = metaData.getFileDirectory(Globals.FILE_FIELD); if (dirs.length == 0) { autoSetNone.setSelected(true); diff --git a/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java b/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java index 3d54021ad52..cf29d747a77 100644 --- a/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java +++ b/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java @@ -15,9 +15,9 @@ */ package net.sf.jabref.external; +import net.sf.jabref.Globals; import net.sf.jabref.model.entry.BibtexEntry; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.FileListTableModel; @@ -38,14 +38,14 @@ public class TransferableFileLinkSelection implements Transferable { public TransferableFileLinkSelection(BasePanel panel, BibtexEntry[] selection) { - String s = selection[0].getField(GUIGlobals.FILE_FIELD); + String s = selection[0].getField(Globals.FILE_FIELD); FileListTableModel tm = new FileListTableModel(); if (s != null) { tm.setContent(s); } if (tm.getRowCount() > 0) { // Find the default directory for this field type, if any: - String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); File expLink = FileUtil.expandFilename(tm.getEntry(0).getLink(), dirs); fileList.add(expLink); diff --git a/src/main/java/net/sf/jabref/external/WriteXMPAction.java b/src/main/java/net/sf/jabref/external/WriteXMPAction.java index 82efdeda50f..04aa413b6c4 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPAction.java @@ -128,8 +128,8 @@ public void run() { } // Then check the "file" field: - dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); - String field = entry.getField(GUIGlobals.FILE_FIELD); + dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); + String field = entry.getField(Globals.FILE_FIELD); if (field != null) { FileListTableModel tm = new FileListTableModel(); tm.setContent(field); diff --git a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java index e816ed43b66..12311889dbc 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java @@ -15,6 +15,7 @@ */ package net.sf.jabref.external; +import net.sf.jabref.Globals; import net.sf.jabref.gui.*; import net.sf.jabref.gui.worker.AbstractWorker; import net.sf.jabref.gui.entryeditor.EntryEditor; @@ -68,8 +69,8 @@ public void actionPerformed(ActionEvent actionEvent) { } // Then check the "file" field: - dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); - String field = entry.getField(GUIGlobals.FILE_FIELD); + dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD); + String field = entry.getField(Globals.FILE_FIELD); if (field != null) { FileListTableModel tm = new FileListTableModel(); tm.setContent(field); diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index c4a84d9de57..656d7ae3e7f 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -70,7 +70,7 @@ import net.sf.jabref.logic.search.matchers.NoSearchMatcher; import net.sf.jabref.logic.search.matchers.SearchMatcher; import net.sf.jabref.logic.util.io.FileBasedLock; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.database.DatabaseChangeEvent; import net.sf.jabref.model.database.DatabaseChangeEvent.ChangeType; @@ -948,8 +948,8 @@ public void run() { entries.add(bes[0]); ExternalFileType[] types = Globals.prefs.getExternalFileTypeSelection(); ArrayList dirs = new ArrayList<>(); - if (metaData.getFileDirectory(GUIGlobals.FILE_FIELD).length > 0) { - String[] mdDirs = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + if (metaData.getFileDirectory(Globals.FILE_FIELD).length > 0) { + String[] mdDirs = metaData.getFileDirectory(Globals.FILE_FIELD); for (String mdDir : mdDirs) { dirs.add(new File(mdDir)); @@ -1044,7 +1044,7 @@ public void action() { @Override public void run() { BibtexEntry[] bes = mainTable.getSelectedEntries(); - String field = GUIGlobals.FILE_FIELD; + String field = Globals.FILE_FIELD; if (bes != null && bes.length == 1) { Object link = bes[0].getField(field); if (link == null) { @@ -1080,7 +1080,7 @@ public void action() { @Override public void run() { BibtexEntry[] bes = mainTable.getSelectedEntries(); - List files = Util.getListOfLinkedFiles(bes, metaData().getFileDirectory(GUIGlobals.FILE_FIELD)); + List files = Util.getListOfLinkedFiles(bes, metaData().getFileDirectory(Globals.FILE_FIELD)); for (File f : files) { try { JabRefDesktop.openFolderAndSelectFile(f.getAbsolutePath()); diff --git a/src/main/java/net/sf/jabref/gui/BibtexFields.java b/src/main/java/net/sf/jabref/gui/BibtexFields.java index ed668315789..57fe881d534 100644 --- a/src/main/java/net/sf/jabref/gui/BibtexFields.java +++ b/src/main/java/net/sf/jabref/gui/BibtexFields.java @@ -192,7 +192,7 @@ private BibtexFields() { add(new BibtexSingleField("keywords", false, GUIGlobals.SMALL_W)); //FIELD_EXTRAS.put("keywords", "selector"); - dummy = new BibtexSingleField(GUIGlobals.FILE_FIELD, false); + dummy = new BibtexSingleField(Globals.FILE_FIELD, false); dummy.setEditorType(GUIGlobals.FILE_LIST_EDITOR); add(dummy); diff --git a/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java b/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java index ca949cd1e0c..56199364434 100644 --- a/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/FileListEntryEditor.java @@ -35,7 +35,7 @@ import net.sf.jabref.Globals; import net.sf.jabref.JabRefPreferences; import net.sf.jabref.MetaData; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.util.Util; import net.sf.jabref.external.ConfirmCloseFileListEntryEditor; import net.sf.jabref.external.ExternalFileType; @@ -308,7 +308,7 @@ private void storeSettings(FileListEntry entry) { entry.setDescription(description.getText().trim()); // See if we should trim the file link to be relative to the file directory: try { - String[] dirs = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirs = metaData.getFileDirectory(Globals.FILE_FIELD); if (dirs.length == 0) { entry.setLink(link.getText().trim()); } else { @@ -371,7 +371,7 @@ public void actionPerformed(ActionEvent e) { Globals.prefs.put(JabRefPreferences.FILE_WORKING_DIRECTORY, newFile.getParent()); // If the file is below the file directory, make the path relative: - String[] dirsS = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirsS = metaData.getFileDirectory(Globals.FILE_FIELD); newFile = FileUtil.shortenFileName(newFile, dirsS); comp.setText(newFile.getPath()); diff --git a/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java index 427e9d2966a..f283103ff8a 100644 --- a/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java +++ b/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java @@ -68,7 +68,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.entry.BibtexEntryType; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/net/sf/jabref/gui/GUIGlobals.java b/src/main/java/net/sf/jabref/gui/GUIGlobals.java index 3c7a2b5a2c0..dc584b6aa8a 100644 --- a/src/main/java/net/sf/jabref/gui/GUIGlobals.java +++ b/src/main/java/net/sf/jabref/gui/GUIGlobals.java @@ -135,10 +135,6 @@ public class GUIGlobals { public static final int MAX_BACK_HISTORY_SIZE = 10; // The maximum number of "Back" operations stored. - public static final String FILE_FIELD = "file"; - - private static final String FOLDER_FIELD = "folder"; - public static final double SMALL_W = 0.30; public static final double MEDIUM_W = 0.5; public static final double LARGE_W = 1.5; @@ -168,29 +164,7 @@ public class GUIGlobals { public static final int IMPORT_DIALOG_COL_2_WIDTH = 200; public static final int IMPORT_DIALOG_COL_3_WIDTH = 200; - public static final Map LANGUAGES; - static { - LANGUAGES = new TreeMap<>(); - - // LANGUAGES contains mappings for supported languages. - GUIGlobals.LANGUAGES.put("Dansk", "da"); - GUIGlobals.LANGUAGES.put("Deutsch", "de"); - GUIGlobals.LANGUAGES.put("English", "en"); - GUIGlobals.LANGUAGES.put("Español", "es"); - GUIGlobals.LANGUAGES.put("Persian (فارسی)", "fa"); - GUIGlobals.LANGUAGES.put("Fran\u00E7ais", "fr"); - GUIGlobals.LANGUAGES.put("Bahasa Indonesia", "in"); - GUIGlobals.LANGUAGES.put("Italiano", "it"); - GUIGlobals.LANGUAGES.put("Japanese", "ja"); - GUIGlobals.LANGUAGES.put("Nederlands", "nl"); - GUIGlobals.LANGUAGES.put("Norsk", "no"); - GUIGlobals.LANGUAGES.put("Brazilian Portugese", "pt_BR"); - GUIGlobals.LANGUAGES.put("Russian", "ru"); - GUIGlobals.LANGUAGES.put("Turkish", "tr"); - GUIGlobals.LANGUAGES.put("Vietnamese", "vi"); - GUIGlobals.LANGUAGES.put("Simplified Chinese", "zh"); - // Set up entry editor colors, first time: GUIGlobals.updateEntryEditorColors(); } @@ -254,10 +228,10 @@ public static void init() { GUIGlobals.tableIcons.put("ps", label); label = new JLabel(IconTheme.getImage("psSmall")); label.setToolTipText(Localization.lang("Open folder")); - GUIGlobals.tableIcons.put(GUIGlobals.FOLDER_FIELD, label); + GUIGlobals.tableIcons.put(Globals.FOLDER_FIELD, label); label = new JLabel(IconTheme.getImage("psSmall")); label.setToolTipText(Localization.lang("Open file")); - GUIGlobals.tableIcons.put(GUIGlobals.FILE_FIELD, label); + GUIGlobals.tableIcons.put(Globals.FILE_FIELD, label); for (ExternalFileType fileType : Globals.prefs.getExternalFileTypeSelection()) { label = new JLabel(fileType.getIcon()); diff --git a/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java b/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java index 9c5c2823fac..bbb2a4f8c39 100644 --- a/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java +++ b/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java @@ -72,7 +72,7 @@ import net.sf.jabref.gui.undo.UndoableInsertEntry; import net.sf.jabref.gui.undo.UndoableRemoveEntry; import net.sf.jabref.logic.util.strings.StringUtil; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.util.Util; import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; @@ -971,7 +971,7 @@ public void mouseClicked(MouseEvent e) { switch (col) { case FILE_COL: - Object o = entry.getField(GUIGlobals.FILE_FIELD); + Object o = entry.getField(Globals.FILE_FIELD); if (o != null) { FileListTableModel tableModel = new FileListTableModel(); tableModel.setContent((String) o); @@ -1040,7 +1040,7 @@ public void showFileFieldMenu(MouseEvent e) { BibtexEntry entry = sortedList.get(row); JPopupMenu menu = new JPopupMenu(); int count = 0; - Object o = entry.getField(GUIGlobals.FILE_FIELD); + Object o = entry.getField(Globals.FILE_FIELD); FileListTableModel fileList = new FileListTableModel(); fileList.setContent((String) o); // If there are one or more links, open the first one: @@ -1226,13 +1226,13 @@ public void actionPerformed(ActionEvent actionEvent) { public void downloadComplete(FileListEntry file) { ImportInspectionDialog.this.toFront(); // Hack FileListTableModel model = new FileListTableModel(); - String oldVal = entry.getField(GUIGlobals.FILE_FIELD); + String oldVal = entry.getField(Globals.FILE_FIELD); if (oldVal != null) { model.setContent(oldVal); } model.addEntry(model.getRowCount(), file); entries.getReadWriteLock().writeLock().lock(); - entry.setField(GUIGlobals.FILE_FIELD, model.getStringRepresentation()); + entry.setField(Globals.FILE_FIELD, model.getStringRepresentation()); entries.getReadWriteLock().writeLock().unlock(); glTable.repaint(); } @@ -1265,7 +1265,7 @@ public void actionPerformed(ActionEvent actionEvent) { } } final FileListTableModel model = new FileListTableModel(); - String oldVal = entry.getField(GUIGlobals.FILE_FIELD); + String oldVal = entry.getField(Globals.FILE_FIELD); if (oldVal != null) { model.setContent(oldVal); } @@ -1278,7 +1278,7 @@ public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent e) { if (e.getID() > 0) { entries.getReadWriteLock().writeLock().lock(); - entry.setField(GUIGlobals.FILE_FIELD, model.getStringRepresentation()); + entry.setField(Globals.FILE_FIELD, model.getStringRepresentation()); entries.getReadWriteLock().writeLock().unlock(); glTable.repaint(); } @@ -1311,13 +1311,13 @@ public void actionPerformed(ActionEvent actionEvent) { editor.setVisible(true, true); if (editor.okPressed()) { FileListTableModel model = new FileListTableModel(); - String oldVal = entry.getField(GUIGlobals.FILE_FIELD); + String oldVal = entry.getField(Globals.FILE_FIELD); if (oldVal != null) { model.setContent(oldVal); } model.addEntry(model.getRowCount(), flEntry); entries.getReadWriteLock().writeLock().lock(); - entry.setField(GUIGlobals.FILE_FIELD, model.getStringRepresentation()); + entry.setField(Globals.FILE_FIELD, model.getStringRepresentation()); entries.getReadWriteLock().writeLock().unlock(); glTable.repaint(); } @@ -1327,13 +1327,13 @@ public void actionPerformed(ActionEvent actionEvent) { public void downloadComplete(FileListEntry file) { ImportInspectionDialog.this.toFront(); // Hack FileListTableModel model = new FileListTableModel(); - String oldVal = entry.getField(GUIGlobals.FILE_FIELD); + String oldVal = entry.getField(Globals.FILE_FIELD); if (oldVal != null) { model.setContent(oldVal); } model.addEntry(model.getRowCount(), file); entries.getReadWriteLock().writeLock().lock(); - entry.setField(GUIGlobals.FILE_FIELD, model.getStringRepresentation()); + entry.setField(Globals.FILE_FIELD, model.getStringRepresentation()); entries.getReadWriteLock().writeLock().unlock(); glTable.repaint(); } @@ -1391,7 +1391,7 @@ private void setupComparatorChooser() { comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); if (i == FILE_COL) { - comparators.add(new IconComparator(new String[]{GUIGlobals.FILE_FIELD})); + comparators.add(new IconComparator(new String[]{Globals.FILE_FIELD})); } else if (i == PDF_COL) { comparators.add(new IconComparator(new String[]{"pdf"})); } else if (i == PS_COL) { @@ -1500,7 +1500,7 @@ public Object getColumnValue(BibtexEntry entry, int i) { case DUPL_COL: return entry.isGroupHit() ? duplLabel : null; case FILE_COL: - o = entry.getField(GUIGlobals.FILE_FIELD); + o = entry.getField(Globals.FILE_FIELD); if (o != null) { FileListTableModel model = new FileListTableModel(); model.setContent((String) o); diff --git a/src/main/java/net/sf/jabref/gui/MainTableFormat.java b/src/main/java/net/sf/jabref/gui/MainTableFormat.java index 1926d265dfa..27641b65b37 100644 --- a/src/main/java/net/sf/jabref/gui/MainTableFormat.java +++ b/src/main/java/net/sf/jabref/gui/MainTableFormat.java @@ -64,7 +64,7 @@ public class MainTableFormat implements TableFormat { private static final String[] QUALITY = {SpecialFieldsUtils.FIELDNAME_QUALITY}; private static final String[] PRINTED = {SpecialFieldsUtils.FIELDNAME_PRINTED}; private static final String[] READ = {SpecialFieldsUtils.FIELDNAME_READ}; - public static final String[] FILE = {GUIGlobals.FILE_FIELD}; + public static final String[] FILE = {Globals.FILE_FIELD}; private final BasePanel panel; @@ -227,8 +227,8 @@ public Object getColumnValue(BibtexEntry be, int col) { } // Ok, so we are going to display an icon. Find out which one, and return it: - if (iconType[hasField].equals(GUIGlobals.FILE_FIELD)) { - o = FileListTableModel.getFirstLabel(be.getField(GUIGlobals.FILE_FIELD)); + if (iconType[hasField].equals(Globals.FILE_FIELD)) { + o = FileListTableModel.getFirstLabel(be.getField(Globals.FILE_FIELD)); if (fieldCount[1] > 1) { o = modifyIconForMultipleLinks((JLabel) o); @@ -333,7 +333,7 @@ private int[] hasField(BibtexEntry be, String[] field) { return new int[]{-1, -1}; } int hasField = -1; - if (!field[0].equals(GUIGlobals.FILE_FIELD)) { + if (!field[0].equals(Globals.FILE_FIELD)) { for (int i = field.length - 1; i >= 0; i--) { if (hasField(be, field[i])) { hasField = i; @@ -342,7 +342,7 @@ private int[] hasField(BibtexEntry be, String[] field) { return new int[]{hasField, -1}; } else { // We use a FileListTableModel to parse the field content: - Object o = be.getField(GUIGlobals.FILE_FIELD); + Object o = be.getField(Globals.FILE_FIELD); FileListTableModel fileList = new FileListTableModel(); fileList.setContent((String) o); if (field.length == 1) { @@ -448,7 +448,7 @@ public void updateTableFormat() { if (Globals.prefs.getBoolean(JabRefPreferences.EXTRA_FILE_COLUMNS)) { String[] desiredColumns = Globals.prefs.getStringArray(JabRefPreferences.LIST_OF_FILE_COLUMNS); for (String desiredColumn : desiredColumns) { - iconCols.put(coln, new String[]{GUIGlobals.FILE_FIELD, desiredColumn}); + iconCols.put(coln, new String[]{Globals.FILE_FIELD, desiredColumn}); coln++; } } diff --git a/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java b/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java index c2518c7cfd2..451dc584ad5 100644 --- a/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java +++ b/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java @@ -33,7 +33,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.OS; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -334,7 +334,7 @@ public void mouseClicked(MouseEvent e) { //If this is a file link field with specified file types, //we should also pass the types. String[] fileTypes = {}; - if ((hasField == 0) && iconType[hasField].equals(GUIGlobals.FILE_FIELD) && (iconType.length > 1)) { + if ((hasField == 0) && iconType[hasField].equals(Globals.FILE_FIELD) && (iconType.length > 1)) { fileTypes = iconType; } final List listOfFileTypes = Collections.unmodifiableList(Arrays.asList(fileTypes)); @@ -354,7 +354,7 @@ public void run() { // See if this is a simple file link field, or if it is a file-list // field that can specify a list of links: - if (fieldName.equals(GUIGlobals.FILE_FIELD)) { + if (fieldName.equals(Globals.FILE_FIELD)) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); @@ -457,7 +457,7 @@ private void showIconRightClickMenu(MouseEvent e, int row, String[] iconType) { // See if this is a simple file link field, or if it is a file-list // field that can specify a list of links: - if (iconType[0].equals(GUIGlobals.FILE_FIELD)) { + if (iconType[0].equals(Globals.FILE_FIELD)) { // We use a FileListTableModel to parse the field content: Object o = entry.getField(iconType[0]); FileListTableModel fileList = new FileListTableModel(); diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index c5c3051bd55..38e19074e01 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -40,7 +40,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; /** * Displays an BibtexEntry using the given layout format. diff --git a/src/main/java/net/sf/jabref/gui/SearchResultsDialog.java b/src/main/java/net/sf/jabref/gui/SearchResultsDialog.java index 53ec2ba1566..77eada0448e 100644 --- a/src/main/java/net/sf/jabref/gui/SearchResultsDialog.java +++ b/src/main/java/net/sf/jabref/gui/SearchResultsDialog.java @@ -52,7 +52,7 @@ import net.sf.jabref.external.ExternalFileMenuItem; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.strings.StringUtil; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.SortedList; @@ -229,7 +229,7 @@ private void setupComparatorChooser(TableComparatorChooser comparat comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); if (i == FILE_COL) { - comparators.add(new IconComparator(new String[] {GUIGlobals.FILE_FIELD})); + comparators.add(new IconComparator(new String[] {Globals.FILE_FIELD})); } else if (i == URL_COL) { comparators.add(new IconComparator(new String[] {"url"})); } @@ -339,7 +339,7 @@ public void mouseClicked(MouseEvent e) { BasePanel p = entryHome.get(entry); switch (col) { case FILE_COL: - Object o = entry.getField(GUIGlobals.FILE_FIELD); + Object o = entry.getField(Globals.FILE_FIELD); if (o != null) { FileListTableModel tableModel = new FileListTableModel(); tableModel.setContent((String) o); @@ -382,7 +382,7 @@ public void processPopupTrigger(MouseEvent e) { if (col == FILE_COL) { // We use a FileListTableModel to parse the field content: - Object o = entry.getField(GUIGlobals.FILE_FIELD); + Object o = entry.getField(Globals.FILE_FIELD); FileListTableModel fileList = new FileListTableModel(); fileList.setContent((String) o); // If there are one or more links, open the first one: @@ -460,7 +460,7 @@ public Object getColumnValue(BibtexEntry entry, int column) { Object o; switch (column) { case FILE_COL: - o = entry.getField(GUIGlobals.FILE_FIELD); + o = entry.getField(Globals.FILE_FIELD); if (o != null) { FileListTableModel model = new FileListTableModel(); model.setContent((String) o); diff --git a/src/main/java/net/sf/jabref/gui/actions/CleanUpAction.java b/src/main/java/net/sf/jabref/gui/actions/CleanUpAction.java index 67ef43ddf87..fbda440d716 100644 --- a/src/main/java/net/sf/jabref/gui/actions/CleanUpAction.java +++ b/src/main/java/net/sf/jabref/gui/actions/CleanUpAction.java @@ -135,7 +135,7 @@ public void stateChanged(ChangeEvent arg0) { } }); cleanUpRenamePDFonlyRelativePaths = new JCheckBox(Localization.lang("Rename only PDFs having a relative path")); - cleanUpUpgradeExternalLinks = new JCheckBox(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", GUIGlobals.FILE_FIELD)); + cleanUpUpgradeExternalLinks = new JCheckBox(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", Globals.FILE_FIELD)); cleanUpHTML = new JCheckBox(Localization.lang("Run HTML converter on title")); cleanUpCase = new JCheckBox(Localization.lang("Run filter on title keeping the case of selected words")); cleanUpLaTeX = new JCheckBox(Localization.lang("Remove unneccessary $, {, and } and move adjacent numbers into equations")); @@ -457,7 +457,7 @@ private void doCleanUpPageNumbers(BibtexEntry entry, NamedCompound ce) { } private void fixWrongFileEntries(BibtexEntry entry, NamedCompound ce) { - String oldValue = entry.getField(GUIGlobals.FILE_FIELD); + String oldValue = entry.getField(Globals.FILE_FIELD); if (oldValue == null) { return; } @@ -481,13 +481,13 @@ private void fixWrongFileEntries(BibtexEntry entry, NamedCompound ce) { if (changed) { String newValue = flModel.getStringRepresentation(); assert (!oldValue.equals(newValue)); - entry.setField(GUIGlobals.FILE_FIELD, newValue); - ce.addEdit(new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue)); + entry.setField(Globals.FILE_FIELD, newValue); + ce.addEdit(new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue)); } } private void doMakePathsRelative(BibtexEntry entry, NamedCompound ce) { - String oldValue = entry.getField(GUIGlobals.FILE_FIELD); + String oldValue = entry.getField(Globals.FILE_FIELD); if (oldValue == null) { return; } @@ -500,7 +500,7 @@ private void doMakePathsRelative(BibtexEntry entry, NamedCompound ce) { for (int i = 0; i < flModel.getRowCount(); i++) { FileListEntry flEntry = flModel.getEntry(i); String oldFileName = flEntry.getLink(); - String newFileName = FileUtil.shortenFileName(new File(oldFileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString(); + String newFileName = FileUtil.shortenFileName(new File(oldFileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString(); if (!oldFileName.equals(newFileName)) { flEntry.setLink(newFileName); changed = true; @@ -509,14 +509,14 @@ private void doMakePathsRelative(BibtexEntry entry, NamedCompound ce) { if (changed) { String newValue = flModel.getStringRepresentation(); assert (!oldValue.equals(newValue)); - entry.setField(GUIGlobals.FILE_FIELD, newValue); - ce.addEdit(new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue)); + entry.setField(Globals.FILE_FIELD, newValue); + ce.addEdit(new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue)); } } private void doRenamePDFs(BibtexEntry entry, NamedCompound ce) { //Extract the path - String oldValue = entry.getField(GUIGlobals.FILE_FIELD); + String oldValue = entry.getField(Globals.FILE_FIELD); if (oldValue == null) { return; } @@ -542,7 +542,7 @@ private void doRenamePDFs(BibtexEntry entry, NamedCompound ce) { //get new Filename with path //Create new Path based on old Path and new filename - File expandedOldFile = FileUtil.expandFilename(realOldFilename, panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)); + File expandedOldFile = FileUtil.expandFilename(realOldFilename, panel.metaData().getFileDirectory(Globals.FILE_FIELD)); if (expandedOldFile.getParent() == null) { // something went wrong. Just skipt his entry continue; @@ -584,11 +584,11 @@ private void doRenamePDFs(BibtexEntry entry, NamedCompound ce) { if (changed) { String newValue = flModel.getStringRepresentation(); assert (!oldValue.equals(newValue)); - entry.setField(GUIGlobals.FILE_FIELD, newValue); + entry.setField(Globals.FILE_FIELD, newValue); //we put an undo of the field content here //the file is not being renamed back, which leads to inconsistencies //if we put a null undo object here, the change by "doMakePathsRelative" would overwrite the field value nevertheless. - ce.addEdit(new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue)); + ce.addEdit(new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue)); } } diff --git a/src/main/java/net/sf/jabref/logic/util/io/JabRefDesktop.java b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java similarity index 98% rename from src/main/java/net/sf/jabref/logic/util/io/JabRefDesktop.java rename to src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java index 49114440d54..2bad48b0f5f 100644 --- a/src/main/java/net/sf/jabref/logic/util/io/JabRefDesktop.java +++ b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java @@ -1,4 +1,4 @@ -package net.sf.jabref.logic.util.io; +package net.sf.jabref.gui.desktop; import net.sf.jabref.*; import net.sf.jabref.external.ExternalFileType; @@ -338,7 +338,7 @@ else if (answer == JOptionPane.YES_OPTION) { // 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); + String oldValue = entry.getField(Globals.FILE_FIELD); tModel.setContent(oldValue); FileListEntry flEntry = null; // Then find which one we are looking at: @@ -359,9 +359,9 @@ else if (answer == JOptionPane.YES_OPTION) { if (editor.okPressed()) { // Store the changes and add an undo edit: String newValue = tModel.getStringRepresentation(); - UndoableFieldChange ce = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, + UndoableFieldChange ce = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue); - entry.setField(GUIGlobals.FILE_FIELD, newValue); + entry.setField(Globals.FILE_FIELD, newValue); frame.basePanel().undoManager.addEdit(ce); frame.basePanel().markBaseChanged(); // Finally, open the link: diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java index aeeeea19c7e..d1c85627d33 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -74,7 +74,7 @@ import net.sf.jabref.gui.undo.UndoableFieldChange; import net.sf.jabref.gui.undo.UndoableKeyChange; import net.sf.jabref.gui.undo.UndoableRemoveEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.util.Util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java b/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java index f11ab622677..b41e7d900d4 100644 --- a/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java +++ b/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java @@ -51,7 +51,7 @@ import net.sf.jabref.logic.util.io.FileUtil; import net.sf.jabref.logic.util.strings.StringUtil; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.util.Util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/net/sf/jabref/gui/menus/help/ForkMeOnGitHubAction.java b/src/main/java/net/sf/jabref/gui/menus/help/ForkMeOnGitHubAction.java index 561f534bd71..7ea5d3b2c92 100644 --- a/src/main/java/net/sf/jabref/gui/menus/help/ForkMeOnGitHubAction.java +++ b/src/main/java/net/sf/jabref/gui/menus/help/ForkMeOnGitHubAction.java @@ -23,7 +23,7 @@ import net.sf.jabref.JabRef; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; @SuppressWarnings("serial") public class ForkMeOnGitHubAction extends AbstractAction { diff --git a/src/main/java/net/sf/jabref/gui/preftabs/ExternalTab.java b/src/main/java/net/sf/jabref/gui/preftabs/ExternalTab.java index 47c5a8e844d..505b29f3f3e 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/ExternalTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/ExternalTab.java @@ -231,7 +231,7 @@ public void actionPerformed(ActionEvent event) { public void setValues() { pdfDir.setText(prefs.get("pdfDirectory")); psDir.setText(prefs.get("psDirectory")); - fileDir.setText(prefs.get(GUIGlobals.FILE_FIELD + "Directory")); + fileDir.setText(prefs.get(Globals.FILE_FIELD + "Directory")); bibLocationAsFileDir.setSelected(prefs.getBoolean(JabRefPreferences.BIB_LOCATION_AS_FILE_DIR)); bibLocAsPrimaryDir.setSelected(prefs.getBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR)); bibLocAsPrimaryDir.setEnabled(bibLocationAsFileDir.isSelected()); @@ -262,7 +262,7 @@ public void storeSettings() { // We should maybe do some checking on the validity of the contents? prefs.put("pdfDirectory", pdfDir.getText()); prefs.put("psDirectory", psDir.getText()); - prefs.put(GUIGlobals.FILE_FIELD + "Directory", fileDir.getText()); + prefs.put(Globals.FILE_FIELD + "Directory", fileDir.getText()); prefs.putBoolean(JabRefPreferences.BIB_LOCATION_AS_FILE_DIR, bibLocationAsFileDir.isSelected()); prefs.putBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, bibLocAsPrimaryDir.isSelected()); prefs.putBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, matchExactKeyOnly.isSelected()); diff --git a/src/main/java/net/sf/jabref/gui/preftabs/GeneralTab.java b/src/main/java/net/sf/jabref/gui/preftabs/GeneralTab.java index 6dd0fa8ae4e..687a84ab3a0 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/GeneralTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/GeneralTab.java @@ -43,6 +43,8 @@ import net.sf.jabref.logic.l10n.Encodings; import net.sf.jabref.logic.l10n.Localization; +import static net.sf.jabref.logic.l10n.Languages.LANGUAGES; + class GeneralTab extends JPanel implements PrefsTab { private final JCheckBox defSort; @@ -68,7 +70,7 @@ class GeneralTab extends JPanel implements PrefsTab { private final JTextField timeStampFormat; private final JTextField timeStampField; private final JabRefPreferences prefs; - private final JComboBox language = new JComboBox<>(GUIGlobals.LANGUAGES.keySet().toArray(new String[GUIGlobals.LANGUAGES.keySet().size()])); + private final JComboBox language = new JComboBox<>(LANGUAGES.keySet().toArray(new String[LANGUAGES.keySet().size()])); private final JComboBox encodings = new JComboBox<>(Encodings.ENCODINGS); @@ -242,7 +244,7 @@ public void setValues() { // Language choice int ilk = 0; - for (String lan : GUIGlobals.LANGUAGES.values()) { + for (String lan : LANGUAGES.values()) { if (lan.equals(oldLan)) { language.setSelectedIndex(ilk); } @@ -283,9 +285,9 @@ public void storeSettings() { prefs.putBoolean(JabRefPreferences.MARK_IMPORTED_ENTRIES, markImportedEntries.isSelected()); prefs.putBoolean(JabRefPreferences.UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, unmarkAllEntriesBeforeImporting.isSelected()); - if (!GUIGlobals.LANGUAGES.get(language.getSelectedItem()).equals(prefs.get(JabRefPreferences.LANGUAGE))) { - prefs.put(JabRefPreferences.LANGUAGE, GUIGlobals.LANGUAGES.get(language.getSelectedItem())); - Localization.setLanguage(GUIGlobals.LANGUAGES.get(language.getSelectedItem())); + if (!LANGUAGES.get(language.getSelectedItem()).equals(prefs.get(JabRefPreferences.LANGUAGE))) { + prefs.put(JabRefPreferences.LANGUAGE, LANGUAGES.get(language.getSelectedItem())); + Localization.setLanguage(LANGUAGES.get(language.getSelectedItem())); // Update any defaults that might be language dependent: Globals.prefs.setLanguageDependentDefaultValues(); // Warn about restart needed: diff --git a/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java b/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java index bd5baa6450f..d51617069df 100644 --- a/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java +++ b/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java @@ -27,12 +27,11 @@ import net.sf.jabref.*; import net.sf.jabref.exporter.LatexFieldFormatter; import net.sf.jabref.gui.BasePanel; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.logic.bibtex.BibtexEntryWriter; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.util.Util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -95,7 +94,7 @@ public void run() { // the unofficial "mailto:attachment" property boolean openFolders = JabRefPreferences.getInstance().getBoolean(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES); - List fileList = Util.getListOfLinkedFiles(bes, frame.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD)); + List fileList = Util.getListOfLinkedFiles(bes, frame.basePanel().metaData().getFileDirectory(Globals.FILE_FIELD)); for (File f : fileList) { attachments.add(f.getPath()); if (openFolders) { diff --git a/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java b/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java index 0936fc9bda1..40b7d5141eb 100644 --- a/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java +++ b/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java @@ -4,10 +4,10 @@ import java.util.Collection; import java.util.HashMap; +import net.sf.jabref.Globals; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.entry.BibtexEntry; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.JabRef; import net.sf.jabref.gui.FileListEntry; import net.sf.jabref.gui.FileListTableModel; @@ -47,7 +47,7 @@ public DatabaseFileLookup(BibtexDatabase aDatabase) { throw new IllegalArgumentException("Passing a 'null' BibtexDatabase."); } entries = aDatabase.getEntries(); - possibleFilePaths = JabRef.jrf.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + possibleFilePaths = JabRef.jrf.basePanel().metaData().getFileDirectory(Globals.FILE_FIELD); } /** diff --git a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java index bd4f8a214b4..87e46d3922c 100644 --- a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java +++ b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.StringTokenizer; +import net.sf.jabref.Globals; import net.sf.jabref.model.entry.BibtexEntry; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.JabRef; import net.sf.jabref.JabRefPreferences; import net.sf.jabref.external.ExternalFileType; @@ -138,7 +138,7 @@ private void addFileInfo(BibtexEntry entry, File file) { JabRefPreferences jabRefPreferences = JabRefPreferences.getInstance(); ExternalFileType fileType = jabRefPreferences.getExternalFileTypeByExt(externalFileType.getFieldName()); - String[] possibleFilePaths = JabRef.jrf.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] possibleFilePaths = JabRef.jrf.basePanel().metaData().getFileDirectory(Globals.FILE_FIELD); File shortenedFileName = FileUtil.shortenFileName(file, possibleFilePaths); FileListEntry fileListEntry = new FileListEntry("", shortenedFileName.getPath(), fileType); diff --git a/src/main/java/net/sf/jabref/logic/l10n/Languages.java b/src/main/java/net/sf/jabref/logic/l10n/Languages.java new file mode 100644 index 00000000000..cad468be8af --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/l10n/Languages.java @@ -0,0 +1,32 @@ +package net.sf.jabref.logic.l10n; + +import java.util.Map; +import java.util.TreeMap; + +public class Languages { + + public static final Map LANGUAGES; + + static { + LANGUAGES = new TreeMap<>(); + + // LANGUAGES contains mappings for supported languages. + LANGUAGES.put("Dansk", "da"); + LANGUAGES.put("Deutsch", "de"); + LANGUAGES.put("English", "en"); + LANGUAGES.put("Espaol", "es"); + LANGUAGES.put("Persian (?????)", "fa"); + LANGUAGES.put("Fran\u00E7ais", "fr"); + LANGUAGES.put("Bahasa Indonesia", "in"); + LANGUAGES.put("Italiano", "it"); + LANGUAGES.put("Japanese", "ja"); + LANGUAGES.put("Nederlands", "nl"); + LANGUAGES.put("Norsk", "no"); + LANGUAGES.put("Brazilian Portugese", "pt_BR"); + LANGUAGES.put("Russian", "ru"); + LANGUAGES.put("Turkish", "tr"); + LANGUAGES.put("Vietnamese", "vi"); + LANGUAGES.put("Simplified Chinese", "zh"); + } + +} diff --git a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java index ea71c407688..487e124f5f0 100644 --- a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java @@ -1,6 +1,6 @@ package net.sf.jabref.logic.util.io; -import net.sf.jabref.gui.GUIGlobals; +import net.sf.jabref.Globals; import net.sf.jabref.MetaData; import net.sf.jabref.logic.util.OS; import org.apache.commons.logging.Log; @@ -12,10 +12,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.nio.file.DirectoryNotEmptyException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Paths; import java.util.ArrayList; public class FileUtil { @@ -116,7 +112,7 @@ public static File expandFilename(final MetaData metaData, String name) { // Find the default directory for this field type, if any: String[] dir = metaData.getFileDirectory(extension); // Include the standard "file" directory: - String[] fileDir = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + String[] fileDir = metaData.getFileDirectory(Globals.FILE_FIELD); // Include the directory of the bib file: ArrayList al = new ArrayList(); for (String aDir : dir) { diff --git a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java index 939b38b8f3b..5648fca580d 100644 --- a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java +++ b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java @@ -21,7 +21,6 @@ import net.sf.jabref.*; import net.sf.jabref.gui.BasePanel; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.gui.actions.BrowseAction; import net.sf.jabref.gui.entryeditor.EntryEditorTabList; import net.sf.jabref.importer.ParserResult; @@ -87,7 +86,7 @@ public void performAction(BasePanel panel, ParserResult pr) { // Only offer to upgrade links if the pdf/ps fields are used: boolean offerChangeDatabase = linksFound(pr.getDatabase(), FileLinksUpgradeWarning.FIELDS_TO_LOOK_FOR); // If the "file" directory is not set, offer to migrate pdf/ps dir: - boolean offerSetFileDir = !Globals.prefs.hasKey(GUIGlobals.FILE_FIELD + "Directory") + boolean offerSetFileDir = !Globals.prefs.hasKey(Globals.FILE_FIELD + "Directory") && (Globals.prefs.hasKey("pdfDirectory") || Globals.prefs.hasKey("psDirectory")); if (!offerChangeDatabase && !offerChangeSettings && !offerSetFileDir) @@ -192,7 +191,7 @@ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, } if (fileDir != null) { - Globals.prefs.put(GUIGlobals.FILE_FIELD + "Directory", fileDir); + Globals.prefs.put(Globals.FILE_FIELD + "Directory", fileDir); } if (upgradePrefs) { @@ -209,7 +208,7 @@ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, if (!gfs.isEmpty()) { sb.append(";"); } - sb.append(GUIGlobals.FILE_FIELD); + sb.append(Globals.FILE_FIELD); Globals.prefs.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "0", sb.toString()); Globals.prefs.updateEntryEditorTabList(); panel.frame().removeCachedEntryEditors(); @@ -224,7 +223,7 @@ private boolean showsFileInGenFields() { outer: for (int i = 0; i < tabList.getTabCount(); i++) { List fields = tabList.getTabFields(i); for (String field : fields) { - if (field.equals(GUIGlobals.FILE_FIELD)) { + if (field.equals(Globals.FILE_FIELD)) { found = true; break outer; } diff --git a/src/main/java/net/sf/jabref/openoffice/StyleSelectDialog.java b/src/main/java/net/sf/jabref/openoffice/StyleSelectDialog.java index 0379d787184..fb83e7216fa 100644 --- a/src/main/java/net/sf/jabref/openoffice/StyleSelectDialog.java +++ b/src/main/java/net/sf/jabref/openoffice/StyleSelectDialog.java @@ -67,7 +67,7 @@ import net.sf.jabref.external.ExternalFileType; import net.sf.jabref.external.UnknownExternalFileType; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.SortedList; diff --git a/src/main/java/net/sf/jabref/util/Util.java b/src/main/java/net/sf/jabref/util/Util.java index c92d709f998..ad7b0c7aa5f 100644 --- a/src/main/java/net/sf/jabref/util/Util.java +++ b/src/main/java/net/sf/jabref/util/Util.java @@ -64,7 +64,6 @@ import net.sf.jabref.gui.worker.CallBack; import net.sf.jabref.logic.util.date.EasyDateFormat; import net.sf.jabref.gui.EntryMarker; -import net.sf.jabref.gui.GUIGlobals; import net.sf.jabref.Globals; import net.sf.jabref.gui.preftabs.ImportSettingsTab; import net.sf.jabref.JabRefPreferences; @@ -548,7 +547,7 @@ public static NamedCompound upgradePdfPsToFile(Collection entries, for (BibtexEntry entry : entries) { FileListTableModel tableModel = new FileListTableModel(); // If there are already links in the file field, keep those on top: - String oldFileContent = entry.getField(GUIGlobals.FILE_FIELD); + String oldFileContent = entry.getField(Globals.FILE_FIELD); if (oldFileContent != null) { tableModel.setContent(oldFileContent); } @@ -568,8 +567,8 @@ public static NamedCompound upgradePdfPsToFile(Collection entries, } if (tableModel.getRowCount() != oldRowCount) { String newValue = tableModel.getStringRepresentation(); - entry.setField(GUIGlobals.FILE_FIELD, newValue); - ce.addEdit(new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldFileContent, newValue)); + entry.setField(Globals.FILE_FIELD, newValue); + ce.addEdit(new UndoableFieldChange(entry, Globals.FILE_FIELD, oldFileContent, newValue)); } } ce.end(); @@ -1015,7 +1014,7 @@ public static Runnable autoSetLinks(final Collection entries, final public void run() { // determine directories to search in ArrayList dirs = new ArrayList(); - String[] dirsS = metaData.getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirsS = metaData.getFileDirectory(Globals.FILE_FIELD); for (String dirs1 : dirsS) { dirs.add(new File(dirs1)); } @@ -1039,7 +1038,7 @@ public void run() { // Iterate over the entries: for (BibtexEntry anEntry : result.keySet()) { FileListTableModel tableModel; - String oldVal = anEntry.getField(GUIGlobals.FILE_FIELD); + String oldVal = anEntry.getField(Globals.FILE_FIELD); if (singleTableModel == null) { tableModel = new FileListTableModel(); if (oldVal != null) { @@ -1080,12 +1079,12 @@ public void run() { } if (ce != null) { // store undo information - UndoableFieldChange change = new UndoableFieldChange(anEntry, GUIGlobals.FILE_FIELD, oldVal, newVal); + UndoableFieldChange change = new UndoableFieldChange(anEntry, Globals.FILE_FIELD, oldVal, newVal); ce.addEdit(change); } // hack: if table model is given, do NOT modify entry if (singleTableModel == null) { - anEntry.setField(GUIGlobals.FILE_FIELD, newVal); + anEntry.setField(Globals.FILE_FIELD, newVal); } if (changedEntries != null) { changedEntries.add(anEntry); diff --git a/src/main/java/spl/PdfImporter.java b/src/main/java/spl/PdfImporter.java index a8ecd26241b..f026e215d38 100644 --- a/src/main/java/spl/PdfImporter.java +++ b/src/main/java/spl/PdfImporter.java @@ -121,7 +121,7 @@ private List importPdfFiles(List fileNames, OutputPrinter s int globalChoice = Globals.prefs.getInt(ImportSettingsTab.PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE); // Get a list of file directories: - String[] dirsS = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD); + String[] dirsS = panel.metaData().getFileDirectory(Globals.FILE_FIELD); List res = new ArrayList(); @@ -181,7 +181,7 @@ private List importPdfFiles(List fileNames, OutputPrinter s tm.addEntry(0, new FileListEntry(toLink.getName(), FileUtil.shortenFileName(toLink, dirsS).getPath(), Globals.prefs.getExternalFileTypeByName("pdf"))); - entry.setField(GUIGlobals.FILE_FIELD, tm.getStringRepresentation()); + entry.setField(Globals.FILE_FIELD, tm.getStringRepresentation()); res.add(entry); break; diff --git a/src/main/java/spl/listener/LabelLinkListener.java b/src/main/java/spl/listener/LabelLinkListener.java index 1bfbe7c4438..61251696742 100644 --- a/src/main/java/spl/listener/LabelLinkListener.java +++ b/src/main/java/spl/listener/LabelLinkListener.java @@ -1,7 +1,7 @@ package spl.listener; import net.sf.jabref.MetaData; -import net.sf.jabref.logic.util.io.JabRefDesktop; +import net.sf.jabref.gui.desktop.JabRefDesktop; import java.awt.*; import java.awt.event.MouseEvent; diff --git a/src/test/java/net/sf/jabref/gui/autocompleter/AutoCompleterTest.java b/src/test/java/net/sf/jabref/gui/autocompleter/AutoCompleterTest.java new file mode 100644 index 00000000000..ebc44542608 --- /dev/null +++ b/src/test/java/net/sf/jabref/gui/autocompleter/AutoCompleterTest.java @@ -0,0 +1,56 @@ +package net.sf.jabref.gui.autocompleter; + +import net.sf.jabref.JabRef; +import net.sf.jabref.gui.entryeditor.EntryEditor; +import net.sf.jabref.gui.fieldeditors.FieldEditor; +import net.sf.jabref.gui.fieldeditors.TextArea; +import net.sf.jabref.logic.autocompleter.AutoCompleter; +import net.sf.jabref.model.entry.BibtexEntry; +import net.sf.jabref.testutils.TestUtils; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import java.awt.event.ActionEvent; + +public class AutoCompleterTest { + + @Test + @Ignore(value = "works on windows and ubuntu, but not on travis") + public void testEntryEditorForNameFieldAutoCompleter() { + // construct an EntryEditor ... + TestUtils.initJabRef(); + BibtexEntry bibtexEntry = new BibtexEntry(); + bibtexEntry.setField("author", "Brigitte Laurant"); + FieldEditor authorTextField = new TextArea("author", "Hans Meiser"); + EntryEditor editor = new EntryEditor(JabRef.jrf, JabRef.jrf.basePanel(), bibtexEntry); + // perform action ... + editor.storeFieldAction.actionPerformed(new ActionEvent(authorTextField, 0, "")); + // test content of stored words in autocompleter ... + AutoCompleter autoCompleter = JabRef.jrf.basePanel().getAutoCompleters().get("author"); + Assert.assertTrue(autoCompleter.indexContainsWord("Hans Meiser")); + Assert.assertTrue(autoCompleter.indexContainsWord("Meiser, Hans")); + + TestUtils.closeJabRef(); + } + + @Test + @Ignore(value = "works on windows and ubuntu, but not on travis") + public void testEntryEditorForFieldAnotherAutoCompleter() { + // construct an EntryEditor ... + TestUtils.initJabRef(); + BibtexEntry bibtexEntry = new BibtexEntry(); + bibtexEntry.setField("journal", "Testtext"); + FieldEditor authorTextField = new TextArea("journal", "New Testtext"); + EntryEditor editor = new EntryEditor(JabRef.jrf, JabRef.jrf.basePanel(), bibtexEntry); + // perform action ... + editor.storeFieldAction.actionPerformed(new ActionEvent(authorTextField, 0, "")); + // test content of stored words in autocompleter ... + AutoCompleter autoCompleter = JabRef.jrf.basePanel().getAutoCompleters().get("journal"); + Assert.assertTrue(autoCompleter.indexContainsWord("New Testtext")); + + TestUtils.closeJabRef(); + } + + +} diff --git a/src/test/java/net/sf/jabref/logic/autocompleter/AutoCompleterTest.java b/src/test/java/net/sf/jabref/logic/autocompleter/AutoCompleterTest.java index b7dca570d88..1c11d6a9224 100644 --- a/src/test/java/net/sf/jabref/logic/autocompleter/AutoCompleterTest.java +++ b/src/test/java/net/sf/jabref/logic/autocompleter/AutoCompleterTest.java @@ -1,19 +1,14 @@ package net.sf.jabref.logic.autocompleter; -import net.sf.jabref.*; -import net.sf.jabref.gui.entryeditor.EntryEditor; -import net.sf.jabref.gui.fieldeditors.FieldEditor; -import net.sf.jabref.gui.fieldeditors.TextArea; +import net.sf.jabref.Globals; +import net.sf.jabref.JabRef; +import net.sf.jabref.JabRefPreferences; import net.sf.jabref.importer.ParserResult; import net.sf.jabref.model.database.BibtexDatabase; import net.sf.jabref.model.entry.BibtexEntry; -import net.sf.jabref.testutils.TestUtils; - import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; -import java.awt.event.ActionEvent; import java.io.File; /** @@ -28,7 +23,6 @@ public class AutoCompleterTest { public static final String PATH_TO_TEST_BIBTEX = "src/test/resources/net/sf/jabref/bibtexFiles/test.bib"; - @Test public void testAutoCompleterFactory() { Globals.prefs = JabRefPreferences.getInstance(); @@ -142,43 +136,6 @@ public void testNameFieldCompleter() { Globals.prefs.put(JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE, oldACFM); } - @Test - @Ignore(value = "works on windows and ubuntu, but not on travis") - public void testEntryEditorForNameFieldAutoCompleter() { - // construct an EntryEditor ... - TestUtils.initJabRef(); - BibtexEntry bibtexEntry = new BibtexEntry(); - bibtexEntry.setField("author", "Brigitte Laurant"); - FieldEditor authorTextField = new TextArea("author", "Hans Meiser"); - EntryEditor editor = new EntryEditor(JabRef.jrf, JabRef.jrf.basePanel(), bibtexEntry); - // perform action ... - editor.storeFieldAction.actionPerformed(new ActionEvent(authorTextField, 0, "")); - // test content of stored words in autocompleter ... - AutoCompleter autoCompleter = JabRef.jrf.basePanel().getAutoCompleters().get("author"); - Assert.assertTrue(autoCompleter.indexContainsWord("Hans Meiser")); - Assert.assertTrue(autoCompleter.indexContainsWord("Meiser, Hans")); - - TestUtils.closeJabRef(); - } - - @Test - @Ignore(value = "works on windows and ubuntu, but not on travis") - public void testEntryEditorForFieldAnotherAutoCompleter() { - // construct an EntryEditor ... - TestUtils.initJabRef(); - BibtexEntry bibtexEntry = new BibtexEntry(); - bibtexEntry.setField("journal", "Testtext"); - FieldEditor authorTextField = new TextArea("journal", "New Testtext"); - EntryEditor editor = new EntryEditor(JabRef.jrf, JabRef.jrf.basePanel(), bibtexEntry); - // perform action ... - editor.storeFieldAction.actionPerformed(new ActionEvent(authorTextField, 0, "")); - // test content of stored words in autocompleter ... - AutoCompleter autoCompleter = JabRef.jrf.basePanel().getAutoCompleters().get("journal"); - Assert.assertTrue(autoCompleter.indexContainsWord("New Testtext")); - - TestUtils.closeJabRef(); - } - private BibtexDatabase getDatabase() { Globals.prefs = JabRefPreferences.getInstance(); File fileToLoad = new File(AutoCompleterTest.PATH_TO_TEST_BIBTEX); diff --git a/src/test/java/net/sf/jabref/logic/l10n/TestL10nFiles.java b/src/test/java/net/sf/jabref/logic/l10n/TestL10nFiles.java index b9c3b024f0b..7f7fbb1858f 100644 --- a/src/test/java/net/sf/jabref/logic/l10n/TestL10nFiles.java +++ b/src/test/java/net/sf/jabref/logic/l10n/TestL10nFiles.java @@ -1,6 +1,5 @@ package net.sf.jabref.logic.l10n; -import net.sf.jabref.gui.GUIGlobals; import org.junit.Assert; import org.junit.Test; @@ -35,7 +34,7 @@ public void testi10nFiles() throws IOException { @Test public void testCompletenessOfBundles() { - for(String lang : GUIGlobals.LANGUAGES.values()) { + for(String lang : Languages.LANGUAGES.values()) { Assert.assertTrue(Files.exists(Paths.get("src/main/resources").resolve(Localization.INTEGRITY_RESOURCE_PREFIX + "_" + lang + ".properties"))); Assert.assertTrue(Files.exists(Paths.get("src/main/resources").resolve(Localization.MENU_RESOURCE_PREFIX + "_" + lang + ".properties"))); Assert.assertTrue(Files.exists(Paths.get("src/main/resources").resolve(Localization.RESOURCE_PREFIX + "_" + lang + ".properties")));