diff --git a/.gitattributes b/.gitattributes index 9cd68788380..339e48377ba 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,8 @@ gradlew eol=lf *.sh eol=lf +AUTHORS eol=lf + # ensure that line endings of *.java and *.properties are normalized *.properties text *.java text diff --git a/.mailmap b/.mailmap index 3973d080ff0..6e253a75d0f 100644 --- a/.mailmap +++ b/.mailmap @@ -117,3 +117,4 @@ Tim van Rossum Saulius Gražulis Rolf Starre Owen Huang +Anita Armbruster diff --git a/AUTHORS b/AUTHORS index 390c4934ed2..bf276e7e391 100644 --- a/AUTHORS +++ b/AUTHORS @@ -14,6 +14,7 @@ Ambrogio Oliva Andreas Amann Andreas Rudert Anh Nghia Tran +Anita Armbruster Antonio Ribeiro Arno Blouin Behrouz Javanmardi diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b7565acf73..75e81609749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ## [Unreleased] ### Changed +- Continued to redesign the user interface: this time the editor got a fresh coat of paint: + - The buttons were changed to icons. + - Removed the hidden feature that a double click in the editor inserted the current date. + ### Fixed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a23e00315a..ca79a7c87af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,21 +5,11 @@ Take a look at GitHub's excellent [help documentation] for a detailed explanatio We also have [code howtos](https://github.com/JabRef/jabref/wiki/Code-Howtos) and [guidelines for setting up a local workspace](https://github.com/JabRef/jabref/wiki/Guidelines-for-setting-up-a-local-workspace). -For newcomers, [FLOSS Coach](http://www.flosscoach.com/) might be helpful. -It contains steps to get started with JabRef development. - In case you have any question, do not hesitate to write one of our [JabRef developers](https://github.com/orgs/JabRef/teams/developers) an email. ## Formal requirements for a pull request The main goal of the formal requirements is to provide credit to you and to be able to understand the patch. -Nevertheless we aim to keep the code consistently formatted, therefore we additionally have a requirement regarding the source formatter. - - -### Ensure consistent formatting -Ensure your code is formatted according the JabRef formatting guidelines. -When you use Eclipse, the required configuration is generated automatically by `gradlew cleanEclipse eclipse`. - ### Add your change to CHANGELOG.md You should edit the [CHANGELOG.md](CHANGELOG.md) located in the root directory of the JabRef source. @@ -49,7 +39,7 @@ Please make sure there are no duplicates or alternate spellings of your name lis If you need to merge different Git usernames or email addresses you can do so by editing `.mailmap`. More information on this can be found via `man git-shortlog`. -Please, **do not add yourself at `@authors`**. +Please, **do not add yourself at JavaDoc's `@authors`**. The contribution information is tracked via the version control system. Your contribution is considered being made under [MIT license](https://tldrlegal.com/license/mit-license). diff --git a/build.gradle b/build.gradle index 599edd4fd21..85bfcbe70e2 100644 --- a/build.gradle +++ b/build.gradle @@ -136,8 +136,6 @@ dependencies { compile 'org.citationstyles:locales:1.0.1-SNAPSHOT' compile 'de.undercouch:citeproc-java:1.0.1' - compile 'com.github.lgooddatepicker:LGoodDatePicker:8.3.0' - compile 'com.github.tomtung:latex2unicode_2.12:0.2' compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '1.0.+' @@ -390,7 +388,7 @@ task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") { checkstyle { // do not use other packages for checkstyle, excluding gen(erated) sources checkstyleMain.source = "src/main/java" - toolVersion = '6.17' + toolVersion = '7.6.1' } task release(dependsOn: ["media", "releaseJar"]) { diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 6867c04d815..a327d00276f 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -3,30 +3,7 @@ "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - - - - @@ -49,6 +26,19 @@ - + + + + + + + + + + + + + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml new file mode 100644 index 00000000000..7e853704d9d --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/external-libraries.txt b/external-libraries.txt index 7f7484b92e5..6dbe8716f0b 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -175,11 +175,6 @@ Project: SwingX URL: https://swingx.java.net/ License: LGPL-3.0 -Id: com.github.lgooddatepicker:LGoodDatePicker -Project: LGoodDatePicker -URL: https://github.com/LGoodDatePicker/LGoodDatePicker -License: MIT - Id: spin Path: lib/spin.jar Project: Spin diff --git a/src/main/java/oracle/jdbc/OracleConnection.java b/src/main/java/oracle/jdbc/OracleConnection.java index 1bd1e64ca28..693a9ff5814 100644 --- a/src/main/java/oracle/jdbc/OracleConnection.java +++ b/src/main/java/oracle/jdbc/OracleConnection.java @@ -29,7 +29,6 @@ public class OracleConnection implements Connection { public static String DCN_NOTIFY_ROWIDS; public static String DCN_QUERY_CHANGE_NOTIFICATION; - @Override public T unwrap(Class iface) throws SQLException { // Auto-generated method stub diff --git a/src/main/java/org/jabref/Globals.java b/src/main/java/org/jabref/Globals.java index f3e40b17609..f45b08b3df7 100644 --- a/src/main/java/org/jabref/Globals.java +++ b/src/main/java/org/jabref/Globals.java @@ -6,7 +6,7 @@ import org.jabref.collab.FileUpdateMonitor; import org.jabref.gui.GlobalFocusListener; import org.jabref.gui.StateManager; -import org.jabref.gui.keyboard.KeyBindingPreferences; +import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.importer.ImportFormatReader; @@ -48,7 +48,7 @@ public class Globals { */ public static StateManager stateManager = new StateManager(); // Key binding preferences - private static KeyBindingPreferences keyPrefs; + private static KeyBindingRepository keyBindingRepository; // Background tasks private static GlobalFocusListener focusListener; private static FileUpdateMonitor fileUpdateMonitor; @@ -58,11 +58,11 @@ private Globals() { } // Key binding preferences - public static KeyBindingPreferences getKeyPrefs() { - if (keyPrefs == null) { - keyPrefs = new KeyBindingPreferences(prefs); + public static KeyBindingRepository getKeyPrefs() { + if (keyBindingRepository == null) { + keyBindingRepository = prefs.getKeyBindingRepository(); } - return keyPrefs; + return keyBindingRepository; } diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/JabRefExecutorService.java index a87c23b7cda..a376ff4caee 100644 --- a/src/main/java/org/jabref/JabRefExecutorService.java +++ b/src/main/java/org/jabref/JabRefExecutorService.java @@ -33,7 +33,7 @@ public class JabRefExecutorService implements Executor { private final Timer timer = new Timer("timer", true); private Thread remoteThread; - private JabRefExecutorService() {} + private JabRefExecutorService() { } @Override public void execute(Runnable command) { @@ -73,7 +73,7 @@ public void executeInterruptableTask(final Runnable runnable, String taskName) { } public void executeInterruptableTaskAndWait(Runnable runnable) { - if(runnable == null) { + if (runnable == null) { LOGGER.debug("Received null as command for execution"); return; } @@ -92,7 +92,7 @@ public void executeInterruptableTaskAndWait(Runnable runnable) { } public void manageRemoteThread(Thread thread) { - if (this.remoteThread != null){ + if (this.remoteThread != null) { throw new IllegalStateException("Remote thread is already attached"); } else { this.remoteThread = thread; diff --git a/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java b/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java index 48b7d7e48f5..bf3d66ba544 100644 --- a/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java +++ b/src/main/java/org/jabref/cli/ImportInspectionCommandLine.java @@ -17,7 +17,6 @@ public class ImportInspectionCommandLine implements ImportInspector { private final OutputPrinter status = new SystemOutputPrinter(); - @Override public void addEntry(BibEntry entry) { entries.add(entry); @@ -29,7 +28,6 @@ public void setProgress(int current, int max) { .valueOf(max))); } - public Collection query(String query, EntryFetcher fetcher) { entries.clear(); if (fetcher.processQuery(query, ImportInspectionCommandLine.this, status)) { diff --git a/src/main/java/org/jabref/cli/JabRefCLI.java b/src/main/java/org/jabref/cli/JabRefCLI.java index 595ac2513ae..0aa5be8d7a0 100644 --- a/src/main/java/org/jabref/cli/JabRefCLI.java +++ b/src/main/java/org/jabref/cli/JabRefCLI.java @@ -137,7 +137,7 @@ public String getExportMatches() { public boolean isGenerateBibtexKeys() { return cl.hasOption("generateBibtexKeys"); } - public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks");} + public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks"); } private Options getOptions() { Options options = new Options(); diff --git a/src/main/java/org/jabref/collab/ChangeScanner.java b/src/main/java/org/jabref/collab/ChangeScanner.java index 9c96bd27941..c413b583d67 100644 --- a/src/main/java/org/jabref/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/collab/ChangeScanner.java @@ -47,16 +47,16 @@ public class ChangeScanner implements Runnable { private static final String[] SORT_BY = new String[] {FieldName.YEAR, FieldName.AUTHOR, FieldName.TITLE}; + private static final double MATCH_THRESHOLD = 0.4; private final File file; private final BibDatabase databaseInMemory; private final MetaData metadataInMemory; - private final BasePanel panel; + private final BasePanel panel; private final JabRefFrame frame; private BibDatabase databaseInTemp; - private MetaData metadataInTemp; - private static final double MATCH_THRESHOLD = 0.4; + private MetaData metadataInTemp; /** * We create an ArrayList to hold the changes we find. These will be added in the form @@ -464,7 +464,6 @@ private void scanGroups(MetaData inTemp, MetaData onDisk) { } } - @FunctionalInterface public interface DisplayResultCallback { void scanResultsResolved(boolean resolved); diff --git a/src/main/java/org/jabref/collab/EntryChange.java b/src/main/java/org/jabref/collab/EntryChange.java index eaeb5d111ec..7efd5b41126 100644 --- a/src/main/java/org/jabref/collab/EntryChange.java +++ b/src/main/java/org/jabref/collab/EntryChange.java @@ -97,7 +97,6 @@ public JComponent description() { return new JLabel(name); } - static class FieldChange extends Change { private final BibEntry entry; diff --git a/src/main/java/org/jabref/collab/EntryDeleteChange.java b/src/main/java/org/jabref/collab/EntryDeleteChange.java index b9b128dc6bb..758363e113f 100644 --- a/src/main/java/org/jabref/collab/EntryDeleteChange.java +++ b/src/main/java/org/jabref/collab/EntryDeleteChange.java @@ -17,11 +17,11 @@ class EntryDeleteChange extends Change { + private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class); private final BibEntry memEntry; private final BibEntry tmpEntry; - private final JScrollPane sp; - private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class); + private final JScrollPane sp; public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) { diff --git a/src/main/java/org/jabref/collab/FileUpdateMonitor.java b/src/main/java/org/jabref/collab/FileUpdateMonitor.java index 79682178517..e709321405f 100644 --- a/src/main/java/org/jabref/collab/FileUpdateMonitor.java +++ b/src/main/java/org/jabref/collab/FileUpdateMonitor.java @@ -28,7 +28,7 @@ public class FileUpdateMonitor implements Runnable { public void run() { // The running variable is used to make the thread stop when needed. while (true) { - for(Entry e : entries.values()) { + for (Entry e : entries.values()) { try { if (e.hasBeenUpdated()) { e.notifyListener(); @@ -210,7 +210,6 @@ public void decreaseTimeStamp() { } } - private static synchronized Path getTempFile() { Path temporaryFile = null; try { diff --git a/src/main/java/org/jabref/collab/StringAddChange.java b/src/main/java/org/jabref/collab/StringAddChange.java index 28ccb2ca193..b2829830ca1 100644 --- a/src/main/java/org/jabref/collab/StringAddChange.java +++ b/src/main/java/org/jabref/collab/StringAddChange.java @@ -16,12 +16,12 @@ class StringAddChange extends Change { - private final BibtexString string; + private static final Log LOGGER = LogFactory.getLog(StringAddChange.class); + private final BibtexString string; private final InfoPane tp = new InfoPane(); - private final JScrollPane sp = new JScrollPane(tp); - private static final Log LOGGER = LogFactory.getLog(StringAddChange.class); + private final JScrollPane sp = new JScrollPane(tp); public StringAddChange(BibtexString string) { diff --git a/src/main/java/org/jabref/collab/StringChange.java b/src/main/java/org/jabref/collab/StringChange.java index e4352f7d452..c93847d716f 100644 --- a/src/main/java/org/jabref/collab/StringChange.java +++ b/src/main/java/org/jabref/collab/StringChange.java @@ -17,16 +17,16 @@ class StringChange extends Change { + private static final Log LOGGER = LogFactory.getLog(StringChange.class); private final BibtexString string; private final String mem; private final String disk; - private final String label; + private final String label; private final InfoPane tp = new InfoPane(); private final JScrollPane sp = new JScrollPane(tp); - private final BibtexString tmpString; - private static final Log LOGGER = LogFactory.getLog(StringChange.class); + private final BibtexString tmpString; public StringChange(BibtexString string, BibtexString tmpString, String label, String mem, String disk) { diff --git a/src/main/java/org/jabref/collab/StringNameChange.java b/src/main/java/org/jabref/collab/StringNameChange.java index 9caf3970476..b53e7e63098 100644 --- a/src/main/java/org/jabref/collab/StringNameChange.java +++ b/src/main/java/org/jabref/collab/StringNameChange.java @@ -17,13 +17,13 @@ class StringNameChange extends Change { + private static final Log LOGGER = LogFactory.getLog(StringNameChange.class); private final BibtexString string; private final String mem; private final String disk; private final String content; - private final BibtexString tmpString; - private static final Log LOGGER = LogFactory.getLog(StringNameChange.class); + private final BibtexString tmpString; public StringNameChange(BibtexString string, BibtexString tmpString, diff --git a/src/main/java/org/jabref/collab/StringRemoveChange.java b/src/main/java/org/jabref/collab/StringRemoveChange.java index 659c14fa4ad..455704722ea 100644 --- a/src/main/java/org/jabref/collab/StringRemoveChange.java +++ b/src/main/java/org/jabref/collab/StringRemoveChange.java @@ -14,14 +14,14 @@ import org.apache.commons.logging.LogFactory; class StringRemoveChange extends Change { + private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class); private final BibtexString string; - private final BibtexString inMem; + private final BibtexString inMem; private final InfoPane tp = new InfoPane(); private final JScrollPane sp = new JScrollPane(tp); - private final BibtexString tmpString; - private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class); + private final BibtexString tmpString; public StringRemoveChange(BibtexString string, BibtexString tmpString, BibtexString inMem) { diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java index d48ad7102be..e0af977b0ec 100644 --- a/src/main/java/org/jabref/gui/ClipBoardManager.java +++ b/src/main/java/org/jabref/gui/ClipBoardManager.java @@ -40,7 +40,7 @@ public void lostOwnership(Clipboard aClipboard, Transferable aContents) { /** * Places the string into the clipboard using a {@link Transferable}. */ - public void setTransferableClipboardContents(Transferable transferable){ + public void setTransferableClipboardContents(Transferable transferable) { CLIPBOARD.setContents(transferable, this); } @@ -73,13 +73,12 @@ public void setClipboardContents(String aString) { StringSelection stringSelection = new StringSelection(aString); CLIPBOARD.setContents(stringSelection, this); } - + public List extractBibEntriesFromClipboard() { // Get clipboard contents, and see if TransferableBibtexEntry is among the content flavors offered Transferable content = CLIPBOARD.getContents(null); List result = new ArrayList<>(); - if (content.isDataFlavorSupported(TransferableBibtexEntry.entryFlavor)) { // We have determined that the clipboard data is a set of entries. try { diff --git a/src/main/java/org/jabref/gui/DefaultInjector.java b/src/main/java/org/jabref/gui/DefaultInjector.java index bb90b263c39..c4239c9ef8f 100644 --- a/src/main/java/org/jabref/gui/DefaultInjector.java +++ b/src/main/java/org/jabref/gui/DefaultInjector.java @@ -3,8 +3,9 @@ import java.util.function.Function; import org.jabref.Globals; -import org.jabref.gui.keyboard.KeyBindingPreferences; +import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.util.TaskExecutor; +import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.preferences.JabRefPreferences; import com.airhacks.afterburner.injection.Injector; @@ -28,8 +29,10 @@ private static Object createDependency(Class clazz) { return Globals.taskExecutor; } else if (clazz == JabRefPreferences.class) { return Globals.prefs; - } else if (clazz == KeyBindingPreferences.class) { + } else if (clazz == KeyBindingRepository.class) { return Globals.getKeyPrefs(); + } else if (clazz == JournalAbbreviationLoader.class) { + return Globals.journalAbbreviationLoader; } else if (clazz == StateManager.class) { return Globals.stateManager; } else { diff --git a/src/main/java/org/jabref/gui/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/DuplicateResolverDialog.java index 346987ff39d..baae8dac19a 100644 --- a/src/main/java/org/jabref/gui/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/DuplicateResolverDialog.java @@ -36,9 +36,9 @@ public enum DuplicateResolverResult { BREAK } + JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton(); private final JButton cancel = new JButton(Localization.lang("Cancel")); private final JButton merge = new JButton(Localization.lang("Keep merged entry only")); - JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton(); private final JabRefFrame frame; private final JPanel options = new JPanel(); private DuplicateResolverResult status = DuplicateResolverResult.NOT_CHOSEN; @@ -131,7 +131,6 @@ public void windowClosing(WindowEvent e) { both.requestFocus(); } - private void buttonPressed(DuplicateResolverResult result) { status = result; dispose(); diff --git a/src/main/java/org/jabref/gui/DuplicateSearch.java b/src/main/java/org/jabref/gui/DuplicateSearch.java index 28a8795dfbd..fd6537ea3c5 100644 --- a/src/main/java/org/jabref/gui/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/DuplicateSearch.java @@ -143,7 +143,6 @@ public void run() { } - class SearcherRunnable implements Runnable { private volatile boolean finished; diff --git a/src/main/java/org/jabref/gui/FXDialog.java b/src/main/java/org/jabref/gui/FXDialog.java index cd0da6592fd..d59ccaecda4 100644 --- a/src/main/java/org/jabref/gui/FXDialog.java +++ b/src/main/java/org/jabref/gui/FXDialog.java @@ -16,7 +16,7 @@ import org.jabref.Globals; import org.jabref.JabRefGUI; import org.jabref.gui.keyboard.KeyBinding; -import org.jabref.gui.keyboard.KeyBindingPreferences; +import org.jabref.gui.keyboard.KeyBindingRepository; /** * This class provides a super class for all dialogs implemented in JavaFX. @@ -101,9 +101,9 @@ public FXDialog(AlertType type, boolean isModal) { dialogWindow.setOnCloseRequest(evt -> this.close()); - dialogWindow.getScene().setOnKeyPressed(evt -> { - KeyBindingPreferences keyPreferences = Globals.getKeyPrefs(); - if (keyPreferences.checkKeyCombinationEquality(KeyBinding.CLOSE_DIALOG, evt)) { + dialogWindow.getScene().setOnKeyPressed(event -> { + KeyBindingRepository keyBindingRepository = Globals.getKeyPrefs(); + if (keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLOSE_DIALOG, event)) { dialogWindow.close(); } }); diff --git a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java index e2c5e0ee8c8..678fa520942 100644 --- a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java +++ b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java @@ -90,8 +90,6 @@ * GUI Dialog for the feature "Find unlinked files". */ public class FindUnlinkedFilesDialog extends JabRefDialog { - private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class); - /** * Keys to be used for referencing this Action. */ @@ -100,6 +98,8 @@ public class FindUnlinkedFilesDialog extends JabRefDialog { public static final String ACTION_SHORT_DESCRIPTION = Localization .lang("Searches for unlinked PDF files on the file system"); + + private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class); private static final String GLOBAL_PREFS_WORKING_DIRECTORY_KEY = "findUnlinkedFilesWD"; private static final String GLOBAL_PREFS_DIALOG_SIZE_KEY = "findUnlinkedFilesDialogSize"; @@ -448,7 +448,6 @@ private void startSearch() { int counter; - @Override public void stateChanged(ChangeEvent e) { counter++; @@ -1089,7 +1088,6 @@ private static class CheckboxTreeCellRenderer extends DefaultTreeCellRenderer { private final FileSystemView fsv = FileSystemView.getFileSystemView(); - @Override public Component getTreeCellRendererComponent(final JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { diff --git a/src/main/java/org/jabref/gui/GUIGlobals.java b/src/main/java/org/jabref/gui/GUIGlobals.java index 566905acec5..a7cd28c72a2 100644 --- a/src/main/java/org/jabref/gui/GUIGlobals.java +++ b/src/main/java/org/jabref/gui/GUIGlobals.java @@ -24,29 +24,29 @@ * Static variables for graphics files and keyboard shortcuts. */ public class GUIGlobals { - private static final Log LOGGER = LogFactory.getLog(GUIGlobals.class); - - public static final String UNTITLED_TITLE = Localization.lang("untitled"); - public static Font currentFont; - - private static final Map TABLE_ICONS = new HashMap<>(); // Contains table icon mappings. Set up - - // Colors. - public static final Color ENTRY_EDITOR_LABEL_COLOR = new Color(100, 100, 150); // Empty field, blue. - static final Color ACTIVE_TABBED_COLOR = ENTRY_EDITOR_LABEL_COLOR.darker(); // active Database (JTabbedPane) - static final Color INACTIVE_TABBED_COLOR = Color.black; // inactive Database public static Color editorTextColor; public static Color validFieldBackgroundColor; public static Color activeBackgroundColor; public static Color invalidFieldBackgroundColor; + public static Font currentFont; public static final Color NULL_FIELD_COLOR = new Color(75, 130, 95); // Valid field, green. + public static final Color ACTIVE_EDITOR_COLOR = new Color(230, 230, 255); + public static final int WIDTH_ICON_COL = JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_SMALL) + 12; // add some additional space to improve appearance - public static final int WIDTH_ICON_COL = JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_SMALL)+12; // add some additional space to improve appearance - public static final int WIDTH_ICON_COL_RANKING = 5*JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_SMALL); // Width of Ranking Icon Column + public static final int WIDTH_ICON_COL_RANKING = 5 * JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_SMALL); // Width of Ranking Icon Column + public static final String UNTITLED_TITLE = Localization.lang("untitled"); public static final int MAX_BACK_HISTORY_SIZE = 10; // The maximum number of "Back" operations stored. + // Colors. + public static final Color ENTRY_EDITOR_LABEL_COLOR = new Color(100, 100, 150); // Empty field, blue. + + static final Color INACTIVE_TABBED_COLOR = Color.black; // inactive Database + private static final Log LOGGER = LogFactory.getLog(GUIGlobals.class); + private static final Map TABLE_ICONS = new HashMap<>(); // Contains table icon mappings. Set up + static final Color ACTIVE_TABBED_COLOR = ENTRY_EDITOR_LABEL_COLOR.darker(); // active Database (JTabbedPane) + private GUIGlobals() { } diff --git a/src/main/java/org/jabref/gui/IconTheme.java b/src/main/java/org/jabref/gui/IconTheme.java index 58534964a6f..710a847f370 100644 --- a/src/main/java/org/jabref/gui/IconTheme.java +++ b/src/main/java/org/jabref/gui/IconTheme.java @@ -35,6 +35,7 @@ public class IconTheme { + public static Font FONT; /** * JabRef's default color */ @@ -44,7 +45,6 @@ public class IconTheme { private static final Log LOGGER = LogFactory.getLog(IconTheme.class); private static final Map KEY_TO_ICON = readIconThemeFile( IconTheme.class.getResource("/images/Icons.properties"), "/images/external/"); - public static Font FONT; // Christmas edition //public static final Color DEFAULT_COLOR = new Color(0x155115); diff --git a/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java b/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java index 2c605bbf40d..147df8f34f0 100644 --- a/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java +++ b/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java @@ -43,7 +43,6 @@ public void highlightPattern(Optional highlightPattern) { } } - private String getDocumentText() { Document doc = getDocument(); String text; diff --git a/src/main/java/org/jabref/gui/JabRefDialog.java b/src/main/java/org/jabref/gui/JabRefDialog.java index c691694dac7..9bce43511d7 100644 --- a/src/main/java/org/jabref/gui/JabRefDialog.java +++ b/src/main/java/org/jabref/gui/JabRefDialog.java @@ -27,16 +27,6 @@ public JabRefDialog(Frame owner, Class clazz) { trackDialogOpening(clazz); } - public JabRefDialog(Window owner, String title, Class clazz) { - super(owner, title); - - trackDialogOpening(clazz); - } - - private void trackDialogOpening(Class clazz) { - Globals.getTelemetryClient().trackPageView(clazz.getName()); - } - public JabRefDialog(Frame owner, String title, Class clazz) { this(owner, title, true, clazz); } @@ -56,4 +46,14 @@ public JabRefDialog(java.awt.Dialog owner, String titl trackDialogOpening(clazz); } + + public JabRefDialog(Window owner, String title, Class clazz) { + super(owner, title); + + trackDialogOpening(clazz); + } + + private void trackDialogOpening(Class clazz) { + Globals.getTelemetryClient().trackPageView(clazz.getName()); + } } diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 5ad3ea9879c..e849be5d19a 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -960,7 +960,7 @@ public BasePanel getBasePanelAt(int i) { */ public List getBasePanelList() { List returnList = new ArrayList<>(); - for (int i=0; i< getBasePanelCount(); i++) { + for (int i = 0; i < getBasePanelCount(); i++) { returnList.add((BasePanel) tabbedPane.getComponentAt(i)); } return returnList; @@ -1303,7 +1303,7 @@ private void createToolBar() { tlb.setRollover(true); tlb.setFloatable(false); - if(Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) { + if (Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) { tlb.addAction(newBiblatexDatabaseAction); } else { tlb.addAction(newBibtexDatabaseAction); diff --git a/src/main/java/org/jabref/gui/MappedList.java b/src/main/java/org/jabref/gui/MappedList.java index e9b97bd8575..ca43019229d 100644 --- a/src/main/java/org/jabref/gui/MappedList.java +++ b/src/main/java/org/jabref/gui/MappedList.java @@ -90,7 +90,7 @@ protected int[] getPermutation() { @Override public List getRemoved() { ArrayList res = new ArrayList<>(c.getRemovedSize()); - for(E e: c.getRemoved()) { + for (E e: c.getRemoved()) { res.add(mapper.apply(e)); } return res; diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index 72f83c9b3df..848c410e1d3 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -130,7 +130,7 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext) { updateLayout(); } - private void createKeyBindings(){ + private void createKeyBindings() { ActionMap actionMap = this.getActionMap(); InputMap inputMap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); @@ -221,7 +221,7 @@ public void updateLayout() { update(); } - private void updatePreviewLayout(String layoutFile){ + private void updatePreviewLayout(String layoutFile) { StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); try { layout = Optional.of( @@ -264,19 +264,19 @@ public BibEntry getEntry() { public void update() { ExportFormats.entryNumber = 1; // Set entry number in case that is included in the preview layout. - if (citationStyleWorker.isPresent()){ + if (citationStyleWorker.isPresent()) { citationStyleWorker.get().cancel(true); citationStyleWorker = Optional.empty(); } - if (layout.isPresent()){ + if (layout.isPresent()) { StringBuilder sb = new StringBuilder(); bibEntry.ifPresent(entry -> sb.append(layout.get() .doLayout(entry, databaseContext.map(BibDatabaseContext::getDatabase).orElse(null)))); setPreviewLabel(sb.toString()); markHighlights(); } - else if (basePanel.isPresent()){ + else if (basePanel.isPresent()) { citationStyleWorker = Optional.of(new CitationStyleWorker(this, previewPane)); citationStyleWorker.get().execute(); } @@ -325,7 +325,7 @@ public PreviewPanel setFixedLayout(Object parameter) { updatePreviewLayout((String) parameter); } else if (parameter instanceof CitationStyle) { layout = Optional.empty(); - if (basePanel.isPresent()){ + if (basePanel.isPresent()) { basePanel.get().getCitationStyleCache().setCitationStyle((CitationStyle) parameter); } } else { @@ -342,7 +342,6 @@ public PrintAction() { putValue(Action.SHORT_DESCRIPTION, Localization.lang("Print entry preview")); } - @Override public void actionPerformed(ActionEvent arg0) { @@ -401,5 +400,4 @@ public PrintAction getPrintAction() { return printAction; } - } diff --git a/src/main/java/org/jabref/gui/SidePane.java b/src/main/java/org/jabref/gui/SidePane.java index 1362b73f38d..353b74bfc6f 100644 --- a/src/main/java/org/jabref/gui/SidePane.java +++ b/src/main/java/org/jabref/gui/SidePane.java @@ -65,7 +65,7 @@ public void setComponents(Collection comps) { gridBagLayout.setConstraints(c, constraint); mainPanel.add(c); } - if(totalWeights <= 0) { + if (totalWeights <= 0) { // Fill vertical space so that components start at top constraint.weighty = 1; Component bx = Box.createVerticalGlue(); diff --git a/src/main/java/org/jabref/gui/SidePaneComponent.java b/src/main/java/org/jabref/gui/SidePaneComponent.java index 5d5e449a8a6..04a7373babf 100644 --- a/src/main/java/org/jabref/gui/SidePaneComponent.java +++ b/src/main/java/org/jabref/gui/SidePaneComponent.java @@ -112,17 +112,16 @@ public Dimension getMinimumSize() { */ public abstract ToggleAction getToggleAction(); - public class ToggleAction extends MnemonicAwareAction { - public ToggleAction(String text, String description, KeyStroke key, IconTheme.JabRefIcon icon){ + public ToggleAction(String text, String description, KeyStroke key, IconTheme.JabRefIcon icon) { super(icon.getIcon()); putValue(Action.NAME, text); putValue(Action.ACCELERATOR_KEY, key); putValue(Action.SHORT_DESCRIPTION, description); } - public ToggleAction(String text, String description, KeyStroke key, Icon icon){ + public ToggleAction(String text, String description, KeyStroke key, Icon icon) { super(icon); putValue(Action.NAME, text); putValue(Action.ACCELERATOR_KEY, key); @@ -144,7 +143,7 @@ public void actionPerformed(ActionEvent e) { putValue(Action.SELECTED_KEY, manager.isComponentVisible(SidePaneComponent.this.getClass())); } - public void setSelected(boolean selected){ + public void setSelected(boolean selected) { putValue(Action.SELECTED_KEY, selected); } diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java index 2c624af9213..a7136da97b0 100644 --- a/src/main/java/org/jabref/gui/SidePaneManager.java +++ b/src/main/java/org/jabref/gui/SidePaneManager.java @@ -221,7 +221,6 @@ public int compare(SidePaneComponent comp1, SidePaneComponent comp2) { } } - public synchronized void moveUp(SidePaneComponent comp) { if (visible.contains(comp)) { int currIndex = visible.indexOf(comp); diff --git a/src/main/java/org/jabref/gui/TransferableBibtexEntry.java b/src/main/java/org/jabref/gui/TransferableBibtexEntry.java index c8c7f7f63b5..1d0188cd1fa 100644 --- a/src/main/java/org/jabref/gui/TransferableBibtexEntry.java +++ b/src/main/java/org/jabref/gui/TransferableBibtexEntry.java @@ -22,8 +22,8 @@ */ public class TransferableBibtexEntry implements Transferable { - private final List data; public static final DataFlavor entryFlavor = new DataFlavor(BibEntry.class, "JabRef entry"); + private final List data; public TransferableBibtexEntry(List bes) { diff --git a/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java b/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java index 9e9489facaf..9e1fb4f1126 100644 --- a/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java +++ b/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java @@ -19,6 +19,14 @@ public class LookupIdentifierAction extends MnemonicAwareAction { private final JabRefFrame frame; private final IdFetcher fetcher; + public LookupIdentifierAction(JabRefFrame frame, IdFetcher fetcher) { + super(); + this.frame = frame; + this.fetcher = fetcher; + + putValue(Action.NAME, fetcher.getIdentifierName()); + } + @Override public void actionPerformed(ActionEvent actionEvent) { try { @@ -27,12 +35,4 @@ public void actionPerformed(ActionEvent actionEvent) { LOGGER.error(e); } } - - public LookupIdentifierAction(JabRefFrame frame, IdFetcher fetcher) { - super(); - this.frame = frame; - this.fetcher = fetcher; - - putValue(Action.NAME, fetcher.getIdentifierName()); - } } diff --git a/src/main/java/org/jabref/gui/actions/ManageKeywordsAction.java b/src/main/java/org/jabref/gui/actions/ManageKeywordsAction.java index 80c5df1e365..ba7f6b8db2f 100644 --- a/src/main/java/org/jabref/gui/actions/ManageKeywordsAction.java +++ b/src/main/java/org/jabref/gui/actions/ManageKeywordsAction.java @@ -211,7 +211,6 @@ private void addButtonActionListener(JTextField keywordTextField) { return; // nothing to add } - Keyword newKeyword = new Keyword(keywordTextField.getText().trim()); if (keywordListModel.isEmpty()) { keywordListModel.addElement(newKeyword); diff --git a/src/main/java/org/jabref/gui/actions/MnemonicAwareAction.java b/src/main/java/org/jabref/gui/actions/MnemonicAwareAction.java index aa5bb816ddd..13ba654cc38 100644 --- a/src/main/java/org/jabref/gui/actions/MnemonicAwareAction.java +++ b/src/main/java/org/jabref/gui/actions/MnemonicAwareAction.java @@ -15,10 +15,10 @@ */ public abstract class MnemonicAwareAction extends AbstractAction { - public MnemonicAwareAction() {} + public MnemonicAwareAction() { } public MnemonicAwareAction(Icon icon) { - if(icon instanceof IconTheme.FontBasedIcon) { + if (icon instanceof IconTheme.FontBasedIcon) { putValue(Action.SMALL_ICON, ((IconTheme.FontBasedIcon) icon).createSmallIcon()); putValue(Action.LARGE_ICON_KEY, icon); } else { diff --git a/src/main/java/org/jabref/gui/actions/PasteAction.java b/src/main/java/org/jabref/gui/actions/PasteAction.java index a0fe042541f..381b4b3c0fb 100644 --- a/src/main/java/org/jabref/gui/actions/PasteAction.java +++ b/src/main/java/org/jabref/gui/actions/PasteAction.java @@ -36,7 +36,7 @@ public void actionPerformed(ActionEvent evt) { data = URLUtil.cleanGoogleSearchURL(data); // caller - if(target instanceof JTextComponent) { + if (target instanceof JTextComponent) { JTextComponent textField = (JTextComponent) target; // replace text selection textField.replaceSelection(data); diff --git a/src/main/java/org/jabref/gui/actions/SearchForUpdateAction.java b/src/main/java/org/jabref/gui/actions/SearchForUpdateAction.java index f89840324f1..acf9807c849 100644 --- a/src/main/java/org/jabref/gui/actions/SearchForUpdateAction.java +++ b/src/main/java/org/jabref/gui/actions/SearchForUpdateAction.java @@ -9,7 +9,7 @@ public class SearchForUpdateAction extends AbstractAction { - public SearchForUpdateAction(){ + public SearchForUpdateAction() { super(Localization.lang("Check for updates")); } diff --git a/src/main/java/org/jabref/gui/autocompleter/AutoCompleteListener.java b/src/main/java/org/jabref/gui/autocompleter/AutoCompleteListener.java index edf09c161b1..85567638fbe 100644 --- a/src/main/java/org/jabref/gui/autocompleter/AutoCompleteListener.java +++ b/src/main/java/org/jabref/gui/autocompleter/AutoCompleteListener.java @@ -146,7 +146,7 @@ private boolean atEndOfWord(JTextComponent textField) { int nextCharPosition = textField.getCaretPosition(); // position not at the end of input - if(nextCharPosition < textField.getText().length()) { + if (nextCharPosition < textField.getText().length()) { char nextChar = textField.getText().charAt(nextCharPosition); if (!Character.isWhitespace(nextChar)) { return false; diff --git a/src/main/java/org/jabref/gui/autocompleter/AutoCompleteSupport.java b/src/main/java/org/jabref/gui/autocompleter/AutoCompleteSupport.java index 8674c8f8488..7f84a264986 100644 --- a/src/main/java/org/jabref/gui/autocompleter/AutoCompleteSupport.java +++ b/src/main/java/org/jabref/gui/autocompleter/AutoCompleteSupport.java @@ -280,7 +280,7 @@ public void setAutoCompleter(AutoCompleter autoCompleter) { this.autoCompleter = autoCompleter; } - public void setVisible(boolean visible){ + public void setVisible(boolean visible) { popup.setVisible(visible); } diff --git a/src/main/java/org/jabref/gui/autocompleter/ListAutoCompleteRenderer.java b/src/main/java/org/jabref/gui/autocompleter/ListAutoCompleteRenderer.java index eb00f04b59c..968ba47190b 100644 --- a/src/main/java/org/jabref/gui/autocompleter/ListAutoCompleteRenderer.java +++ b/src/main/java/org/jabref/gui/autocompleter/ListAutoCompleteRenderer.java @@ -29,7 +29,6 @@ public class ListAutoCompleteRenderer extends AutoCompleteRenderer { */ private Boolean interpretSelectionChangeAsAccept = true; - @Override public void update(List autoCompletions) { if (autoCompletions == null) { diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java index 7451b53787c..f14b7ab073f 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java +++ b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java @@ -37,11 +37,11 @@ public class BibtexKeyPatternPanel extends JPanel { protected final GridBagLayout gbl = new GridBagLayout(); protected final GridBagConstraints con = new GridBagConstraints(); - private final HelpAction help; - // default pattern protected final JTextField defaultPat = new JTextField(); + private final HelpAction help; + // one field for each type private final Map textFields = new HashMap<>(); private final BasePanel panel; diff --git a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java index a1b9d87b66c..97599ce1915 100644 --- a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java @@ -300,7 +300,6 @@ private Formatter getFieldFormatter() { return selectedFormatter; } - class EnablementStatusListener implements ActionListener { public EnablementStatusListener(boolean initialStatus) { diff --git a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java index a05a4a5d213..bda919a872e 100644 --- a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java +++ b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java @@ -46,16 +46,17 @@ public class ContentSelectorDialog extends JabRefDialog { + private static final String WORD_FIRSTLINE_TEXT = Localization.lang(""); - private static final String FIELD_FIRST_LINE = Localization.lang(""); private final MetaData metaData; private String currentField; private final JabRefFrame frame; @@ -74,12 +75,11 @@ public class ContentSelectorDialog extends JabRefDialog { private final JTextField fieldNameField = new JTextField("", 20); private final JTextField wordEditField = new JTextField("", 20); private final JScrollPane fPane = new JScrollPane(fieldList); - private final JScrollPane wPane = new JScrollPane(wordList); + private final JScrollPane wPane = new JScrollPane(wordList); private final Map> wordListModels = new HashMap<>(); - private final List removedFields = new ArrayList<>(); - private static final Log LOGGER = LogFactory.getLog(ContentSelectorDialog.class); + private final List removedFields = new ArrayList<>(); /** @@ -476,7 +476,6 @@ private void initLayout() { } - private class FieldNameFocusAdapter extends FocusAdapter { /** diff --git a/src/main/java/org/jabref/gui/contentselector/FieldContentSelector.java b/src/main/java/org/jabref/gui/contentselector/FieldContentSelector.java index 6442f25c8b2..1501ea7f294 100644 --- a/src/main/java/org/jabref/gui/contentselector/FieldContentSelector.java +++ b/src/main/java/org/jabref/gui/contentselector/FieldContentSelector.java @@ -162,7 +162,6 @@ private void selectionMade() { return; } - String currentText = editor.getText(); KeywordList words = KeywordList.parse(currentText, this.delimiter.charAt(0)); boolean alreadyInList = words.contains(new Keyword(chosen)); diff --git a/src/main/java/org/jabref/gui/customentrytypes/EntryCustomizationDialog.java b/src/main/java/org/jabref/gui/customentrytypes/EntryCustomizationDialog.java index 9be44d6b270..5005644c299 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/EntryCustomizationDialog.java +++ b/src/main/java/org/jabref/gui/customentrytypes/EntryCustomizationDialog.java @@ -52,9 +52,11 @@ public class EntryCustomizationDialog extends JabRefDialog implements ListSelectionListener { - private final JabRefFrame frame; protected GridBagLayout gbl = new GridBagLayout(); protected GridBagConstraints con = new GridBagConstraints(); + protected JButton helpButton; + protected JButton delete; + private final JabRefFrame frame; private FieldSetComponent reqComp; private FieldSetComponent optComp; private FieldSetComponent optComp2; @@ -62,8 +64,6 @@ public class EntryCustomizationDialog extends JabRefDialog implements ListSelect private JButton ok; private JButton cancel; private JButton apply; - protected JButton helpButton; - protected JButton delete; private final List preset = InternalBibtexFields.getAllPublicFieldNames(); private String lastSelected; private final Map> reqLists = new HashMap<>(); @@ -303,7 +303,7 @@ private void applyChanges() { } // update all affected entries if something has been changed - if(!actuallyChangedTypes.isEmpty()) { + if (!actuallyChangedTypes.isEmpty()) { updateEntriesForChangedTypes(actuallyChangedTypes); } diff --git a/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java b/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java index ab0597f3be1..b65f477db5e 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java +++ b/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java @@ -43,20 +43,20 @@ */ class FieldSetComponent extends JPanel { - private final Set additionListeners = new HashSet<>(); protected final JList list; - private final JScrollPane sp; protected DefaultListModel listModel; - private JComboBox sel; - private JTextField input; - private final JButton add; protected final JButton remove; - private JButton up; - private JButton down; protected final GridBagLayout gbl = new GridBagLayout(); protected final GridBagConstraints con = new GridBagConstraints(); protected final boolean forceLowerCase; protected boolean changesMade; + private final Set additionListeners = new HashSet<>(); + private final JScrollPane sp; + private JComboBox sel; + private JTextField input; + private final JButton add; + private JButton up; + private JButton down; private final Set modelListeners = new HashSet<>(); @@ -352,5 +352,4 @@ public void focusLost(FocusEvent e) { } } - } diff --git a/src/main/java/org/jabref/gui/date/DatePickerButton.java b/src/main/java/org/jabref/gui/date/DatePickerButton.java deleted file mode 100644 index a13412a4b13..00000000000 --- a/src/main/java/org/jabref/gui/date/DatePickerButton.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.jabref.gui.date; - -import java.awt.BorderLayout; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; - -import javax.swing.JComponent; -import javax.swing.JPanel; - -import org.jabref.Globals; -import org.jabref.gui.IconTheme; -import org.jabref.gui.fieldeditors.FieldEditor; -import org.jabref.preferences.JabRefPreferences; - -import com.github.lgooddatepicker.components.DatePicker; -import com.github.lgooddatepicker.components.DatePickerSettings; -import com.github.lgooddatepicker.optionalusertools.DateChangeListener; -import com.github.lgooddatepicker.zinternaltools.DateChangeEvent; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * wrapper and service class for the DatePicker handling at the EntryEditor - */ -public class DatePickerButton implements DateChangeListener { - - private static final Log LOGGER = LogFactory.getLog(DatePickerButton.class); - - private final DatePicker datePicker; - private final JPanel panel = new JPanel(); - private final FieldEditor editor; - private final DateTimeFormatter dateTimeFormatter; - - - public DatePickerButton(FieldEditor pEditor, boolean useIsoFormat) { - if (useIsoFormat) { - dateTimeFormatter = DateTimeFormatter.ISO_DATE; - } else { - dateTimeFormatter = DateTimeFormatter.ofPattern(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT)); - } - - // Create a date picker with hidden text field (showing button only). - DatePickerSettings dateSettings = new DatePickerSettings(); - dateSettings.setVisibleDateTextField(false); - dateSettings.setGapBeforeButtonPixels(0); - - datePicker = new DatePicker(dateSettings); - datePicker.addDateChangeListener(this); - datePicker.getComponentToggleCalendarButton().setIcon(IconTheme.JabRefIcon.DATE_PICKER.getIcon()); - datePicker.getComponentToggleCalendarButton().setText(""); - - panel.setLayout(new BorderLayout()); - panel.add(datePicker, BorderLayout.WEST); - editor = pEditor; - } - - @Override - public void dateChanged(DateChangeEvent dateChangeEvent) { - LocalDate date = datePicker.getDate(); - String newDate = ""; - if (date != null) { - newDate = dateTimeFormatter.format(date.atStartOfDay()); - } - if (!newDate.equals(editor.getText())) { - editor.setText(newDate); - } - // Set focus to editor component after changing its text: - editor.requestFocus(); - } - - public JComponent getDatePicker() { - //return datePicker; - return panel; - } - - /** - * Used to set the calender popup to the currently used Date - * @param dateString - */ - public void updateDatePickerDate(String dateString) { - // unregister DateChangeListener before update to prevent circular calls resulting in IllegalStateExceptions - datePicker.removeDateChangeListener(this); - - if(dateString!=null && !dateString.isEmpty()) { - try { - datePicker.setDate(LocalDate.parse(dateString, dateTimeFormatter)); - } catch (DateTimeParseException exception) { - LOGGER.warn("Unable to parse stored date for field '"+editor.getFieldName()+"' with current settings. " - + "Clear button in calender popup will not work."); - } - } - - datePicker.addDateChangeListener(this); - } -} diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java index c660b59470e..524a01848a8 100644 --- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java @@ -288,7 +288,7 @@ public static void openBrowserShowPopup(String url) { String openManually = Localization.lang("Please open %0 manually.", url); String copiedToClipboard = Localization.lang("The_link_has_been_copied_to_the_clipboard."); JabRefGUI.getMainFrame().output(couldNotOpenBrowser); - JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(), couldNotOpenBrowser + "\n" + openManually +"\n"+ + JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(), couldNotOpenBrowser + "\n" + openManually + "\n" + copiedToClipboard, couldNotOpenBrowser, JOptionPane.ERROR_MESSAGE); } } diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 5abbab5cf49..f589ee7cd17 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -93,7 +93,7 @@ public void openConsole(String absolutePath) throws IOException { public void openPdfWithParameters(String filePath, List parameters) throws IOException { String application; - if(JabRefPreferences.getInstance().get(USE_PDF_READER).equals(JabRefPreferences.getInstance().get(ADOBE_ACROBAT_COMMAND))){ + if (JabRefPreferences.getInstance().get(USE_PDF_READER).equals(JabRefPreferences.getInstance().get(ADOBE_ACROBAT_COMMAND))) { application = "acroread"; StringJoiner sj = new StringJoiner(" "); diff --git a/src/main/java/org/jabref/gui/desktop/os/Windows.java b/src/main/java/org/jabref/gui/desktop/os/Windows.java index 2a3f2aa3da9..5de0f056f65 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Windows.java +++ b/src/main/java/org/jabref/gui/desktop/os/Windows.java @@ -26,7 +26,7 @@ public void openFile(String filePath, String fileType) throws IOException { openFileWithApplication(filePath, type.get().getOpenWithApplication()); } else { // quote String so explorer handles URL query strings correctly - String quotePath = "\"" + filePath +"\""; + String quotePath = "\"" + filePath + "\""; new ProcessBuilder("explorer.exe", quotePath).start(); } } diff --git a/src/main/java/org/jabref/gui/documentviewer/ShowDocumentViewerAction.java b/src/main/java/org/jabref/gui/documentviewer/ShowDocumentViewerAction.java index 1ca9913faad..e31e844f9c9 100644 --- a/src/main/java/org/jabref/gui/documentviewer/ShowDocumentViewerAction.java +++ b/src/main/java/org/jabref/gui/documentviewer/ShowDocumentViewerAction.java @@ -11,7 +11,6 @@ import org.jabref.gui.actions.MnemonicAwareAction; import org.jabref.logic.l10n.Localization; - public class ShowDocumentViewerAction extends MnemonicAwareAction { public ShowDocumentViewerAction(String title, String tooltip, Icon iconFile) { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index d4f6e5b5f00..28b0493e9fb 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -610,24 +610,9 @@ public Optional getExtra(final FieldEditor editor) { final Set fieldExtras = InternalBibtexFields.getFieldProperties(fieldName); - // timestamp or a other field with datepicker command - if (Globals.prefs.get(JabRefPreferences.TIME_STAMP_FIELD).equals(fieldName) - || fieldExtras.contains(FieldProperty.DATE)) { - // double click AND datefield => insert the current date (today) - return FieldExtraComponents.getDateTimeExtraComponent(editor, - fieldExtras.contains(FieldProperty.DATE), fieldExtras.contains(FieldProperty.ISO_DATE)); - } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { - return FieldExtraComponents.getExternalExtraComponent(panel, editor); - } else if (fieldExtras.contains(FieldProperty.JOURNAL_NAME)) { - // Add controls for switching between abbreviated and full journal names. - // If this field also has a FieldContentSelector, we need to combine these. - return FieldExtraComponents.getJournalExtraComponent(frame, panel, editor, entry, contentSelectors, - storeFieldAction); - } else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { + if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); - } else if (fieldExtras.contains(FieldProperty.OWNER)) { - return FieldExtraComponents.getSetOwnerExtraComponent(editor, storeFieldAction); } else if (fieldExtras.contains(FieldProperty.YES_NO)) { return FieldExtraComponents.getYesNoExtraComponent(editor, this); } else if (fieldExtras.contains(FieldProperty.MONTH)) { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java index 3f2da06a572..40d64e5aa64 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java @@ -52,22 +52,19 @@ */ class EntryEditorTab { + // UGLY HACK to have a pointer to the fileListEditor to call autoSetLinks() + public FileListEditor fileListEditor; private final JPanel panel = new JPanel(); - private final JScrollPane scrollPane = new JScrollPane(panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); private final List fields; - private final EntryEditor parent; - private final Map editors = new HashMap<>(); private final FocusListener fieldListener = new EntryEditorTabFocusListener(this); private final String tabTitle; private final JabRefFrame frame; private final BasePanel basePanel; - // UGLY HACK to have a pointer to the fileListEditor to call autoSetLinks() - public FileListEditor fileListEditor; private FieldEditorFX activeField; private BibEntry entry; private boolean updating; @@ -166,7 +163,7 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField fieldEditor.setAutoCompleteListener(autoCompleteListener); */ - FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService()); + FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService(), Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences(), Globals.prefs); editors.put(fieldName, fieldEditor); /* // TODO: Reenable this @@ -182,6 +179,18 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField } */ + /* + // TODO: Reenable content selector + if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(editor.getFieldName()).isEmpty()) { + FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false, + ", "); + contentSelectors.add(ws); + controls.add(ws, BorderLayout.NORTH); + } + //} else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { + //return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); + */ + builder.append(new FieldNameLabel(fieldName)); JFXPanel swingPanel = new JFXPanel(); @@ -339,16 +348,16 @@ public boolean updateField(String field, String content) { // TODO: Reenable or probably better delete this /* FieldEditor fieldEditor = editors.get(field); - if (fieldEditor.getText().equals(content)){ + if (fieldEditor.getText().equals(content)) { return true; } // trying to preserve current edit position (fixes SF bug #1285) - if(fieldEditor.getTextComponent() instanceof JTextComponent) { + if (fieldEditor.getTextComponent() instanceof JTextComponent) { int initialCaretPosition = ((JTextComponent) fieldEditor).getCaretPosition(); fieldEditor.setText(content); int textLength = fieldEditor.getText().length(); - if(initialCaretPosition getRelatedArticles() { - return relatedArticles; - } - /** * Takes the selected entry, runs a request to Mr. DLib and returns the recommendations as a JEditorPane * @param selectedEntry The entry selected by the user @@ -58,6 +50,14 @@ public EntryEditorTabRelatedArticles(BibEntry selectedEntry) { setDefaultContent(); } + /** + * Access related acticles delivered by Mr. DLib. + * @return the list of BibEntries, representing the related articles deliverd by MR. DLib + */ + public List getRelatedArticles() { + return relatedArticles; + } + /** * Takes a List of HTML snippets stored in the field "html_representation" of a list of bibentries and sets it in the JEditorPane @@ -176,8 +176,6 @@ protected List doInBackground() throws Exception { return fetcher.performSearch(selectedEntry); } - } - } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTabbedPane.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTabbedPane.java index ad96e8da0d2..48ffd21aef1 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTabbedPane.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTabbedPane.java @@ -10,7 +10,7 @@ public EntryEditorTabbedPane() { super(); } - public void hidePdfTab(FileAnnotationTab pdfTab){ + public void hidePdfTab(FileAnnotationTab pdfTab) { this.pdfTab = pdfTab; this.remove(pdfTab); } diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java index ab466a57ab7..123f5179158 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java @@ -1,8 +1,5 @@ package org.jabref.gui.entryeditor; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -11,28 +8,19 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.JPanel; -import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.JabRefFrame; import org.jabref.gui.contentselector.FieldContentSelector; -import org.jabref.gui.date.DatePickerButton; -import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.entryeditor.EntryEditor.StoreFieldAction; import org.jabref.gui.fieldeditors.FieldEditor; -import org.jabref.gui.undo.UndoableFieldChange; -import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseMode; -import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; import org.jabref.model.entry.Month; -import org.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,113 +28,10 @@ public class FieldExtraComponents { private static final Log LOGGER = LogFactory.getLog(FieldExtraComponents.class); - private static final String ABBREVIATION_TOOLTIP_TEXT = "" - + Localization.lang("Switches between full and abbreviated journal name if the journal name is known.") - + "
" + Localization.lang("To set up, go to") + " " + Localization.lang("Options") + " -> " - + Localization.lang("Manage journal abbreviations") + ""; private FieldExtraComponents() { } - /** - * Add controls for switching between abbreviated and full journal names. - * If this field also has a FieldContentSelector, we need to combine these. - * - * @param panel - * @param editor - * @param entry - * @param storeFieldAction - * @return - */ - public static Optional getJournalExtraComponent(JabRefFrame frame, BasePanel panel, FieldEditor editor, - BibEntry entry, Set contentSelectors, StoreFieldAction storeFieldAction) { - JPanel controls = new JPanel(); - controls.setLayout(new BorderLayout()); - if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(editor.getFieldName()).isEmpty()) { - FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false, - ", "); - contentSelectors.add(ws); - controls.add(ws, BorderLayout.NORTH); - } - - - // Button to toggle abbreviated/full journal names - JButton button = new JButton(Localization.lang("Toggle abbreviation")); - button.setToolTipText(ABBREVIATION_TOOLTIP_TEXT); - button.addActionListener(actionEvent -> { - String text = editor.getText(); - JournalAbbreviationRepository abbreviationRepository = Globals.journalAbbreviationLoader - .getRepository(Globals.prefs.getJournalAbbreviationPreferences()); - if (abbreviationRepository.isKnownName(text)) { - String s = abbreviationRepository.getNextAbbreviation(text).orElse(text); - - if (s != null) { - editor.setText(s); - storeFieldAction.actionPerformed(new ActionEvent(editor, 0, "")); - panel.getUndoManager().addEdit(new UndoableFieldChange(entry, editor.getFieldName(), text, s)); - } - } - }); - - controls.add(button, BorderLayout.SOUTH); - return Optional.of(controls); - } - - /** - * Set up a mouse listener for opening an external viewer for with with EXTRA_EXTERNAL - * - * @param fieldEditor - * @param panel - * @return - */ - public static Optional getExternalExtraComponent(BasePanel panel, FieldEditor fieldEditor) { - JPanel controls = new JPanel(); - controls.setLayout(new BorderLayout()); - JButton button = new JButton(Localization.lang("Open")); - button.setEnabled(false); - button.addActionListener(actionEvent -> { - try { - JabRefDesktop.openExternalViewer(panel.getBibDatabaseContext(), fieldEditor.getText(), fieldEditor.getFieldName()); - } catch (IOException ex) { - panel.output(Localization.lang("Unable to open link.")); - } - }); - - controls.add(button, BorderLayout.SOUTH); - - // enable/disable button - /* - JTextComponent url = (JTextComponent) fieldEditor; - - url.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void changedUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - @Override - public void insertUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - @Override - public void removeUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - private void checkUrl() { - if (URLUtil.isURL(url.getText())) { - button.setEnabled(true); - } else { - button.setEnabled(false); - } - } - }); - */ - - return Optional.of(controls); - } - /** * Return a dropdown list containing Yes and No for fields with EXTRA_YES_NO * @@ -198,23 +83,6 @@ public static Optional getMonthExtraComponent(FieldEditor fieldEdito } - /** - * Return a button which sets the owner if the field for fields with EXTRA_SET_OWNER - * @param fieldEditor - * @param storeFieldAction - * @return - */ - public static Optional getSetOwnerExtraComponent(FieldEditor fieldEditor, - StoreFieldAction storeFieldAction) { - JButton button = new JButton(Localization.lang("Auto")); - button.addActionListener(actionEvent -> { - fieldEditor.setText(Globals.prefs.get(JabRefPreferences.DEFAULT_OWNER)); - storeFieldAction.actionPerformed(new ActionEvent(fieldEditor, 0, "")); - }); - return Optional.of(button); - - } - /** * Return a button opening a content selector for fields where one exists * @@ -226,7 +94,7 @@ public static Optional getSetOwnerExtraComponent(FieldEditor fieldEd * @return */ public static Optional getSelectorExtraComponent(JabRefFrame frame, BasePanel panel, FieldEditor editor, - Set contentSelectors, StoreFieldAction storeFieldAction) { + Set contentSelectors, StoreFieldAction storeFieldAction) { FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false, InternalBibtexFields.getFieldProperties(editor.getFieldName()) .contains(FieldProperty.PERSON_NAMES) ? " and " : ", "); @@ -234,68 +102,6 @@ public static Optional getSelectorExtraComponent(JabRefFrame frame, return Optional.of(ws); } - /** - * Set up field such that double click inserts the current date - * If isDataPicker is True, a button with a data picker is returned - * - * @param editor reference to the FieldEditor to display the date value - * @param useDatePicker shows a DatePickerButton if true - * @param useIsoFormat if true ISO format is always used - * @return - */ - public static Optional getDateTimeExtraComponent(FieldEditor editor, boolean useDatePicker, - boolean useIsoFormat) { - /* - ((JTextArea) editor).addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) {// double click - String date = ""; - if(useIsoFormat) { - date = DateTimeFormatter.ISO_DATE.format(LocalDate.now()); - } else { - date = DateTimeFormatter.ofPattern(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT)).format( - LocalDateTime.now()); - } - editor.setText(date); - } - } - }); - */ - - // insert a datepicker, if the extras field contains this command - if (useDatePicker) { - DatePickerButton datePicker = new DatePickerButton(editor, useIsoFormat); - - /* - // register a DocumentListener on the underlying text document which notifies the DatePicker which date is currently set - ((JTextArea) editor).getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void insertUpdate(DocumentEvent e) { - datePicker.updateDatePickerDate(editor.getText()); - } - - @Override - public void removeUpdate(DocumentEvent e) { - datePicker.updateDatePickerDate(editor.getText()); - } - - @Override - public void changedUpdate(DocumentEvent e) { - datePicker.updateDatePickerDate(editor.getText()); - } - }); - */ - - return Optional.of(datePicker.getDatePicker()); - } else { - return Optional.empty(); - } - - } - /** * Return a dropdown list with the alternatives for editor type fields * @@ -349,7 +155,7 @@ public static Optional getPaginationExtraComponent(FieldEditor field */ public static Optional getTypeExtraComponent(FieldEditor fieldEditor, EntryEditor entryEditor, - boolean isPatent) { + boolean isPatent) { String[] optionValues; String[] optionDescriptions; if (isPatent) { diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java index 7c6901c310d..d59939d7e99 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java @@ -40,7 +40,6 @@ import static org.jabref.model.pdf.FileAnnotationType.NONE; - class FileAnnotationTab extends JPanel { private final JList annotationList = new JList<>(); @@ -127,7 +126,7 @@ private void addAnnotations() { */ private void updateShownAnnotations(List annotations) { listModel.clear(); - if (annotations.isEmpty()) { + if (annotations == null || annotations.isEmpty()) { listModel.addElement(new FileAnnotation("", LocalDateTime.now(), 0, Localization.lang("File has no attached annotations"), NONE, Optional.empty())); } else { Comparator byPage = Comparator.comparingInt(FileAnnotation::getPage); @@ -333,7 +332,6 @@ private void updateMarkingType(FileAnnotation annotation) { } } - private class AnnotationListSelectionListener implements ListSelectionListener { @Override public void valueChanged(ListSelectionEvent e) { diff --git a/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleController.java b/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleController.java index 0f7f8e601d3..641cec00f88 100644 --- a/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleController.java +++ b/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleController.java @@ -22,7 +22,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.IconTheme; import org.jabref.gui.keyboard.KeyBinding; -import org.jabref.gui.keyboard.KeyBindingPreferences; +import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.logic.util.BuildInfo; public class ErrorConsoleController extends AbstractController { @@ -36,7 +36,7 @@ public class ErrorConsoleController extends AbstractController selectedEntries = messagesListView.getSelectionModel().getSelectedItems(); viewModel.copyLog(selectedEntries); } diff --git a/src/main/java/org/jabref/gui/exporter/ExportAction.java b/src/main/java/org/jabref/gui/exporter/ExportAction.java index 51bfacbd1a1..306aff7d677 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportAction.java +++ b/src/main/java/org/jabref/gui/exporter/ExportAction.java @@ -55,7 +55,6 @@ class InternalExportAction extends MnemonicAwareAction { private final boolean selectedOnly; - public InternalExportAction(JabRefFrame frame, boolean selectedOnly) { this.frame = frame; this.selectedOnly = selectedOnly; @@ -122,7 +121,6 @@ public void actionPerformed(ActionEvent e) { String errorMessage; - @Override public void run() { try { diff --git a/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialog.java b/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialog.java index 9effdcc1839..98f331f4bd6 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialog.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialog.java @@ -160,7 +160,6 @@ public void actionPerformed(ActionEvent e) { table.requestFocus(); } - private static class ExportTableFormat implements TableFormat> { @Override diff --git a/src/main/java/org/jabref/gui/exporter/RtfTransferable.java b/src/main/java/org/jabref/gui/exporter/RtfTransferable.java index b3446da258c..5d936b98086 100644 --- a/src/main/java/org/jabref/gui/exporter/RtfTransferable.java +++ b/src/main/java/org/jabref/gui/exporter/RtfTransferable.java @@ -8,7 +8,6 @@ import java.util.Arrays; import java.util.List; - public class RtfTransferable implements Transferable { private static final DataFlavor RTF_FLAVOR = new DataFlavor("text/rtf; class=java.io.InputStream", "RTF Format"); diff --git a/src/main/java/org/jabref/gui/externalfiles/SynchronizeFileField.java b/src/main/java/org/jabref/gui/externalfiles/SynchronizeFileField.java index 6ad850141af..80af1d3b043 100644 --- a/src/main/java/org/jabref/gui/externalfiles/SynchronizeFileField.java +++ b/src/main/java/org/jabref/gui/externalfiles/SynchronizeFileField.java @@ -271,10 +271,8 @@ public void update() { } } - static class OptionsDialog extends JabRefDialog { - private final JButton ok = new JButton(Localization.lang("OK")); private final JButton cancel = new JButton(Localization.lang("Cancel")); private final BibDatabaseContext databaseContext; diff --git a/src/main/java/org/jabref/gui/externalfiles/TransferableFileLinkSelection.java b/src/main/java/org/jabref/gui/externalfiles/TransferableFileLinkSelection.java index 4565db036dd..89a32975070 100644 --- a/src/main/java/org/jabref/gui/externalfiles/TransferableFileLinkSelection.java +++ b/src/main/java/org/jabref/gui/externalfiles/TransferableFileLinkSelection.java @@ -21,10 +21,9 @@ */ public class TransferableFileLinkSelection implements Transferable { - private final List fileList = new ArrayList<>(); - private static final Log LOGGER = LogFactory.getLog(TransferableFileLinkSelection.class); + private final List fileList = new ArrayList<>(); public TransferableFileLinkSelection(BasePanel panel, List selection) { BibEntry entry = selection.get(0); diff --git a/src/main/java/org/jabref/gui/externalfiles/WriteXMPAction.java b/src/main/java/org/jabref/gui/externalfiles/WriteXMPAction.java index 258e21ab846..9eb50acadbf 100644 --- a/src/main/java/org/jabref/gui/externalfiles/WriteXMPAction.java +++ b/src/main/java/org/jabref/gui/externalfiles/WriteXMPAction.java @@ -181,7 +181,6 @@ public void update() { String.valueOf(entriesChanged), String.valueOf(skipped), String.valueOf(errors))); } - class OptionsDialog extends JabRefDialog { private final JButton okButton = new JButton(Localization.lang("OK")); diff --git a/src/main/java/org/jabref/gui/externalfiles/WriteXMPEntryEditorAction.java b/src/main/java/org/jabref/gui/externalfiles/WriteXMPEntryEditorAction.java index c25731b9a2a..0778e2e642c 100644 --- a/src/main/java/org/jabref/gui/externalfiles/WriteXMPEntryEditorAction.java +++ b/src/main/java/org/jabref/gui/externalfiles/WriteXMPEntryEditorAction.java @@ -69,7 +69,6 @@ public void actionPerformed(ActionEvent actionEvent) { setEnabled(true); } - class WriteXMPWorker extends AbstractWorker { private final List files; diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileType.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileType.java index 06e9f9e9b81..335b78ffcfc 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileType.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileType.java @@ -70,8 +70,8 @@ public static ExternalFileType buildFromArgs(String[] val) { icon = IconTheme.JabRefIcon.FILE.getSmallIcon(); // check whether there is another icon defined for this file type - for(ExternalFileType fileType : ExternalFileTypes.getDefaultExternalFileTypes()) { - if(fileType.getName().equals(name)) { + for (ExternalFileType fileType : ExternalFileTypes.getDefaultExternalFileTypes()) { + if (fileType.getName().equals(name)) { icon = fileType.icon; break; } diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEditor.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEditor.java index a7ef4cbacd9..ebfaa5c707d 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEditor.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEditor.java @@ -235,7 +235,6 @@ public static AbstractAction getAction(JDialog dialog) { return new EditExternalFileTypesAction(dialog); } - class EditListener implements ActionListener { @Override @@ -255,7 +254,6 @@ static class IconRenderer implements TableCellRenderer { private final JLabel lab = new JLabel(); - @Override public Component getTableCellRendererComponent(JTable tab, Object value, boolean isSelected, boolean hasFocus, int row, int column) { diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEntryEditor.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEntryEditor.java index c8d1e52efec..5a327c96c0b 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEntryEditor.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypeEntryEditor.java @@ -254,6 +254,4 @@ public boolean okPressed() { return okPressed; } - - } diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 486bd50faf4..ba4633d6cfd 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -16,6 +16,9 @@ public final class ExternalFileTypes { + // The only instance of this class: + private static ExternalFileTypes singleton; + // This String is used in the encoded list in prefs of external file type // modifications, in order to indicate a removed default file type: private static final String FILE_TYPE_REMOVED_FLAG = "REMOVED"; @@ -26,9 +29,9 @@ public final class ExternalFileTypes { private final ExternalFileType HTML_FALLBACK_TYPE = new ExternalFileType("URL", "html", "text/html", "", "www", IconTheme.JabRefIcon.WWW.getSmallIcon()); - // The only instance of this class: - private static ExternalFileTypes singleton; - + private ExternalFileTypes() { + updateExternalFileTypes(); + } public static ExternalFileTypes getInstance() { if (ExternalFileTypes.singleton == null) { @@ -37,10 +40,6 @@ public static ExternalFileTypes getInstance() { return ExternalFileTypes.singleton; } - private ExternalFileTypes() { - updateExternalFileTypes(); - } - public static List getDefaultExternalFileTypes() { List list = new ArrayList<>(); list.add(new ExternalFileType("PDF", "pdf", "application/pdf", "evince", "pdfSmall", diff --git a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java new file mode 100644 index 00000000000..dd357a3685b --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java @@ -0,0 +1,27 @@ +package org.jabref.gui.fieldeditors; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +import org.jabref.gui.AbstractViewModel; +import org.jabref.gui.util.BindingsHelper; +import org.jabref.model.entry.BibEntry; + +public class AbstractEditorViewModel extends AbstractViewModel { + protected StringProperty text = new SimpleStringProperty(""); + + public StringProperty textProperty() { + return text; + } + + public void bindToEntry(String fieldName, BibEntry entry) { + BindingsHelper.bindBidirectional( + this.textProperty(), + entry.getFieldBinding(fieldName), + newValue -> { + if (newValue != null) { + entry.setField(fieldName, newValue); + } + }); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/DateEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/DateEditor.fxml new file mode 100644 index 00000000000..8d8e17b2188 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/DateEditor.fxml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/DateEditor.java b/src/main/java/org/jabref/gui/fieldeditors/DateEditor.java new file mode 100644 index 00000000000..84a33ec0fb4 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/DateEditor.java @@ -0,0 +1,42 @@ +package org.jabref.gui.fieldeditors; + +import java.time.format.DateTimeFormatter; + +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.control.DatePicker; +import javafx.scene.layout.HBox; + +import org.jabref.gui.util.ControlHelper; +import org.jabref.model.entry.BibEntry; + +public class DateEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private DateEditorViewModel viewModel; + @FXML private DatePicker datePicker; + + public DateEditor(String fieldName, DateTimeFormatter dateFormatter) { + this.fieldName = fieldName; + this.viewModel = new DateEditorViewModel(dateFormatter); + + ControlHelper.loadFXMLForControl(this); + + datePicker.setConverter(viewModel.getDateToStringConverter()); + datePicker.getEditor().textProperty().bindBidirectional(viewModel.textProperty()); + } + + public DateEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + viewModel.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/DateEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/DateEditorViewModel.java new file mode 100644 index 00000000000..09dd3ea98dc --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/DateEditorViewModel.java @@ -0,0 +1,41 @@ +package org.jabref.gui.fieldeditors; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +import javafx.util.StringConverter; + +import org.jabref.model.entry.Date; +import org.jabref.model.strings.StringUtil; + +public class DateEditorViewModel extends AbstractEditorViewModel { + private final DateTimeFormatter dateFormatter; + + public DateEditorViewModel(DateTimeFormatter dateFormatter) { + this.dateFormatter = dateFormatter; + } + + public StringConverter getDateToStringConverter() { + return new StringConverter() { + + @Override + public String toString(LocalDate date) { + if (date != null) { + return dateFormatter.format(date); + } else { + return ""; + } + } + + @Override + public LocalDate fromString(String string) { + if (StringUtil.isNotBlank(string)) { + // We accept all kinds of dates (not just in the format specified) + return Date.parse(string).map(Date::toLocalDate).orElse(null); + } else { + return null; + } + } + }; + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index a61d6cc9bb5..7e986c44b23 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -7,13 +7,9 @@ import javafx.scene.text.Font; import org.jabref.gui.GUIGlobals; -import org.jabref.gui.util.BindingsHelper; -import org.jabref.model.entry.BibEntry; public class EditorTextArea extends javafx.scene.control.TextArea implements Initializable { - private String fieldName; - public EditorTextArea() { this(""); } @@ -48,16 +44,4 @@ private String convertToHex(java.awt.Color color) { public void initialize(URL location, ResourceBundle resources) { } - - public void bindToEntry(String fieldName, BibEntry entry) { - this.fieldName = fieldName; - BindingsHelper.bindBidirectional( - this.textProperty(), - entry.getFieldBinding(fieldName), - newValue -> { - if (newValue != null) { - entry.setField(fieldName, newValue); - } - }); - } } diff --git a/src/main/java/org/jabref/gui/fieldeditors/EntryLinkListEditor.java b/src/main/java/org/jabref/gui/fieldeditors/EntryLinkListEditor.java index 65100f7c795..bde39c7cd94 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EntryLinkListEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EntryLinkListEditor.java @@ -50,8 +50,9 @@ import org.apache.commons.logging.LogFactory; public class EntryLinkListEditor extends JTable implements FieldEditor { - private static final Log LOGGER = LogFactory.getLog(EntryLinkListEditor.class); + private static final String layoutFormat = "\\begin{author}\\format[Authors(2,1),LatexToUnicode]{\\author}\\end{author}\\begin{title}, \"\\format[LatexToUnicode]{\\title}\"\\end{title}\\begin{year}, \\year\\end{year}"; + private static final Log LOGGER = LogFactory.getLog(EntryLinkListEditor.class); private final FieldNameLabel label; private final JabRefFrame frame; private final BibDatabaseContext databaseContext; @@ -62,9 +63,8 @@ public class EntryLinkListEditor extends JTable implements FieldEditor { private final JPopupMenu menu = new JPopupMenu(); private final boolean singleEntry; private final JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon()); - private final JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon()); - private static final String layoutFormat = "\\begin{author}\\format[Authors(2,1),LatexToUnicode]{\\author}\\end{author}\\begin{title}, \"\\format[LatexToUnicode]{\\title}\"\\end{title}\\begin{year}, \\year\\end{year}"; + private final JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon()); public EntryLinkListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, String fieldName, String content, EntryEditor entryEditor, boolean singleEntry) { @@ -173,7 +173,6 @@ public void actionPerformed(ActionEvent actionEvent) { updateButtonStates(); } - private void jumpToEntry() { String entryKey = null; @@ -269,7 +268,6 @@ public String getSelectedText() { return null; } - private void addEntry() { int row = getSelectedRow(); if (row == -1) { @@ -282,7 +280,6 @@ private void addEntry() { updateButtonStates(); } - private void removeEntries() { int[] rows = getSelectedRows(); if (rows != null) { @@ -306,6 +303,7 @@ private void updateButtonStates() { } } } + private void moveEntry(int i) { int[] sel = getSelectedRows(); if ((sel.length != 1) || (tableModel.getRowCount() < 2)) { @@ -326,7 +324,6 @@ private void moveEntry(int i) { adjustColumnWidth(); } - class TableClickListener extends MouseAdapter { @Override diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 00ad7941dc5..9d1628713ca 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -1,40 +1,39 @@ package org.jabref.gui.fieldeditors; +import java.time.format.DateTimeFormatter; import java.util.Set; import org.jabref.Globals; import org.jabref.gui.DialogService; import org.jabref.gui.util.TaskExecutor; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; import org.jabref.preferences.JabRefPreferences; - public class FieldEditors { - public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService) { + public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences, JabRefPreferences preferences) { final Set fieldExtras = InternalBibtexFields.getFieldProperties(fieldName); - // TODO: Implement this + // TODO: Implement all of them if (Globals.prefs.get(JabRefPreferences.TIME_STAMP_FIELD).equals(fieldName) || fieldExtras.contains(FieldProperty.DATE)) { - // timestamp or a other field with datepicker command - // double click AND datefield => insert the current date (today) - //return FieldExtraComponents.getDateTimeExtraComponent(editor, - // fieldExtras.contains(FieldProperty.DATE), fieldExtras.contains(FieldProperty.ISO_DATE)); + if (fieldExtras.contains(FieldProperty.ISO_DATE)) { + return new DateEditor(fieldName, DateTimeFormatter.ISO_DATE); + } else { + return new DateEditor(fieldName, DateTimeFormatter.ofPattern(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT))); + } } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { - //return FieldExtraComponents.getExternalExtraComponent(panel, editor); + return new UrlEditor(fieldName, dialogService); } else if (fieldExtras.contains(FieldProperty.JOURNAL_NAME)) { - // Add controls for switching between abbreviated and full journal names. - // If this field also has a FieldContentSelector, we need to combine these. - //return FieldExtraComponents.getJournalExtraComponent(frame, panel, editor, entry, contentSelectors, storeFieldAction); - //} else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { - //return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); + return new JournalEditor(fieldName, journalAbbreviationLoader, journalAbbreviationPreferences); } else if (fieldExtras.contains(FieldProperty.DOI) || fieldExtras.contains(FieldProperty.EPRINT) || fieldExtras.contains(FieldProperty.ISBN)) { return new IdentifierEditor(fieldName, taskExecutor, dialogService); } else if (fieldExtras.contains(FieldProperty.OWNER)) { - //return FieldExtraComponents.getSetOwnerExtraComponent(editor, storeFieldAction); + return new OwnerEditor(fieldName, preferences); } else if (fieldExtras.contains(FieldProperty.YES_NO)) { //return FieldExtraComponents.getYesNoExtraComponent(editor, this); } else if (fieldExtras.contains(FieldProperty.MONTH)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java b/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java index d3aaf013ab1..393107ba6c3 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java @@ -35,5 +35,4 @@ private static String getFieldNameLabelText(String fieldName) { return ' ' + FieldName.getDisplayName(fieldName) + ' '; } - } diff --git a/src/main/java/org/jabref/gui/fieldeditors/FileListEditorTransferHandler.java b/src/main/java/org/jabref/gui/fieldeditors/FileListEditorTransferHandler.java index 5e0e9ffcf36..7f8e3766877 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FileListEditorTransferHandler.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FileListEditorTransferHandler.java @@ -27,14 +27,14 @@ class FileListEditorTransferHandler extends TransferHandler { + private static final Log LOGGER = LogFactory.getLog(FileListEditorTransferHandler.class); private DataFlavor urlFlavor; private final DataFlavor stringFlavor; private final JabRefFrame frame; private final EntryContainer entryContainer; private final TransferHandler textTransferHandler; - private DroppedFileHandler droppedFileHandler; - private static final Log LOGGER = LogFactory.getLog(FileListEditorTransferHandler.class); + private DroppedFileHandler droppedFileHandler; /** diff --git a/src/main/java/org/jabref/gui/fieldeditors/HtmlTransferable.java b/src/main/java/org/jabref/gui/fieldeditors/HtmlTransferable.java index 852cec59865..47e866f73c0 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/HtmlTransferable.java +++ b/src/main/java/org/jabref/gui/fieldeditors/HtmlTransferable.java @@ -19,16 +19,13 @@ public class HtmlTransferable implements Transferable { public static final DataFlavor HTML_FLAVOR = new DataFlavor("text/html;charset=utf-8;class=java.lang.String", "HTML Format"); public static final DataFlavor TEXT_FLAVOR = DataFlavor.stringFlavor; - private static final List ALL_FLAVORS = Arrays.asList(HTML_FLAVOR, DataFlavor.allHtmlFlavor, TEXT_FLAVOR); - - private final String htmlText; - private final String plainText; - private static final Pattern HTML_NEWLINE = Pattern.compile(" ?
|
"); private static final Pattern REMOVE_HTML = Pattern.compile("<(?!br)(?!BR).*?>"); private static final Pattern WHITESPACE_AROUND_NEWLINE = Pattern.compile("(?m)^\\s+|\\v+"); private static final Pattern DOUBLE_WHITESPACES = Pattern.compile("[ ]{2,}"); + private final String htmlText; + private final String plainText; public HtmlTransferable(String html) { this.htmlText = html; diff --git a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml index f5f3c888828..6475d53ae00 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml +++ b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml @@ -8,7 +8,7 @@ - + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java new file mode 100644 index 00000000000..a2e8eb2095a --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java @@ -0,0 +1,50 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.util.ControlHelper; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; +import org.jabref.model.entry.BibEntry; + +public class JournalEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private JournalEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { + this.fieldName = fieldName; + this.viewModel = new JournalEditorViewModel(journalAbbreviationLoader, journalAbbreviationPreferences); + + ControlHelper.loadFXMLForControl(this); + + textArea.textProperty().bindBidirectional(viewModel.textProperty()); + } + + public JournalEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + viewModel.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void toggleAbbreviation(ActionEvent event) { + viewModel.toggleAbbreviation(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java new file mode 100644 index 00000000000..18cff62a6f5 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java @@ -0,0 +1,35 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; +import org.jabref.logic.journals.JournalAbbreviationRepository; +import org.jabref.model.strings.StringUtil; + +public class JournalEditorViewModel extends AbstractEditorViewModel { + private final JournalAbbreviationLoader journalAbbreviationLoader; + private final JournalAbbreviationPreferences journalAbbreviationPreferences; + + public JournalEditorViewModel(JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { + this.journalAbbreviationLoader = journalAbbreviationLoader; + this.journalAbbreviationPreferences = journalAbbreviationPreferences; + } + + public void toggleAbbreviation() { + if (StringUtil.isBlank(text.get())) { + return; + } + + JournalAbbreviationRepository abbreviationRepository = journalAbbreviationLoader.getRepository(journalAbbreviationPreferences); + if (abbreviationRepository.isKnownName(text.get())) { + Optional nextAbbreviation = abbreviationRepository.getNextAbbreviation(text.get()); + + if (nextAbbreviation.isPresent()) { + text.set(nextAbbreviation.get()); + // TODO: Add undo + //panel.getUndoManager().addEdit(new UndoableFieldChange(entry, editor.getFieldName(), text, nextAbbreviation)); + } + } + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml new file mode 100644 index 00000000000..90fb1394b58 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java new file mode 100644 index 00000000000..a89355c07f3 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java @@ -0,0 +1,49 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.util.ControlHelper; +import org.jabref.model.entry.BibEntry; +import org.jabref.preferences.JabRefPreferences; + +public class OwnerEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private OwnerEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public OwnerEditor(String fieldName, JabRefPreferences preferences) { + this.fieldName = fieldName; + this.viewModel = new OwnerEditorViewModel(preferences); + + ControlHelper.loadFXMLForControl(this); + + textArea.textProperty().bindBidirectional(viewModel.textProperty()); + } + + public OwnerEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + viewModel.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void setOwner(ActionEvent event) { + viewModel.setOwner(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java new file mode 100644 index 00000000000..321e3e0011f --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java @@ -0,0 +1,15 @@ +package org.jabref.gui.fieldeditors; + +import org.jabref.preferences.JabRefPreferences; + +public class OwnerEditorViewModel extends AbstractEditorViewModel { + private final JabRefPreferences preferences; + + public OwnerEditorViewModel(JabRefPreferences preferences) { + this.preferences = preferences; + } + + public void setOwner() { + text.set(preferences.get(JabRefPreferences.DEFAULT_OWNER)); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.fxml index 31c0decce02..3e8a15ef23e 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.fxml +++ b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.fxml @@ -3,5 +3,5 @@ - + diff --git a/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java index 2f789145fad..9832880b92e 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java @@ -10,16 +10,21 @@ public class SimpleEditor extends HBox implements FieldEditorFX { protected final String fieldName; + @FXML private final SimpleEditorViewModel viewModel; @FXML private EditorTextArea textArea; public SimpleEditor(String fieldName) { this.fieldName = fieldName; + this.viewModel = new SimpleEditorViewModel(); + ControlHelper.loadFXMLForControl(this); + + textArea.textProperty().bindBidirectional(viewModel.textProperty()); } @Override public void bindToEntry(BibEntry entry) { - textArea.bindToEntry(fieldName, entry); + viewModel.bindToEntry(fieldName, entry); } @Override diff --git a/src/main/java/org/jabref/gui/fieldeditors/SimpleEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditorViewModel.java new file mode 100644 index 00000000000..2892b5ac730 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/SimpleEditorViewModel.java @@ -0,0 +1,4 @@ +package org.jabref.gui.fieldeditors; + +public class SimpleEditorViewModel extends AbstractEditorViewModel { +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.fxml new file mode 100644 index 00000000000..93ef3509a98 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java new file mode 100644 index 00000000000..9b75b39d9f5 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java @@ -0,0 +1,49 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.DialogService; +import org.jabref.gui.util.ControlHelper; +import org.jabref.model.entry.BibEntry; + +public class UrlEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private UrlEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public UrlEditor(String fieldName, DialogService dialogService) { + this.fieldName = fieldName; + this.viewModel = new UrlEditorViewModel(dialogService); + + ControlHelper.loadFXMLForControl(this); + + textArea.textProperty().bindBidirectional(viewModel.textProperty()); + } + + public UrlEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + viewModel.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void openExternalLink(ActionEvent event) { + viewModel.openExternalLink(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java new file mode 100644 index 00000000000..61394dbe8c0 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java @@ -0,0 +1,47 @@ +package org.jabref.gui.fieldeditors; + +import java.io.IOException; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; + +import org.jabref.gui.DialogService; +import org.jabref.gui.desktop.JabRefDesktop; +import org.jabref.logic.l10n.Localization; +import org.jabref.logic.net.URLUtil; +import org.jabref.model.strings.StringUtil; + +import org.fxmisc.easybind.EasyBind; + +public class UrlEditorViewModel extends AbstractEditorViewModel { + private DialogService dialogService; + private BooleanProperty validUrlIsNotPresent = new SimpleBooleanProperty(true); + + public UrlEditorViewModel(DialogService dialogService) { + this.dialogService = dialogService; + + validUrlIsNotPresent.bind( + EasyBind.map(text, input -> StringUtil.isBlank(input) || !URLUtil.isURL(input)) + ); + } + + public boolean isValidUrlIsNotPresent() { + return validUrlIsNotPresent.get(); + } + + public BooleanProperty validUrlIsNotPresentProperty() { + return validUrlIsNotPresent; + } + + public void openExternalLink() { + if (StringUtil.isBlank(text.get())) { + return; + } + + try { + JabRefDesktop.openBrowser(text.get()); + } catch (IOException ex) { + dialogService.notify(Localization.lang("Unable to open link.")); + } + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/XmlTransferable.java b/src/main/java/org/jabref/gui/fieldeditors/XmlTransferable.java index 07b40ad21f2..457e9f446fd 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/XmlTransferable.java +++ b/src/main/java/org/jabref/gui/fieldeditors/XmlTransferable.java @@ -7,7 +7,6 @@ import java.util.Arrays; import java.util.List; - public class XmlTransferable implements Transferable { private static final DataFlavor XML_FLAVOR = new DataFlavor("application/xml;charset=utf-8;class=java.lang.String", "XML Format"); diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/FieldTextMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/FieldTextMenu.java index 6b4fd23134d..042175fd6d0 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/FieldTextMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/FieldTextMenu.java @@ -21,16 +21,16 @@ import org.jabref.model.strings.StringUtil; public class FieldTextMenu implements MouseListener { + private static final int MAX_PASTE_PREVIEW_LENGTH = 20; private final FieldEditor field; private final JPopupMenu inputMenu = new JPopupMenu(); private final CopyAction copyAction; private final PasteAction pasteAction; + private final JMenuItem doiMenuItem; private ProtectedTermsMenu protectedTermsMenu; - private static final int MAX_PASTE_PREVIEW_LENGTH = 20; - public FieldTextMenu(FieldEditor fieldComponent) { field = fieldComponent; diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java index 6d6e5427095..cf85e144a3d 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java @@ -48,8 +48,8 @@ public void updateFiles() { if (!list.isInternalList()) { JMenuItem fileItem = new JMenuItem(list.getDescription()); externalFiles.add(fileItem); - fileItem.addActionListener(event -> {String selectedText = opener.getSelectedText(); - if((selectedText != null) && !selectedText.isEmpty()) { + fileItem.addActionListener(event -> { String selectedText = opener.getSelectedText(); + if ((selectedText != null) && !selectedText.isEmpty()) { list.addProtectedTerm(selectedText); } }); diff --git a/src/main/java/org/jabref/gui/filelist/FileListEntry.java b/src/main/java/org/jabref/gui/filelist/FileListEntry.java index 3a5c11e33a7..23ebefc2a92 100644 --- a/src/main/java/org/jabref/gui/filelist/FileListEntry.java +++ b/src/main/java/org/jabref/gui/filelist/FileListEntry.java @@ -8,12 +8,13 @@ /** * This class represents a file link for a Bibtex entry. */ + public class FileListEntry { private String description; private String link; - + private Optional type; public FileListEntry(String description, String link) { diff --git a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java index 5d30e7bfcce..f6032b4a58d 100644 --- a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java +++ b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java @@ -65,29 +65,66 @@ */ public class FileListEntryEditor { - private static final Log LOGGER = LogFactory.getLog(FileListEntryEditor.class); + private static final Pattern REMOTE_LINK_PATTERN = Pattern.compile("[a-z]+://.*"); + private static final Log LOGGER = LogFactory.getLog(FileListEntryEditor.class); private JDialog diag; private final JTextField link = new JTextField(); private final JTextField description = new JTextField(); - private final JButton ok = new JButton(Localization.lang("OK")); + private final JButton ok = new JButton(Localization.lang("OK")); private final JComboBox types; private final JProgressBar prog = new JProgressBar(SwingConstants.HORIZONTAL); + //Do not make this variable final, as then the lambda action listener will fail on compile + private JabRefFrame frame; + + private boolean showSaveDialog; + private final JLabel downloadLabel = new JLabel(Localization.lang("Downloading...")); - private ConfirmCloseFileListEntryEditor externalConfirm; + private final ActionListener browsePressed = e -> { + String fileText = link.getText().trim(); + Optional file = FileHelper.expandFilename(this.databaseContext, fileText, + Globals.prefs.getFileDirectoryPreferences()); + Path workingDir = file.orElse(Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY))); + + String fileName = Paths.get(fileText).getFileName().toString(); + + FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() + .withInitialDirectory(workingDir) + .withInitialFileName(fileName).build(); + DialogService ds = new FXDialogService(); + Optional path; + if (showSaveDialog) { + path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileSaveDialog(fileDialogConfiguration)); + } else { + path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration)); + } + + path.ifPresent(selection -> { + File newFile = selection.toFile(); + // Store the directory for next time: + Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, newFile.getPath()); + + // If the file is below the file directory, make the path relative: + List fileDirs = this.databaseContext + .getFileDirectories(Globals.prefs.getFileDirectoryPreferences()); + newFile = FileUtil.shortenFileName(newFile, fileDirs); + + link.setText(newFile.getPath()); + link.requestFocus(); + }); + }; + private ConfirmCloseFileListEntryEditor externalConfirm; private FileListEntry entry; //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; - private boolean showSaveDialog; - - private static final Pattern REMOTE_LINK_PATTERN = Pattern.compile("[a-z]+://.*"); + private boolean dontOpenBrowseUntilDisposed; public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton, BibDatabaseContext databaseContext, boolean showSaveDialog) { @@ -350,39 +387,4 @@ private void storeSettings(FileListEntry listEntry) { public boolean okPressed() { return okPressed; } - - private final ActionListener browsePressed = e -> { - String fileText = link.getText().trim(); - Optional file = FileHelper.expandFilename(this.databaseContext, fileText, - Globals.prefs.getFileDirectoryPreferences()); - Path workingDir = file.orElse(Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY))); - - String fileName = Paths.get(fileText).getFileName().toString(); - - FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .withInitialDirectory(workingDir) - .withInitialFileName(fileName).build(); - DialogService ds = new FXDialogService(); - - Optional path; - if (showSaveDialog) { - path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileSaveDialog(fileDialogConfiguration)); - } else { - path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration)); - } - - path.ifPresent(selection -> { - File newFile = selection.toFile(); - // Store the directory for next time: - Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, newFile.getPath()); - - // If the file is below the file directory, make the path relative: - List fileDirs = this.databaseContext - .getFileDirectories(Globals.prefs.getFileDirectoryPreferences()); - newFile = FileUtil.shortenFileName(newFile, fileDirs); - - link.setText(newFile.getPath()); - link.requestFocus(); - }); - }; } diff --git a/src/main/java/org/jabref/gui/filelist/FileListTableModel.java b/src/main/java/org/jabref/gui/filelist/FileListTableModel.java index fc415c27664..2dcb0d4909f 100644 --- a/src/main/java/org/jabref/gui/filelist/FileListTableModel.java +++ b/src/main/java/org/jabref/gui/filelist/FileListTableModel.java @@ -123,7 +123,8 @@ private FileListEntry setContent(String val, boolean firstOnly, boolean deduceUn List fields = FileFieldParser.parse(value); List files = new ArrayList<>(); - for(LinkedFile entry : fields) { + for (LinkedFile entry : fields) { + if (entry.isEmpty()) { continue; } diff --git a/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java b/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java index 9b6a761ba8c..7b669fb0e90 100644 --- a/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java +++ b/src/main/java/org/jabref/gui/groups/EntryTableTransferHandler.java @@ -44,13 +44,13 @@ public class EntryTableTransferHandler extends TransferHandler { + private static final boolean DROP_ALLOWED = true; + private static final Log LOGGER = LogFactory.getLog(EntryTableTransferHandler.class); private final MainTable entryTable; private final JabRefFrame frame; private final BasePanel panel; private DataFlavor urlFlavor; private final DataFlavor stringFlavor; - private static final boolean DROP_ALLOWED = true; - private static final Log LOGGER = LogFactory.getLog(EntryTableTransferHandler.class); private boolean draggingFile; /** diff --git a/src/main/java/org/jabref/gui/groups/GroupSelector.java b/src/main/java/org/jabref/gui/groups/GroupSelector.java index a3dc06b7fee..c5ff928e176 100644 --- a/src/main/java/org/jabref/gui/groups/GroupSelector.java +++ b/src/main/java/org/jabref/gui/groups/GroupSelector.java @@ -435,7 +435,7 @@ public int getRescalingWeight() { @Override public void componentClosing() { - if (panel != null) {// panel may be null if no file is open any more + if (panel != null) { // panel may be null if no file is open any more panel.getMainTable().getTableModel().updateGroupingState(MainTableDataModel.DisplayOption.DISABLED); } getToggleAction().setSelected(false); @@ -599,8 +599,6 @@ public GroupTreeNodeViewModel getNodeToUse() { } } - - private class SortDirectSubgroupsAction extends NodeAction { public SortDirectSubgroupsAction() { diff --git a/src/main/java/org/jabref/gui/groups/UndoableAddOrRemoveGroup.java b/src/main/java/org/jabref/gui/groups/UndoableAddOrRemoveGroup.java index 14a91547a35..7e0e40f9f49 100644 --- a/src/main/java/org/jabref/gui/groups/UndoableAddOrRemoveGroup.java +++ b/src/main/java/org/jabref/gui/groups/UndoableAddOrRemoveGroup.java @@ -8,6 +8,12 @@ class UndoableAddOrRemoveGroup extends AbstractUndoableJabRefEdit { + /** Adding of a single node (group). */ + public static final int ADD_NODE = 0; + /** Removal of a single node. Children, if any, are kept. */ + public static final int REMOVE_NODE_KEEP_CHILDREN = 1; + /** Removal of a node and all of its children. */ + public static final int REMOVE_NODE_AND_CHILDREN = 2; /** The root of the global groups tree */ private final GroupTreeNodeViewModel m_groupsRootHandle; /** The subtree that was added or removed */ @@ -24,12 +30,6 @@ class UndoableAddOrRemoveGroup extends AbstractUndoableJabRefEdit { * REMOVE_NODE_AND_CHILDREN) */ private final int m_editType; - /** Adding of a single node (group). */ - public static final int ADD_NODE = 0; - /** Removal of a single node. Children, if any, are kept. */ - public static final int REMOVE_NODE_KEEP_CHILDREN = 1; - /** Removal of a node and all of its children. */ - public static final int REMOVE_NODE_AND_CHILDREN = 2; /** * Creates an object that can undo/redo an edit event. diff --git a/src/main/java/org/jabref/gui/importer/EntryFromFileCreator.java b/src/main/java/org/jabref/gui/importer/EntryFromFileCreator.java index 84d4371ffdd..8eecebbbffa 100644 --- a/src/main/java/org/jabref/gui/importer/EntryFromFileCreator.java +++ b/src/main/java/org/jabref/gui/importer/EntryFromFileCreator.java @@ -29,10 +29,10 @@ */ public abstract class EntryFromFileCreator implements FileFilter { - protected final ExternalFileType externalFileType; - private static final int MIN_PATH_TOKEN_LENGTH = 4; + protected final ExternalFileType externalFileType; + /** * Constructor.
* Forces subclasses to provide an {@link ExternalFileType} instance, which diff --git a/src/main/java/org/jabref/gui/importer/FetcherPreviewDialog.java b/src/main/java/org/jabref/gui/importer/FetcherPreviewDialog.java index 816d66aef01..af21bfecb2d 100644 --- a/src/main/java/org/jabref/gui/importer/FetcherPreviewDialog.java +++ b/src/main/java/org/jabref/gui/importer/FetcherPreviewDialog.java @@ -166,7 +166,6 @@ private void setSelectionAll(boolean select) { glTable.repaint(); } - static class TableEntry { private final String id; @@ -197,7 +196,6 @@ static class PreviewRenderer implements TableCellRenderer { private final JLabel label = new JLabel(); - @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, @@ -280,7 +278,6 @@ public Object getColumnValue(TableEntry entry, int i) { } - public boolean isOkPressed() { return okPressed; } diff --git a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java index c89b2cb08f7..6ac11db7a3d 100644 --- a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java @@ -1,6 +1,7 @@ package org.jabref.gui.importer.actions; -import java.nio.file.Path; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -9,16 +10,13 @@ import org.jabref.Globals; import org.jabref.JabRefExecutorService; import org.jabref.gui.BasePanel; -import org.jabref.gui.DialogService; -import org.jabref.gui.FXDialogService; +import org.jabref.gui.FileDialog; import org.jabref.gui.JabRefFrame; import org.jabref.gui.MergeDialog; import org.jabref.gui.actions.BaseAction; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableInsertEntry; import org.jabref.gui.undo.UndoableInsertString; -import org.jabref.gui.util.DefaultTaskExecutor; -import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.importer.OpenDatabase; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; @@ -39,13 +37,12 @@ import org.apache.commons.logging.LogFactory; public class AppendDatabaseAction implements BaseAction { - private static final Log LOGGER = LogFactory.getLog(AppendDatabaseAction.class); private final JabRefFrame frame; private final BasePanel panel; - private List filesToOpen = new ArrayList<>(); + private final List filesToOpen = new ArrayList<>(); public AppendDatabaseAction(JabRefFrame frame, BasePanel panel) { this.frame = frame; @@ -60,21 +57,15 @@ public void action() { md.setLocationRelativeTo(panel); md.setVisible(true); if (md.isOkPressed()) { - - FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .withDefaultExtension(FileExtensions.BIBTEX_DB) - .addExtensionFilter(FileExtensions.BIBTEX_DB) - .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)) - .build(); - - DialogService ds = new FXDialogService(); - List chosen = DefaultTaskExecutor - .runInJavaFXThread(() -> ds.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration)); - + FileDialog dialog = new FileDialog(frame).withExtension(FileExtensions.BIBTEX_DB); + dialog.setDefaultExtension(FileExtensions.BIBTEX_DB); + List chosen = dialog.showDialogAndGetMultipleFiles(); if (chosen.isEmpty()) { return; } - filesToOpen = chosen; + for (String aChosen : chosen) { + filesToOpen.add(new File(aChosen)); + } // Run the actual open in a thread to prevent the program // locking until the file is loaded. @@ -90,17 +81,16 @@ private void openIt(boolean importEntries, boolean importStrings, boolean import if (filesToOpen.isEmpty()) { return; } - for (Path file : filesToOpen) { + for (File file : filesToOpen) { try { - Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent().toString()); + Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent()); // Should this be done _after_ we know it was successfully opened? - ParserResult pr = OpenDatabase.loadDatabase(file.toAbsolutePath().toString(), + ParserResult pr = OpenDatabase.loadDatabase(file, Globals.prefs.getImportFormatPreferences()); AppendDatabaseAction.mergeFromBibtex(frame, panel, pr, importEntries, importStrings, importGroups, importSelectorWords); - panel.output( - Localization.lang("Imported from library") + " '" + file.toAbsolutePath().toString() + "'"); - } catch (KeyCollisionException ex) { + panel.output(Localization.lang("Imported from library") + " '" + file.getPath() + "'"); + } catch (IOException | KeyCollisionException ex) { LOGGER.warn("Could not open database", ex); JOptionPane.showMessageDialog(panel, ex.getMessage(), Localization.lang("Open library"), JOptionPane.ERROR_MESSAGE); @@ -167,7 +157,7 @@ private static void mergeFromBibtex(JabRefFrame frame, BasePanel panel, ParserRe if (importSelectorWords) { - for (ContentSelector selector : meta.getContentSelectorList()) { + for (ContentSelector selector: meta.getContentSelectorList()) { panel.getBibDatabaseContext().getMetaData().addContentSelector(selector); } } diff --git a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java index 417d01a0ab9..a2506ac13a7 100644 --- a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java @@ -97,12 +97,12 @@ private JPanel createCheckBoxPanel(List newTypes, List dif JPanel checkboxPanel = new JPanel(); checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.PAGE_AXIS)); - JLabel customFoundLabel = new JLabel(Localization.lang("Custom entry types found in file")+"."); + JLabel customFoundLabel = new JLabel(Localization.lang("Custom entry types found in file") + "."); Font boldStandardFont = new Font(customFoundLabel.getFont().getFontName(), Font.BOLD, customFoundLabel.getFont().getSize()); customFoundLabel.setFont(boldStandardFont); checkboxPanel.add(customFoundLabel); - JLabel selectLabel = new JLabel(Localization.lang("Select all customized types to be stored in local preferences")+":"); + JLabel selectLabel = new JLabel(Localization.lang("Select all customized types to be stored in local preferences") + ":"); selectLabel.setFont(boldStandardFont); checkboxPanel.add(selectLabel); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java index b7bac6ce97f..f2fa6f03099 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java @@ -49,12 +49,6 @@ public class ACMPortalFetcher implements PreviewEntryFetcher { private static final Log LOGGER = LogFactory.getLog(ACMPortalFetcher.class); - private final HtmlToLatexFormatter htmlToLatexFormatter = new HtmlToLatexFormatter(); - private final ProtectTermsFormatter protectTermsFormatter = new ProtectTermsFormatter( - new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences())); - private final UnitsToLatexFormatter unitsToLatexFormatter = new UnitsToLatexFormatter(); - private String terms; - private static final String START_URL = "http://portal.acm.org/"; private static final String SEARCH_URL_PART = "results.cfm?query="; private static final String SEARCH_URL_PART_II = "&dl="; @@ -75,19 +69,8 @@ public class ACMPortalFetcher implements PreviewEntryFetcher { private static final String START_BIBTEX_ENTRY = "@"; private static final String END_BIBTEX_ENTRY_HTML = ""; - private final JRadioButton acmButton = new JRadioButton(Localization.lang("The ACM Digital Library")); - private final JRadioButton guideButton = new JRadioButton(Localization.lang("The Guide to Computing Literature")); - private final JCheckBox absCheckBox = new JCheckBox(Localization.lang("Include abstracts"), false); - private static final int PER_PAGE = 20; // Fetch only one page. Otherwise, the user will get blocked by ACM. 100 has been the old setting. See Bug 3532752 - https://sourceforge.net/tracker/index.php?func=detail&aid=3532752&group_id=92314&atid=600306 private static final int WAIT_TIME = 200; - private boolean shouldContinue; - - // user settings - private boolean fetchAbstract; - private boolean acmOrGuide; - - private int piv; private static final Pattern HITS_PATTERN = Pattern.compile("(\\d+,*\\d*) results found"); private static final Pattern MAX_HITS_PATTERN = Pattern @@ -102,6 +85,26 @@ public class ACMPortalFetcher implements PreviewEntryFetcher { private static final Pattern ABSTRACT_PATTERN = Pattern.compile("
(.*?)
"); private static final Pattern SOURCE_PATTERN = Pattern.compile("([^<]*)"); + private final HtmlToLatexFormatter htmlToLatexFormatter = new HtmlToLatexFormatter(); + + private final ProtectTermsFormatter protectTermsFormatter = new ProtectTermsFormatter( + new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences())); + + private final UnitsToLatexFormatter unitsToLatexFormatter = new UnitsToLatexFormatter(); + private String terms; + private final JRadioButton acmButton = new JRadioButton(Localization.lang("The ACM Digital Library")); + + private final JRadioButton guideButton = new JRadioButton(Localization.lang("The Guide to Computing Literature")); + private final JCheckBox absCheckBox = new JCheckBox(Localization.lang("Include abstracts"), false); + + private boolean shouldContinue; + // user settings + private boolean fetchAbstract; + + private boolean acmOrGuide; + + private int piv; + @Override public JPanel getOptionsPanel() { JPanel pan = new JPanel(); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/CiteSeerXFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/CiteSeerXFetcher.java index 16c5983469b..ffe11017c57 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/CiteSeerXFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/CiteSeerXFetcher.java @@ -32,8 +32,6 @@ public class CiteSeerXFetcher implements EntryFetcher { + "&submit=Search&sort=rlv&t=doc"; private static final Pattern CITE_LINK_PATTERN = Pattern.compile(""); - private boolean stopFetching; - private static final String BASE_PATTERN = ""; private static final Pattern TITLE_PATTERN = Pattern @@ -46,6 +44,8 @@ public class CiteSeerXFetcher implements EntryFetcher { private static final Log LOGGER = LogFactory.getLog(CiteSeerXFetcher.class); + private boolean stopFetching; + @Override public boolean processQuery(String query, ImportInspector inspector, OutputPrinter status) { stopFetching = false; @@ -124,8 +124,6 @@ private static String getCitationsFromUrl(String urlQuery, List ids) thr return null; } - - private static BibEntry getSingleCitation(String urlString) throws IOException { String cont = new URLDownload(urlString).asString(); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java index 155d92593ed..5bd10e6d06b 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java @@ -33,7 +33,6 @@ import org.jabref.logic.util.OS; import org.jabref.preferences.JabRefPreferences; - public class GeneralFetcher extends SidePaneComponent implements ActionListener { private final JTextField tf = new JTextField(); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java index cb3aa4c84e9..8147ca9d12e 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java @@ -29,6 +29,7 @@ import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.URLDownload; import org.jabref.model.entry.BibEntry; @@ -67,9 +68,8 @@ public class IEEEXploreFetcher implements EntryFetcher { private final UnitsToLatexFormatter unitsToLatexFormatter = new UnitsToLatexFormatter(); private final HtmlToLatexFormatter htmlToLatexFormatter = new HtmlToLatexFormatter(); private final JCheckBox absCheckBox = new JCheckBox(Localization.lang("Include abstracts"), false); - - private boolean shouldContinue; private final JournalAbbreviationLoader abbreviationLoader; + private boolean shouldContinue; public IEEEXploreFetcher(JournalAbbreviationLoader abbreviationLoader) { @@ -167,7 +167,6 @@ public boolean processQuery(String query, ImportInspector dialog, OutputPrinter return false; } - @Override public String getTitle() { return "IEEEXplore"; @@ -331,7 +330,7 @@ private BibEntry cleanup(BibEntry entry) { entry.getField(FieldName.PAGES).ifPresent(pages -> { String[] pageNumbers = pages.split("-"); if (pageNumbers.length == 2) { - if (pageNumbers[0].equals(pageNumbers[1])) {// single page + if (pageNumbers[0].equals(pageNumbers[1])) { // single page entry.setField(FieldName.PAGES, pageNumbers[0]); } else { entry.setField(FieldName.PAGES, pages.replace("-", "--")); @@ -406,9 +405,10 @@ private BibEntry cleanup(BibEntry entry) { fullName = fullName.replace(" - ", "-"); //IEE Proceedings- fullName = fullName.trim(); - if (Globals.prefs.getBoolean(JabRefPreferences.USE_IEEE_ABRV)) { + JournalAbbreviationPreferences journalAbbreviationPreferences = Globals.prefs.getJournalAbbreviationPreferences(); + if (journalAbbreviationPreferences.useIEEEAbbreviations()) { fullName = abbreviationLoader - .getRepository(Globals.prefs.getJournalAbbreviationPreferences()) + .getRepository(journalAbbreviationPreferences) .getMedlineAbbreviation(fullName) .orElse(fullName); } @@ -484,5 +484,4 @@ private BibEntry cleanup(BibEntry entry) { return entry; } - } diff --git a/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java index 8bdce779290..fc3244521b0 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java @@ -252,7 +252,7 @@ public boolean processQuery(String query, ImportInspector dialog, OutputPrinter } catch (SAXException e) { String url = constructUrl(OAI2Fetcher.fixKey(key)); LOGGER.error("Error while fetching from " + getTitle(), e); - ((ImportInspectionDialog)dialog).showMessage(Localization.lang("Error while fetching from %0", getTitle()) +"\n"+ + ((ImportInspectionDialog)dialog).showMessage(Localization.lang("Error while fetching from %0", getTitle()) + "\n" + Localization.lang("A SAX exception occurred while parsing '%0':", url), Localization.lang("Search %0", getTitle()), JOptionPane.ERROR_MESSAGE); } diff --git a/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java index 6d2c7893e70..459bad48a68 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/SearchBasedEntryFetcher.java @@ -20,7 +20,7 @@ /** * Wrapper around {@link SearchBasedFetcher} which implements the old {@link EntryFetcher} interface. */ -public class SearchBasedEntryFetcher implements EntryFetcher{ +public class SearchBasedEntryFetcher implements EntryFetcher { private static final Log LOGGER = LogFactory.getLog(SearchBasedEntryFetcher.class); private final SearchBasedFetcher fetcher; diff --git a/src/main/java/org/jabref/gui/importer/fetcher/SpringerFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/SpringerFetcher.java index 58e2ed74057..c1181ae00e3 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/SpringerFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/SpringerFetcher.java @@ -31,7 +31,6 @@ public class SpringerFetcher implements EntryFetcher { private static final int MAX_PER_PAGE = 100; private boolean shouldContinue; - @Override public void stopFetching() { shouldContinue = false; diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsController.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsController.java index ff8ade44058..7bc81684347 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsController.java +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsController.java @@ -20,10 +20,13 @@ import org.jabref.gui.IconTheme; import org.jabref.gui.util.TaskExecutor; import org.jabref.gui.util.ValueTableCellFactory; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.preferences.PreferencesService; public class ManageJournalAbbreviationsController extends AbstractController { + @FXML public Label loadingLabel; + @FXML public ProgressIndicator progressIndicator; @FXML private TableView journalAbbreviationsTable; @FXML private TableColumn journalTableNameColumn; @FXML private TableColumn journalTableAbbreviationColumn; @@ -34,17 +37,14 @@ public class ManageJournalAbbreviationsController extends AbstractController { @@ -124,7 +126,7 @@ void addBuiltInLists() { BackgroundTask .wrap(() -> { - if (preferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV)) { + if (abbreviationsPreferences.useIEEEAbbreviations()) { return JournalAbbreviationLoader.getOfficialIEEEAbbreviations(); } else { return JournalAbbreviationLoader.getStandardIEEEAbbreviations(); @@ -150,7 +152,7 @@ private void addList(String name, List abbreviations) { * Read all saved file paths and read their abbreviations */ public void createFileObjects() { - List externalFiles = preferences.getStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS); + List externalFiles = abbreviationsPreferences.getExternalJournalLists(); externalFiles.forEach(name -> openFile(Paths.get(name))); } @@ -316,14 +318,14 @@ public void saveJournalAbbreviationFiles() { * This method stores all file paths of the files in the journalFiles property * to the global JabRef preferences. Pseudo abbreviation files will not be stored. */ - public void saveExternalFilesList() { + private void saveExternalFilesList() { List extFiles = new ArrayList<>(); journalFiles.forEach(file -> { if (!file.isBuiltInListProperty().get()) { file.getAbsolutePath().ifPresent(path -> extFiles.add(path.toAbsolutePath().toString())); } }); - preferences.putStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, extFiles); + abbreviationsPreferences.setExternalJournalLists(extFiles); } /** @@ -346,8 +348,11 @@ public void selectLastJournalFile() { public void saveEverythingAndUpdateAutoCompleter() { saveExternalFilesList(); saveJournalAbbreviationFiles(); + // Update journal abbreviation loader - journalAbbreviationLoader.update(JournalAbbreviationPreferences.fromPreferences(preferences)); + journalAbbreviationLoader.update(abbreviationsPreferences); + + preferences.storeJournalAbbreviationPreferences(abbreviationsPreferences); } public SimpleListProperty journalFilesProperty() { diff --git a/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java b/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java index 2570d4035f9..b8444e27ca8 100644 --- a/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java +++ b/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java @@ -405,7 +405,6 @@ public void actionPerformed(ActionEvent e) { } } - private static void doCopyOrCut(JTextComponent jtc, boolean copy) { if (jtc != null) { int caretPosition = jtc.getCaretPosition(); @@ -582,20 +581,19 @@ public void actionPerformed(ActionEvent event) { } } - /** - * Manages all killed (cut) text pieces in a ring which is accessible - * through {@link YankPopAction}. - *

- * Also provides an unmodifiable copy of all cut pieces. - */ public static class KillRing { + /** + * Manages all killed (cut) text pieces in a ring which is accessible + * through {@link YankPopAction}. + *

+ * Also provides an unmodifiable copy of all cut pieces. + */ + private static final KillRing INSTANCE = new KillRing(); private JTextComponent jtc; private final LinkedList ring = new LinkedList<>(); - private Iterator iter = ring.iterator(); - - private static final KillRing INSTANCE = new KillRing(); + private Iterator iter = ring.iterator(); public static KillRing getInstance() { return KillRing.INSTANCE; @@ -776,7 +774,6 @@ public void actionPerformed(ActionEvent event) { } } - private static int getWordEnd(JTextComponent jtc, int start) throws BadLocationException { try { diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingAction.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingAction.java index 0f44160dacb..6086057dde6 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingAction.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingAction.java @@ -10,7 +10,6 @@ import org.jabref.gui.IconTheme; import org.jabref.logic.l10n.Localization; - public class KeyBindingAction extends AbstractAction { diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingPreferences.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingPreferences.java deleted file mode 100644 index 38b29d9e011..00000000000 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingPreferences.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.jabref.gui.keyboard; - -import java.awt.AWTError; -import java.awt.HeadlessException; -import java.awt.Toolkit; -import java.awt.event.InputEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.SortedMap; -import java.util.stream.Collectors; - -import javax.swing.KeyStroke; - -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyCombination; -import javafx.scene.input.KeyEvent; - -import org.jabref.logic.util.OS; -import org.jabref.preferences.JabRefPreferences; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class KeyBindingPreferences { - - private static final Log LOGGER = LogFactory.getLog(KeyBindingPreferences.class); - - private int shortcutMask = -1; - - private final JabRefPreferences prefs; - - private KeyBindingRepository keyBindingRepository = new KeyBindingRepository(); - - - public KeyBindingPreferences(JabRefPreferences prefs) { - this.prefs = Objects.requireNonNull(prefs); - restoreKeyBindings(); - } - - /** - * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences. - */ - public KeyStroke getKey(KeyBinding bindName) { - - String s = keyBindingRepository.get(bindName.getKey()); - - if (OS.OS_X) { - return getKeyForMac(KeyStroke.getKeyStroke(s)); - } else { - return KeyStroke.getKeyStroke(s); - } - } - - public KeyCombination getKeyCombination(KeyBinding bindName) { - String binding = keyBindingRepository.get(bindName.getKey()); - return KeyCombination.valueOf(binding); - } - - /** - * Check if the given keyCombination equals the given keyEvent - * - * @param combination as KeyCombination - * @param keyEvent as KeEvent - * @return true if matching, else false - */ - public boolean checkKeyCombinationEquality(KeyCombination combination, KeyEvent keyEvent) { - KeyCode code = keyEvent.getCode(); - if (code == KeyCode.UNDEFINED) { - return false; - } - // gather the pressed modifier keys - String modifiers = ""; - if (keyEvent.isControlDown()) { - modifiers = "ctrl"; - } - if (keyEvent.isShiftDown()) { - modifiers += " shift"; - } - if (keyEvent.isAltDown()) { - modifiers += " alt"; - } - modifiers = modifiers.trim(); - String newShortcut = (modifiers.isEmpty()) ? code.toString() : modifiers + " " + code; - KeyCombination pressedCombination = KeyCombination.valueOf(newShortcut); - return combination.equals(pressedCombination); - } - - /** - * Check if the given KeyBinding equals the given keyEvent - * - * @param binding as KeyBinding - * @param keyEvent as KeEvent - * @return true if matching, else false - */ - public boolean checkKeyCombinationEquality(KeyBinding binding, KeyEvent keyEvent) { - KeyCombination keyCombination = getKeyCombination(binding); - return checkKeyCombinationEquality(keyCombination, keyEvent); - } - - /** - * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences, but adapted for Mac - * users, with the Command key preferred instead of Control. - * TODO: Move to OS.java? Or replace with portable Java key codes, i.e. KeyEvent - */ - private KeyStroke getKeyForMac(KeyStroke ks) { - if (ks == null) { - return null; - } - int keyCode = ks.getKeyCode(); - if ((ks.getModifiers() & InputEvent.CTRL_MASK) == 0) { - return ks; - } else { - int modifiers = 0; - if ((ks.getModifiers() & InputEvent.SHIFT_MASK) != 0) { - modifiers = modifiers | InputEvent.SHIFT_MASK; - } - if ((ks.getModifiers() & InputEvent.ALT_MASK) != 0) { - modifiers = modifiers | InputEvent.ALT_MASK; - } - - if (shortcutMask == -1) { - try { - shortcutMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - } catch (AWTError | HeadlessException e) { - LOGGER.warn("Problem geting shortcut mask", e); - } - } - - return KeyStroke.getKeyStroke(keyCode, shortcutMask + modifiers); - } - } - - /** - * Stores new key bindings into Preferences, provided they actually differ from the old ones. - */ - public void setNewKeyBindings(SortedMap newBindings) { - if (!newBindings.equals(keyBindingRepository.getKeyBindings())) { - // This confirms that the bindings have actually changed. - List bindNames = newBindings.keySet().stream().map(KeyBinding::getKey).collect(Collectors.toList()); - List bindings = new ArrayList<>(newBindings.values()); - prefs.putStringList(JabRefPreferences.BIND_NAMES, bindNames); - prefs.putStringList(JabRefPreferences.BINDINGS, bindings); - keyBindingRepository.overwriteBindings(newBindings); - } - } - - private void restoreKeyBindings() { - // First read the bindings, and their names. - List bindNames = prefs.getStringList(JabRefPreferences.BIND_NAMES); - List bindings = prefs.getStringList(JabRefPreferences.BINDINGS); - - // Then set up the key bindings HashMap. - if ((bindNames.isEmpty()) || (bindings.isEmpty()) || (bindNames.size() != bindings.size())) { - // Nothing defined in Preferences, or something is wrong. - keyBindingRepository = new KeyBindingRepository(); - return; - } - - for (int i = 0; i < bindNames.size(); i++) { - keyBindingRepository.put(bindNames.get(i), bindings.get(i)); - } - } - - - /** - * Returns the HashMap containing all key bindings. - */ - public SortedMap getKeyBindings() { - return keyBindingRepository.getKeyBindings(); - } -} diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingRepository.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingRepository.java index 3a830150008..7c23c772c6c 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingRepository.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingRepository.java @@ -1,26 +1,56 @@ package org.jabref.gui.keyboard; +import java.awt.AWTError; +import java.awt.HeadlessException; +import java.awt.Toolkit; +import java.awt.event.InputEvent; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import java.util.Optional; import java.util.SortedMap; import java.util.TreeMap; +import java.util.stream.Collectors; + +import javax.swing.KeyStroke; + +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyCombination; +import javafx.scene.input.KeyEvent; + +import org.jabref.logic.util.OS; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; public class KeyBindingRepository { + private static final Log LOGGER = LogFactory.getLog(KeyBindingRepository.class); /** * sorted by localization */ private final SortedMap bindings; + private int shortcutMask = -1; public KeyBindingRepository() { - bindings = new TreeMap<>((k1, k2) -> k1.getLocalization().compareTo(k2.getLocalization())); - for (KeyBinding keyBinding : KeyBinding.values()) { - bindings.put(keyBinding, keyBinding.getDefaultBinding()); - } + this(Collections.emptyList(), Collections.emptyList()); } - public KeyBindingRepository(SortedMap bindings) { - this.bindings = bindings; + public KeyBindingRepository(List bindNames, List bindings) { + this.bindings = new TreeMap<>(Comparator.comparing(KeyBinding::getLocalization)); + + if ((bindNames.isEmpty()) || (bindings.isEmpty()) || (bindNames.size() != bindings.size())) { + // Use default key bindings + for (KeyBinding keyBinding : KeyBinding.values()) { + put(keyBinding, keyBinding.getDefaultBinding()); + } + } else { + for (int i = 0; i < bindNames.size(); i++) { + put(bindNames.get(i), bindings.get(i)); + } + } } public Optional get(KeyBinding key) { @@ -29,26 +59,24 @@ public Optional get(KeyBinding key) { public String get(String key) { Optional keyBinding = getKeyBinding(key); - Optional result = keyBinding.flatMap(k -> Optional.ofNullable(bindings.get(k))); + Optional result = keyBinding.flatMap(k -> Optional.ofNullable(bindings.get(k))); - if(result.isPresent()) { + if (result.isPresent()) { return result.get(); - } else if(keyBinding.isPresent()){ + } else if (keyBinding.isPresent()) { return keyBinding.get().getDefaultBinding(); } else { return "Not associated"; } } + /** + * Returns the HashMap containing all key bindings. + */ public SortedMap getKeyBindings() { return new TreeMap<>(bindings); } - public void overwriteBindings(SortedMap newBindings) { - bindings.clear(); - newBindings.forEach(this::put); - } - public void put(KeyBinding key, String value) { getKeyBinding(key).ifPresent(binding -> bindings.put(binding, value)); } @@ -77,4 +105,104 @@ public int size() { return this.bindings.size(); } + /** + * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences. + */ + public KeyStroke getKey(KeyBinding bindName) { + + String s = get(bindName.getKey()); + + if (OS.OS_X) { + return getKeyForMac(KeyStroke.getKeyStroke(s)); + } else { + return KeyStroke.getKeyStroke(s); + } + } + + private KeyCombination getKeyCombination(KeyBinding bindName) { + String binding = get(bindName.getKey()); + return KeyCombination.valueOf(binding); + } + + /** + * Check if the given keyCombination equals the given keyEvent + * + * @param combination as KeyCombination + * @param keyEvent as KeEvent + * @return true if matching, else false + */ + public boolean checkKeyCombinationEquality(KeyCombination combination, KeyEvent keyEvent) { + KeyCode code = keyEvent.getCode(); + if (code == KeyCode.UNDEFINED) { + return false; + } + // gather the pressed modifier keys + String modifiers = ""; + if (keyEvent.isControlDown()) { + modifiers = "ctrl"; + } + if (keyEvent.isShiftDown()) { + modifiers += " shift"; + } + if (keyEvent.isAltDown()) { + modifiers += " alt"; + } + modifiers = modifiers.trim(); + String newShortcut = (modifiers.isEmpty()) ? code.toString() : modifiers + " " + code; + KeyCombination pressedCombination = KeyCombination.valueOf(newShortcut); + return combination.equals(pressedCombination); + } + + /** + * Check if the given KeyBinding equals the given keyEvent + * + * @param binding as KeyBinding + * @param keyEvent as KeEvent + * @return true if matching, else false + */ + public boolean checkKeyCombinationEquality(KeyBinding binding, KeyEvent keyEvent) { + KeyCombination keyCombination = getKeyCombination(binding); + return checkKeyCombinationEquality(keyCombination, keyEvent); + } + + /** + * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences, but adapted for Mac + * users, with the Command key preferred instead of Control. + * TODO: Move to OS.java? Or replace with portable Java key codes, i.e. KeyEvent + */ + private KeyStroke getKeyForMac(KeyStroke ks) { + if (ks == null) { + return null; + } + int keyCode = ks.getKeyCode(); + if ((ks.getModifiers() & InputEvent.CTRL_MASK) == 0) { + return ks; + } else { + int modifiers = 0; + if ((ks.getModifiers() & InputEvent.SHIFT_MASK) != 0) { + modifiers = modifiers | InputEvent.SHIFT_MASK; + } + if ((ks.getModifiers() & InputEvent.ALT_MASK) != 0) { + modifiers = modifiers | InputEvent.ALT_MASK; + } + + if (shortcutMask == -1) { + try { + shortcutMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + } catch (AWTError | HeadlessException e) { + LOGGER.warn("Problem geting shortcut mask", e); + } + } + + return KeyStroke.getKeyStroke(keyCode, shortcutMask + modifiers); + } + } + + public List getBindNames() { + return bindings.keySet().stream().map(KeyBinding::getKey).collect(Collectors.toList()); + } + + public List getBindings() { + return new ArrayList<>(bindings.values()); + } } diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingViewModel.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingViewModel.java index a87993ce2b2..95152ae1c66 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingViewModel.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingViewModel.java @@ -24,17 +24,12 @@ public class KeyBindingViewModel { private KeyBinding keyBinding = null; private String realBinding = ""; - private final SimpleStringProperty displayName = new SimpleStringProperty(); - private final SimpleStringProperty shownBinding = new SimpleStringProperty(); - private final KeyBindingCategory category; - - public ObservableList getChildren() { - return children; - } - private ObservableList children = FXCollections.observableArrayList(); private KeyBindingRepository keyBindingRepository; + private final SimpleStringProperty displayName = new SimpleStringProperty(); + private final SimpleStringProperty shownBinding = new SimpleStringProperty(); + private final KeyBindingCategory category; public KeyBindingViewModel(KeyBindingRepository keyBindingRepository, KeyBinding keyBinding, String binding) { this(keyBindingRepository, keyBinding.getCategory()); @@ -49,6 +44,10 @@ public KeyBindingViewModel(KeyBindingRepository keyBindingRepository, KeyBinding setDisplayName(); } + public ObservableList getChildren() { + return children; + } + public KeyBinding getKeyBinding() { return keyBinding; } diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogController.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogController.java index 74a68b9f88b..21767bb255d 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogController.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogController.java @@ -14,6 +14,7 @@ import org.jabref.gui.IconTheme; import org.jabref.gui.util.RecursiveTreeItem; import org.jabref.gui.util.ViewModelTreeTableCellFactory; +import org.jabref.preferences.PreferencesService; import org.fxmisc.easybind.EasyBind; @@ -24,12 +25,13 @@ public class KeyBindingsDialogController extends AbstractController shortcutColumn; @FXML private TreeTableColumn resetColumn; - @Inject private KeyBindingPreferences keyBindingPreferences; + @Inject private KeyBindingRepository keyBindingRepository; @Inject private DialogService dialogService; + @Inject private PreferencesService preferences; @FXML private void initialize() { - viewModel = new KeyBindingsDialogViewModel(keyBindingPreferences, dialogService); + viewModel = new KeyBindingsDialogViewModel(keyBindingRepository, dialogService, preferences); keyBindingsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); viewModel.selectedKeyBindingProperty().bind( diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java index 1eb4f203687..c0f3c414af0 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java @@ -12,31 +12,31 @@ import org.jabref.gui.AbstractViewModel; import org.jabref.gui.DialogService; import org.jabref.logic.l10n.Localization; +import org.jabref.preferences.PreferencesService; public class KeyBindingsDialogViewModel extends AbstractViewModel { - private final KeyBindingPreferences keyBindingPreferences; - private KeyBindingRepository keyBindingRepository; + private final KeyBindingRepository keyBindingRepository; + private final PreferencesService preferences; + private final ObjectProperty selectedKeyBinding = new SimpleObjectProperty<>(); + private final ObjectProperty rootKeyBinding = new SimpleObjectProperty<>(); private DialogService dialogService; + public KeyBindingsDialogViewModel(KeyBindingRepository keyBindingRepository, DialogService dialogService, PreferencesService preferences) { + this.keyBindingRepository = Objects.requireNonNull(keyBindingRepository); + this.dialogService = Objects.requireNonNull(dialogService); + this.preferences = Objects.requireNonNull(preferences); + populateTable(); + } + public ObjectProperty selectedKeyBindingProperty() { return selectedKeyBinding; } - private final ObjectProperty selectedKeyBinding = new SimpleObjectProperty<>(); - private final ObjectProperty rootKeyBinding = new SimpleObjectProperty<>(); - public ObjectProperty rootKeyBindingProperty() { return rootKeyBinding; } - public KeyBindingsDialogViewModel(KeyBindingPreferences keyBindingPreferences, DialogService dialogService) { - this.keyBindingPreferences = Objects.requireNonNull(keyBindingPreferences); - this.dialogService = Objects.requireNonNull(dialogService); - keyBindingRepository = new KeyBindingRepository(keyBindingPreferences.getKeyBindings()); - populateTable(); - } - /** * Read all keybindings from the keybinding repository and create table keybinding models for them */ @@ -71,7 +71,7 @@ public void setNewBindingForCurrent(KeyEvent event) { } public void saveKeyBindings() { - keyBindingPreferences.setNewKeyBindings(keyBindingRepository.getKeyBindings()); + preferences.storeKeyBindingRepository(keyBindingRepository); String title = Localization.lang("Key bindings changed"); String content = Localization.lang("Your new key bindings have been stored.") + '\n' diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index fbb438d2a7e..ea754e6fd24 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -63,43 +63,43 @@ import org.apache.commons.logging.LogFactory; public class MainTable extends JTable { - private static final Log LOGGER = LogFactory.getLog(MainTable.class); + private static GeneralRenderer defRenderer; + private static GeneralRenderer reqRenderer; + private static GeneralRenderer optRenderer; + private static GeneralRenderer resolvedRenderer; + private static GeneralRenderer grayedOutRenderer; + private static GeneralRenderer veryGrayedOutRenderer; + + private static List markedRenderers; + + private static IncompleteRenderer incRenderer; + private static CompleteRenderer compRenderer; + private static CompleteRenderer grayedOutNumberRenderer; + private static CompleteRenderer veryGrayedOutNumberRenderer; + + private static List markedNumberRenderers; + private static final Log LOGGER = LogFactory.getLog(MainTable.class); private final MainTableFormat tableFormat; - private final BasePanel panel; + private final BasePanel panel; private final boolean tableColorCodes; private final boolean tableResolvedColorCodes; private final DefaultEventSelectionModel localSelectionModel; private final TableComparatorChooser comparatorChooser; - private final JScrollPane pane; + private final JScrollPane pane; // needed to activate/deactivate the listener private final PersistenceTableColumnListener tableColumnListener; - private final MainTableDataModel model; + private final MainTableDataModel model; // Enum used to define how a cell should be rendered. private enum CellRendererMode { REQUIRED, RESOLVED, OPTIONAL, OTHER - } - private static GeneralRenderer defRenderer; - private static GeneralRenderer reqRenderer; - private static GeneralRenderer optRenderer; - private static GeneralRenderer resolvedRenderer; - private static GeneralRenderer grayedOutRenderer; - private static GeneralRenderer veryGrayedOutRenderer; - - private static List markedRenderers; - - private static IncompleteRenderer incRenderer; - private static CompleteRenderer compRenderer; - private static CompleteRenderer grayedOutNumberRenderer; - private static CompleteRenderer veryGrayedOutNumberRenderer; - - private static List markedNumberRenderers; + } static { MainTable.updateRenderers(); diff --git a/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java b/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java index 68e2640c9b5..3fc3065d8ac 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java @@ -171,7 +171,7 @@ SortedList getSortedForUserDefinedTableColumnSorting() { } public void updateGroupFilter() { - if(getGroupingState() == DisplayOption.FILTER) { + if (getGroupingState() == DisplayOption.FILTER) { filterGroupToggle.start(); } else { filterGroupToggle.stop(); diff --git a/src/main/java/org/jabref/gui/maintable/MainTableFormat.java b/src/main/java/org/jabref/gui/maintable/MainTableFormat.java index 6b10c668316..2dda88ae52f 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableFormat.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableFormat.java @@ -126,7 +126,6 @@ public void updateTableFormat() { tableColumns.add(new MainTableColumn(columnName, Arrays.asList(fields), database)); } - // Add the "special" icon columns (e.g., ranking, file, ...) that are enabled in preferences. if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) { if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RANKING)) { @@ -149,7 +148,6 @@ public void updateTableFormat() { } } - } } diff --git a/src/main/java/org/jabref/gui/maintable/MainTableNameFormatter.java b/src/main/java/org/jabref/gui/maintable/MainTableNameFormatter.java index d04994bbdf2..a9c222a0bbf 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableNameFormatter.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableNameFormatter.java @@ -6,8 +6,8 @@ public class MainTableNameFormatter { - private MainTableNameFormatter(){} - + private MainTableNameFormatter() { } + /** * Format a name field for the table, according to user preferences. * diff --git a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java b/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java index 8c449f1c3f3..29980ede4d6 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java @@ -81,7 +81,7 @@ public MainTableSelectionListener(BasePanel panel, MainTable table) { this.panel = panel; this.tableRows = table.getTableModel().getTableRows(); PreviewPanel previewPanel = panel.getPreviewPanel(); - if (previewPanel != null){ + if (previewPanel != null) { preview = previewPanel; } else { preview = new PreviewPanel(panel.getBibDatabaseContext(), null, panel); @@ -100,7 +100,7 @@ public void listChanged(ListEvent e) { } EventList selected = e.getSourceList(); - if (selected.isEmpty()){ + if (selected.isEmpty()) { return; } @@ -370,8 +370,8 @@ private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn colum // 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(!column.getBibtexFields().isEmpty()) { - for(String field : column.getBibtexFields()) { + if (!column.getBibtexFields().isEmpty()) { + for (String field : column.getBibtexFields()) { if (FieldName.FILE.equals(field)) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); @@ -455,11 +455,11 @@ public void setPreviewActive(boolean enabled) { } } - public void nextPreviewStyle(){ + public void nextPreviewStyle() { cyclePreview(Globals.prefs.getPreviewPreferences().getPreviewCyclePosition() + 1); } - public void previousPreviewStyle(){ + public void previousPreviewStyle() { cyclePreview(Globals.prefs.getPreviewPreferences().getPreviewCyclePosition() - 1); } diff --git a/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java b/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java index dd2a8da0f6e..538d9ac695f 100644 --- a/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java +++ b/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java @@ -27,14 +27,14 @@ */ public class PersistenceTableColumnListener implements TableColumnModelListener { + private static final String RECEIVED_NULL_EVENT = " received null event"; + private static final String SIMPLE_CLASS_NAME = PersistenceTableColumnListener.class.getSimpleName(); // needed to get column names / indices mapped from view to model // and to access the table model private final MainTable mainTable; - private static final String RECEIVED_NULL_EVENT = " received null event"; - /** * @param mainTable */ diff --git a/src/main/java/org/jabref/gui/maintable/SpecialMainTableColumnsBuilder.java b/src/main/java/org/jabref/gui/maintable/SpecialMainTableColumnsBuilder.java index 89759212c12..415b3082fe5 100644 --- a/src/main/java/org/jabref/gui/maintable/SpecialMainTableColumnsBuilder.java +++ b/src/main/java/org/jabref/gui/maintable/SpecialMainTableColumnsBuilder.java @@ -165,7 +165,6 @@ public Object getColumnValue(BibEntry entry) { */ MainTableColumn createFileIconColumn(String externalFileTypeName) { - return new MainTableColumn(externalFileTypeName, Collections.singletonList(FieldName.FILE), new JLabel()) { @Override diff --git a/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java b/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java index dafde5aa47f..8cd9c4f3954 100644 --- a/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java +++ b/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java @@ -49,11 +49,12 @@ public JPopupMenu getChangeentryTypePopupMenu(BasePanel panel) { * Remove all types from the menu. Then cycle through all available * types, and add them. */ + private void populateChangeEntryTypeMenu(JMenu menu, BasePanel panel) { menu.removeAll(); // biblatex? - if(panel.getBibDatabaseContext().isBiblatexMode()) { + if (panel.getBibDatabaseContext().isBiblatexMode()) { for (EntryType type : EntryTypes.getAllValues(BibDatabaseMode.BIBLATEX)) { menu.add(new ChangeTypeAction(type, panel)); } @@ -71,7 +72,6 @@ private void populateChangeEntryTypeMenu(JMenu menu, BasePanel panel) { // ieeetran createEntryTypeSection(panel, menu, "IEEETran Entries", IEEETranEntryTypes.ALL); - List customTypes = EntryTypes.getAllCustomTypes(BibDatabaseMode.BIBTEX); if (!customTypes.isEmpty()) { menu.addSeparator(); @@ -87,7 +87,7 @@ private void createEntryTypeSection(BasePanel panel, JMenu menu, String title, L Font font = new Font(menu.getFont().getName(), Font.ITALIC, menu.getFont().getSize()); header.setFont(font); header.setEnabled(false); - if(!types.isEmpty()) { + if (!types.isEmpty()) { menu.add(header); } diff --git a/src/main/java/org/jabref/gui/menus/RightClickMenu.java b/src/main/java/org/jabref/gui/menus/RightClickMenu.java index fbf761aa9de..a72d4f3e977 100644 --- a/src/main/java/org/jabref/gui/menus/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/menus/RightClickMenu.java @@ -247,7 +247,6 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { groupMoveTo.setEnabled(groupsPresent); } - @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // Nothing to do @@ -273,7 +272,7 @@ private boolean isAnyFieldSetForSelectedEntry(List fieldnames) { private Icon getFileIconForSelectedEntry() { if (panel.getMainTable().getSelectedRowCount() == 1) { BibEntry entry = panel.getMainTable().getSelected().get(0); - if(entry.hasField(FieldName.FILE)) { + if (entry.hasField(FieldName.FILE)) { JLabel label = FileListTableModel.getFirstLabel(entry.getField(FieldName.FILE).get()); if (label != null) { return label.getIcon(); diff --git a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeWorker.java b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeWorker.java index 9053549b210..4ab8b3daac4 100644 --- a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeWorker.java +++ b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeWorker.java @@ -18,7 +18,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - public class FetchAndMergeWorker extends SwingWorker, Void> { private static final Log LOGGER = LogFactory.getLog(FetchAndMergeWorker.class); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java index cbf4a3e761d..c3cc49260a7 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java @@ -58,6 +58,17 @@ public class MergeEntries { private static final Log LOGGER = LogFactory.getLog(MergeEntries.class); + private static final String MARGIN = "10px"; + + private static final List HEADING_LABELS = new ArrayList<>(6); + + private static final CellConstraints CELL_CONSTRAINTS = new CellConstraints(); + private static final String[] DIFF_MODES = {Localization.lang("Plain text"), + Localization.lang("Show diff") + " - " + Localization.lang("word"), + Localization.lang("Show diff") + " - " + Localization.lang("character"), + Localization.lang("Show symmetric diff") + " - " + Localization.lang("word"), + Localization.lang("Show symmetric diff") + " - " + Localization.lang("character")}; + // Headings private final List columnHeadings = Arrays.asList(Localization.lang("Field"), Localization.lang("Left entry"), @@ -65,12 +76,6 @@ public class MergeEntries { Localization.lang("None"), Localization.lang("Right"), Localization.lang("Right entry")); - private static final String[] DIFF_MODES = {Localization.lang("Plain text"), - Localization.lang("Show diff") + " - " + Localization.lang("word"), - Localization.lang("Show diff") + " - " + Localization.lang("character"), - Localization.lang("Show symmetric diff") + " - " + Localization.lang("word"), - Localization.lang("Show symmetric diff") + " - " + Localization.lang("character")}; - private final Set identicalFields = new HashSet<>(); private final Set differentFields = new HashSet<>(); private final BibEntry mergedEntry = new BibEntry(); @@ -87,16 +92,11 @@ public class MergeEntries { private final JComboBox diffMode = new JComboBox<>(); private final Map leftTextPanes = new HashMap<>(); private final Map rightTextPanes = new HashMap<>(); + private final Map> radioButtons = new HashMap<>(); private final JPanel mainPanel = new JPanel(); - private static final String MARGIN = "10px"; - - private static final List HEADING_LABELS = new ArrayList<>(6); - - private static final CellConstraints CELL_CONSTRAINTS = new CellConstraints(); - /** @@ -166,7 +166,6 @@ private void initialize() { int maxLabelWidth = setupFieldRows(mergePanel); - // Create and add scrollpane scrollPane = new JScrollPane(mergePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index dbb4200862e..3ecc385a7dd 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -29,11 +29,11 @@ */ public class MergeEntriesDialog extends JabRefDialog { - private final BasePanel panel; - private final CellConstraints cc = new CellConstraints(); - private static final String MERGE_ENTRIES = Localization.lang("Merge entries"); private static final String MARGIN = "5px"; + private final BasePanel panel; + + private final CellConstraints cc = new CellConstraints(); public MergeEntriesDialog(BasePanel panel) { super(panel.frame(), MERGE_ENTRIES, true, MergeEntriesDialog.class); @@ -112,7 +112,6 @@ private void init(List selected) { layout.insertRow(1, RowSpec.decode(MARGIN)); layout.insertColumn(1, ColumnSpec.decode(MARGIN)); - WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeFetchedEntryDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeFetchedEntryDialog.java index 10d801bea46..abf8ff23ac9 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeFetchedEntryDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeFetchedEntryDialog.java @@ -32,6 +32,7 @@ */ public class MergeFetchedEntryDialog extends JabRefDialog { + private static final String MARGIN = "5px"; private final BasePanel panel; private final CellConstraints cc = new CellConstraints(); private final BibEntry originalEntry; @@ -39,7 +40,6 @@ public class MergeFetchedEntryDialog extends JabRefDialog { private NamedCompound ce; private MergeEntries mergeEntries; private final String type; - private static final String MARGIN = "5px"; public MergeFetchedEntryDialog(BasePanel panel, BibEntry originalEntry, BibEntry fetchedEntry, String type) { @@ -94,7 +94,7 @@ private void init() { } private class CancelAction extends AbstractAction { - CancelAction(){ + CancelAction() { putValue(Action.NAME, Localization.lang("Cancel")); } @@ -106,7 +106,7 @@ public void actionPerformed(ActionEvent e) { } private class ReplaceAction extends AbstractAction { - ReplaceAction(){ + ReplaceAction() { putValue(Action.NAME, Localization.lang("Replace original entry")); } @@ -123,7 +123,7 @@ public void actionPerformed(ActionEvent e) { String oldType = originalEntry.getType(); String newType = mergedEntry.getType(); - if(!oldType.equalsIgnoreCase(newType)) { + if (!oldType.equalsIgnoreCase(newType)) { originalEntry.setType(newType); ce.addEdit(new UndoableChangeType(originalEntry, oldType, newType)); edited = true; diff --git a/src/main/java/org/jabref/gui/openoffice/CitationManager.java b/src/main/java/org/jabref/gui/openoffice/CitationManager.java index 647f23dced5..47a90885688 100644 --- a/src/main/java/org/jabref/gui/openoffice/CitationManager.java +++ b/src/main/java/org/jabref/gui/openoffice/CitationManager.java @@ -48,13 +48,13 @@ */ class CitationManager { + private static final Log LOGGER = LogFactory.getLog(CitationManager.class); private final OOBibBase ooBase; private final JDialog diag; private final EventList list; private final JTable table; - private final DefaultEventTableModel tableModel; - private static final Log LOGGER = LogFactory.getLog(CitationManager.class); + private final DefaultEventTableModel tableModel; public CitationManager(final JabRefFrame frame, OOBibBase ooBase) @@ -133,8 +133,6 @@ public void showDialog() { diag.setVisible(true); } - - private static class CitationEntryFormat implements TableFormat { @Override diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java index 384be7ac7bc..cefd592556d 100644 --- a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java +++ b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java @@ -110,6 +110,7 @@ class OOBibBase { private static final int AUTHORYEAR_INTEXT = 2; private static final int INVISIBLE_CIT = 3; + private static final Log LOGGER = LogFactory.getLog(OOBibBase.class); private XMultiServiceFactory mxDocFactory; private XTextDocument mxDoc; private XText text; @@ -117,24 +118,23 @@ class OOBibBase { private XTextViewCursorSupplier xViewCursorSupplier; private XComponent xCurrentComponent; private XPropertySet propertySet; - private XPropertyContainer userProperties; + private XPropertyContainer userProperties; private final boolean atEnd; private final Comparator entryComparator; private final Comparator yearAuthorTitleComparator; private final FieldComparator authComp = new FieldComparator(FieldName.AUTHOR); private final FieldComparator yearComp = new FieldComparator(FieldName.YEAR); - private final FieldComparator titleComp = new FieldComparator(FieldName.TITLE); + private final FieldComparator titleComp = new FieldComparator(FieldName.TITLE); private final List> authorYearTitleList = new ArrayList<>(3); + private final List> yearAuthorTitleList = new ArrayList<>(3); private final Map uniquefiers = new HashMap<>(); private List sortedReferenceMarks; - private static final Log LOGGER = LogFactory.getLog(OOBibBase.class); - public OOBibBase(String pathToOO, boolean atEnd) throws IOException, IllegalAccessException, InvocationTargetException, BootstrapException, CreationException, UnknownPropertyException, @@ -1025,7 +1025,7 @@ private void createBibTextSection2(boolean end) // Create a new TextSection from the document factory and access it's XNamed interface XNamed xChildNamed; try { - xChildNamed= UnoRuntime.queryInterface(XNamed.class, + xChildNamed = UnoRuntime.queryInterface(XNamed.class, mxDocFactory.createInstance("com.sun.star.text.TextSection")); } catch (Exception e) { throw new CreationException(e.getMessage()); @@ -1344,7 +1344,6 @@ public int hashCode() { } - public BibDatabase generateDatabase(List databases) throws NoSuchElementException, WrappedTargetException { BibDatabase resultDatabase = new BibDatabase(); diff --git a/src/main/java/org/jabref/gui/plaintextimport/TagToMarkedTextStore.java b/src/main/java/org/jabref/gui/plaintextimport/TagToMarkedTextStore.java index ec13194e303..9b191abdd1e 100644 --- a/src/main/java/org/jabref/gui/plaintextimport/TagToMarkedTextStore.java +++ b/src/main/java/org/jabref/gui/plaintextimport/TagToMarkedTextStore.java @@ -57,7 +57,6 @@ public void setStyleForTag(String tag, String style, StyledDocument doc) { } } - private static class TMarkedStoreItem { private final int start; diff --git a/src/main/java/org/jabref/gui/plaintextimport/TextInputDialog.java b/src/main/java/org/jabref/gui/plaintextimport/TextInputDialog.java index b684e0429ca..6ce4035ede6 100644 --- a/src/main/java/org/jabref/gui/plaintextimport/TextInputDialog.java +++ b/src/main/java/org/jabref/gui/plaintextimport/TextInputDialog.java @@ -522,7 +522,6 @@ private String[] getAllFields() { return allFields.toArray(new String[allFields.size()]); } - private class PasteAction extends BasicAction { public PasteAction() { @@ -598,7 +597,6 @@ class FieldListSelectionHandler implements ListSelectionListener { private int lastIndex = -1; - @Override public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); diff --git a/src/main/java/org/jabref/gui/preftabs/AdvancedTab.java b/src/main/java/org/jabref/gui/preftabs/AdvancedTab.java index ae967c7fcf7..d83cdcc85b5 100644 --- a/src/main/java/org/jabref/gui/preftabs/AdvancedTab.java +++ b/src/main/java/org/jabref/gui/preftabs/AdvancedTab.java @@ -14,6 +14,7 @@ import org.jabref.gui.help.HelpAction; import org.jabref.gui.remote.JabRefMessageHandler; import org.jabref.logic.help.HelpFile; +import org.jabref.logic.journals.JournalAbbreviationPreferences; import org.jabref.logic.l10n.Localization; import org.jabref.logic.remote.RemotePreferences; import org.jabref.logic.remote.RemoteUtil; @@ -95,16 +96,18 @@ public AdvancedTab(JabRefPreferences prefs) { public void setValues() { useRemoteServer.setSelected(remotePreferences.useRemoteServer()); remoteServerPort.setText(String.valueOf(remotePreferences.getPort())); - useIEEEAbrv.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_IEEE_ABRV)); + useIEEEAbrv.setSelected(Globals.prefs.getJournalAbbreviationPreferences().useIEEEAbbreviations()); useCaseKeeperOnSearch.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)); useUnitFormatterOnSearch.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH)); } @Override public void storeSettings() { - if (preferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV) != useIEEEAbrv.isSelected()) { - preferences.putBoolean(JabRefPreferences.USE_IEEE_ABRV, useIEEEAbrv.isSelected()); - Globals.journalAbbreviationLoader.update(Globals.prefs.getJournalAbbreviationPreferences()); + JournalAbbreviationPreferences journalAbbreviationPreferences = Globals.prefs.getJournalAbbreviationPreferences(); + if (journalAbbreviationPreferences.useIEEEAbbreviations() != useIEEEAbrv.isSelected()) { + journalAbbreviationPreferences.setUseIEEEAbbreviations(useIEEEAbrv.isSelected()); + Globals.prefs.storeJournalAbbreviationPreferences(journalAbbreviationPreferences); + Globals.journalAbbreviationLoader.update(journalAbbreviationPreferences); } storeRemoteSettings(); diff --git a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java index 246917230fd..60a28465179 100644 --- a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java @@ -68,7 +68,7 @@ public static List getAvailableLookAndFeels() { // Try to find L&F Class.forName(l); lookAndFeels.add(l); - } catch (ClassNotFoundException|IllegalAccessError ignored) { + } catch (ClassNotFoundException | IllegalAccessError ignored) { // LookAndFeel class does not exist or we don't have rights to access it // Ignore it } @@ -164,9 +164,9 @@ public AppearancePrefsTab(JabRefPreferences prefs) { .add(new JLabel(" ")).xy(1,3) .add(new JLabel(Localization.lang("Menu and label font size") + ":")).xy(2,3) .add(fontSize).xy(4,3) - .add(new JLabel(Localization.lang("Size of large icons")+":")).xy(2, 5) + .add(new JLabel(Localization.lang("Size of large icons") + ":")).xy(2, 5) .add(largeIconsTextField).xy(4,5) - .add(new JLabel(Localization.lang("Size of small icons")+":")).xy(6, 5) + .add(new JLabel(Localization.lang("Size of small icons") + ":")).xy(6, 5) .add(smallIconsTextField).xy(8,5) .build(); @@ -289,7 +289,7 @@ public void storeSettings() { .concat(Localization.lang("You must restart JabRef for this to come into effect.")), Localization.lang("Changed font settings"), JOptionPane.WARNING_MESSAGE); } - } else if (overrideFonts.isSelected() != oldOverrideFontSize){ + } else if (overrideFonts.isSelected() != oldOverrideFontSize) { prefs.remove(JabRefPreferences.ICON_SIZE_SMALL); prefs.remove(JabRefPreferences.ICON_SIZE_LARGE); prefs.remove(JabRefPreferences.MENU_FONT_SIZE); diff --git a/src/main/java/org/jabref/gui/preftabs/ColorSetupPanel.java b/src/main/java/org/jabref/gui/preftabs/ColorSetupPanel.java index a68a8b4fd51..41b6154016c 100644 --- a/src/main/java/org/jabref/gui/preftabs/ColorSetupPanel.java +++ b/src/main/java/org/jabref/gui/preftabs/ColorSetupPanel.java @@ -79,12 +79,12 @@ public ColorSetupPanel(JCheckBox colorCodes, JCheckBox resolvedColorCodes, JChec int col = 0; int row; for (ColorButton but : buttons) { - row = (2*(rowcnt/2)) + 1; // == 2*floor(rowcnt/2) + 1 - builder.add((JButton)but).xy((6*col)+1, row); - builder.add(but.getDefaultButton()).xy((6*col)+3, row); - builder.add(but.getName()).xy((6*col)+5, row); + row = (2 * (rowcnt / 2)) + 1; // == 2*floor(rowcnt/2) + 1 + builder.add((JButton)but).xy((6 * col) + 1, row); + builder.add(but.getDefaultButton()).xy((6 * col) + 3, row); + builder.add(but.getName()).xy((6 * col) + 5, row); but.addActionListener(new ColorButtonListener(but)); - col = 1-col; // Change 0 -> 1 -> 0 ... + col = 1 - col; // Change 0 -> 1 -> 0 ... rowcnt++; } @@ -108,7 +108,6 @@ public void storeSettings() { } } - static class ColorButtonListener implements ActionListener { private final ColorButton button; diff --git a/src/main/java/org/jabref/gui/preftabs/EntryEditorPrefsTab.java b/src/main/java/org/jabref/gui/preftabs/EntryEditorPrefsTab.java index 81ba43af6a2..55fd2aa5ed3 100644 --- a/src/main/java/org/jabref/gui/preftabs/EntryEditorPrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/EntryEditorPrefsTab.java @@ -118,7 +118,7 @@ public EntryEditorPrefsTab(JabRefPreferences prefs) { builder.add(autoComplete, cc.xy(2, 17)); DefaultFormBuilder builder3 = new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:150dlu","")); - JLabel label = new JLabel(Localization.lang("Use autocompletion for the following fields")+":"); + JLabel label = new JLabel(Localization.lang("Use autocompletion for the following fields") + ":"); builder3.append(label); builder3.append(autoCompFields); diff --git a/src/main/java/org/jabref/gui/preftabs/ExternalTab.java b/src/main/java/org/jabref/gui/preftabs/ExternalTab.java index fd71d472503..0f32dba10af 100644 --- a/src/main/java/org/jabref/gui/preftabs/ExternalTab.java +++ b/src/main/java/org/jabref/gui/preftabs/ExternalTab.java @@ -129,7 +129,7 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere pdfLayoutConstrains.gridx = 2; pdfOptionPanel.add(browseAdobeAcrobatReader, pdfLayoutConstrains); - if(OS.WINDOWS){ + if (OS.WINDOWS) { readerOptions.add(sumatraReader); browseSumatraReader.addActionListener(e -> showSumatraChooser()); pdfLayoutConstrains.gridy = 1; @@ -221,10 +221,10 @@ public void setValues() { consoleCommand.setText(Globals.prefs.get(JabRefPreferences.CONSOLE_COMMAND)); adobeAcrobatReaderPath.setText(Globals.prefs.get(JabRefPreferences.ADOBE_ACROBAT_COMMAND)); - if(OS.WINDOWS){ + if (OS.WINDOWS) { sumatraReaderPath.setText(Globals.prefs.get(JabRefPreferences.SUMATRA_PDF_COMMAND)); - if(Globals.prefs.get(JabRefPreferences.USE_PDF_READER).equals(adobeAcrobatReaderPath.getText())){ + if (Globals.prefs.get(JabRefPreferences.USE_PDF_READER).equals(adobeAcrobatReaderPath.getText())) { adobeAcrobatReader.setSelected(true); } else if (Globals.prefs.get(JabRefPreferences.USE_PDF_READER).equals(sumatraReaderPath.getText())) { sumatraReader.setSelected(true); @@ -242,7 +242,7 @@ public void storeSettings() { prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected()); prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText()); prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText()); - if(OS.WINDOWS) { + if (OS.WINDOWS) { prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText()); } readerSelected(); @@ -271,7 +271,7 @@ private void showConsoleChooser() { } } - private void showAdobeChooser(){ + private void showAdobeChooser() { JFileChooser adobeChooser = new JFileChooser(); int answer = adobeChooser.showOpenDialog(ExternalTab.this); if (answer == JFileChooser.APPROVE_OPTION) { @@ -288,7 +288,7 @@ private void showSumatraChooser() { } private void readerSelected() { - if(adobeAcrobatReader.isSelected()) { + if (adobeAcrobatReader.isSelected()) { prefs.put(JabRefPreferences.USE_PDF_READER, adobeAcrobatReaderPath.getText()); } else if (sumatraReader.isSelected()) { diff --git a/src/main/java/org/jabref/gui/preftabs/FontSelectorDialog.java b/src/main/java/org/jabref/gui/preftabs/FontSelectorDialog.java index f7b43589922..f743e93c9f1 100644 --- a/src/main/java/org/jabref/gui/preftabs/FontSelectorDialog.java +++ b/src/main/java/org/jabref/gui/preftabs/FontSelectorDialog.java @@ -113,15 +113,20 @@ Portions copyright (C) 1999 Jason Ginchereau public class FontSelectorDialog extends JabRefDialog { + /** + * For some reason the default Java fonts show up in the + * list with .bold, .bolditalic, and .italic extensions. + */ + private static final String[] HIDEFONTS = {".bold", ".italic"}; private static final String PLAIN = "plain"; private static final String BOLD = "bold"; private static final String BOLD_ITALIC = "bold-italic"; + private static final String ITALIC = "italic"; private static final String[] styles = {PLAIN, BOLD, ITALIC, BOLD_ITALIC}; private static final String[] sizes = {"9", "10", "12", "14", "16", "18", "24"}; - // private members private boolean isOK; private final JTextField familyField = new JTextField(); @@ -130,13 +135,8 @@ public class FontSelectorDialog extends JabRefDialog { private final JList sizeList = new JList<>(sizes); private final JTextField styleField = new JTextField(); private final JList styleList = new JList<>(styles); - private final JLabel preview; - /** - * For some reason the default Java fonts show up in the - * list with .bold, .bolditalic, and .italic extensions. - */ - private static final String[] HIDEFONTS = {".bold", ".italic"}; + private final JLabel preview; public FontSelectorDialog(Component comp, Font font) { @@ -261,8 +261,6 @@ public Optional getSelectedFont() { return Optional.of(new Font(familyField.getText(), styleList.getSelectedIndex(), size)); } - - private static String[] getFontList() { try { String[] nameArray = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); diff --git a/src/main/java/org/jabref/gui/preftabs/GeneralTab.java b/src/main/java/org/jabref/gui/preftabs/GeneralTab.java index 630a0ef71a2..cd9046ea57b 100644 --- a/src/main/java/org/jabref/gui/preftabs/GeneralTab.java +++ b/src/main/java/org/jabref/gui/preftabs/GeneralTab.java @@ -182,7 +182,7 @@ public void setValues() { inspectionWarnDupli.setSelected(prefs.getBoolean(JabRefPreferences.WARN_ABOUT_DUPLICATES_IN_INSPECTION)); markImportedEntries.setSelected(prefs.getBoolean(JabRefPreferences.MARK_IMPORTED_ENTRIES)); unmarkAllEntriesBeforeImporting.setSelected(prefs.getBoolean(JabRefPreferences.UNMARK_ALL_ENTRIES_BEFORE_IMPORTING)); - if(Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) { + if (Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) { biblatexMode.setSelectedItem(BibDatabaseMode.BIBLATEX); } else { biblatexMode.setSelectedItem(BibDatabaseMode.BIBTEX); diff --git a/src/main/java/org/jabref/gui/preftabs/ImportSettingsTab.java b/src/main/java/org/jabref/gui/preftabs/ImportSettingsTab.java index 7721c329a4d..75fd32434c8 100644 --- a/src/main/java/org/jabref/gui/preftabs/ImportSettingsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/ImportSettingsTab.java @@ -23,12 +23,12 @@ public class ImportSettingsTab extends JPanel implements PrefsTab { - public static final int DEFAULT_STYLE = ImportDialog.CONTENT; - - private static final String[] DEFAULT_FILENAMEPATTERNS_DISPLAY = new String[] {"bibtexkey", "bibtexkey - title",}; public static final String[] DEFAULT_FILENAMEPATTERNS = new String[] {"\\bibtexkey", "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; + public static final int DEFAULT_STYLE = ImportDialog.CONTENT; + private static final String[] DEFAULT_FILENAMEPATTERNS_DISPLAY = new String[] {"bibtexkey", "bibtexkey - title",}; + private final JabRefPreferences prefs; private final JRadioButton radioButtonXmp; private final JRadioButton radioButtonPDFcontent; diff --git a/src/main/java/org/jabref/gui/preftabs/NameFormatterTab.java b/src/main/java/org/jabref/gui/preftabs/NameFormatterTab.java index a0fd47fb8c7..13729c60779 100644 --- a/src/main/java/org/jabref/gui/preftabs/NameFormatterTab.java +++ b/src/main/java/org/jabref/gui/preftabs/NameFormatterTab.java @@ -42,7 +42,6 @@ public class NameFormatterTab extends JPanel implements PrefsTab { private final List tableRows = new ArrayList<>(10); - static class TableRow { private String name; @@ -211,7 +210,6 @@ public void setValues() { rowCount = tableRows.size() + 5; } - class DeleteRowAction extends AbstractAction { public DeleteRowAction() { diff --git a/src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java b/src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java index ec44edb1f8f..7cc66841421 100644 --- a/src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java @@ -33,7 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - public class PreviewPrefsTab extends JPanel implements PrefsTab { private static final Log LOGGER = LogFactory.getLog(PreviewPrefsTab.class); @@ -63,7 +62,7 @@ public PreviewPrefsTab() { setupGui(); } - private void setupLogic(){ + private void setupLogic() { chosen.getSelectionModel().addListSelectionListener(event -> { boolean selectionEmpty = ((ListSelectionModel) event.getSource()).isSelectionEmpty(); btnLeft.setEnabled(!selectionEmpty); @@ -112,7 +111,6 @@ private void setupLogic(){ chosen.setSelectedIndices(ArrayUtils.toPrimitive(newSelectedIndices.toArray(new Integer[newSelectedIndices.size()]))); }); - btnDefault.addActionListener(event -> layout.setText(Globals.prefs.getPreviewPreferences() .getPreviewStyleDefault().replace("__NEWLINE__", "\n"))); @@ -132,7 +130,7 @@ private void setupLogic(){ }); } - private void setupGui(){ + private void setupGui() { JPanel chooseStyle = FormBuilder.create() .columns("0:grow, $lcgap, pref, $lcgap, 0:grow") .rows("pref, $lg, fill:pref:grow, $lg, pref:grow, $lg, pref:grow, $lg, pref:grow") @@ -184,7 +182,7 @@ public void setValues() { } availableModel.clear(); - if (!isPreviewChosen){ + if (!isPreviewChosen) { availableModel.addElement(Localization.lang("Preview")); } @@ -193,7 +191,7 @@ public void setValues() { btnUp.setEnabled(!chosen.isSelectionEmpty()); btnDown.setEnabled(!chosen.isSelectionEmpty()); - if (discoverCitationStyleWorker != null){ + if (discoverCitationStyleWorker != null) { discoverCitationStyleWorker.cancel(true); } @@ -204,7 +202,7 @@ protected List doInBackground() throws Exception { } @Override - public void done(){ + public void done() { if (this.isCancelled()) { return; } diff --git a/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java b/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java index 9d9ebe993cd..5176a32b1a3 100644 --- a/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java @@ -450,7 +450,6 @@ public void setValues() { } - class DeleteRowAction extends AbstractAction { public DeleteRowAction() { diff --git a/src/main/java/org/jabref/gui/preftabs/XmpPrefsTab.java b/src/main/java/org/jabref/gui/preftabs/XmpPrefsTab.java index fde40e04db4..81e5fb10fde 100644 --- a/src/main/java/org/jabref/gui/preftabs/XmpPrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/XmpPrefsTab.java @@ -151,7 +151,6 @@ public void setValueAt(Object value, int row, int col) { add(pan, BorderLayout.CENTER); } - class DeleteRowAction extends AbstractAction { public DeleteRowAction() { diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationButton.java b/src/main/java/org/jabref/gui/push/PushToApplicationButton.java index 57bc3488509..4bf755a0c68 100644 --- a/src/main/java/org/jabref/gui/push/PushToApplicationButton.java +++ b/src/main/java/org/jabref/gui/push/PushToApplicationButton.java @@ -44,6 +44,7 @@ */ public class PushToApplicationButton implements ActionListener { + private static final Icon ARROW_ICON = IconTheme.JabRefIcon.DOWN.getSmallIcon(); private final JabRefFrame frame; private final List pushActions; private JPanel comp; @@ -52,7 +53,6 @@ public class PushToApplicationButton implements ActionListener { private JPopupMenu popup; private final Map actions = new HashMap<>(); private final Dimension buttonDim = new Dimension(23, 23); - private static final Icon ARROW_ICON = IconTheme.JabRefIcon.DOWN.getSmallIcon(); private final MenuAction mAction = new MenuAction(); private final JPopupMenu optPopup = new JPopupMenu(); private final JMenuItem settings = new JMenuItem(Localization.lang("Settings")); @@ -181,7 +181,6 @@ public void actionPerformed(ActionEvent e) { action.actionPerformed(new ActionEvent(toApp, 0, "push")); } - private static class BooleanHolder { public boolean value; @@ -192,7 +191,6 @@ public BooleanHolder(boolean value) { } } - public static void showSettingsDialog(JFrame parent, PushToApplication toApp, JPanel options) { final BooleanHolder okPressed = new BooleanHolder(false); @@ -237,7 +235,6 @@ public void actionPerformed(ActionEvent e) { } } - class PopupItemActionListener implements ActionListener { private final PushToApplication application; diff --git a/src/main/java/org/jabref/gui/push/PushToEmacs.java b/src/main/java/org/jabref/gui/push/PushToEmacs.java index f8c39aebd0b..7dacedf2a97 100644 --- a/src/main/java/org/jabref/gui/push/PushToEmacs.java +++ b/src/main/java/org/jabref/gui/push/PushToEmacs.java @@ -29,7 +29,6 @@ public class PushToEmacs extends AbstractPushToApplication implements PushToAppl private final JTextField additionalParams = new JTextField(30); - @Override public String getApplicationName() { return "Emacs"; diff --git a/src/main/java/org/jabref/gui/push/PushToLyx.java b/src/main/java/org/jabref/gui/push/PushToLyx.java index 646744cb5d0..f766c3573f6 100644 --- a/src/main/java/org/jabref/gui/push/PushToLyx.java +++ b/src/main/java/org/jabref/gui/push/PushToLyx.java @@ -27,7 +27,6 @@ public class PushToLyx extends AbstractPushToApplication implements PushToApplic private static final Log LOGGER = LogFactory.getLog(PushToLyx.class); - @Override public String getApplicationName() { return "LyX/Kile"; @@ -45,11 +44,11 @@ protected void initParameters() { @Override public void operationCompleted(BasePanel panel) { - if(couldNotConnect) { + if (couldNotConnect) { panel.output(Localization.lang("Error") + ": " + Localization.lang("verify that LyX is running and that the lyxpipe is valid") + ". [" + commandPath + "]"); - } else if(couldNotCall) { + } else if (couldNotCall) { panel.output(Localization.lang("Error") + ": " + Localization.lang("unable to write to") + " " + commandPath + ".in"); diff --git a/src/main/java/org/jabref/gui/push/PushToVim.java b/src/main/java/org/jabref/gui/push/PushToVim.java index 8cc57d9ba34..1077ec6dfa7 100644 --- a/src/main/java/org/jabref/gui/push/PushToVim.java +++ b/src/main/java/org/jabref/gui/push/PushToVim.java @@ -28,7 +28,6 @@ public class PushToVim extends AbstractPushToApplication implements PushToApplic private final JTextField vimServer = new JTextField(30); - @Override public String getApplicationName() { return "Vim"; diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index e6c8f7b44b8..53ba13620b0 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -307,7 +307,7 @@ private void clearSearch(BasePanel currentBasePanel) { currentBasePanel.setCurrentSearchQuery(null); } - if (dontSelectSearchBar){ + if (dontSelectSearchBar) { dontSelectSearchBar = false; return; } @@ -401,7 +401,7 @@ public void setSearchResultFrame(SearchResultFrame searchResultFrame) { } public void setSearchTerm(String searchTerm, boolean dontSelectSearchBar) { - if (searchTerm.equals(searchField.getText())){ + if (searchTerm.equals(searchField.getText())) { return; } diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchWorker.java b/src/main/java/org/jabref/gui/search/GlobalSearchWorker.java index a364df529b6..40ba9aee8bb 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchWorker.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchWorker.java @@ -18,7 +18,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - class GlobalSearchWorker extends SwingWorker>, Void> { private static final Log LOGGER = LogFactory.getLog(GlobalSearchWorker.class); diff --git a/src/main/java/org/jabref/gui/search/SearchResultFrame.java b/src/main/java/org/jabref/gui/search/SearchResultFrame.java index ffb43514da6..7df262a9585 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultFrame.java +++ b/src/main/java/org/jabref/gui/search/SearchResultFrame.java @@ -81,11 +81,6 @@ */ public class SearchResultFrame { - private static final Log LOGGER = LogFactory.getLog(SearchResultFrame.class); - - private final JabRefFrame frame; - - private JFrame searchResultFrame; private static final String[] FIELDS = new String[] { FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, FieldName.JOURNAL }; @@ -93,6 +88,11 @@ public class SearchResultFrame { private static final int FILE_COL = 1; private static final int URL_COL = 2; private static final int PAD = 3; + + private static final Log LOGGER = LogFactory.getLog(SearchResultFrame.class); + + private final JabRefFrame frame; + private JFrame searchResultFrame; private final JLabel fileLabel = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon()); private final JLabel urlLabel = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon()); @@ -390,27 +390,27 @@ private void addEntry(BibEntry entry, BasePanel panel) { entries.add(entry); entryHome.put(entry, panel); - if (preview.getEntry() == null || !preview.getBasePanel().isPresent()){ + if (preview.getEntry() == null || !preview.getBasePanel().isPresent()) { preview.setEntry(entry); preview.setBasePanel(panel); preview.setDatabaseContext(panel.getBibDatabaseContext()); } } - private void selectEntryInBasePanel(BibEntry entry){ + private void selectEntryInBasePanel(BibEntry entry) { BasePanel basePanel = entryHome.get(entry); frame.showBasePanel(basePanel); basePanel.requestFocus(); basePanel.highlightEntry(entry); } - public void dispose(){ + public void dispose() { frame.getGlobalSearchBar().setSearchResultFrame(null); searchResultFrame.dispose(); frame.getGlobalSearchBar().focus(); } - public void focus(){ + public void focus() { entryTable.requestFocus(); } @@ -567,7 +567,7 @@ public int getColumnCount() { public String getColumnName(int column) { if (column >= PAD) { return StringUtil.capitalizeFirst(FIELDS[column - PAD]); - } else if (column == DATABASE_COL){ + } else if (column == DATABASE_COL) { return Localization.lang("Library"); } else { return ""; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java index ef8abfcac31..bed9b589bc7 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java @@ -19,13 +19,13 @@ public class SpecialFieldAction implements BaseAction { + private static final Log LOGGER = LogFactory.getLog(SpecialFieldAction.class); private final JabRefFrame frame; private final SpecialField specialField; private final String value; private final boolean nullFieldIfValueIsTheSame; - private final String undoText; - private static final Log LOGGER = LogFactory.getLog(SpecialFieldAction.class); + private final String undoText; /** @@ -55,7 +55,7 @@ public void action() { for (BibEntry be : bes) { // if (value==null) and then call nullField has been omitted as updatefield also handles value==null List changes = SpecialFieldsUtils.updateField(specialField, value, be, nullFieldIfValueIsTheSame, Globals.prefs.isKeywordSyncEnabled(), Globals.prefs.getKeywordDelimiter()); - for(FieldChange change: changes) { + for (FieldChange change: changes) { ce.addEdit(new UndoableFieldChange(change)); } } diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDatabaseChangeListener.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDatabaseChangeListener.java index 1ede5e8007e..4b4f0d23e79 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDatabaseChangeListener.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDatabaseChangeListener.java @@ -34,7 +34,7 @@ public void listen(EntryAddedEvent event) { // NamedCompount code similar to SpecialFieldUpdateListener NamedCompound nc = new NamedCompound(Localization.lang("Synchronized special fields based on keywords")); List changes = SpecialFieldsUtils.syncSpecialFieldsFromKeywords(entry, Globals.prefs.getKeywordDelimiter()); - for(FieldChange change: changes) { + for (FieldChange change: changes) { nc.addEdit(new UndoableFieldChange(change)); } // Don't insert the compound into the undoManager, diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java index 636eb75656a..02e4d4d3966 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java @@ -18,7 +18,6 @@ import com.jgoodies.looks.HeaderStyle; import com.jgoodies.looks.Options; - public class SpecialFieldDropDown { private SpecialFieldDropDown() { @@ -46,7 +45,6 @@ public static JButton generateSpecialFieldButtonWithDropDown(SpecialField field, return button; } - private static class MenuButtonActionListener implements ActionListener { private JPopupMenu popup; @@ -80,7 +78,6 @@ public void actionPerformed(ActionEvent e) { popup.show(button, 0, dim.height); } - private class PopupitemActionListener implements ActionListener { private final BasePanel panel; diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java index 6afd56839da..df4fc097198 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java @@ -13,7 +13,7 @@ public class SpecialFieldValueViewModel { private final SpecialFieldValue value; - public SpecialFieldValueViewModel(SpecialFieldValue value){ + public SpecialFieldValueViewModel(SpecialFieldValue value) { Objects.requireNonNull(value); this.value = value; @@ -67,7 +67,7 @@ public JLabel createSpecialFieldValueLabel() { public String getMenuString() { - switch(value){ + switch (value) { case PRINTED: return Localization.lang("Toggle print status"); case CLEAR_PRIORITY: @@ -107,7 +107,7 @@ public String getMenuString() { public String getToolTipText() { - switch(value){ + switch (value) { case PRINTED: return Localization.lang("Toggle print status"); case CLEAR_PRIORITY: @@ -147,7 +147,7 @@ public String getToolTipText() { public String getActionName() { - switch(value){ + switch (value) { case PRINTED: return "togglePrinted"; case CLEAR_PRIORITY: diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java index d48f9051c13..dcace6e65bd 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java @@ -10,17 +10,16 @@ import org.jabref.model.entry.specialfields.SpecialField; import org.jabref.model.entry.specialfields.SpecialFieldValue; - public class SpecialFieldViewModel { private final SpecialField field; - public SpecialFieldViewModel(SpecialField field){ + public SpecialFieldViewModel(SpecialField field) { Objects.requireNonNull(field); this.field = field; } - public SpecialFieldAction getSpecialFieldAction(SpecialFieldValue value, JabRefFrame frame){ + public SpecialFieldAction getSpecialFieldAction(SpecialFieldValue value, JabRefFrame frame) { return new SpecialFieldAction(frame, field, value.getFieldValue().orElse(null), // if field contains only one value, it has to be nulled // otherwise, another setting does not empty the field @@ -47,7 +46,7 @@ public Icon getRepresentingIcon() { } } - public String getLocalization(){ + public String getLocalization() { switch (field) { case PRINTED: return Localization.lang("Printed"); diff --git a/src/main/java/org/jabref/gui/undo/AbstractUndoableJabRefEdit.java b/src/main/java/org/jabref/gui/undo/AbstractUndoableJabRefEdit.java index 3e692a3311f..fe9473ed8fb 100644 --- a/src/main/java/org/jabref/gui/undo/AbstractUndoableJabRefEdit.java +++ b/src/main/java/org/jabref/gui/undo/AbstractUndoableJabRefEdit.java @@ -4,7 +4,6 @@ import org.jabref.logic.l10n.Localization; - public class AbstractUndoableJabRefEdit extends AbstractUndoableEdit { @Override diff --git a/src/main/java/org/jabref/gui/undo/CountingUndoManager.java b/src/main/java/org/jabref/gui/undo/CountingUndoManager.java index 069dcc3ea1c..9cb372a29b1 100644 --- a/src/main/java/org/jabref/gui/undo/CountingUndoManager.java +++ b/src/main/java/org/jabref/gui/undo/CountingUndoManager.java @@ -47,7 +47,6 @@ public synchronized boolean hasChanged() { return (current != unchangedPoint); } - public void registerListener(Object object) { this.eventBus.register(object); postUndoRedoEvent(); // Send event to trigger changes diff --git a/src/main/java/org/jabref/gui/undo/UndoableInsertEntry.java b/src/main/java/org/jabref/gui/undo/UndoableInsertEntry.java index 0628dce10f4..b400199ae99 100644 --- a/src/main/java/org/jabref/gui/undo/UndoableInsertEntry.java +++ b/src/main/java/org/jabref/gui/undo/UndoableInsertEntry.java @@ -17,11 +17,11 @@ */ public class UndoableInsertEntry extends AbstractUndoableJabRefEdit { + private static final Log LOGGER = LogFactory.getLog(UndoableInsertEntry.class); private final BibDatabase base; private final BibEntry entry; - private final BasePanel panel; - private static final Log LOGGER = LogFactory.getLog(UndoableInsertEntry.class); + private final BasePanel panel; public UndoableInsertEntry(BibDatabase base, BibEntry entry, BasePanel panel) { @@ -30,7 +30,6 @@ public UndoableInsertEntry(BibDatabase base, BibEntry entry, this.panel = panel; } - @Override public String getPresentationName() { return Localization.lang("insert entry %0", diff --git a/src/main/java/org/jabref/gui/undo/UndoableRemoveEntry.java b/src/main/java/org/jabref/gui/undo/UndoableRemoveEntry.java index 72be753a90b..805dfc317f3 100644 --- a/src/main/java/org/jabref/gui/undo/UndoableRemoveEntry.java +++ b/src/main/java/org/jabref/gui/undo/UndoableRemoveEntry.java @@ -18,11 +18,11 @@ */ public class UndoableRemoveEntry extends AbstractUndoableJabRefEdit { + private static final Log LOGGER = LogFactory.getLog(UndoableRemoveEntry.class); private final BibDatabase base; private final BibEntry entry; - private final BasePanel panel; - private static final Log LOGGER = LogFactory.getLog(UndoableRemoveEntry.class); + private final BasePanel panel; public UndoableRemoveEntry(BibDatabase base, BibEntry entry, BasePanel panel) { diff --git a/src/main/java/org/jabref/gui/undo/UndoableRemoveString.java b/src/main/java/org/jabref/gui/undo/UndoableRemoveString.java index 5eadbb423fc..57e0bc5ddf4 100644 --- a/src/main/java/org/jabref/gui/undo/UndoableRemoveString.java +++ b/src/main/java/org/jabref/gui/undo/UndoableRemoveString.java @@ -12,11 +12,11 @@ public class UndoableRemoveString extends AbstractUndoableJabRefEdit { + private static final Log LOGGER = LogFactory.getLog(UndoableRemoveString.class); private final BibDatabase base; private final BibtexString string; - private final BasePanel panel; - private static final Log LOGGER = LogFactory.getLog(UndoableRemoveString.class); + private final BasePanel panel; public UndoableRemoveString(BasePanel panel, BibDatabase base, BibtexString string) { diff --git a/src/main/java/org/jabref/gui/util/DirectoryDialogConfiguration.java b/src/main/java/org/jabref/gui/util/DirectoryDialogConfiguration.java index 4948f4043d5..aa82819a9bb 100644 --- a/src/main/java/org/jabref/gui/util/DirectoryDialogConfiguration.java +++ b/src/main/java/org/jabref/gui/util/DirectoryDialogConfiguration.java @@ -9,14 +9,14 @@ public class DirectoryDialogConfiguration { private final Path initialDirectory; - public Optional getInitialDirectory() { - return Optional.ofNullable(initialDirectory); - } - private DirectoryDialogConfiguration(Path initialDirectory) { this.initialDirectory = initialDirectory; } + public Optional getInitialDirectory() { + return Optional.ofNullable(initialDirectory); + } + public static class Builder { private Path initialDirectory; diff --git a/src/main/java/org/jabref/gui/util/FileDialogConfiguration.java b/src/main/java/org/jabref/gui/util/FileDialogConfiguration.java index a3d0b2640c6..035fa120557 100644 --- a/src/main/java/org/jabref/gui/util/FileDialogConfiguration.java +++ b/src/main/java/org/jabref/gui/util/FileDialogConfiguration.java @@ -21,6 +21,14 @@ public class FileDialogConfiguration { private final FileChooser.ExtensionFilter defaultExtension; private final String initialFileName; + private FileDialogConfiguration(Path initialDirectory, List extensionFilters, + FileChooser.ExtensionFilter defaultExtension, String initialFileName) { + this.initialDirectory = initialDirectory; + this.extensionFilters = Objects.requireNonNull(extensionFilters); + this.defaultExtension = defaultExtension; + this.initialFileName = initialFileName; + } + public Optional getInitialDirectory() { return Optional.ofNullable(initialDirectory); } @@ -33,14 +41,6 @@ public String getInitialFileName() { return initialFileName; } - private FileDialogConfiguration(Path initialDirectory, List extensionFilters, - FileChooser.ExtensionFilter defaultExtension, String initialFileName) { - this.initialDirectory = initialDirectory; - this.extensionFilters = Objects.requireNonNull(extensionFilters); - this.defaultExtension = defaultExtension; - this.initialFileName = initialFileName; - } - public List getExtensionFilters() { return extensionFilters; } diff --git a/src/main/java/org/jabref/gui/util/RecursiveTreeItem.java b/src/main/java/org/jabref/gui/util/RecursiveTreeItem.java index 059e5ccb883..e6f15fb2caf 100644 --- a/src/main/java/org/jabref/gui/util/RecursiveTreeItem.java +++ b/src/main/java/org/jabref/gui/util/RecursiveTreeItem.java @@ -47,13 +47,13 @@ private RecursiveTreeItem(final T value, Node graphic, Callback{ - if(newValue != null){ + valueProperty().addListener((obs, oldValue, newValue)-> { + if (newValue != null) { addChildrenListener(newValue); bindExpandedProperty(newValue, expandedProperty); } @@ -66,17 +66,17 @@ private void bindExpandedProperty(T value, Callback expanded } } - private void addChildrenListener(T value){ + private void addChildrenListener(T value) { children = new FilteredList<>(childrenFactory.call(value)); children.predicateProperty().bind(Bindings.createObjectBinding(() -> this::showNode, filter)); children.forEach(this::addAsChild); children.addListener((ListChangeListener) change -> { - while(change.next()){ + while (change.next()) { - if(change.wasRemoved()){ - change.getRemoved().forEach(t->{ + if (change.wasRemoved()) { + change.getRemoved().forEach(t-> { final List> itemsToRemove = RecursiveTreeItem.this.getChildren().stream().filter(treeItem -> treeItem.getValue().equals(t)).collect(Collectors.toList()); RecursiveTreeItem.this.getChildren().removeAll(itemsToRemove); diff --git a/src/main/java/org/jabref/gui/util/WindowLocation.java b/src/main/java/org/jabref/gui/util/WindowLocation.java index cd59a116536..2655fc9857c 100644 --- a/src/main/java/org/jabref/gui/util/WindowLocation.java +++ b/src/main/java/org/jabref/gui/util/WindowLocation.java @@ -53,7 +53,7 @@ public void displayWindowAtStoredLocation() { WindowPosition storedPosition = getStoredLocation(); // preference values are wrong/not in multi-monitor setup anymore - if(!isDisplayable(storedPosition)) { + if (!isDisplayable(storedPosition)) { // adapt position to be inside available boundaries storedPosition = adaptPosition(storedPosition); } diff --git a/src/main/java/org/jabref/gui/worker/CitationStyleWorker.java b/src/main/java/org/jabref/gui/worker/CitationStyleWorker.java index fca9c12ddeb..4a8bbdd629e 100644 --- a/src/main/java/org/jabref/gui/worker/CitationStyleWorker.java +++ b/src/main/java/org/jabref/gui/worker/CitationStyleWorker.java @@ -32,7 +32,7 @@ public CitationStyleWorker(PreviewPanel previewPanel, JEditorPane previewPane) { Objects.requireNonNull(previewPane); Optional basePanel = previewPanel.getBasePanel(); - if (basePanel.isPresent()){ + if (basePanel.isPresent()) { CitationStyle citationStyle = basePanel.get().getCitationStyleCache().getCitationStyle(); previewPane.setText("" + Localization.lang("Processing %0", Localization.lang("Citation Style")) + ": " + citationStyle.getTitle() + " ..." + ""); diff --git a/src/main/java/org/jabref/gui/worker/LookupIdentifiersWorker.java b/src/main/java/org/jabref/gui/worker/LookupIdentifiersWorker.java index 15d92af902d..a859b3d6099 100644 --- a/src/main/java/org/jabref/gui/worker/LookupIdentifiersWorker.java +++ b/src/main/java/org/jabref/gui/worker/LookupIdentifiersWorker.java @@ -20,11 +20,11 @@ public class LookupIdentifiersWorker extends AbstractWorker { + private static final Log LOGGER = LogFactory.getLog(LookupIdentifiersWorker.class); private final JabRefFrame frame; private final IdFetcher fetcher; - private String message; - private static final Log LOGGER = LogFactory.getLog(LookupIdentifiersWorker.class); + private String message; public LookupIdentifiersWorker(JabRefFrame frame, IdFetcher fetcher) { this.frame = Objects.requireNonNull(frame); diff --git a/src/main/java/org/jabref/gui/worker/MarkEntriesAction.java b/src/main/java/org/jabref/gui/worker/MarkEntriesAction.java index 3321ea4b609..ed2ed9f93da 100644 --- a/src/main/java/org/jabref/gui/worker/MarkEntriesAction.java +++ b/src/main/java/org/jabref/gui/worker/MarkEntriesAction.java @@ -20,12 +20,12 @@ public class MarkEntriesAction extends AbstractWorker implements ActionListener { + private static final Log LOGGER = LogFactory.getLog(MarkEntriesAction.class); private final JabRefFrame frame; private final int level; private final JMenuItem menuItem; - private int besLength; - private static final Log LOGGER = LogFactory.getLog(MarkEntriesAction.class); + private int besLength; public MarkEntriesAction(JabRefFrame frame, int level) { this.frame = frame; diff --git a/src/main/java/org/jabref/gui/worker/VersionWorker.java b/src/main/java/org/jabref/gui/worker/VersionWorker.java index 348eb938b86..c6b853215ff 100644 --- a/src/main/java/org/jabref/gui/worker/VersionWorker.java +++ b/src/main/java/org/jabref/gui/worker/VersionWorker.java @@ -60,8 +60,8 @@ protected List doInBackground() throws Exception { } @Override - public void done(){ - if (this.isCancelled()){ + public void done() { + if (this.isCancelled()) { return; } diff --git a/src/main/java/org/jabref/logic/TypedBibEntry.java b/src/main/java/org/jabref/logic/TypedBibEntry.java index 735a84d8035..0352f6fb3c8 100644 --- a/src/main/java/org/jabref/logic/TypedBibEntry.java +++ b/src/main/java/org/jabref/logic/TypedBibEntry.java @@ -40,7 +40,7 @@ public TypedBibEntry(BibEntry entry, BibDatabaseContext databaseContext) { */ public boolean hasAllRequiredFields() { Optional type = EntryTypes.getType(entry.getType(), this.mode); - if(type.isPresent()) { + if (type.isPresent()) { return entry.allFieldsPresent(type.get().getRequiredFields(), database.orElse(null)); } else { return true; diff --git a/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java b/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java index 1ab5745edfe..4f4f26ba910 100644 --- a/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java +++ b/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java @@ -50,7 +50,7 @@ public AbstractAutoCompleter(AutoCompletePreferences preferences) { */ @Override public List complete(String toComplete) { - if(toComplete == null) { + if (toComplete == null) { return new ArrayList<>(); } if (isTooShortToComplete(toComplete)) { diff --git a/src/main/java/org/jabref/logic/autocompleter/AutoCompleteFirstNameMode.java b/src/main/java/org/jabref/logic/autocompleter/AutoCompleteFirstNameMode.java index a0838e30cdf..b9e4e3e8c18 100644 --- a/src/main/java/org/jabref/logic/autocompleter/AutoCompleteFirstNameMode.java +++ b/src/main/java/org/jabref/logic/autocompleter/AutoCompleteFirstNameMode.java @@ -1,6 +1,5 @@ package org.jabref.logic.autocompleter; - public enum AutoCompleteFirstNameMode { ONLY_FULL, ONLY_ABBREVIATED, diff --git a/src/main/java/org/jabref/logic/autocompleter/AutoCompletePreferences.java b/src/main/java/org/jabref/logic/autocompleter/AutoCompletePreferences.java index 52e6ef607b9..36c95725f5f 100644 --- a/src/main/java/org/jabref/logic/autocompleter/AutoCompletePreferences.java +++ b/src/main/java/org/jabref/logic/autocompleter/AutoCompletePreferences.java @@ -9,14 +9,17 @@ public class AutoCompletePreferences { - private final JabRefPreferences preferences; - private static final String AUTOCOMPLETER_SHORTEST_TO_COMPLETE = "shortestToComplete"; private static final String AUTOCOMPLETER_FIRSTNAME_MODE = "autoCompFirstNameMode"; private static final String AUTOCOMPLETER_LAST_FIRST = "autoCompLF"; private static final String AUTOCOMPLETER_FIRST_LAST = "autoCompFF"; private static final String AUTOCOMPLETER_COMPLETE_FIELDS = "autoCompleteFields"; + private final JabRefPreferences preferences; + + public AutoCompletePreferences(JabRefPreferences preferences) { + this.preferences = Objects.requireNonNull(preferences); + } public static void putDefaults(Map defaults) { defaults.put(AUTOCOMPLETER_SHORTEST_TO_COMPLETE, 1); @@ -26,10 +29,6 @@ public static void putDefaults(Map defaults) { defaults.put(AUTOCOMPLETER_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords"); } - public AutoCompletePreferences(JabRefPreferences preferences) { - this.preferences = Objects.requireNonNull(preferences); - } - public int getShortestLengthToComplete() { return preferences.getInt(AUTOCOMPLETER_SHORTEST_TO_COMPLETE); } diff --git a/src/main/java/org/jabref/logic/autocompleter/DefaultAutoCompleter.java b/src/main/java/org/jabref/logic/autocompleter/DefaultAutoCompleter.java index db9981e9720..319f573edce 100644 --- a/src/main/java/org/jabref/logic/autocompleter/DefaultAutoCompleter.java +++ b/src/main/java/org/jabref/logic/autocompleter/DefaultAutoCompleter.java @@ -13,10 +13,10 @@ */ class DefaultAutoCompleter extends AbstractAutoCompleter { - private final String fieldName; - private static final String SEPARATING_CHARS = ";,\n "; + private final String fieldName; + /** * @see AutoCompleterFactory */ diff --git a/src/main/java/org/jabref/logic/auxparser/AuxParser.java b/src/main/java/org/jabref/logic/auxparser/AuxParser.java index ddba6e7f6d5..33c331559bf 100644 --- a/src/main/java/org/jabref/logic/auxparser/AuxParser.java +++ b/src/main/java/org/jabref/logic/auxparser/AuxParser.java @@ -133,7 +133,7 @@ private void resolveTags(AuxParserResult result) { for (String key : result.getUniqueKeys()) { Optional entry = masterDatabase.getEntryByKey(key); - if(result.getGeneratedBibDatabase().getEntryByKey(key).isPresent()) { + if (result.getGeneratedBibDatabase().getEntryByKey(key).isPresent()) { // do nothing, key has already been processed } else if (entry.isPresent()) { insertEntry(entry.get(), result); diff --git a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java index 8b239a95530..e37ff1143b2 100644 --- a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java +++ b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java @@ -58,7 +58,7 @@ public void write(BibEntry entry, Writer out, BibDatabaseMode bibDatabaseMode, B private void writeUserComments(BibEntry entry, Writer out) throws IOException { String userComments = entry.getUserComments(); - if(!userComments.isEmpty()) { + if (!userComments.isEmpty()) { out.write(userComments + OS.NEWLINE); } } diff --git a/src/main/java/org/jabref/logic/bibtex/DuplicateCheck.java b/src/main/java/org/jabref/logic/bibtex/DuplicateCheck.java index b0773a11c37..1131737d727 100644 --- a/src/main/java/org/jabref/logic/bibtex/DuplicateCheck.java +++ b/src/main/java/org/jabref/logic/bibtex/DuplicateCheck.java @@ -26,8 +26,9 @@ * This class contains utility method for duplicate checking of entries. */ public class DuplicateCheck { - private static final Log LOGGER = LogFactory.getLog(DuplicateCheck.class); + public static double duplicateThreshold = 0.75; // The overall threshold to signal a duplicate pair + private static final Log LOGGER = LogFactory.getLog(DuplicateCheck.class); /* * Integer values for indicating result of duplicate check (for entries): */ @@ -35,9 +36,8 @@ public class DuplicateCheck { private static final int EQUAL = 1; private static final int EMPTY_IN_ONE = 2; private static final int EMPTY_IN_TWO = 3; - private static final int EMPTY_IN_BOTH = 4; - public static double duplicateThreshold = 0.75; // The overall threshold to signal a duplicate pair + private static final int EMPTY_IN_BOTH = 4; // Non-required fields are investigated only if the required fields give a value within // the doubt range of the threshold: private static final double DOUBT_RANGE = 0.05; @@ -54,7 +54,7 @@ public class DuplicateCheck { DuplicateCheck.FIELD_WEIGHTS.put(FieldName.JOURNAL, 2.); } - private DuplicateCheck() {} + private DuplicateCheck() { } /** * Checks if the two entries represent the same publication. diff --git a/src/main/java/org/jabref/logic/bibtex/FieldContentParser.java b/src/main/java/org/jabref/logic/bibtex/FieldContentParser.java index e2f796f1862..43c05b1a2fd 100644 --- a/src/main/java/org/jabref/logic/bibtex/FieldContentParser.java +++ b/src/main/java/org/jabref/logic/bibtex/FieldContentParser.java @@ -16,11 +16,11 @@ */ public class FieldContentParser { - private final Set multiLineFields; - // 's' matches a space, tab, new line, carriage return. private static final Pattern WHITESPACE = Pattern.compile("\\s+"); + private final Set multiLineFields; + public FieldContentParser(FieldContentParserPreferences prefs) { Objects.requireNonNull(prefs); diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java index b8a1fe54ab2..ee44c5925b6 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java @@ -60,13 +60,13 @@ private static Collator getCollator() { } private FieldType determineFieldType() { - if(BibEntry.TYPE_HEADER.equals(this.field[0])) { + if (BibEntry.TYPE_HEADER.equals(this.field[0])) { return FieldType.TYPE; } else if (InternalBibtexFields.getFieldProperties(this.field[0]).contains(FieldProperty.PERSON_NAMES)) { return FieldType.NAME; } else if (FieldName.YEAR.equals(this.field[0])) { return FieldType.YEAR; - } else if(FieldName.MONTH.equals(this.field[0])) { + } else if (FieldName.MONTH.equals(this.field[0])) { return FieldType.MONTH; } else { return FieldType.OTHER; @@ -102,7 +102,7 @@ public int compare(BibEntry e1, BibEntry e2) { // Catch all cases involving null: if ((f1 == null) && (f2 == null)) { return 0; - } else if(f1 == null) { + } else if (f1 == null) { return multiplier; } else if (f2 == null) { return -multiplier; diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java index 95006d82352..d7fc64c35fd 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java @@ -489,7 +489,7 @@ public static String applyModifiers(final String label, final List parts Optional formatter = Formatters.getFormatterForModifier(modifier); if (formatter.isPresent()) { resultingLabel = formatter.get().format(label); - } else if (!modifier.isEmpty() && (modifier.length()>= 2) && (modifier.charAt(0) == '(') && modifier.endsWith(")")) { + } else if (!modifier.isEmpty() && (modifier.length() >= 2) && (modifier.charAt(0) == '(') && modifier.endsWith(")")) { // Alternate text modifier in parentheses. Should be inserted if // the label is empty: if (label.isEmpty() && (modifier.length() > 2)) { @@ -680,7 +680,7 @@ else if (val.matches("edtr\\d+")) { return ""; } else { // num counts from 1 to n, but index in arrayList count from 0 to n-1 - return separatedKeywords.get(num-1).toString(); + return separatedKeywords.get(num - 1).toString(); } } else if (val.matches("keywords\\d*")) { // return all keywords, not separated @@ -834,7 +834,6 @@ public static String camelizeSignificantWordsInTitle(String title) { return stringJoiner.toString(); } - public static String removeSmallWords(String title) { StringJoiner stringJoiner = new StringJoiner(" "); String formattedTitle = formatTitle(title); diff --git a/src/main/java/org/jabref/logic/bst/BibtexWidth.java b/src/main/java/org/jabref/logic/bst/BibtexWidth.java index f81bae97627..d7538eafb26 100644 --- a/src/main/java/org/jabref/logic/bst/BibtexWidth.java +++ b/src/main/java/org/jabref/logic/bst/BibtexWidth.java @@ -160,7 +160,6 @@ private static int getSpecialCharWidth(char[] c, int pos) { public static int getCharWidth(char c) { - if ((c >= 0) && (c < 128)) { return BibtexWidth.widths[c]; } else { diff --git a/src/main/java/org/jabref/logic/bst/VM.java b/src/main/java/org/jabref/logic/bst/VM.java index 162384ff21b..6c8d9cce1f8 100644 --- a/src/main/java/org/jabref/logic/bst/VM.java +++ b/src/main/java/org/jabref/logic/bst/VM.java @@ -40,6 +40,12 @@ public class VM implements Warn { + public static final Integer FALSE = 0; + + public static final Integer TRUE = 1; + + private static final Pattern ADD_PERIOD_PATTERN = Pattern.compile("([^\\.\\?\\!\\}\\s])(\\}|\\s)*$"); + private static final Log LOGGER = LogFactory.getLog(VM.class); private List entries; @@ -52,10 +58,6 @@ public class VM implements Warn { private Stack stack = new Stack<>(); - public static final Integer FALSE = 0; - - public static final Integer TRUE = 1; - private final Map buildInFunctions; private File file; @@ -66,9 +68,6 @@ public class VM implements Warn { private String preamble = ""; - private static final Pattern ADD_PERIOD_PATTERN = Pattern.compile("([^\\.\\?\\!\\}\\s])(\\}|\\s)*$"); - - public static class Identifier { public final String name; @@ -830,7 +829,6 @@ private boolean assign(BstEntry context, Object o1, Object o2) { return false; } - public String run(BibDatabase db) { preamble = db.getPreamble().orElse(""); return run(db.getEntries()); @@ -946,7 +944,6 @@ private void macro(Tree child) { functions.put(name, new MacroFunction(replacement)); } - public class MacroFunction implements BstFunction { private final String replacement; @@ -1047,7 +1044,6 @@ private void execute(Tree child) { execute(child.getChild(0).getText(), null); } - public class StackFunction implements BstFunction { private final Tree localTree; @@ -1101,7 +1097,6 @@ public void execute(BstEntry context) { } } - private void push(Tree t) { stack.push(t); } @@ -1182,7 +1177,6 @@ private void strings(Tree child) { } } - public static class BstEntry { private final BibEntry entry; @@ -1207,7 +1201,6 @@ public BibEntry getBibtexEntry() { } } - private void push(Integer integer) { stack.push(integer); } diff --git a/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java b/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java index d6cd1c85c53..e5ce5494dc0 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java +++ b/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java @@ -81,7 +81,7 @@ private static CitationStyle createCitationStyleFromSource(final String source, */ public static CitationStyle createCitationStyleFromFile(final String styleFile) { if (!isCitationStyleFile(styleFile)) { - LOGGER.error("Can only load style files: "+ styleFile); + LOGGER.error("Can only load style files: " + styleFile); return null; } @@ -96,15 +96,15 @@ public static CitationStyle createCitationStyleFromFile(final String styleFile) text = new String(Files.readAllBytes(Paths.get(styleFile)), StandardCharsets.UTF_8); } return createCitationStyleFromSource(text, styleFile); - } catch (NoSuchFileException e){ - LOGGER.error("Could not find file: "+ styleFile, e); + } catch (NoSuchFileException e) { + LOGGER.error("Could not find file: " + styleFile, e); } catch (IOException e) { LOGGER.error("Error reading source file", e); } return null; } - public static CitationStyle getDefault(){ + public static CitationStyle getDefault() { return createCitationStyleFromFile(DEFAULT); } @@ -141,7 +141,7 @@ public static List discoverCitationStyles() { /** * Checks if the given style file is a CitationStyle */ - public static boolean isCitationStyleFile(String styleFile){ + public static boolean isCitationStyleFile(String styleFile) { return Arrays.stream(FileExtensions.CITATION_STYLE.getExtensions()).anyMatch(styleFile::endsWith); } diff --git a/src/main/java/org/jabref/logic/citationstyle/CitationStyleCache.java b/src/main/java/org/jabref/logic/citationstyle/CitationStyleCache.java index bf3474261c6..d693b36d628 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CitationStyleCache.java +++ b/src/main/java/org/jabref/logic/citationstyle/CitationStyleCache.java @@ -45,7 +45,7 @@ public String getCitationFor(BibEntry entry) { public void setCitationStyle(CitationStyle citationStyle) { Objects.requireNonNull(citationStyle); - if (!this.citationStyle.equals(citationStyle)){ + if (!this.citationStyle.equals(citationStyle)) { this.citationStyle = citationStyle; this.citationStylesCache.clear(); } @@ -55,7 +55,6 @@ public CitationStyle getCitationStyle() { return citationStyle; } - private class BibDatabaseEntryListener { /** * removes the outdated citation of the changed entry diff --git a/src/main/java/org/jabref/logic/citationstyle/CitationStyleOutputFormat.java b/src/main/java/org/jabref/logic/citationstyle/CitationStyleOutputFormat.java index ca6d0ea92fd..24005afdcfe 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CitationStyleOutputFormat.java +++ b/src/main/java/org/jabref/logic/citationstyle/CitationStyleOutputFormat.java @@ -1,6 +1,5 @@ package org.jabref.logic.citationstyle; - import org.jabref.logic.util.OS; public enum CitationStyleOutputFormat { diff --git a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java index 223d97e9f16..739fa740e1e 100644 --- a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java @@ -53,7 +53,7 @@ private List determineCleanupActions(CleanupPreset preset) { if (preset.isConvertToBiblatex()) { jobs.add(new BiblatexCleanup()); } - if(preset.getFormatterCleanups().isEnabled()) { + if (preset.getFormatterCleanups().isEnabled()) { jobs.addAll(preset.getFormatterCleanups().getConfiguredActions()); } if (preset.isCleanUpUpgradeExternalLinks()) { diff --git a/src/main/java/org/jabref/logic/cleanup/Cleanups.java b/src/main/java/org/jabref/logic/cleanup/Cleanups.java index 31af37bd341..17072cb723e 100644 --- a/src/main/java/org/jabref/logic/cleanup/Cleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/Cleanups.java @@ -27,7 +27,6 @@ public class Cleanups { public static final FieldFormatterCleanups RECOMMEND_BIBLATEX_ACTIONS; public static List availableFormatters; - static { availableFormatters = new ArrayList<>(); availableFormatters.addAll(Formatters.ALL); @@ -107,8 +106,6 @@ public static List parse(String formatterString) { currentIndex = -1; } while (true); - - } } catch (StringIndexOutOfBoundsException ignore) { // if this exception occurs, the remaining part of the save actions string is invalid. diff --git a/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java b/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java index 71e42d0c1a9..61a36268ae6 100644 --- a/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java @@ -10,7 +10,6 @@ import org.jabref.model.entry.FieldName; import org.jabref.model.entry.identifier.ISSN; - public class ISSNCleanup implements CleanupJob { @Override diff --git a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java index 42dafd86d59..a5f0ee879c8 100644 --- a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java @@ -27,12 +27,12 @@ public class MoveFilesCleanup implements CleanupJob { + private static final Log LOGGER = LogFactory.getLog(MoveFilesCleanup.class); private final BibDatabaseContext databaseContext; private final FileDirectoryPreferences fileDirectoryPreferences; - private final LayoutFormatterPreferences layoutPrefs; + private final LayoutFormatterPreferences layoutPrefs; private final String fileDirPattern; - private static final Log LOGGER = LogFactory.getLog(MoveFilesCleanup.class); private LinkedFile singleFileFieldCleanup; diff --git a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java index 86ba8544a4c..4a1f0b1815b 100644 --- a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java @@ -48,7 +48,7 @@ public List cleanup(BibEntry entry) { if (changed) { Optional change = entry.setFiles(newFileList); - if(change.isPresent()) { + if (change.isPresent()) { return Collections.singletonList(change.get()); } else { return Collections.emptyList(); diff --git a/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java b/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java index bf3d5ee1f17..b43e8663924 100644 --- a/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java +++ b/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java @@ -131,11 +131,11 @@ private static Optional getSaveOrder(SavePreferences preference * 3. order specified in preferences */ - if(preferences.isSaveInOriginalOrder()) { + if (preferences.isSaveInOriginalOrder()) { return Optional.empty(); } - if(preferences.getTakeMetadataSaveOrderInAccount()) { + if (preferences.getTakeMetadataSaveOrderInAccount()) { return metaData.getSaveOrderConfig(); } @@ -234,7 +234,7 @@ protected void writeMetaData(MetaData metaData, GlobalBibtexKeyPattern globalCit Map serializedMetaData = MetaDataSerializer.getSerializedStringMap(metaData, globalCiteKeyPattern); - for(Map.Entry metaItem : serializedMetaData.entrySet()) { + for (Map.Entry metaItem : serializedMetaData.entrySet()) { writeMetaDataItem(metaItem); } } diff --git a/src/main/java/org/jabref/logic/exporter/BibtexDatabaseWriter.java b/src/main/java/org/jabref/logic/exporter/BibtexDatabaseWriter.java index a22d3942449..32ea57162a2 100644 --- a/src/main/java/org/jabref/logic/exporter/BibtexDatabaseWriter.java +++ b/src/main/java/org/jabref/logic/exporter/BibtexDatabaseWriter.java @@ -84,7 +84,7 @@ protected void writeString(BibtexString bibtexString, boolean isFirstString, int // Write user comments String userComments = bibtexString.getUserComments(); - if(!userComments.isEmpty()) { + if (!userComments.isEmpty()) { getWriter().write(userComments + OS.NEWLINE); } @@ -128,7 +128,7 @@ protected void writeEntryTypeDefinition(CustomEntryType customType) throws SaveE @Override protected void writePrelogue(BibDatabaseContext bibDatabaseContext, Charset encoding) throws SaveException { - if(encoding == null) { + if (encoding == null) { return; } diff --git a/src/main/java/org/jabref/logic/exporter/ExportFormat.java b/src/main/java/org/jabref/logic/exporter/ExportFormat.java index bf009494c3e..871d3509136 100644 --- a/src/main/java/org/jabref/logic/exporter/ExportFormat.java +++ b/src/main/java/org/jabref/logic/exporter/ExportFormat.java @@ -31,6 +31,9 @@ */ public class ExportFormat implements IExportFormat { + private static final String LAYOUT_PREFIX = "/resource/layout/"; + + private static final Log LOGGER = LogFactory.getLog(ExportFormat.class); private String displayName; private String consoleName; private String lfFileName; @@ -39,12 +42,9 @@ public class ExportFormat implements IExportFormat { private Charset encoding; // If this value is set, it will be used to override // the default encoding for the getCurrentBasePanel. private LayoutFormatterPreferences layoutPreferences; - private SavePreferences savePreferences; + private SavePreferences savePreferences; private boolean customExport; - private static final String LAYOUT_PREFIX = "/resource/layout/"; - - private static final Log LOGGER = LogFactory.getLog(ExportFormat.class); /** * Initialize another export format based on templates stored in dir with @@ -179,7 +179,6 @@ private Reader getReader(String filename) throws IOException { return reader; } - @Override public void performExport(final BibDatabaseContext databaseContext, final String file, final Charset encoding, List entries) throws Exception { diff --git a/src/main/java/org/jabref/logic/exporter/ExportFormats.java b/src/main/java/org/jabref/logic/exporter/ExportFormats.java index 38c04466d76..c24a165c694 100644 --- a/src/main/java/org/jabref/logic/exporter/ExportFormats.java +++ b/src/main/java/org/jabref/logic/exporter/ExportFormats.java @@ -10,11 +10,11 @@ public class ExportFormats { - private static final Map EXPORT_FORMATS = new TreeMap<>(); - // Global variable that is used for counting output entries when exporting: public static int entryNumber; + private static final Map EXPORT_FORMATS = new TreeMap<>(); + private ExportFormats() { } diff --git a/src/main/java/org/jabref/logic/exporter/GroupSerializer.java b/src/main/java/org/jabref/logic/exporter/GroupSerializer.java index a309bfaf76f..a1731250cd1 100644 --- a/src/main/java/org/jabref/logic/exporter/GroupSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/GroupSerializer.java @@ -104,7 +104,7 @@ public List serializeTree(GroupTreeNode node) { representation.add(String.valueOf(node.getLevel()) + ' ' + serializeGroup(node.getGroup())); // Append children - for(GroupTreeNode child : node.getChildren()) { + for (GroupTreeNode child : node.getChildren()) { representation.addAll(serializeTree(child)); } diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index ef24a5e87b0..92944665575 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -44,7 +44,7 @@ public static Map getSerializedStringMap(MetaData metaData, metaData.getUserFileDirectories().forEach((user, path) -> stringyMetaData .put(MetaData.FILE_DIRECTORY + '-' + user, Collections.singletonList(path.trim()))); - for(ContentSelector selector: metaData.getContentSelectorList()){ + for (ContentSelector selector: metaData.getContentSelectorList()) { stringyMetaData.put(MetaData.SELECTOR_META_PREFIX + selector.getFieldName(), selector.getValues()); } @@ -58,10 +58,10 @@ public static Map getSerializedStringMap(MetaData metaData, // finally add all unknown meta data items to the serialization map Map> unknownMetaData = metaData.getUnknownMetaData(); - for(Map.Entry> entry : unknownMetaData.entrySet()){ + for (Map.Entry> entry : unknownMetaData.entrySet()) { StringBuilder value = new StringBuilder(); value.append(OS.NEWLINE); - for(String line: entry.getValue()){ + for (String line: entry.getValue()) { value.append(line.replaceAll(";", "\\\\;") + MetaData.SEPARATOR_STRING + OS.NEWLINE); } serializedMetaData.put(entry.getKey(), value.toString()); diff --git a/src/main/java/org/jabref/logic/exporter/ModsExportFormat.java b/src/main/java/org/jabref/logic/exporter/ModsExportFormat.java index f78ef87eda0..45055f5d25f 100644 --- a/src/main/java/org/jabref/logic/exporter/ModsExportFormat.java +++ b/src/main/java/org/jabref/logic/exporter/ModsExportFormat.java @@ -53,10 +53,10 @@ */ class ModsExportFormat extends ExportFormat { + protected static final String MODS_NAMESPACE_URI = "http://www.loc.gov/mods/v3"; private static final String MINUS = "-"; private static final String DOUBLE_MINUS = "--"; private static final String MODS_SCHEMA_LOCATION = "http://www.loc.gov/standards/mods/v3/mods-3-6.xsd"; - protected static final String MODS_NAMESPACE_URI = "http://www.loc.gov/mods/v3"; private JAXBContext context; @@ -182,7 +182,6 @@ private void createMarshallerAndWriteToFile(String file, JAXBElement entries; - private static final Log LOGGER = LogFactory.getLog(OOCalcDatabase.class); + private final List entries; + public OOCalcDatabase(BibDatabase bibtex, List entries) { // Make a list of comparators for sorting the entries: diff --git a/src/main/java/org/jabref/logic/exporter/OpenDocumentRepresentation.java b/src/main/java/org/jabref/logic/exporter/OpenDocumentRepresentation.java index 98e5f25e0c8..44b202a17ee 100644 --- a/src/main/java/org/jabref/logic/exporter/OpenDocumentRepresentation.java +++ b/src/main/java/org/jabref/logic/exporter/OpenDocumentRepresentation.java @@ -29,10 +29,10 @@ */ class OpenDocumentRepresentation { + private static final Log LOGGER = LogFactory.getLog(OpenDocumentRepresentation.class); private final List entries; - private final BibDatabase database; - private static final Log LOGGER = LogFactory.getLog(OpenDocumentRepresentation.class); + private final BibDatabase database; public OpenDocumentRepresentation(BibDatabase database, List entries) { diff --git a/src/main/java/org/jabref/logic/exporter/SaveSession.java b/src/main/java/org/jabref/logic/exporter/SaveSession.java index 5fe760bf680..853276294f9 100644 --- a/src/main/java/org/jabref/logic/exporter/SaveSession.java +++ b/src/main/java/org/jabref/logic/exporter/SaveSession.java @@ -11,10 +11,10 @@ public abstract class SaveSession { + protected boolean backup; protected final Charset encoding; protected final VerifyingWriter writer; private final List undoableFieldChanges = new ArrayList<>(); - protected boolean backup; protected SaveSession(Charset encoding, boolean backup, VerifyingWriter writer) { this.encoding = Objects.requireNonNull(encoding); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java index 6efc2a4c81e..9f76d279d68 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java @@ -27,7 +27,6 @@ public class NormalizePagesFormatter implements Formatter { private static final String PAGES_REPLACE_PATTERN = "${startpage}--${endpage}"; private static final String SINGLE_PAGE_REPLACE_PATTERN = "$1"; - @Override public String getName() { return Localization.lang("Normalize page numbers"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 85cee4d837c..69e7c8c316a 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -32,7 +32,7 @@ public String format(String value) { // It could be that the removed braces were not matching // For example, "{A} test {B}" results in "A} test {B" // In this case, trimmed has a closing } without an opening { before that - if(hasNegativeBraceCount(trimmed)) { + if (hasNegativeBraceCount(trimmed)) { return formatted; } else { formatted = trimmed; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java index 19167f357a4..357f6f4d480 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java @@ -93,7 +93,6 @@ public UnitsToLatexFormatter() { Collections.sort(prefixUnitCombinations, new StringLengthComparator()); // Sort based on string length } - @Override public String format(String text) { Objects.requireNonNull(text); diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java index a5267cce181..65474d3d2fd 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java @@ -67,7 +67,6 @@ public void toLowerCase() { } } - public void toUpperFirst() { for (int i = 0; i < chars.length; i++) { if (protectedChars[i]) { diff --git a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java index 5135efab104..317edafe048 100644 --- a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java +++ b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java @@ -45,7 +45,6 @@ public class ImportFormatReader { private ImportFormatPreferences importFormatPreferences; - public void resetImportFormats(ImportFormatPreferences newImportFormatPreferences, XMPPreferences xmpPreferences) { this.importFormatPreferences = newImportFormatPreferences; diff --git a/src/main/java/org/jabref/logic/importer/Importer.java b/src/main/java/org/jabref/logic/importer/Importer.java index 49c241b6f4b..13ea10bfb8c 100644 --- a/src/main/java/org/jabref/logic/importer/Importer.java +++ b/src/main/java/org/jabref/logic/importer/Importer.java @@ -141,7 +141,7 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if(!(obj instanceof Importer)) { + if (!(obj instanceof Importer)) { return false; } Importer other = (Importer)obj; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ACS.java b/src/main/java/org/jabref/logic/importer/fetcher/ACS.java index 0ca485c6809..d485ce3bf17 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ACS.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ACS.java @@ -42,13 +42,13 @@ public Optional findFullText(BibEntry entry) throws IOException { // DOI search Optional doi = entry.getField(FieldName.DOI).flatMap(DOI::parse); - if(doi.isPresent()) { + if (doi.isPresent()) { String source = String.format(SOURCE, doi.get().getDOI()); // Retrieve PDF link Document html = Jsoup.connect(source).ignoreHttpErrors(true).get(); Element link = html.select(".pdf-high-res a").first(); - if(link != null) { + if (link != null) { LOGGER.info("Fulltext PDF found @ ACS."); pdfLink = Optional.of(new URL(source.replaceFirst("/abs/", "/pdf/"))); } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java b/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java index f6f51599288..f3ecdc21700 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java @@ -130,7 +130,7 @@ public List performSearch(String query) throws FetcherException { try { URLConnection connection = getURLForQuery(query).openConnection(); connection.setRequestProperty("User-Agent", URLDownload.USER_AGENT); - try(InputStream stream = connection.getInputStream()) { + try (InputStream stream = connection.getInputStream()) { List fetchedEntries = getParser().parseEntries(stream); // Post-cleanup diff --git a/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java b/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java index 7205b12ba1f..1a1a47d2423 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java @@ -117,14 +117,14 @@ public List performSearch(String query) throws FetcherException { addHitsFromQuery(foundEntries, uriBuilder.toString()); - if(foundEntries.size()==10) { + if (foundEntries.size() == 10) { uriBuilder.addParameter("start", "10"); addHitsFromQuery(foundEntries, uriBuilder.toString()); } return foundEntries; } catch (URISyntaxException e) { - throw new FetcherException("Error while fetching from "+getName(), e); + throw new FetcherException("Error while fetching from " + getName(), e); } catch (IOException e) { // if there are too much requests from the same IP adress google is answering with a 503 and redirecting to a captcha challenge // The caught IOException looks for example like this: @@ -133,7 +133,7 @@ public List performSearch(String query) throws FetcherException { throw new FetcherException("Fetching from Google Scholar failed.", Localization.lang("This might be caused by reaching the traffic limitation of Google Scholar (see 'Help' for details)."), e); } else { - throw new FetcherException("Error while fetching from "+getName(), e); + throw new FetcherException("Error while fetching from " + getName(), e); } } } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IEEE.java b/src/main/java/org/jabref/logic/importer/fetcher/IEEE.java index a79fcfac814..d7b02b16bda 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IEEE.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IEEE.java @@ -30,7 +30,6 @@ public class IEEE implements FulltextFetcher { private static final String IEEE_DOI = "10.1109"; private static final String BASE_URL = "http://ieeexplore.ieee.org"; - @Override public Optional findFullText(BibEntry entry) throws IOException { Objects.requireNonNull(entry); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java index 8bc99bd77df..beb309bcdc1 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java @@ -16,7 +16,7 @@ */ public class IsbnFetcher extends AbstractIsbnFetcher { - public IsbnFetcher(ImportFormatPreferences importFormatPreferences){ + public IsbnFetcher(ImportFormatPreferences importFormatPreferences) { super(importFormatPreferences); } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java index 99cc4678d1d..82c50b95ff4 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java @@ -81,7 +81,6 @@ public Optional performSearchById(String identifier) throws FetcherExc return Optional.of(entry); } - @Override public void doPostCleanup(BibEntry entry) { // We MUST NOT clean the URL. this is the deal with @manastungare - see https://github.com/JabRef/jabref/issues/684#issuecomment-266541507 diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java b/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java index a68eb77f06b..8d9e8e049dd 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java @@ -41,7 +41,7 @@ public Optional findFullText(BibEntry entry) throws IOException { // Try unique DOI first Optional doi = entry.getField(FieldName.DOI).flatMap(DOI::parse); - if(doi.isPresent()) { + if (doi.isPresent()) { // Available in catalog? try { String sciLink = getUrlByDoi(doi.get().getDOI()); @@ -70,7 +70,7 @@ public Optional findFullText(BibEntry entry) throws IOException { return pdfLink; } } - } catch(UnirestException e) { + } catch (UnirestException e) { LOGGER.warn("ScienceDirect API request failed", e); } } @@ -89,14 +89,14 @@ private String getUrlByDoi(String doi) throws UnirestException { JSONObject json = jsonResponse.getBody().getObject(); JSONArray links = json.getJSONObject("full-text-retrieval-response").getJSONObject("coredata").getJSONArray("link"); - for (int i=0; i < links.length(); i++) { + for (int i = 0; i < links.length(); i++) { JSONObject link = links.getJSONObject(i); if (link.getString("@rel").equals("scidir")) { sciLink = link.getString("@href"); } } return sciLink; - } catch(JSONException e) { + } catch (JSONException e) { LOGGER.debug("No ScienceDirect link found in API request", e); return sciLink; } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/SpringerLink.java b/src/main/java/org/jabref/logic/importer/fetcher/SpringerLink.java index e3bcd15039f..1cebab8d3d8 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/SpringerLink.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/SpringerLink.java @@ -38,7 +38,7 @@ public Optional findFullText(BibEntry entry) throws IOException { // Try unique DOI first Optional doi = entry.getField(FieldName.DOI).flatMap(DOI::parse); - if(doi.isPresent()) { + if (doi.isPresent()) { // Available in catalog? try { HttpResponse jsonResponse = Unirest.get(API_URL) @@ -53,7 +53,7 @@ public Optional findFullText(BibEntry entry) throws IOException { LOGGER.info("Fulltext PDF found @ Springer."); pdfLink = Optional.of(new URL("http", CONTENT_HOST, String.format("/content/pdf/%s.pdf", doi.get().getDOI()))); } - } catch(UnirestException e) { + } catch (UnirestException e) { LOGGER.warn("SpringerLink API request failed", e); } } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibTeXMLImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/BibTeXMLImporter.java index 399bf7fa466..21299906087 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibTeXMLImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibTeXMLImporter.java @@ -47,7 +47,6 @@ public class BibTeXMLImporter extends Importer { private static final List IGNORED_METHODS = Arrays.asList("getClass", "getAnnotate", "getContents", "getPrice", "getSize", "getChapter"); - @Override public String getName() { return "BibTeXML"; diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexImporter.java index 5ba4700bf9a..ec51bf4685f 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexImporter.java @@ -58,7 +58,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) throw } } - if(suppliedEncoding.isPresent()) { + if (suppliedEncoding.isPresent()) { return super.importDatabase(filePath, suppliedEncoding.get()); } else { return super.importDatabase(filePath, defaultEncoding); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index 37fd25fe1da..e0c6f122a05 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -159,7 +159,6 @@ private void initializeParserResult() { parserResult = new ParserResult(database, new MetaData(), entryTypes); } - private void parseDatabaseID() throws IOException { while (!eof) { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java index 243aff8b711..b6ecf195f9f 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java @@ -32,7 +32,7 @@ public List parseEntries(InputStream inputStream) throws ParseExceptio DocumentBuilder dbuild = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document content = dbuild.parse(inputStream); return this.parseEntries(content); - } catch (ParserConfigurationException|SAXException|IOException exception) { + } catch (ParserConfigurationException | SAXException | IOException exception) { throw new ParseException(exception); } } @@ -353,7 +353,6 @@ private BibEntry parseEntry(Element e) { //entryType = "online"; } - /* * Wahrscheinlichkeit, dass ZDB-ID * vorhanden ist, ist größer als ISBN bei diff --git a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java index 8999fbc697e..a9dc90f5179 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java @@ -45,7 +45,6 @@ public class IsiImporter extends Importer { // extra | at the end: private static final Pattern ISI_PATTERN = Pattern.compile("FN ISI Export Format|VR 1.|PY \\d{4}"); - @Override public String getName() { return "ISI"; diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java index cb626f2e2c2..5cdf1601f9a 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java @@ -34,7 +34,6 @@ public class MedlinePlainImporter extends Importer { private static final Pattern CREATE_DATE_PATTERN = Pattern.compile("\\d{4}/[0123]?\\d/\\s?[012]\\d:[0-5]\\d"); private static final Pattern COMPLETE_DATE_PATTERN = Pattern.compile("\\d{8}"); - @Override public String getName() { return "Medline/PubMed Plain"; diff --git a/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java index 945dfcd5498..2708b05ae20 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java @@ -70,7 +70,6 @@ public class ModsImporter extends Importer { private static final Pattern MODS_PATTERN = Pattern.compile(""); private JAXBContext context; - @Override public boolean isRecognizedFormat(BufferedReader input) throws IOException { return input.lines().anyMatch(line -> MODS_PATTERN.matcher(line).find()); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java index cd4b6208a1b..3aa99e0e337 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java @@ -256,6 +256,8 @@ public void characters(char ch[], int start, int length) throws SAXException { } - }; + } + + ; } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java index afa753bb8e0..3aea796e7bd 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java @@ -124,7 +124,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { h.put(FieldName.ISSUE, matcher.group(3)); h.put(FieldName.PAGES, matcher.group(4)); h.put(FieldName.YEAR, matcher.group(5)); - } else if ((matcher = OvidImporter.OVID_SOURCE_PATTERN_NO_ISSUE.matcher(content)).find()) {// may be missing the issue + } else if ((matcher = OvidImporter.OVID_SOURCE_PATTERN_NO_ISSUE.matcher(content)).find()) { // may be missing the issue h.put(FieldName.JOURNAL, matcher.group(1)); h.put(FieldName.VOLUME, matcher.group(2)); h.put(FieldName.PAGES, matcher.group(3)); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java index 4508b8c4c9b..c212b4fc096 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java @@ -474,7 +474,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { result.add(entry); } catch (EncryptedPdfsNotSupportedException e) { return ParserResult.fromErrorMessage(Localization.lang("Decryption not supported.")); - } catch(IOException exception) { + } catch (IOException exception) { return ParserResult.fromError(exception); } catch (FetcherException e) { return ParserResult.fromErrorMessage(e.getMessage()); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java index ff927d3638f..49af1941ba7 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java @@ -29,7 +29,6 @@ public class RisImporter extends Importer { private static final Pattern RECOGNIZED_FORMAT_PATTERN = Pattern.compile("TY - .*"); - @Override public String getName() { return "RIS"; diff --git a/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java b/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java index ff0334c2c7a..8551e1eca9b 100644 --- a/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java +++ b/src/main/java/org/jabref/logic/importer/util/INSPIREBibtexFilterReader.java @@ -22,13 +22,13 @@ */ public class INSPIREBibtexFilterReader extends FilterReader { - private final BufferedReader inReader; + private static final Pattern PATTERN = Pattern.compile("@Article\\{.*,"); + private final BufferedReader inReader; private String line; private int pos; - private boolean pre; - private static final Pattern PATTERN = Pattern.compile("@Article\\{.*,"); + private boolean pre; public INSPIREBibtexFilterReader(final Reader initialReader) { diff --git a/src/main/java/org/jabref/logic/importer/util/JSONEntryParser.java b/src/main/java/org/jabref/logic/importer/util/JSONEntryParser.java index 0e2af600f81..72d33e2c07c 100644 --- a/src/main/java/org/jabref/logic/importer/util/JSONEntryParser.java +++ b/src/main/java/org/jabref/logic/importer/util/JSONEntryParser.java @@ -30,8 +30,6 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry, Character keywordS // Fields that are accessible in the journal part of the BibJson object String[] journalSingleFieldStrings = {FieldName.PUBLISHER, FieldName.NUMBER, FieldName.VOLUME}; - - BibEntry entry = new BibEntry(); entry.setType("article"); diff --git a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java index 904fdfc501f..b44a51c1a96 100644 --- a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java +++ b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java @@ -45,7 +45,6 @@ public static MetaData parse(MetaData metaData, Map data, Charac for (Map.Entry entry : data.entrySet()) { List value = getAsList(entry.getValue()); - if (entry.getKey().startsWith(MetaData.PREFIX_KEYPATTERN)) { String entryType = entry.getKey().substring(MetaData.PREFIX_KEYPATTERN.length()); nonDefaultCiteKeyPatterns.put(entryType, Collections.singletonList(getSingleItem(value))); @@ -55,7 +54,7 @@ public static MetaData parse(MetaData metaData, Map data, Charac String user = entry.getKey().substring(MetaData.FILE_DIRECTORY.length() + 1); metaData.setUserFileDirectory(user, getSingleItem(value)); continue; - } else if(entry.getKey().startsWith(MetaData.SELECTOR_META_PREFIX)){ + } else if (entry.getKey().startsWith(MetaData.SELECTOR_META_PREFIX)) { metaData.addContentSelector(ContentSelectors.parse(entry.getKey().substring(MetaData.SELECTOR_META_PREFIX.length()), StringUtil.unquote(entry.getValue(), MetaData.ESCAPE_CHARACTER))); continue; } diff --git a/src/main/java/org/jabref/logic/integrity/EntryLinkChecker.java b/src/main/java/org/jabref/logic/integrity/EntryLinkChecker.java index 933d64910fe..9dad4ac8a45 100644 --- a/src/main/java/org/jabref/logic/integrity/EntryLinkChecker.java +++ b/src/main/java/org/jabref/logic/integrity/EntryLinkChecker.java @@ -14,7 +14,6 @@ import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; - public class EntryLinkChecker implements Checker { private final BibDatabase database; diff --git a/src/main/java/org/jabref/logic/integrity/FileChecker.java b/src/main/java/org/jabref/logic/integrity/FileChecker.java index 38049a3c284..56b9f89ca17 100644 --- a/src/main/java/org/jabref/logic/integrity/FileChecker.java +++ b/src/main/java/org/jabref/logic/integrity/FileChecker.java @@ -23,7 +23,6 @@ public FileChecker(BibDatabaseContext context, FileDirectoryPreferences fileDire this.fileDirectoryPreferences = fileDirectoryPreferences; } - @Override public Optional checkValue(String value) { List linkedFiles = FileFieldParser.parse(value).stream() diff --git a/src/main/java/org/jabref/logic/integrity/ISBNChecker.java b/src/main/java/org/jabref/logic/integrity/ISBNChecker.java index 1441909c642..a8aa29054c0 100644 --- a/src/main/java/org/jabref/logic/integrity/ISBNChecker.java +++ b/src/main/java/org/jabref/logic/integrity/ISBNChecker.java @@ -5,7 +5,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.identifier.ISBN; - public class ISBNChecker implements ValueChecker { @Override diff --git a/src/main/java/org/jabref/logic/integrity/ISSNChecker.java b/src/main/java/org/jabref/logic/integrity/ISSNChecker.java index 9046c5e845c..11dae320d84 100644 --- a/src/main/java/org/jabref/logic/integrity/ISSNChecker.java +++ b/src/main/java/org/jabref/logic/integrity/ISSNChecker.java @@ -5,7 +5,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.identifier.ISSN; - public class ISSNChecker implements ValueChecker { @Override diff --git a/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java b/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java index e349e4ef093..62e49aa6232 100644 --- a/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java +++ b/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java @@ -70,7 +70,6 @@ private List checkBibtexEntry(BibEntry entry) { return result; } - @FunctionalInterface public interface Checker { List check(BibEntry entry); diff --git a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java index eb0916a41d5..c5d8eab569f 100644 --- a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java +++ b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java @@ -1,6 +1,5 @@ package org.jabref.logic.journals; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -24,10 +23,10 @@ */ public class AbbreviationParser { - private final List abbreviations = new LinkedList<>(); - private static final Log LOGGER = LogFactory.getLog(AbbreviationParser.class); + private final List abbreviations = new LinkedList<>(); + public void readJournalListFromResource(String resourceFileName) { URL url = Objects.requireNonNull(JournalAbbreviationRepository.class.getResource(Objects.requireNonNull(resourceFileName))); try { @@ -38,7 +37,7 @@ public void readJournalListFromResource(String resourceFileName) { } public void readJournalListFromFile(File file) throws FileNotFoundException { - try(FileReader reader = new FileReader(Objects.requireNonNull(file))) { + try (FileReader reader = new FileReader(Objects.requireNonNull(file))) { readJournalList(reader); } catch (FileNotFoundException e) { throw e; @@ -65,7 +64,7 @@ public void readJournalListFromFile(File file, Charset encoding) throws FileNotF * @param in */ private void readJournalList(Reader in) { - try(BufferedReader reader = new BufferedReader(in)){ + try (BufferedReader reader = new BufferedReader(in)) { String line; while ((line = reader.readLine()) != null) { addLine(line); diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java index 0554f4053d7..21f4f59f5bf 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java @@ -20,6 +20,37 @@ public class JournalAbbreviationLoader { private static final String JOURNALS_IEEE_ABBREVIATION_LIST_WITH_TEXT = "/journals/IEEEJournalListText.txt"; private JournalAbbreviationRepository journalAbbrev; + public static List getOfficialIEEEAbbreviations() { + return readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_CODE); + } + + public static List getStandardIEEEAbbreviations() { + return readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_TEXT); + } + + public static List getBuiltInAbbreviations() { + return readJournalListFromResource(JOURNALS_FILE_BUILTIN); + } + + public static List readJournalListFromResource(String resource) { + AbbreviationParser parser = new AbbreviationParser(); + parser.readJournalListFromResource(Objects.requireNonNull(resource)); + return parser.getAbbreviations(); + } + + public static List readJournalListFromFile(File file) throws FileNotFoundException { + LOGGER.debug("Reading journal list from file " + file); + AbbreviationParser parser = new AbbreviationParser(); + parser.readJournalListFromFile(Objects.requireNonNull(file)); + return parser.getAbbreviations(); + } + + public static List readJournalListFromFile(File file, Charset encoding) throws FileNotFoundException { + LOGGER.debug("Reading journal list from file " + file); + AbbreviationParser parser = new AbbreviationParser(); + parser.readJournalListFromFile(Objects.requireNonNull(file), Objects.requireNonNull(encoding)); + return parser.getAbbreviations(); + } public void update(JournalAbbreviationPreferences journalAbbreviationPreferences) { journalAbbrev = new JournalAbbreviationRepository(); @@ -32,7 +63,7 @@ public void update(JournalAbbreviationPreferences journalAbbreviationPreferences journalAbbrev.addEntries(readJournalListFromResource(JOURNALS_FILE_BUILTIN)); // read IEEE list - if (journalAbbreviationPreferences.isUseIEEEAbbreviations()) { + if (journalAbbreviationPreferences.useIEEEAbbreviations()) { journalAbbrev.addEntries(getOfficialIEEEAbbreviations()); } else { journalAbbrev.addEntries(getStandardIEEEAbbreviations()); @@ -66,42 +97,10 @@ public void update(JournalAbbreviationPreferences journalAbbreviationPreferences } - public static List getOfficialIEEEAbbreviations() { - return readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_CODE); - } - - public static List getStandardIEEEAbbreviations() { - return readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_TEXT); - } - - public static List getBuiltInAbbreviations() { - return readJournalListFromResource(JOURNALS_FILE_BUILTIN); - } - public JournalAbbreviationRepository getRepository(JournalAbbreviationPreferences journalAbbreviationPreferences) { if (journalAbbrev == null) { update(journalAbbreviationPreferences); } return journalAbbrev; } - - public static List readJournalListFromResource(String resource) { - AbbreviationParser parser = new AbbreviationParser(); - parser.readJournalListFromResource(Objects.requireNonNull(resource)); - return parser.getAbbreviations(); - } - - public static List readJournalListFromFile(File file) throws FileNotFoundException { - LOGGER.debug("Reading journal list from file " + file); - AbbreviationParser parser = new AbbreviationParser(); - parser.readJournalListFromFile(Objects.requireNonNull(file)); - return parser.getAbbreviations(); - } - - public static List readJournalListFromFile(File file, Charset encoding) throws FileNotFoundException { - LOGGER.debug("Reading journal list from file " + file); - AbbreviationParser parser = new AbbreviationParser(); - parser.readJournalListFromFile(Objects.requireNonNull(file), Objects.requireNonNull(encoding)); - return parser.getAbbreviations(); - } } diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationPreferences.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationPreferences.java index 3a1463c6ef7..994e5114552 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationPreferences.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationPreferences.java @@ -3,16 +3,12 @@ import java.nio.charset.Charset; import java.util.List; -import org.jabref.preferences.JabRefPreferences; - public class JournalAbbreviationPreferences { - private final List externalJournalLists; private final String personalJournalLists; - private final boolean useIEEEAbbreviations; private final Charset defaultEncoding; - - + private List externalJournalLists; + private boolean useIEEEAbbreviations; public JournalAbbreviationPreferences(List externalJournalLists, String personalJournalLists, boolean useIEEEAbbreviations, Charset defaultEncoding) { this.externalJournalLists = externalJournalLists; @@ -21,22 +17,23 @@ public JournalAbbreviationPreferences(List externalJournalLists, String this.defaultEncoding = defaultEncoding; } - public static JournalAbbreviationPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new JournalAbbreviationPreferences( - jabRefPreferences.getStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS), - jabRefPreferences.get(JabRefPreferences.PERSONAL_JOURNAL_LIST), - jabRefPreferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV), jabRefPreferences.getDefaultEncoding()); + public void setUseIEEEAbbreviations(boolean useIEEEAbbreviations) { + this.useIEEEAbbreviations = useIEEEAbbreviations; } public List getExternalJournalLists() { return externalJournalLists; } + public void setExternalJournalLists(List externalJournalLists) { + this.externalJournalLists = externalJournalLists; + } + public String getPersonalJournalLists() { return personalJournalLists; } - public boolean isUseIEEEAbbreviations() { + public boolean useIEEEAbbreviations() { return useIEEEAbbreviations; } diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java index 50aa063d873..56a26be1b39 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java @@ -18,14 +18,14 @@ */ public class JournalAbbreviationRepository { + private static final Log LOGGER = LogFactory.getLog(JournalAbbreviationRepository.class); private final Map fullNameLowerCase2Abbreviation = new HashMap<>(); private final Map isoLowerCase2Abbreviation = new HashMap<>(); + private final Map medlineLowerCase2Abbreviation = new HashMap<>(); private final SortedSet abbreviations = new TreeSet<>(); - private static final Log LOGGER = LogFactory.getLog(JournalAbbreviationRepository.class); - public JournalAbbreviationRepository(Abbreviation... abbreviations) { for (Abbreviation abbreviation : abbreviations) { addEntry(abbreviation); diff --git a/src/main/java/org/jabref/logic/l10n/Localization.java b/src/main/java/org/jabref/logic/l10n/Localization.java index 7667be55d25..8fafc13b3ae 100644 --- a/src/main/java/org/jabref/logic/l10n/Localization.java +++ b/src/main/java/org/jabref/logic/l10n/Localization.java @@ -11,12 +11,12 @@ import org.apache.commons.logging.LogFactory; public class Localization { - private static final Log LOGGER = LogFactory.getLog(Localization.class); - public static final String RESOURCE_PREFIX = "l10n/JabRef"; public static final String MENU_RESOURCE_PREFIX = "l10n/Menu"; public static final String BIBTEX = "BibTeX"; + private static final Log LOGGER = LogFactory.getLog(Localization.class); + private static ResourceBundle messages; private static ResourceBundle menuTitles; @@ -29,8 +29,8 @@ public static LocalizationBundle getMessages() { public static void setLanguage(String language) { Optional knownLanguage = Languages.convertToSupportedLocale(language); - if(!knownLanguage.isPresent()) { - LOGGER.warn("Language " + language + " is not supported by JabRef (Default:" + Locale.getDefault()+ ")"); + if (!knownLanguage.isPresent()) { + LOGGER.warn("Language " + language + " is not supported by JabRef (Default:" + Locale.getDefault() + ")"); setLanguage("en"); return; } @@ -84,14 +84,14 @@ protected static String translate(ResourceBundle resBundle, String idForErrorMes } public static String lang(String key, String... params) { - if(messages == null) { + if (messages == null) { setLanguage("en"); } return translate(messages, "message", key, params); } public static String menuTitle(String key, String... params) { - if(menuTitles == null) { + if (menuTitles == null) { setLanguage("en"); } return translate(menuTitles, "menu item", key, params); diff --git a/src/main/java/org/jabref/logic/layout/Layout.java b/src/main/java/org/jabref/logic/layout/Layout.java index 4ce57619c86..8b541cc36a3 100644 --- a/src/main/java/org/jabref/logic/layout/Layout.java +++ b/src/main/java/org/jabref/logic/layout/Layout.java @@ -16,12 +16,12 @@ */ public class Layout { + private static final Log LOGGER = LogFactory.getLog(Layout.class); + private final List layoutEntries; private final List missingFormatters = new ArrayList<>(); - private static final Log LOGGER = LogFactory.getLog(Layout.class); - public Layout(List parsedEntries, LayoutFormatterPreferences prefs) { List tmpEntries = new ArrayList<>(parsedEntries.size()); diff --git a/src/main/java/org/jabref/logic/layout/format/Authors.java b/src/main/java/org/jabref/logic/layout/format/Authors.java index 384e22ea67a..b1514623c87 100644 --- a/src/main/java/org/jabref/logic/layout/format/Authors.java +++ b/src/main/java/org/jabref/logic/layout/format/Authors.java @@ -98,7 +98,6 @@ public class Authors extends AbstractParamLayoutFormatter { private String lastSeparator = Authors.AND; private String etAlString = " et al."; - @Override public void setArgument(String arg) { List parts = AbstractParamLayoutFormatter.parseArgument(arg); diff --git a/src/main/java/org/jabref/logic/layout/format/CreateDocBookAuthors.java b/src/main/java/org/jabref/logic/layout/format/CreateDocBookAuthors.java index 146e2cf6ac8..d2ffb6d250c 100644 --- a/src/main/java/org/jabref/logic/layout/format/CreateDocBookAuthors.java +++ b/src/main/java/org/jabref/logic/layout/format/CreateDocBookAuthors.java @@ -12,7 +12,6 @@ public class CreateDocBookAuthors implements LayoutFormatter { private static final XMLChars XML_CHARS = new XMLChars(); - @Override public String format(String fieldText) { diff --git a/src/main/java/org/jabref/logic/layout/format/DateFormatter.java b/src/main/java/org/jabref/logic/layout/format/DateFormatter.java index fe8d6436b8d..cfcc976b5f5 100644 --- a/src/main/java/org/jabref/logic/layout/format/DateFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/DateFormatter.java @@ -5,12 +5,10 @@ import org.jabref.logic.layout.ParamLayoutFormatter; - public class DateFormatter implements ParamLayoutFormatter { private String formatString = "yyyy-MM-dd"; // Use ISO-format as default - @Override public String format(String fieldText) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatString); diff --git a/src/main/java/org/jabref/logic/layout/format/Default.java b/src/main/java/org/jabref/logic/layout/format/Default.java index b53f1798f1b..6c2a5d6c60e 100644 --- a/src/main/java/org/jabref/logic/layout/format/Default.java +++ b/src/main/java/org/jabref/logic/layout/format/Default.java @@ -10,7 +10,6 @@ public class Default implements ParamLayoutFormatter { private String defValue = ""; - @Override public void setArgument(String arg) { this.defValue = arg; diff --git a/src/main/java/org/jabref/logic/layout/format/HTMLParagraphs.java b/src/main/java/org/jabref/logic/layout/format/HTMLParagraphs.java index 420b5d3a483..6ff02794dda 100644 --- a/src/main/java/org/jabref/logic/layout/format/HTMLParagraphs.java +++ b/src/main/java/org/jabref/logic/layout/format/HTMLParagraphs.java @@ -13,7 +13,6 @@ public class HTMLParagraphs implements LayoutFormatter { private static final Pattern BEFORE_NEW_LINES_PATTERN = Pattern.compile("(.*?)\\n\\s*\\n"); - @Override public String format(String fieldText) { diff --git a/src/main/java/org/jabref/logic/layout/format/IfPlural.java b/src/main/java/org/jabref/logic/layout/format/IfPlural.java index 38b45efc036..46eb9fa0e08 100644 --- a/src/main/java/org/jabref/logic/layout/format/IfPlural.java +++ b/src/main/java/org/jabref/logic/layout/format/IfPlural.java @@ -23,7 +23,6 @@ public class IfPlural extends AbstractParamLayoutFormatter { private String pluralText; private String singularText; - @Override public void setArgument(String arg) { List parts = AbstractParamLayoutFormatter.parseArgument(arg); diff --git a/src/main/java/org/jabref/logic/layout/format/Iso690FormatDate.java b/src/main/java/org/jabref/logic/layout/format/Iso690FormatDate.java index 841d0ed1f4d..ecd7cf7fb8c 100644 --- a/src/main/java/org/jabref/logic/layout/format/Iso690FormatDate.java +++ b/src/main/java/org/jabref/logic/layout/format/Iso690FormatDate.java @@ -19,7 +19,7 @@ public String format(String s) { //parte el string en los distintos campos de la fecha if (date.length == 1) { //sólo pone el año sb.append(date[0].trim()); - } else if (date.length == 2) {//primer campo mes, segundo campo año + } else if (date.length == 2) { //primer campo mes, segundo campo año //cambiamos al formato año - mes sb.append(date[1].trim()).append('-').append(date[0].trim()); } else if (date.length == 3) { diff --git a/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java b/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java index 41a8278e8d0..6f8bdf016d8 100644 --- a/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java +++ b/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java @@ -33,10 +33,10 @@ public String format(String s) { String name; String surname; - if (author.length == 1) {// Caso 1.0: Sólo un campo + if (author.length == 1) { // Caso 1.0: Sólo un campo sb.append(author[0].trim().toUpperCase(Locale.ROOT)); - } else if (author.length == 2) {// Caso 1.1: Nombre Apellido + } else if (author.length == 2) { // Caso 1.1: Nombre Apellido //primer campo Nombre name = author[0].trim(); //Segundo campo Apellido @@ -47,7 +47,7 @@ public String format(String s) { sb.append(", "); sb.append(name); - } else if (author.length == 3) {// Caso 1.2: Nombre Apellido1 Apellido2 + } else if (author.length == 3) { // Caso 1.2: Nombre Apellido1 Apellido2 //primer campo Nombre name = author[0].trim(); //Segundo y tercer campo Apellido1 Apellido2 @@ -58,7 +58,7 @@ public String format(String s) { sb.append(", "); sb.append(name); - } else if (author.length == 4) {// Caso 1.3: Nombre SegundoNombre Apellido1 Apellido2 + } else if (author.length == 4) { // Caso 1.3: Nombre SegundoNombre Apellido1 Apellido2 //primer y segundo campo Nombre SegundoNombre name = author[0].trim() + ' ' + author[1].trim(); //tercer y cuarto campo Apellido1 Apellido2 @@ -82,7 +82,7 @@ public String format(String s) { } if (i < authors.length - 2) { //si hay mas de 2 autores, lo separamos por ", " sb.append(", "); - } else if (i == authors.length - 2) {// si hay 2 autores, lo separamos por " y " + } else if (i == authors.length - 2) { // si hay 2 autores, lo separamos por " y " sb.append(" y "); } } diff --git a/src/main/java/org/jabref/logic/layout/format/NameFormatter.java b/src/main/java/org/jabref/logic/layout/format/NameFormatter.java index 7fa424881c0..8c70fad7ea2 100644 --- a/src/main/java/org/jabref/logic/layout/format/NameFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/NameFormatter.java @@ -159,8 +159,6 @@ public String format(String fieldText) { return format(fieldText, parameter); } - - public void setParameter(String parameter) { this.parameter = parameter; } diff --git a/src/main/java/org/jabref/logic/layout/format/NameFormatterPreferences.java b/src/main/java/org/jabref/logic/layout/format/NameFormatterPreferences.java index 897b77e23d7..ef509030eff 100644 --- a/src/main/java/org/jabref/logic/layout/format/NameFormatterPreferences.java +++ b/src/main/java/org/jabref/logic/layout/format/NameFormatterPreferences.java @@ -17,7 +17,6 @@ public List getNameFormatterKey() { return nameFormatterKey; } - public List getNameFormatterValue() { return nameFormatterValue; } diff --git a/src/main/java/org/jabref/logic/layout/format/Replace.java b/src/main/java/org/jabref/logic/layout/format/Replace.java index a1cb430a311..c8e4b60f86a 100644 --- a/src/main/java/org/jabref/logic/layout/format/Replace.java +++ b/src/main/java/org/jabref/logic/layout/format/Replace.java @@ -38,7 +38,6 @@ public class Replace extends AbstractParamLayoutFormatter { private String regex; private String replaceWith; - @Override public void setArgument(String arg) { List parts = AbstractParamLayoutFormatter.parseArgument(arg); diff --git a/src/main/java/org/jabref/logic/layout/format/RisAuthors.java b/src/main/java/org/jabref/logic/layout/format/RisAuthors.java index f9806cd5c62..b1f9439dc11 100644 --- a/src/main/java/org/jabref/logic/layout/format/RisAuthors.java +++ b/src/main/java/org/jabref/logic/layout/format/RisAuthors.java @@ -8,7 +8,6 @@ public class RisAuthors implements ParamLayoutFormatter { private String arg = ""; - @Override public String format(String s) { if (s == null) { diff --git a/src/main/java/org/jabref/logic/layout/format/WrapContent.java b/src/main/java/org/jabref/logic/layout/format/WrapContent.java index 6c8e7c94d5b..10152395390 100644 --- a/src/main/java/org/jabref/logic/layout/format/WrapContent.java +++ b/src/main/java/org/jabref/logic/layout/format/WrapContent.java @@ -18,7 +18,6 @@ public class WrapContent extends AbstractParamLayoutFormatter { private String before; private String after; - @Override public void setArgument(String arg) { List parts = AbstractParamLayoutFormatter.parseArgument(arg); diff --git a/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java b/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java index d312a2ceb9b..93c12ff9f39 100644 --- a/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java +++ b/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java @@ -78,7 +78,6 @@ public class WrapFileLinks extends AbstractParamLayoutFormatter { private static final Log LOGGER = LogFactory.getLog(WrapFileLinks.class); - // Define codes for the various escape sequences that can be inserted: private static final int STRING = 0; private static final int ITERATION_COUNT = 1; private static final int FILE_PATH = 2; diff --git a/src/main/java/org/jabref/logic/layout/format/XMLChars.java b/src/main/java/org/jabref/logic/layout/format/XMLChars.java index 2d65f043709..59c98142969 100644 --- a/src/main/java/org/jabref/logic/layout/format/XMLChars.java +++ b/src/main/java/org/jabref/logic/layout/format/XMLChars.java @@ -17,7 +17,6 @@ public class XMLChars implements LayoutFormatter { private boolean[] forceReplace; - static { ASCII_TO_XML_CHARS.put("<", "<"); ASCII_TO_XML_CHARS.put("\"", """); @@ -47,8 +46,6 @@ private static String firstFormat(String s) { return s.replaceAll("&|\\\\&", "&").replace("--", "–"); } - - private String restFormat(String toFormat) { String fieldText = toFormat.replace("}", "").replace("{", ""); diff --git a/src/main/java/org/jabref/logic/logging/LogMessages.java b/src/main/java/org/jabref/logic/logging/LogMessages.java index d626f292789..06f10f1c3eb 100644 --- a/src/main/java/org/jabref/logic/logging/LogMessages.java +++ b/src/main/java/org/jabref/logic/logging/LogMessages.java @@ -14,6 +14,8 @@ public class LogMessages { private static LogMessages instance = new LogMessages(); + private final ObservableList messages = FXCollections.observableArrayList(); + private LogMessages() { } @@ -21,8 +23,6 @@ public static LogMessages getInstance() { return instance; } - private final ObservableList messages = FXCollections.observableArrayList(); - public ObservableList getMessages() { return FXCollections.unmodifiableObservableList(messages); } diff --git a/src/main/java/org/jabref/logic/msbib/MSBibDatabase.java b/src/main/java/org/jabref/logic/msbib/MSBibDatabase.java index 0cfd3e69cdb..56703304e3d 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibDatabase.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibDatabase.java @@ -31,11 +31,11 @@ */ public class MSBibDatabase { - private static final Log LOGGER = LogFactory.getLog(MSBibDatabase.class); - public static final String NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography"; public static final String PREFIX = "b:"; + private static final Log LOGGER = LogFactory.getLog(MSBibDatabase.class); + private Set entries; diff --git a/src/main/java/org/jabref/logic/msbib/MSBibEntry.java b/src/main/java/org/jabref/logic/msbib/MSBibEntry.java index 85566964b84..7e1cb3d2758 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibEntry.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibEntry.java @@ -26,9 +26,16 @@ */ class MSBibEntry { + /** + * Allows 20.3-2007|||20/3- 2007 etc. + * (\d{1,2})\s?[.,-/]\s?(\d{1,2})\s?[.,-/]\s?(\d{2,4}) + * 1-2 DIGITS SPACE SEPERATOR SPACE 1-2 DIGITS SPACE SEPERATOR SPACE 2-4 DIGITS + */ + private static final Pattern DATE_PATTERN = Pattern + .compile("(\\d{1,2})\\s*[.,-/]\\s*(\\d{1,2})\\s*[.,-/]\\s*(\\d{2,4})"); + // MSBib fields and values public Map fields = new HashMap<>(); - public List authors; public List bookAuthors; public List editors; @@ -43,10 +50,10 @@ class MSBibEntry { public List interviewers; public List interviewees; public List inventors; + public List counsels; public PageNumbers pages; - public String standardNumber; public String address; public String conferenceName; @@ -61,6 +68,7 @@ class MSBibEntry { public String day; public String number; public String patentNumber; + public String journalName; private String bibtexEntryType; @@ -74,14 +82,6 @@ class MSBibEntry { */ private final Pattern ADDRESS_PATTERN = Pattern.compile("\\b(\\w+)\\s?[,]?\\s?(\\w*)\\s?[,]?\\s?(\\w*)\\b"); - /** - * Allows 20.3-2007|||20/3- 2007 etc. - * (\d{1,2})\s?[.,-/]\s?(\d{1,2})\s?[.,-/]\s?(\d{2,4}) - * 1-2 DIGITS SPACE SEPERATOR SPACE 1-2 DIGITS SPACE SEPERATOR SPACE 2-4 DIGITS - */ - private static final Pattern DATE_PATTERN = Pattern - .compile("(\\d{1,2})\\s*[.,-/]\\s*(\\d{1,2})\\s*[.,-/]\\s*(\\d{2,4})"); - public MSBibEntry() { //empty } diff --git a/src/main/java/org/jabref/logic/msbib/PageNumbers.java b/src/main/java/org/jabref/logic/msbib/PageNumbers.java index 89faaf53247..e5b7e270c50 100644 --- a/src/main/java/org/jabref/logic/msbib/PageNumbers.java +++ b/src/main/java/org/jabref/logic/msbib/PageNumbers.java @@ -8,11 +8,11 @@ import org.w3c.dom.Node; public class PageNumbers { + private static final Pattern PAGE_PATTERN = Pattern.compile("\\s*(\\d+)\\s*-{1,2}\\s*(\\d+)\\s*"); private String freeform; private int start; - private int end; - private static final Pattern PAGE_PATTERN = Pattern.compile("\\s*(\\d+)\\s*-{1,2}\\s*(\\d+)\\s*"); + private int end; public PageNumbers(String pages) { parsePageNums(pages); diff --git a/src/main/java/org/jabref/logic/net/URLDownload.java b/src/main/java/org/jabref/logic/net/URLDownload.java index 37582330ec1..bbda7b99901 100644 --- a/src/main/java/org/jabref/logic/net/URLDownload.java +++ b/src/main/java/org/jabref/logic/net/URLDownload.java @@ -55,10 +55,10 @@ * Each call to a public method creates a new HTTP connection. Nothing is cached. */ public class URLDownload { - private static final Log LOGGER = LogFactory.getLog(URLDownload.class); - public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"; + private static final Log LOGGER = LogFactory.getLog(URLDownload.class); + private final URL source; private final Map parameters = new HashMap<>(); @@ -252,7 +252,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType) { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } - }}; + } }; // Install the all-trusting trust manager try { diff --git a/src/main/java/org/jabref/logic/net/URLUtil.java b/src/main/java/org/jabref/logic/net/URLUtil.java index 0d86550eb1c..079e1bf2f61 100644 --- a/src/main/java/org/jabref/logic/net/URLUtil.java +++ b/src/main/java/org/jabref/logic/net/URLUtil.java @@ -30,7 +30,7 @@ private URLUtil() { public static String cleanGoogleSearchURL(String url) { Objects.requireNonNull(url); - if(!url.matches(GOOGLE_SEARCH_EXP)) { + if (!url.matches(GOOGLE_SEARCH_EXP)) { return url; } // Extract destination URL @@ -52,7 +52,7 @@ public static String cleanGoogleSearchURL(String url) { String decode = URLDecoder.decode(value, StandardCharsets.UTF_8.name()); // url? - if(decode.matches(URL_EXP)) { + if (decode.matches(URL_EXP)) { return decode; } } diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index d2758ba2cf8..acaa48c8a1a 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -53,90 +53,90 @@ */ public class OOBibStyle implements Comparable { - public static final String UNDEFINED_CITATION_MARKER = "??"; - private String name = ""; - private final SortedSet journals = new TreeSet<>(); - - // Formatter to be run on fields before they are used as part of citation marker: - private final LayoutFormatter fieldFormatter = new OOPreFormatter(); - - private Layout defaultBibLayout; - - // reference layout mapped from entry type number: - private final Map bibLayout = new HashMap<>(); - - private final Map properties = new HashMap<>(); - private final Map citProperties = new HashMap<>(); + public static final String ITALIC_ET_AL = "ItalicEtAl"; + public static final String MULTI_CITE_CHRONOLOGICAL = "MultiCiteChronological"; + public static final String MINIMUM_GROUPING_COUNT = "MinimumGroupingCount"; + public static final String ET_AL_STRING = "EtAlString"; + public static final String MAX_AUTHORS_FIRST = "MaxAuthorsFirst"; + public static final String REFERENCE_HEADER_PARAGRAPH_FORMAT = "ReferenceHeaderParagraphFormat"; + public static final String REFERENCE_PARAGRAPH_FORMAT = "ReferenceParagraphFormat"; + public static final String TITLE = "Title"; + public static final String UNDEFINED_CITATION_MARKER = "??"; private static final Pattern NUM_PATTERN = Pattern.compile("-?\\d+"); - - private boolean valid; - - private final boolean fromResource; - - private final String path; - - - enum BibStyleMode { - NONE, - LAYOUT, - PROPERTIES, - CITATION, - NAME, - JOURNALS - } private static final String LAYOUT_MRK = "LAYOUT"; private static final String PROPERTIES_MARK = "PROPERTIES"; private static final String CITATION_MARK = "CITATION"; private static final String NAME_MARK = "NAME"; private static final String JOURNALS_MARK = "JOURNALS"; private static final String DEFAULT_MARK = "default"; - private File styleFile; - private final Charset encoding; - private long styleFileModificationTime = Long.MIN_VALUE; - private String localCopy; - private static final String BRACKET_AFTER_IN_LIST = "BracketAfterInList"; private static final String BRACKET_BEFORE_IN_LIST = "BracketBeforeInList"; private static final String UNIQUEFIER_SEPARATOR = "UniquefierSeparator"; - public static final String ITALIC_ET_AL = "ItalicEtAl"; private static final String BIBTEX_KEY_CITATIONS = "BibTeXKeyCitations"; - public static final String MULTI_CITE_CHRONOLOGICAL = "MultiCiteChronological"; private static final String SUBSCRIPT_CITATIONS = "SubscriptCitations"; private static final String SUPERSCRIPT_CITATIONS = "SuperscriptCitations"; private static final String BOLD_CITATIONS = "BoldCitations"; private static final String ITALIC_CITATIONS = "ItalicCitations"; private static final String CITATION_CHARACTER_FORMAT = "CitationCharacterFormat"; private static final String FORMAT_CITATIONS = "FormatCitations"; - public static final String MINIMUM_GROUPING_COUNT = "MinimumGroupingCount"; private static final String GROUPED_NUMBERS_SEPARATOR = "GroupedNumbersSeparator"; private static final String PAGE_INFO_SEPARATOR = "PageInfoSeparator"; private static final String CITATION_SEPARATOR = "CitationSeparator"; private static final String IN_TEXT_YEAR_SEPARATOR = "InTextYearSeparator"; - public static final String ET_AL_STRING = "EtAlString"; - public static final String MAX_AUTHORS_FIRST = "MaxAuthorsFirst"; private static final String MAX_AUTHORS = "MaxAuthors"; private static final String YEAR_FIELD = "YearField"; private static final String AUTHOR_FIELD = "AuthorField"; - public static final String REFERENCE_HEADER_PARAGRAPH_FORMAT = "ReferenceHeaderParagraphFormat"; - public static final String REFERENCE_PARAGRAPH_FORMAT = "ReferenceParagraphFormat"; private static final String BRACKET_AFTER = "BracketAfter"; private static final String BRACKET_BEFORE = "BracketBefore"; private static final String IS_NUMBER_ENTRIES = "IsNumberEntries"; private static final String IS_SORT_BY_POSITION = "IsSortByPosition"; private static final String SORT_ALGORITHM = "SortAlgorithm"; private static final String OXFORD_COMMA = "OxfordComma"; - public static final String TITLE = "Title"; private static final String YEAR_SEPARATOR = "YearSeparator"; private static final String AUTHOR_LAST_SEPARATOR_IN_TEXT = "AuthorLastSeparatorInText"; private static final String AUTHOR_LAST_SEPARATOR = "AuthorLastSeparator"; + private static final String AUTHOR_SEPARATOR = "AuthorSeparator"; - private final LayoutFormatterPreferences prefs; private static final Pattern QUOTED = Pattern.compile("\".*\""); private static final Log LOGGER = LogFactory.getLog(OOBibStyle.class); + private String name = ""; + + private final SortedSet journals = new TreeSet<>(); + // Formatter to be run on fields before they are used as part of citation marker: + private final LayoutFormatter fieldFormatter = new OOPreFormatter(); + + private Layout defaultBibLayout; + + // reference layout mapped from entry type number: + private final Map bibLayout = new HashMap<>(); + + private final Map properties = new HashMap<>(); + + private final Map citProperties = new HashMap<>(); + + private boolean valid; + private final boolean fromResource; + private final String path; + + enum BibStyleMode { + NONE, + LAYOUT, + PROPERTIES, + CITATION, + NAME, + JOURNALS + } + + private File styleFile; + private final Charset encoding; + private long styleFileModificationTime = Long.MIN_VALUE; + private String localCopy; + private final LayoutFormatterPreferences prefs; + public OOBibStyle(File styleFile, LayoutFormatterPreferences prefs, Charset encoding) throws IOException { @@ -538,7 +538,6 @@ public String getCitationMarker(List entries, Map oldUniqVal = entry.getField(UNIQUEFIER_FIELD); - // Set the uniq field with the supplied uniquefier: if (uniquefier == null) { entry.clearField(UNIQUEFIER_FIELD); diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java index aa4f088442b..54137950ca5 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficePreferences.java @@ -20,8 +20,6 @@ */ public class OpenOfficePreferences { - private final JabRefPreferences preferences; - public static final String DEFAULT_WINDOWS_PATH = "C:\\Program Files\\OpenOffice.org 4"; public static final String DEFAULT_WIN_EXEC_PATH = "C:\\Program Files\\OpenOffice.org 4\\program\\soffice.exe"; public static final String WINDOWS_EXECUTABLE = "soffice.exe"; @@ -36,6 +34,8 @@ public class OpenOfficePreferences { public static final List OO_JARS = Arrays.asList("unoil.jar", "jurt.jar", "juh.jar", "ridl.jar"); + private final JabRefPreferences preferences; + public OpenOfficePreferences(JabRefPreferences preferences) { this.preferences = preferences; } @@ -124,6 +124,7 @@ public String getCurrentStyle() { public void clearCurrentStyle() { preferences.remove(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE); } + public void setCurrentStyle(String path) { preferences.put(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE, path); } diff --git a/src/main/java/org/jabref/logic/openoffice/StyleLoader.java b/src/main/java/org/jabref/logic/openoffice/StyleLoader.java index 0e51b4aa506..405478002c9 100644 --- a/src/main/java/org/jabref/logic/openoffice/StyleLoader.java +++ b/src/main/java/org/jabref/logic/openoffice/StyleLoader.java @@ -16,11 +16,11 @@ public class StyleLoader { - private static final Log LOGGER = LogFactory.getLog(StyleLoader.class); - public static final String DEFAULT_AUTHORYEAR_STYLE_PATH = "/resource/openoffice/default_authoryear.jstyle"; public static final String DEFAULT_NUMERICAL_STYLE_PATH = "/resource/openoffice/default_numerical.jstyle"; + private static final Log LOGGER = LogFactory.getLog(StyleLoader.class); + // All internal styles private final List internalStyleFiles = Arrays.asList(DEFAULT_AUTHORYEAR_STYLE_PATH, DEFAULT_NUMERICAL_STYLE_PATH); diff --git a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java index 60fad7633ef..75a024e205e 100644 --- a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java +++ b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java @@ -13,16 +13,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - public class FileAnnotationCache { + private static final Log LOGGER = LogFactory.getLog(FileAnnotation.class); //cache size in entries private final static int CACHE_SIZE = 10; + //the inner list holds the annotations per file, the outer collection maps this to a BibEntry. private LoadingCache>> annotationCache; - private static final Log LOGGER = LogFactory.getLog(FileAnnotation.class); - public FileAnnotationCache(BibDatabaseContext context) { annotationCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build(new CacheLoader>>() { @Override diff --git a/src/main/java/org/jabref/logic/pdf/PdfAnnotationImporter.java b/src/main/java/org/jabref/logic/pdf/PdfAnnotationImporter.java index 4089d1b4e47..3caf4c216cb 100644 --- a/src/main/java/org/jabref/logic/pdf/PdfAnnotationImporter.java +++ b/src/main/java/org/jabref/logic/pdf/PdfAnnotationImporter.java @@ -26,7 +26,6 @@ import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; import org.apache.pdfbox.util.PDFTextStripperByArea; - public class PdfAnnotationImporter implements AnnotationImporter { private static final Log LOGGER = LogFactory.getLog(PdfAnnotationImporter.class); @@ -99,7 +98,6 @@ private FileAnnotation createMarkedAnnotations(int pageIndex, PDPage page, PDAnn return new FileAnnotation(annotation, pageIndex + 1, annotationBelongingToMarking); } - private String extractMarkedText(PDPage page, PDAnnotation annotation) throws IOException { //highlighted or underlined text has to be extracted by the rectangle calculated from the marking PDFTextStripperByArea stripperByArea = new PDFTextStripperByArea(); diff --git a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsList.java b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsList.java index 585006ba11d..8517c453c50 100644 --- a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsList.java +++ b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsList.java @@ -41,12 +41,10 @@ public String getDescription() { return description; } - public List getTermList() { return termsList; } - public String getLocation() { return location; } diff --git a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsLoader.java b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsLoader.java index 006ffbe1aa8..f5bf6ab3da3 100644 --- a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsLoader.java +++ b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsLoader.java @@ -19,12 +19,12 @@ public class ProtectedTermsLoader { + private static final Map internalLists = new HashMap<>(); + private static final Log LOGGER = LogFactory.getLog(ProtectedTermsLoader.class); private final List mainList = new ArrayList<>(); - private static final Map internalLists = new HashMap<>(); - static { internalLists.put("/protectedterms/months_weekdays.terms", Localization.lang("Months and weekdays in English")); internalLists.put("/protectedterms/countries_territories.terms", @@ -33,15 +33,14 @@ public class ProtectedTermsLoader { Localization.lang("Electrical engineering terms")); } + public ProtectedTermsLoader(ProtectedTermsPreferences preferences) { + update(preferences); + } public static List getInternalLists() { return new ArrayList<>(internalLists.keySet()); } - public ProtectedTermsLoader(ProtectedTermsPreferences preferences) { - update(preferences); - } - public void update(ProtectedTermsPreferences preferences) { mainList.clear(); @@ -109,6 +108,7 @@ public void reloadProtectedTermsList(ProtectedTermsList list) { } } + public List getProtectedTermsLists() { return mainList; } diff --git a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java index 22695ef938d..aac990c5b9c 100644 --- a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java +++ b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java @@ -1,6 +1,5 @@ package org.jabref.logic.protectedterms; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -26,13 +25,12 @@ */ public class ProtectedTermsParser { - private final List terms = new ArrayList<>(); + private static final Log LOGGER = LogFactory.getLog(ProtectedTermsParser.class); + private final List terms = new ArrayList<>(); private String description = Localization.lang("The text after the last line starting with # will be used"); - private String location; - - private static final Log LOGGER = LogFactory.getLog(ProtectedTermsParser.class); + private String location; public void readTermsFromResource(String resourceFileName, String descriptionString) { URL url = Objects @@ -46,10 +44,9 @@ public void readTermsFromResource(String resourceFileName, String descriptionStr } } - public void readTermsFromFile(File file) throws FileNotFoundException { location = file.getAbsolutePath(); - try(FileReader reader = new FileReader(Objects.requireNonNull(file))) { + try (FileReader reader = new FileReader(Objects.requireNonNull(file))) { readTermsList(reader); } catch (FileNotFoundException e) { throw e; diff --git a/src/main/java/org/jabref/logic/remote/server/RemoteListenerServerLifecycle.java b/src/main/java/org/jabref/logic/remote/server/RemoteListenerServerLifecycle.java index 48d3cfd02a1..c043a186c26 100644 --- a/src/main/java/org/jabref/logic/remote/server/RemoteListenerServerLifecycle.java +++ b/src/main/java/org/jabref/logic/remote/server/RemoteListenerServerLifecycle.java @@ -18,10 +18,10 @@ */ public class RemoteListenerServerLifecycle implements AutoCloseable { - private RemoteListenerServerThread remoteListenerServerThread; - private static final Log LOGGER = LogFactory.getLog(RemoteListenerServerLifecycle.class); + private RemoteListenerServerThread remoteListenerServerThread; + public void stop() { if (isOpen()) { remoteListenerServerThread.interrupt(); diff --git a/src/main/java/org/jabref/logic/search/DatabaseSearcher.java b/src/main/java/org/jabref/logic/search/DatabaseSearcher.java index ec672298a91..425fee9c9b8 100644 --- a/src/main/java/org/jabref/logic/search/DatabaseSearcher.java +++ b/src/main/java/org/jabref/logic/search/DatabaseSearcher.java @@ -17,10 +17,10 @@ */ public class DatabaseSearcher { + private static final Log LOGGER = LogFactory.getLog(DatabaseSearcher.class); private final SearchQuery query; - private final BibDatabase database; - private static final Log LOGGER = LogFactory.getLog(DatabaseSearcher.class); + private final BibDatabase database; public DatabaseSearcher(SearchQuery query, BibDatabase database) { this.query = Objects.requireNonNull(query); diff --git a/src/main/java/org/jabref/logic/search/SearchQueryHighlightObservable.java b/src/main/java/org/jabref/logic/search/SearchQueryHighlightObservable.java index 50fa04fa9af..8046f442446 100644 --- a/src/main/java/org/jabref/logic/search/SearchQueryHighlightObservable.java +++ b/src/main/java/org/jabref/logic/search/SearchQueryHighlightObservable.java @@ -42,6 +42,7 @@ public void removeSearchListener(SearchQueryHighlightListener listener) { * * @param searchQuery the search query */ + public void fireSearchlistenerEvent(SearchQuery searchQuery) { Objects.requireNonNull(searchQuery); diff --git a/src/main/java/org/jabref/logic/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java b/src/main/java/org/jabref/logic/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java index c608ef5e967..292b0dd263f 100644 --- a/src/main/java/org/jabref/logic/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java +++ b/src/main/java/org/jabref/logic/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java @@ -30,10 +30,10 @@ public String getDescription() { : Localization.lang("This search contains entries in which any field contains the term %0", StringUtil.quoteForHTML(firstWord))); - if(words.size() > 1) { + if (words.size() > 1) { List unprocessedWords = words.subList(1, words.size()); List unprocessedWordsInHtmlFormat = new LinkedList<>(); - for(String word : unprocessedWords) { + for (String word : unprocessedWords) { unprocessedWordsInHtmlFormat.add(String.format("%s", StringUtil.quoteForHTML(word))); } String andSeparator = String.format(" %s ", Localization.lang("and")); @@ -46,7 +46,7 @@ public String getDescription() { } private String getCaseSensitiveDescription() { - if(caseSensitive) { + if (caseSensitive) { return Localization.lang("case sensitive"); } else { return Localization.lang("case insensitive"); diff --git a/src/main/java/org/jabref/logic/specialfields/SpecialFieldsUtils.java b/src/main/java/org/jabref/logic/specialfields/SpecialFieldsUtils.java index 125a153c710..e5e1bf2764f 100644 --- a/src/main/java/org/jabref/logic/specialfields/SpecialFieldsUtils.java +++ b/src/main/java/org/jabref/logic/specialfields/SpecialFieldsUtils.java @@ -1,6 +1,5 @@ package org.jabref.logic.specialfields; - import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -60,7 +59,7 @@ private static List exportFieldToKeywords(SpecialField specialField public static List syncKeywordsFromSpecialFields(BibEntry entry, Character keywordDelimiter) { List fieldChanges = new ArrayList<>(); - for(SpecialField field: SpecialField.values()) { + for (SpecialField field: SpecialField.values()) { fieldChanges.addAll(SpecialFieldsUtils.exportFieldToKeywords(field, entry, keywordDelimiter)); } @@ -97,7 +96,7 @@ public static List syncSpecialFieldsFromKeywords(BibEntry entry, Ch KeywordList keywordList = entry.getKeywords(keywordDelimiter); - for(SpecialField field: SpecialField.values()) { + for (SpecialField field: SpecialField.values()) { fieldChanges.addAll(SpecialFieldsUtils.importKeywordsForField(keywordList, field, entry)); } @@ -114,9 +113,9 @@ public static void synchronizeSpecialFields(KeywordList keywordsToAdd, KeywordLi // Priority clone = keywordsToAdd.createClone(); - for(SpecialField field: SpecialField.values()){ + for (SpecialField field: SpecialField.values()) { clone.retainAll(field.getKeyWords()); - if(!clone.isEmpty()) { + if (!clone.isEmpty()) { keywordsToRemove.addAll(field.getKeyWords()); } } diff --git a/src/main/java/org/jabref/logic/util/OS.java b/src/main/java/org/jabref/logic/util/OS.java index bf284f4a054..2f97a16de20 100644 --- a/src/main/java/org/jabref/logic/util/OS.java +++ b/src/main/java/org/jabref/logic/util/OS.java @@ -6,13 +6,6 @@ * Operating system (OS) detection */ public class OS { - // https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/SystemUtils.html - private static final String OS_NAME = System.getProperty("os.name", "unknown").toLowerCase(Locale.ROOT); - - public static final boolean LINUX = OS_NAME.startsWith("linux"); - public static final boolean WINDOWS = OS_NAME.startsWith("win"); - public static final boolean OS_X = OS_NAME.startsWith("mac"); - // File separator obtained from system public static final String FILE_SEPARATOR = System.getProperty("file.separator"); @@ -20,6 +13,13 @@ public class OS { // will be overridden in initialization due to feature #857 @ JabRef.java public static String NEWLINE = System.lineSeparator(); + // https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/SystemUtils.html + private static final String OS_NAME = System.getProperty("os.name", "unknown").toLowerCase(Locale.ROOT); + public static final boolean LINUX = OS_NAME.startsWith("linux"); + public static final boolean WINDOWS = OS_NAME.startsWith("win"); + + public static final boolean OS_X = OS_NAME.startsWith("mac"); + private OS() { } } diff --git a/src/main/java/org/jabref/logic/util/UpdateFieldPreferences.java b/src/main/java/org/jabref/logic/util/UpdateFieldPreferences.java index f5485558dc8..03cf0839202 100644 --- a/src/main/java/org/jabref/logic/util/UpdateFieldPreferences.java +++ b/src/main/java/org/jabref/logic/util/UpdateFieldPreferences.java @@ -27,17 +27,14 @@ public boolean isUseOwner() { return useOwner; } - public boolean isUseTimeStamp() { return useTimeStamp; } - public String getTimeStampField() { return timeStampField; } - public String getDefaultOwner() { return defaultOwner; } diff --git a/src/main/java/org/jabref/logic/util/Version.java b/src/main/java/org/jabref/logic/util/Version.java index c67831bd4ca..735c930cde6 100644 --- a/src/main/java/org/jabref/logic/util/Version.java +++ b/src/main/java/org/jabref/logic/util/Version.java @@ -23,12 +23,12 @@ */ public class Version { + public static final String JABREF_DOWNLOAD_URL = "https://downloads.jabref.org"; private static final Log LOGGER = LogFactory.getLog(Version.class); + private static final Version UNKNOWN_VERSION = new Version(); private final static Pattern VERSION_PATTERN = Pattern.compile("(?\\d+)(\\.(?\\d+))?(\\.(?\\d+))?(?-alpha|-beta)?(?-?dev)?.*"); - - public static final String JABREF_DOWNLOAD_URL = "https://downloads.jabref.org"; private static final String JABREF_GITHUB_RELEASES = "https://api.github.com/repos/JabRef/JabRef/releases"; @@ -249,7 +249,6 @@ public String toString() { return this.getFullVersion(); } - public enum DevelopmentStage { UNKNOWN("", 0), ALPHA("-alpha", 1), diff --git a/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java b/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java index 47b784515e5..cd8d402fc74 100644 --- a/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java +++ b/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java @@ -67,5 +67,6 @@ private List parseFileField(BibEntry entry) { .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); + } } diff --git a/src/main/java/org/jabref/logic/util/io/FileBasedLock.java b/src/main/java/org/jabref/logic/util/io/FileBasedLock.java index 904b79ef4f7..9b4be7453ca 100644 --- a/src/main/java/org/jabref/logic/util/io/FileBasedLock.java +++ b/src/main/java/org/jabref/logic/util/io/FileBasedLock.java @@ -11,17 +11,17 @@ import org.apache.commons.logging.LogFactory; public class FileBasedLock { - private static final Log LOGGER = LogFactory.getLog(FileBasedLock.class); - - private static final String LOCKFILE_SUFFIX = ".lock"; - // default retry count for aquiring file lock - private static final int AQUIRE_LOCK_RETRY = 10; - /** * The age in ms of a lockfile before JabRef will offer to "steal" the locked file. */ public static final long LOCKFILE_CRITICAL_AGE = 60000; + private static final Log LOGGER = LogFactory.getLog(FileBasedLock.class); + private static final String LOCKFILE_SUFFIX = ".lock"; + + // default retry count for aquiring file lock + private static final int AQUIRE_LOCK_RETRY = 10; + private FileBasedLock() { } diff --git a/src/main/java/org/jabref/logic/util/io/FileHistory.java b/src/main/java/org/jabref/logic/util/io/FileHistory.java index ff4e35f7195..387dee3347c 100644 --- a/src/main/java/org/jabref/logic/util/io/FileHistory.java +++ b/src/main/java/org/jabref/logic/util/io/FileHistory.java @@ -6,10 +6,10 @@ public class FileHistory { - private final LinkedList history; - private static final int HISTORY_SIZE = 8; + private final LinkedList history; + public FileHistory(List fileList) { history = new LinkedList<>(Objects.requireNonNull(fileList)); diff --git a/src/main/java/org/jabref/logic/util/io/FileUtil.java b/src/main/java/org/jabref/logic/util/io/FileUtil.java index a2867390ffe..16e40692f01 100644 --- a/src/main/java/org/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/org/jabref/logic/util/io/FileUtil.java @@ -34,9 +34,8 @@ import org.apache.commons.logging.LogFactory; public class FileUtil { - private static final Log LOGGER = LogFactory.getLog(FileUtil.class); - public static final boolean isPosixCompilant = FileSystems.getDefault().supportedFileAttributeViews().contains("posix"); + private static final Log LOGGER = LogFactory.getLog(FileUtil.class); private FileUtil() { } @@ -328,7 +327,7 @@ public static Optional find(String filename, Path rootDirectory) { .filter(Files::isRegularFile) .filter(f -> f.getFileName().toString().equals(filename)) .findFirst(); - } catch(IOException ex) { + } catch (IOException ex) { LOGGER.error("Error trying to locate the file " + filename + " inside the directory " + rootDirectory); } return Optional.empty(); diff --git a/src/main/java/org/jabref/logic/util/strings/DiffHighlighting.java b/src/main/java/org/jabref/logic/util/strings/DiffHighlighting.java index b7fe2213291..acd358d99e4 100644 --- a/src/main/java/org/jabref/logic/util/strings/DiffHighlighting.java +++ b/src/main/java/org/jabref/logic/util/strings/DiffHighlighting.java @@ -11,18 +11,17 @@ public class DiffHighlighting { + public static final String HTML_START = ""; + public static final String HTML_END = ""; private static final String ADDITION_START = ""; private static final String REMOVAL_START = ""; private static final String CHANGE_START = ""; - private static final String TAG_END = ""; - public static final String HTML_START = ""; - public static final String HTML_END = ""; + private static final String TAG_END = ""; private DiffHighlighting() { } - public static String generateDiffHighlighting(String baseString, String modifiedString, String separator) { Objects.requireNonNull(separator); if ((baseString != null) && (modifiedString != null)) { diff --git a/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java b/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java index 8f9cfb5290e..4a6e04811f3 100644 --- a/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java +++ b/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java @@ -5,18 +5,25 @@ public class HTMLUnicodeConversionMaps { + // most of the LaTeX commands can be read at http://en.wikibooks.org/wiki/LaTeX/Accents + // The symbols can be seen at http://www.fileformat.info/info/unicode/char/a4/index.htm. Replace "a4" with the U+ number + // http://detexify.kirelabs.org/classify.html and http://www.ctan.org/tex-archive/info/symbols/comprehensive/ might help to find the right LaTeX command + // http://llg.cubic.org/docs/ent2latex.html and http://www.w3.org/TR/xml-entity-names/byalpha.html are also useful + public static final Map HTML_LATEX_CONVERSION_MAP = new HashMap<>(); + public static final Map ESCAPED_ACCENTS = new HashMap<>(); + public static final Map UNICODE_ESCAPED_ACCENTS = new HashMap<>(); + public static final Map NUMERICAL_LATEX_CONVERSION_MAP = new HashMap<>(); + public static final Map UNICODE_LATEX_CONVERSION_MAP = new HashMap<>(); + public static final Map LATEX_HTML_CONVERSION_MAP = new HashMap<>(); + public static final Map LATEX_UNICODE_CONVERSION_MAP = new HashMap<>(); + /* Portions © International Organization for Standardization 1986: Permission to copy in any form is granted for use with conforming SGML systems and applications as defined in ISO 8879, provided this notice is included in all copies. */ - // most of the LaTeX commands can be read at http://en.wikibooks.org/wiki/LaTeX/Accents - // The symbols can be seen at http://www.fileformat.info/info/unicode/char/a4/index.htm. Replace "a4" with the U+ number - // http://detexify.kirelabs.org/classify.html and http://www.ctan.org/tex-archive/info/symbols/comprehensive/ might help to find the right LaTeX command - // http://llg.cubic.org/docs/ent2latex.html and http://www.w3.org/TR/xml-entity-names/byalpha.html are also useful // as well as http://www.w3.org/Math/characters/unicode.xml - // An array of arrays of strings in the format: // {"decimal number of HTML entity", "text HTML entity", "corresponding LaTeX command"} // Leaving a field empty is OK as it then will not be included @@ -755,6 +762,7 @@ public class HTMLUnicodeConversionMaps { {"119984", "Uscr", "$\\mathcal{U}$"} // script capital U -- possibly use \mathscr }; + // List of combining accents private static final String[][] ACCENT_LIST = new String[][] {{"768", "`"}, // Grave {"769", "'"}, // Acute @@ -843,15 +851,6 @@ public class HTMLUnicodeConversionMaps { {"866", "sliding"}, // Double rightwards arrow below - requires extraipa }; - public static final Map HTML_LATEX_CONVERSION_MAP = new HashMap<>(); - public static final Map ESCAPED_ACCENTS = new HashMap<>(); - public static final Map UNICODE_ESCAPED_ACCENTS = new HashMap<>(); - public static final Map NUMERICAL_LATEX_CONVERSION_MAP = new HashMap<>(); - public static final Map UNICODE_LATEX_CONVERSION_MAP = new HashMap<>(); - public static final Map LATEX_HTML_CONVERSION_MAP = new HashMap<>(); - public static final Map LATEX_UNICODE_CONVERSION_MAP = new HashMap<>(); - - static { for (String[] aConversionList : CONVERSION_LIST) { if (!(aConversionList[2].isEmpty())) { diff --git a/src/main/java/org/jabref/logic/xmp/XMPSchemaBibtex.java b/src/main/java/org/jabref/logic/xmp/XMPSchemaBibtex.java index 85b125632e6..8b4017f7b39 100644 --- a/src/main/java/org/jabref/logic/xmp/XMPSchemaBibtex.java +++ b/src/main/java/org/jabref/logic/xmp/XMPSchemaBibtex.java @@ -37,7 +37,6 @@ public class XMPSchemaBibtex extends XMPSchema { private static final Set PRESERVE_WHITE_SPACE = new HashSet<>(); - static { XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.ABSTRACT); XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.NOTE); @@ -261,8 +260,6 @@ public static Map getAllProperties(XMPSchema schema, String name return result; } - - public void setBibtexEntry(BibEntry entry, XMPPreferences xmpPreferences) { setBibtexEntry(entry, null, xmpPreferences); } diff --git a/src/main/java/org/jabref/logic/xmp/XMPUtil.java b/src/main/java/org/jabref/logic/xmp/XMPUtil.java index 26a70fc5810..a2473751925 100644 --- a/src/main/java/org/jabref/logic/xmp/XMPUtil.java +++ b/src/main/java/org/jabref/logic/xmp/XMPUtil.java @@ -759,7 +759,6 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, BibEntry entry continue; } - /* * All others (including the bibtex key) get packaged in the * relation attribute diff --git a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java index 287a6981a11..9fe196af88b 100644 --- a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java +++ b/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java @@ -11,14 +11,11 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; -import org.jabref.gui.DialogService; -import org.jabref.gui.FXDialogService; +import org.jabref.gui.FileDialog; import org.jabref.gui.entryeditor.EntryEditorTabList; import org.jabref.gui.importer.actions.GUIPostOpenAction; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; -import org.jabref.gui.util.DefaultTaskExecutor; -import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.cleanup.UpgradePdfPsToFileCleanup; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; @@ -94,8 +91,7 @@ public boolean isActionNecessary(ParserResult pr) { || Globals.prefs.hasKey(FieldName.PS + FileDirectoryPreferences.DIR_SUFFIX)); // First check if this warning is disabled: - return Globals.prefs.getBoolean(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING) - && isThereSomethingToBeDone(); + return Globals.prefs.getBoolean(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING) && isThereSomethingToBeDone(); } /** @@ -107,18 +103,15 @@ public boolean isActionNecessary(ParserResult pr) { @Override public void performAction(BasePanel panel, ParserResult parserResult) { - if (!isThereSomethingToBeDone()) { + if (!isThereSomethingToBeDone()) { return; // Nothing to do, just return. } - JCheckBox changeSettings = new JCheckBox( - Localization.lang("Change table column and General fields settings to use the new feature"), + JCheckBox changeSettings = new JCheckBox(Localization.lang("Change table column and General fields settings to use the new feature"), offerChangeSettings); - JCheckBox changeDatabase = new JCheckBox( - Localization.lang("Upgrade old external file links to use the new feature"), + JCheckBox changeDatabase = new JCheckBox(Localization.lang("Upgrade old external file links to use the new feature"), offerChangeDatabase); - JCheckBox setFileDir = new JCheckBox(Localization.lang("Set main external file directory") + ":", - offerSetFileDir); + JCheckBox setFileDir = new JCheckBox(Localization.lang("Set main external file directory") + ":", offerSetFileDir); JTextField fileDir = new JTextField(30); JCheckBox doNotShowDialog = new JCheckBox(Localization.lang("Do not show these options in the future"), false); @@ -129,9 +122,7 @@ public void performAction(BasePanel panel, ParserResult parserResult) { // See updated JabRef_en.properties modifications by python syncLang.py -s -u int row = 1; formBuilder.add(new JLabel("" + Localization.lang("This library uses outdated file links.") + "

" - + Localization - .lang("JabRef no longer supports 'ps' or 'pdf' fields.
File links are now stored in the 'file' field and files are stored in an external file directory.
To make use of this feature, JabRef needs to upgrade file links.

") - + "

" + + Localization.lang("JabRef no longer supports 'ps' or 'pdf' fields.
File links are now stored in the 'file' field and files are stored in an external file directory.
To make use of this feature, JabRef needs to upgrade file links.

") + "

" + Localization.lang("Do you want JabRef to do the following operations?") + "")).xy(1, row); if (offerChangeSettings) { @@ -154,14 +145,10 @@ public void performAction(BasePanel panel, ParserResult parserResult) { builderPanel.add(setFileDir); builderPanel.add(fileDir); JButton browse = new JButton(Localization.lang("Browse")); - - FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build(); - DialogService ds = new FXDialogService(); - - browse.addActionListener( - e -> DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration)) - .ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString()))); + browse.addActionListener(e -> + new FileDialog(null).showDialogAndGetSelectedFile() + .ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString())) + ); builderPanel.add(browse); formBuilder.appendRows("2dlu, p"); row += 2; @@ -185,7 +172,7 @@ public void performAction(BasePanel panel, ParserResult parserResult) { } private boolean isThereSomethingToBeDone() { - return offerChangeSettings || offerChangeDatabase || offerSetFileDir; + return offerChangeSettings || offerChangeDatabase || offerSetFileDir; } /** @@ -214,7 +201,7 @@ private boolean linksFound(BibDatabase database, String[] fields) { * @param fileDir The path to the file directory to set, or null if it should not be set. */ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, - boolean upgradeDatabase, String fileDir) { + boolean upgradeDatabase, String fileDir) { if (upgradeDatabase) { // Update file links links in the database: diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 65e38b4187f..70d8926306c 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -29,11 +29,11 @@ public static void upgradePrefsToOrgJabRef() { JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); try { - if (mainPrefsNode.childrenNames().length!=0) { + if (mainPrefsNode.childrenNames().length != 0) { // skip further processing as prefs already have been migrated LOGGER.debug("New prefs node already exists with content - skipping migration"); } else { - if( mainPrefsNode.parent().parent().nodeExists("net/sf/jabref")) { + if ( mainPrefsNode.parent().parent().nodeExists("net/sf/jabref")) { LOGGER.info("Migrating old preferences."); Preferences oldNode = mainPrefsNode.parent().parent().node("net/sf/jabref"); copyPrefsRecursively(oldNode, mainPrefsNode); @@ -44,9 +44,8 @@ public static void upgradePrefsToOrgJabRef() { } } - private static void copyPrefsRecursively(Preferences from, Preferences to) throws BackingStoreException { - for(String key : from.keys()) { + for (String key : from.keys()) { String newValue = from.get(key, ""); if (newValue.contains("net.sf")) { newValue = newValue.replaceAll("net\\.sf", "org"); @@ -161,12 +160,12 @@ public static void upgradeLabelPatternToBibtexKeyPattern() { Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); // Migrate default pattern - if (mainPrefsNode.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN, null)==null) { + if (mainPrefsNode.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN, null) == null) { // Check whether old defaultLabelPattern is set String oldDefault = mainPrefsNode.get("defaultLabelPattern", null); - if(oldDefault!=null) { + if (oldDefault != null) { prefs.put(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN, oldDefault); - LOGGER.info("Upgraded old default key generator pattern '"+oldDefault+"' to new version."); + LOGGER.info("Upgraded old default key generator pattern '" + oldDefault + "' to new version."); } } diff --git a/src/main/java/org/jabref/model/EntryTypes.java b/src/main/java/org/jabref/model/EntryTypes.java index 6405138a6fd..ab6307ad3f2 100644 --- a/src/main/java/org/jabref/model/EntryTypes.java +++ b/src/main/java/org/jabref/model/EntryTypes.java @@ -134,7 +134,7 @@ public static Optional getStandardType(String name, BibDatabaseMode m } public static void addOrModifyCustomEntryType(CustomEntryType customEntryType, BibDatabaseMode mode) { - if(BibDatabaseMode.BIBLATEX == mode) { + if (BibDatabaseMode.BIBLATEX == mode) { BIBLATEX.addOrModifyEntryType(customEntryType); } else if (BibDatabaseMode.BIBTEX == mode) { BIBTEX.addOrModifyEntryType(customEntryType); @@ -159,7 +159,7 @@ public static Collection getAllValues(BibDatabaseMode type) { */ public static List getAllCustomTypes(BibDatabaseMode mode) { Collection allTypes = getAllValues(mode); - if(mode == BibDatabaseMode.BIBTEX) { + if (mode == BibDatabaseMode.BIBTEX) { return allTypes.stream().filter(entryType -> !BibtexEntryTypes.getType(entryType.getName()).isPresent()) .filter(entryType -> !IEEETranEntryTypes.getType(entryType.getName()).isPresent()) .collect(Collectors.toList()); @@ -198,8 +198,8 @@ public static void removeType(String name, BibDatabaseMode type) { } public static void removeAllCustomEntryTypes() { - for(BibDatabaseMode type : BibDatabaseMode.values()) { - for(String typeName : new HashSet<>(getAllTypes(type))) { + for (BibDatabaseMode type : BibDatabaseMode.values()) { + for (String typeName : new HashSet<>(getAllTypes(type))) { getType(typeName, type).ifPresent(entryType -> { if (entryType instanceof CustomEntryType) { removeType(typeName, type); diff --git a/src/main/java/org/jabref/model/TreeNode.java b/src/main/java/org/jabref/model/TreeNode.java index 07f0454f095..2a1b25a2c7e 100644 --- a/src/main/java/org/jabref/model/TreeNode.java +++ b/src/main/java/org/jabref/model/TreeNode.java @@ -601,7 +601,7 @@ public void subscribeToDescendantChanged(Consumer subscriber) { protected void notifyAboutDescendantChange(T source) { onDescendantChanged.accept(source); - if( !isRoot()) { + if (!isRoot()) { parent.notifyAboutDescendantChange(source); } } diff --git a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java b/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java index 2b5f32c7818..5a4f800107b 100644 --- a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java +++ b/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java @@ -56,7 +56,7 @@ private List cleanupSingleField(String fieldKey, BibEntry entry) { if (oldValue.equals(newValue)) { return new ArrayList<>(); } else { - if(newValue.isEmpty()) { + if (newValue.isEmpty()) { entry.clearField(fieldKey); newValue = null; } else { diff --git a/src/main/java/org/jabref/model/cleanup/Formatter.java b/src/main/java/org/jabref/model/cleanup/Formatter.java index 3cddb82e82c..5b5dcd5673f 100644 --- a/src/main/java/org/jabref/model/cleanup/Formatter.java +++ b/src/main/java/org/jabref/model/cleanup/Formatter.java @@ -65,7 +65,7 @@ default int defaultHashCode() { * @return true if the object is a formatter with the same key */ default boolean defaultEquals(Object obj) { - if(obj instanceof Formatter) { + if (obj instanceof Formatter) { return getKey().equals(((Formatter)obj).getKey()); } else { return false; diff --git a/src/main/java/org/jabref/model/database/event/ChangePropagation.java b/src/main/java/org/jabref/model/database/event/ChangePropagation.java index e45261ec4e9..c562e5cde9d 100644 --- a/src/main/java/org/jabref/model/database/event/ChangePropagation.java +++ b/src/main/java/org/jabref/model/database/event/ChangePropagation.java @@ -1,6 +1,5 @@ package org.jabref.model.database.event; - public enum ChangePropagation { POST_EVENT, DO_NOT_POST_EVENT } diff --git a/src/main/java/org/jabref/model/entry/AuthorList.java b/src/main/java/org/jabref/model/entry/AuthorList.java index 6ae2c33afbd..dedf8c1a67e 100644 --- a/src/main/java/org/jabref/model/entry/AuthorList.java +++ b/src/main/java/org/jabref/model/entry/AuthorList.java @@ -513,7 +513,6 @@ public String getAsLastFirstNamesWithAnd(boolean abbreviate) { return authorLastFirstAnds[abbrInt]; } - authorLastFirstAnds[abbrInt] = getAuthors().stream().map(author -> author.getLastFirst(abbreviate)) .collect(Collectors.joining(" and ")); return authorLastFirstAnds[abbrInt]; diff --git a/src/main/java/org/jabref/model/entry/AuthorListParser.java b/src/main/java/org/jabref/model/entry/AuthorListParser.java index c0da99da0bf..234371d4a98 100644 --- a/src/main/java/org/jabref/model/entry/AuthorListParser.java +++ b/src/main/java/org/jabref/model/entry/AuthorListParser.java @@ -10,6 +10,28 @@ public class AuthorListParser { + private static final int TOKEN_GROUP_LENGTH = 4; // number of entries for a token + + // the following are offsets of an entry in a group of entries for one token + private static final int OFFSET_TOKEN = 0; // String -- token itself; + + private static final int OFFSET_TOKEN_ABBR = 1; // String -- token abbreviation; + + private static final int OFFSET_TOKEN_TERM = 2; // Character -- token terminator (either " " or + // "-") comma) + + // Token types (returned by getToken procedure) + private static final int TOKEN_EOF = 0; + + private static final int TOKEN_AND = 1; + + private static final int TOKEN_COMMA = 2; + + private static final int TOKEN_WORD = 3; + + // Constant HashSet containing names of TeX special characters + private static final Set TEX_NAMES = new HashSet<>(); + /** the raw bibtex author/editor field */ private String original; @@ -22,17 +44,13 @@ public class AuthorListParser { /** end of token abbreviation (always: tokenStart < tokenAbbr <= tokenEnd), only valid if getToken returns TOKEN_WORD */ private int tokenAbbr; + /** either space of dash */ private char tokenTerm; /** true if upper-case token, false if lower-case */ private boolean tokenCase; - - // Constant HashSet containing names of TeX special characters - private static final Set TEX_NAMES = new HashSet<>(); - - // and static constructor to initialize it static { TEX_NAMES.add("aa"); TEX_NAMES.add("ae"); @@ -48,26 +66,6 @@ public class AuthorListParser { TEX_NAMES.add("j"); } - - private static final int TOKEN_GROUP_LENGTH = 4; // number of entries for a token - - // the following are offsets of an entry in a group of entries for one token - private static final int OFFSET_TOKEN = 0; // String -- token itself; - - private static final int OFFSET_TOKEN_ABBR = 1; // String -- token abbreviation; - - private static final int OFFSET_TOKEN_TERM = 2; // Character -- token terminator (either " " or - // "-") comma) - - // Token types (returned by getToken procedure) - private static final int TOKEN_EOF = 0; - - private static final int TOKEN_AND = 1; - - private static final int TOKEN_COMMA = 2; - - private static final int TOKEN_WORD = 3; - /** * Parses the String containing person names and returns a list of person information. * @@ -135,7 +133,7 @@ private Optional getAuthor() { if (vonStart < 0) { if (!tokenCase) { int previousTermToken = (tokens.size() - TOKEN_GROUP_LENGTH - TOKEN_GROUP_LENGTH) + OFFSET_TOKEN_TERM; - if((previousTermToken >= 0) && tokens.get(previousTermToken).equals('-')) { + if ((previousTermToken >= 0) && tokens.get(previousTermToken).equals('-')) { // We are in a first name which contained a hyphen break; } @@ -250,7 +248,7 @@ private Optional getAuthor() { false); String jrPart = jrPartStart < 0 ? null : concatTokens(tokens, jrPartStart, jrPartEnd, OFFSET_TOKEN, false); - if((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase(Locale.ROOT)) && (lastPart.length() < 5)) { + if ((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase(Locale.ROOT)) && (lastPart.length() < 5)) { // The last part is a small string in complete upper case, so interpret it as initial of the first name // This is the case for example in "Smith SH" which we think of as lastname=Smith and firstname=SH // The length < 5 constraint should allow for "Smith S.H." as input diff --git a/src/main/java/org/jabref/model/entry/BiblatexEntryTypes.java b/src/main/java/org/jabref/model/entry/BiblatexEntryTypes.java index a418d1e1d45..b304cb6845b 100644 --- a/src/main/java/org/jabref/model/entry/BiblatexEntryTypes.java +++ b/src/main/java/org/jabref/model/entry/BiblatexEntryTypes.java @@ -31,7 +31,6 @@ public class BiblatexEntryTypes { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Article"; @@ -64,7 +63,6 @@ public List getPrimaryOptionalFields() { FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Book"; @@ -94,7 +92,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "MvBook"; @@ -129,7 +126,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINT, FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "InBook"; @@ -205,7 +201,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Booklet"; @@ -238,7 +233,6 @@ public List getPrimaryOptionalFields() { FieldName.URLDATE); } - @Override public String getName() { return "Collection"; @@ -268,7 +262,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "MvCollection"; @@ -303,7 +296,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "InCollection"; @@ -356,7 +348,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINT, FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Manual"; @@ -383,7 +374,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Misc"; @@ -408,7 +398,6 @@ public List getPrimaryOptionalFields() { FieldName.URLDATE); } - @Override public String getName() { return "Online"; @@ -435,7 +424,6 @@ public List getPrimaryOptionalFields() { FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Patent"; @@ -462,7 +450,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Periodical"; @@ -518,7 +505,6 @@ public List getPrimaryOptionalFields() { FieldName.URLDATE); } - @Override public String getName() { return "Proceedings"; @@ -549,7 +535,6 @@ public List getPrimaryOptionalFields() { FieldName.URLDATE); } - @Override public String getName() { return "MvProceedings"; @@ -583,7 +568,6 @@ public List getPrimaryOptionalFields() { FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "InProceedings"; @@ -684,7 +668,6 @@ public List getPrimaryOptionalFields() { FieldName.URLDATE); } - @Override public String getName() { return "Report"; @@ -702,7 +685,6 @@ public List getPrimaryOptionalFields() { addAllRequired(FieldName.ENTRYSET, FieldName.CROSSREF); } - @Override public String getName() { return "Set"; @@ -725,7 +707,6 @@ public String getName() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Thesis"; @@ -750,7 +731,6 @@ public List getPrimaryOptionalFields() { FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "Unpublished"; @@ -829,7 +809,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "MastersThesis"; @@ -858,7 +837,6 @@ public List getPrimaryOptionalFields() { FieldName.EPRINTCLASS, FieldName.EPRINTTYPE, FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "PhdThesis"; @@ -888,7 +866,6 @@ public List getPrimaryOptionalFields() { FieldName.URL, FieldName.URLDATE); } - @Override public String getName() { return "TechReport"; @@ -937,7 +914,6 @@ public List getPrimaryOptionalFields() { FieldName.CTLNAME_FORMAT_STRING, FieldName.CTLNAME_LATEX_CMD, FieldName.CTLNAME_URL_PREFIX); } - @Override public String getName() { return "IEEEtranBSTCTL"; diff --git a/src/main/java/org/jabref/model/entry/BibtexString.java b/src/main/java/org/jabref/model/entry/BibtexString.java index 19b9b482d1d..b03d9ba08e7 100644 --- a/src/main/java/org/jabref/model/entry/BibtexString.java +++ b/src/main/java/org/jabref/model/entry/BibtexString.java @@ -130,7 +130,7 @@ public String getParsedSerialization() { return parsedSerialization; } - public boolean hasChanged(){ + public boolean hasChanged() { return hasChanged; } @@ -138,7 +138,7 @@ public boolean hasChanged(){ * Returns user comments (arbitrary text before the string) if there are any. If not returns the empty string */ public String getUserComments() { - if(parsedSerialization != null) { + if (parsedSerialization != null) { try { // get the text before the string @@ -150,7 +150,7 @@ public String getUserComments() { if (prolog.length() > 0) { return prolog; } - } catch(StringIndexOutOfBoundsException ignore) { + } catch (StringIndexOutOfBoundsException ignore) { // if this occurs a broken parsed serialization has been set, so just do nothing } } diff --git a/src/main/java/org/jabref/model/entry/CustomEntryType.java b/src/main/java/org/jabref/model/entry/CustomEntryType.java index ee4bf134caa..4ea86a82c5c 100644 --- a/src/main/java/org/jabref/model/entry/CustomEntryType.java +++ b/src/main/java/org/jabref/model/entry/CustomEntryType.java @@ -43,7 +43,7 @@ public CustomEntryType(String name, String required, String optional) { public static Optional parse(String comment) { String rest = comment.substring(ENTRYTYPE_FLAG.length()); int indexEndOfName = rest.indexOf(':'); - if(indexEndOfName < 0) { + if (indexEndOfName < 0) { return Optional.empty(); } String fieldsDescription = rest.substring(indexEndOfName + 2); diff --git a/src/main/java/org/jabref/model/entry/Date.java b/src/main/java/org/jabref/model/entry/Date.java index 77109b8b83f..40823cf766f 100644 --- a/src/main/java/org/jabref/model/entry/Date.java +++ b/src/main/java/org/jabref/model/entry/Date.java @@ -50,7 +50,6 @@ public static Optional parse(Optional yearValue, Optional Optional month = monthValue.flatMap(Month::parse); Optional day = dayValue.flatMap(Date::convertToInt); - if (year.isPresent()) { TemporalAccessor date; if (month.isPresent()) { @@ -102,6 +101,10 @@ public Optional getDay() { return get(ChronoField.DAY_OF_MONTH); } + public LocalDate toLocalDate() { + return LocalDate.from(date); + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/org/jabref/model/entry/FileFieldParser.java b/src/main/java/org/jabref/model/entry/FileFieldParser.java index 8f8ab78ebd8..52f7b7080b6 100644 --- a/src/main/java/org/jabref/model/entry/FileFieldParser.java +++ b/src/main/java/org/jabref/model/entry/FileFieldParser.java @@ -64,9 +64,9 @@ private static LinkedFile convert(List entry) { } LinkedFile field = new LinkedFile(entry.get(0), entry.get(1), entry.get(2)); // link is only mandatory field - if(field.getDescription().isEmpty() && field.getLink().isEmpty() && !field.getFileType().isEmpty()) { + if (field.getDescription().isEmpty() && field.getLink().isEmpty() && !field.getFileType().isEmpty()) { field = new LinkedFile("", field.getFileType(), ""); - } else if(!field.getDescription().isEmpty() && field.getLink().isEmpty() && field.getFileType().isEmpty()) { + } else if (!field.getDescription().isEmpty() && field.getLink().isEmpty() && field.getFileType().isEmpty()) { field = new LinkedFile("", field.getDescription(), ""); } entry.clear(); diff --git a/src/main/java/org/jabref/model/entry/InternalBibtexFields.java b/src/main/java/org/jabref/model/entry/InternalBibtexFields.java index a22b764deb1..46c6cc14e9a 100644 --- a/src/main/java/org/jabref/model/entry/InternalBibtexFields.java +++ b/src/main/java/org/jabref/model/entry/InternalBibtexFields.java @@ -37,12 +37,6 @@ public class InternalBibtexFields { */ public static final List DEFAULT_GENERAL_FIELDS = Arrays.asList(FieldName.CROSSREF, FieldName.KEYWORDS, FieldName.FILE, FieldName.DOI, FieldName.URL, FieldName.COMMENT, FieldName.OWNER, FieldName.TIMESTAMP); - // contains all bibtex-field objects (BibtexSingleField) - private final Map fieldSet; - - // the name with the current time stamp field, needed in case we want to change it - private String timeStampField; - // Lists of fields with special properties private static final List INTEGER_FIELDS = Arrays.asList(FieldName.CTLMAX_NAMES_FORCED_ETAL, FieldName.CTLNAMES_SHOW_ETAL, FieldName.CTLALT_STRETCH_FACTOR, FieldName.VOLUMES, FieldName.PMID); @@ -89,6 +83,12 @@ public class InternalBibtexFields { // singleton instance private static InternalBibtexFields RUNTIME = new InternalBibtexFields(FieldName.TIMESTAMP); + // contains all bibtex-field objects (BibtexSingleField) + private final Map fieldSet; + + // the name with the current time stamp field, needed in case we want to change it + private String timeStampField; + private InternalBibtexFields(String timeStampFieldName) { fieldSet = new HashMap<>(); diff --git a/src/main/java/org/jabref/model/entry/identifier/DOI.java b/src/main/java/org/jabref/model/entry/identifier/DOI.java index 1aae4633a5e..7daa8aa2ef8 100644 --- a/src/main/java/org/jabref/model/entry/identifier/DOI.java +++ b/src/main/java/org/jabref/model/entry/identifier/DOI.java @@ -64,12 +64,12 @@ public DOI(String doi) { String trimmedDoi = doi.trim(); // HTTP URL decoding - if(doi.matches(HTTP_EXP)) { + if (doi.matches(HTTP_EXP)) { try { // decodes path segment URI url = new URI(trimmedDoi); trimmedDoi = url.getScheme() + "://" + url.getHost() + url.getPath(); - } catch(URISyntaxException e) { + } catch (URISyntaxException e) { throw new IllegalArgumentException(doi + " is not a valid HTTP DOI."); } } @@ -107,7 +107,7 @@ public static Optional parse(String doi) { * @param doi the DOI string * @return true if DOI is valid, false otherwise */ - public static boolean isValid(String doi){ + public static boolean isValid(String doi) { return parse(doi).isPresent(); } @@ -154,7 +154,7 @@ public Optional getExternalURI() { try { URI uri = new URI(RESOLVER.getScheme(), RESOLVER.getHost(), "/" + doi, null); return Optional.of(uri); - } catch(URISyntaxException e) { + } catch (URISyntaxException e) { // should never happen LOGGER.error(doi + " could not be encoded as URI.", e); return Optional.empty(); diff --git a/src/main/java/org/jabref/model/entry/identifier/Eprint.java b/src/main/java/org/jabref/model/entry/identifier/Eprint.java index 2704144399f..863841fc3c8 100644 --- a/src/main/java/org/jabref/model/entry/identifier/Eprint.java +++ b/src/main/java/org/jabref/model/entry/identifier/Eprint.java @@ -18,9 +18,11 @@ * @see https://arxiv.org/help/arxiv_identifier * @see https://arxiv.org/hypertex/bibstyles/ */ + public class Eprint implements Identifier { public static final URI RESOLVER = URI.create("http://arxiv.org"); private static final Log LOGGER = LogFactory.getLog(Eprint.class); + // Regex // (see https://arxiv.org/help/arxiv_identifier) private static final String EPRINT_EXP = "" @@ -39,6 +41,7 @@ public class Eprint implements Identifier { private static final String HTTP_EXP = "https?://[^\\s]+?" + EPRINT_EXP; // Pattern private static final Pattern EXACT_EPRINT_PATT = Pattern.compile("^(?:https?://[^\\s]+?)?" + EPRINT_EXP + "$", Pattern.CASE_INSENSITIVE); + // DOI private final String eprint; @@ -57,12 +60,12 @@ public Eprint(String eprint) { String trimmedId = eprint.trim(); // HTTP URL decoding - if(eprint.matches(HTTP_EXP)) { + if (eprint.matches(HTTP_EXP)) { try { // decodes path segment URI url = new URI(trimmedId); trimmedId = url.getScheme() + "://" + url.getHost() + url.getPath(); - } catch(URISyntaxException e) { + } catch (URISyntaxException e) { throw new IllegalArgumentException(eprint + " is not a valid HTTP Eprint identifier."); } } @@ -104,7 +107,7 @@ public Optional getExternalURI() { try { URI uri = new URI(RESOLVER.getScheme(), RESOLVER.getHost(), "/abs/" + eprint, null); return Optional.of(uri); - } catch(URISyntaxException e) { + } catch (URISyntaxException e) { // should never happen LOGGER.error(eprint + " could not be encoded as URI.", e); return Optional.empty(); diff --git a/src/main/java/org/jabref/model/groups/GroupTreeNode.java b/src/main/java/org/jabref/model/groups/GroupTreeNode.java index 9b16be98f38..d5bbb62e6e4 100644 --- a/src/main/java/org/jabref/model/groups/GroupTreeNode.java +++ b/src/main/java/org/jabref/model/groups/GroupTreeNode.java @@ -143,18 +143,18 @@ public List getContainingGroups(List entries, boolean r List groups = new ArrayList<>(); // Add myself if I contain the entries - if(requireAll) { - if(this.group.containsAll(entries)) { + if (requireAll) { + if (this.group.containsAll(entries)) { groups.add(this); } } else { - if(this.group.containsAny(entries)) { + if (this.group.containsAny(entries)) { groups.add(this); } } // Traverse children - for(GroupTreeNode child : getChildren()) { + for (GroupTreeNode child : getChildren()) { groups.addAll(child.getContainingGroups(entries, requireAll)); } @@ -174,7 +174,7 @@ public List getMatchingGroups(List entries) { } // Traverse children - for(GroupTreeNode child : getChildren()) { + for (GroupTreeNode child : getChildren()) { groups.addAll(child.getMatchingGroups(entries)); } diff --git a/src/main/java/org/jabref/model/metadata/ContentSelectors.java b/src/main/java/org/jabref/model/metadata/ContentSelectors.java index b51cf5d5112..96269ff9349 100644 --- a/src/main/java/org/jabref/model/metadata/ContentSelectors.java +++ b/src/main/java/org/jabref/model/metadata/ContentSelectors.java @@ -21,8 +21,8 @@ public void addContentSelector(ContentSelector contentSelector) { } public List getSelectorValuesForField(String fieldName) { - for(ContentSelector selector: contentSelectors) { - if(selector.getFieldName().equals(fieldName)){ + for (ContentSelector selector: contentSelectors) { + if (selector.getFieldName().equals(fieldName)) { return selector.getValues(); } } @@ -40,12 +40,12 @@ public void removeSelector(String fieldName) { } } - if(toRemove != null){ + if (toRemove != null) { contentSelectors.remove(toRemove); } } - public List getContentSelectors(){ + public List getContentSelectors() { return Collections.unmodifiableList(contentSelectors); } @@ -61,7 +61,7 @@ public static ContentSelector parse(String key, String values) { public List getFieldNamesWithSelectors() { List result = new ArrayList<>(contentSelectors.size()); - for(ContentSelector selector: contentSelectors) { + for (ContentSelector selector: contentSelectors) { result.add(selector.getFieldName()); } diff --git a/src/main/java/org/jabref/model/metadata/FileDirectoryPreferences.java b/src/main/java/org/jabref/model/metadata/FileDirectoryPreferences.java index 081416efe80..b24a699da8d 100644 --- a/src/main/java/org/jabref/model/metadata/FileDirectoryPreferences.java +++ b/src/main/java/org/jabref/model/metadata/FileDirectoryPreferences.java @@ -35,7 +35,7 @@ public Optional getFileDirectory(String field) { return Optional.of(path); } return Optional.empty(); - } catch(InvalidPathException ex) { + } catch (InvalidPathException ex) { return Optional.empty(); } } diff --git a/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java b/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java index df8eb98a7d9..1f88c5640f5 100644 --- a/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java +++ b/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java @@ -20,6 +20,52 @@ public class SaveOrderConfig { // quick hack for outside modifications public final SortCriterion[] sortCriteria = new SortCriterion[3]; + public SaveOrderConfig() { + // fill default values + setSaveInOriginalOrder(); + sortCriteria[0] = new SortCriterion(); + sortCriteria[1] = new SortCriterion(); + sortCriteria[2] = new SortCriterion(); + } + + public SaveOrderConfig(boolean saveInOriginalOrder, SortCriterion first, SortCriterion second, + SortCriterion third) { + this.saveInOriginalOrder = saveInOriginalOrder; + sortCriteria[0] = first; + sortCriteria[1] = second; + sortCriteria[2] = third; + } + + private SaveOrderConfig(List data) { + Objects.requireNonNull(data); + + if (data.isEmpty()) { + throw new IllegalArgumentException(); + } + + String choice = data.get(0); + if (ORIGINAL.equals(choice)) { + setSaveInOriginalOrder(); + } else { + setSaveInSpecifiedOrder(); + } + + if (data.size() >= 3) { + sortCriteria[0] = new SortCriterion(data.get(1), data.get(2)); + } else { + sortCriteria[0] = new SortCriterion(); + } + if (data.size() >= 5) { + sortCriteria[1] = new SortCriterion(data.get(3), data.get(4)); + } else { + sortCriteria[1] = new SortCriterion(); + } + if (data.size() >= 7) { + sortCriteria[2] = new SortCriterion(data.get(5), data.get(6)); + } else { + sortCriteria[2] = new SortCriterion(); + } + } public static SaveOrderConfig parse(List orderedData) { return new SaveOrderConfig(orderedData); } @@ -27,8 +73,8 @@ public static SaveOrderConfig parse(List orderedData) { public static class SortCriterion { public String field; - public boolean descending; + public boolean descending; public SortCriterion() { this.field = ""; @@ -43,7 +89,6 @@ public SortCriterion(String field, boolean descending) { this.field = field; this.descending = descending; } - @Override public String toString() { final StringBuilder sb = new StringBuilder("SortCriterion{"); @@ -70,14 +115,7 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(field, descending); } - } - public SaveOrderConfig(boolean saveInOriginalOrder, SortCriterion first, SortCriterion second, - SortCriterion third) { - this.saveInOriginalOrder = saveInOriginalOrder; - sortCriteria[0] = first; - sortCriteria[1] = second; - sortCriteria[2] = third; } @Override @@ -100,14 +138,6 @@ public int hashCode() { return Objects.hash(saveInOriginalOrder, Arrays.hashCode(sortCriteria)); } - public SaveOrderConfig() { - // fill default values - setSaveInOriginalOrder(); - sortCriteria[0] = new SortCriterion(); - sortCriteria[1] = new SortCriterion(); - sortCriteria[2] = new SortCriterion(); - } - @Override public String toString() { final StringBuilder sb = new StringBuilder("SaveOrderConfig{"); @@ -117,37 +147,6 @@ public String toString() { return sb.toString(); } - private SaveOrderConfig(List data) { - Objects.requireNonNull(data); - - if (data.isEmpty()) { - throw new IllegalArgumentException(); - } - - String choice = data.get(0); - if (ORIGINAL.equals(choice)) { - setSaveInOriginalOrder(); - } else { - setSaveInSpecifiedOrder(); - } - - if (data.size() >= 3) { - sortCriteria[0] = new SortCriterion(data.get(1), data.get(2)); - } else { - sortCriteria[0] = new SortCriterion(); - } - if (data.size() >= 5) { - sortCriteria[1] = new SortCriterion(data.get(3), data.get(4)); - } else { - sortCriteria[1] = new SortCriterion(); - } - if (data.size() >= 7) { - sortCriteria[2] = new SortCriterion(data.get(5), data.get(6)); - } else { - sortCriteria[2] = new SortCriterion(); - } - } - public void setSaveInOriginalOrder() { this.saveInOriginalOrder = true; } diff --git a/src/main/java/org/jabref/model/pdf/FileAnnotationType.java b/src/main/java/org/jabref/model/pdf/FileAnnotationType.java index af32ba182cb..3bc7b56012c 100644 --- a/src/main/java/org/jabref/model/pdf/FileAnnotationType.java +++ b/src/main/java/org/jabref/model/pdf/FileAnnotationType.java @@ -1,6 +1,5 @@ package org.jabref.model.pdf; - public enum FileAnnotationType { TEXT("Text"), HIGHLIGHT("Highlight"), diff --git a/src/main/java/org/jabref/model/search/matchers/AndMatcher.java b/src/main/java/org/jabref/model/search/matchers/AndMatcher.java index 55a4659ff91..c39b3c36ffc 100644 --- a/src/main/java/org/jabref/model/search/matchers/AndMatcher.java +++ b/src/main/java/org/jabref/model/search/matchers/AndMatcher.java @@ -15,7 +15,7 @@ public boolean isMatch(BibEntry bibEntry) { // We let each rule add a maximum of 1 to the score. for (SearchMatcher rule : matchers) { - if(rule.isMatch(bibEntry)) { + if (rule.isMatch(bibEntry)) { score++; } } diff --git a/src/main/java/org/jabref/model/search/matchers/MatcherSet.java b/src/main/java/org/jabref/model/search/matchers/MatcherSet.java index f4e154faef2..934ea16b598 100644 --- a/src/main/java/org/jabref/model/search/matchers/MatcherSet.java +++ b/src/main/java/org/jabref/model/search/matchers/MatcherSet.java @@ -8,6 +8,8 @@ public abstract class MatcherSet implements SearchMatcher { + protected final List matchers = new Vector<>(); + @Override public boolean equals(Object o) { if (this == o) { @@ -28,8 +30,6 @@ public int hashCode() { return matchers.hashCode(); } - protected final List matchers = new Vector<>(); - public void addRule(SearchMatcher newRule) { matchers.add(Objects.requireNonNull(newRule)); } diff --git a/src/main/java/org/jabref/model/search/matchers/MatcherSets.java b/src/main/java/org/jabref/model/search/matchers/MatcherSets.java index a32a7ff1abe..ca2017005a5 100644 --- a/src/main/java/org/jabref/model/search/matchers/MatcherSets.java +++ b/src/main/java/org/jabref/model/search/matchers/MatcherSets.java @@ -1,6 +1,5 @@ package org.jabref.model.search.matchers; - public class MatcherSets { public enum MatcherType { diff --git a/src/main/java/org/jabref/model/search/matchers/OrMatcher.java b/src/main/java/org/jabref/model/search/matchers/OrMatcher.java index 2aceb4e58c0..ffd2ebf1e28 100644 --- a/src/main/java/org/jabref/model/search/matchers/OrMatcher.java +++ b/src/main/java/org/jabref/model/search/matchers/OrMatcher.java @@ -15,7 +15,7 @@ public boolean isMatch(BibEntry bibEntry) { // We let each rule add a maximum of 1 to the score. for (SearchMatcher rule : matchers) { - if(rule.isMatch(bibEntry)) { + if (rule.isMatch(bibEntry)) { score++; } } diff --git a/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java b/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java index 8b2d542b504..8405b10fab8 100644 --- a/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java +++ b/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java @@ -45,12 +45,12 @@ public boolean applyRule(String query, BibEntry bibEntry) { Iterator unmatchedWordsIterator = unmatchedWords.iterator(); while (unmatchedWordsIterator.hasNext()) { String word = unmatchedWordsIterator.next(); - if(formattedFieldContent.contains(word)) { + if (formattedFieldContent.contains(word)) { unmatchedWordsIterator.remove(); } } - if(unmatchedWords.isEmpty()) { + if (unmatchedWords.isEmpty()) { return true; } } diff --git a/src/main/java/org/jabref/model/search/rules/GrammarBasedSearchRule.java b/src/main/java/org/jabref/model/search/rules/GrammarBasedSearchRule.java index 8360c32db8a..1cabbeaabbe 100644 --- a/src/main/java/org/jabref/model/search/rules/GrammarBasedSearchRule.java +++ b/src/main/java/org/jabref/model/search/rules/GrammarBasedSearchRule.java @@ -38,7 +38,6 @@ public class GrammarBasedSearchRule implements SearchRule { private ParseTree tree; private String query; - public static class ThrowingErrorListener extends BaseErrorListener { public static final ThrowingErrorListener INSTANCE = new ThrowingErrorListener(); @@ -222,7 +221,7 @@ public Boolean visitStart(SearchParser.StartContext ctx) { public Boolean visitComparison(SearchParser.ComparisonContext context) { // remove possible enclosing " symbols String right = context.right.getText(); - if(right.startsWith("\"") && right.endsWith("\"")) { + if (right.startsWith("\"") && right.endsWith("\"")) { right = right.substring(1, right.length() - 1); } diff --git a/src/main/java/org/jabref/model/search/rules/SentenceAnalyzer.java b/src/main/java/org/jabref/model/search/rules/SentenceAnalyzer.java index 05c861e3774..89987d9d5ac 100644 --- a/src/main/java/org/jabref/model/search/rules/SentenceAnalyzer.java +++ b/src/main/java/org/jabref/model/search/rules/SentenceAnalyzer.java @@ -20,7 +20,7 @@ public List getWords() { StringBuilder stringBuilder = new StringBuilder(); boolean escaped = false; boolean quoted = false; - for(char c : query.toCharArray()) { + for (char c : query.toCharArray()) { // Check if we are entering an escape sequence: if (!escaped && c == ESCAPE_CHAR) { escaped = true; diff --git a/src/main/java/org/jabref/model/strings/StringUtil.java b/src/main/java/org/jabref/model/strings/StringUtil.java index 29ffbf4dd2f..9f52af3fffb 100644 --- a/src/main/java/org/jabref/model/strings/StringUtil.java +++ b/src/main/java/org/jabref/model/strings/StringUtil.java @@ -168,7 +168,6 @@ public static String getCorrectFileName(String orgName, String defaultExtension) return ""; } - if (orgName.toLowerCase(Locale.ROOT).endsWith("." + defaultExtension.toLowerCase(Locale.ROOT))) { return orgName; } @@ -678,6 +677,7 @@ public static String unquote(String toUnquote, char quoteChar) { } return result.toString(); } + public static String stripAccents(String searchQuery) { return StringUtils.stripAccents(searchQuery); } diff --git a/src/main/java/org/jabref/pdfimport/PdfImporter.java b/src/main/java/org/jabref/pdfimport/PdfImporter.java index 12e58af4f4c..5b28a2bbc60 100644 --- a/src/main/java/org/jabref/pdfimport/PdfImporter.java +++ b/src/main/java/org/jabref/pdfimport/PdfImporter.java @@ -43,12 +43,12 @@ public class PdfImporter { + private static final Log LOGGER = LogFactory.getLog(PdfImporter.class); private final JabRefFrame frame; private final BasePanel panel; private final MainTable entryTable; - private final int dropRow; - private static final Log LOGGER = LogFactory.getLog(PdfImporter.class); + private final int dropRow; /** * Creates the PdfImporter diff --git a/src/main/java/org/jabref/preferences/CustomExportList.java b/src/main/java/org/jabref/preferences/CustomExportList.java index 6a5f00270d6..db63efc8366 100644 --- a/src/main/java/org/jabref/preferences/CustomExportList.java +++ b/src/main/java/org/jabref/preferences/CustomExportList.java @@ -28,11 +28,11 @@ public class CustomExportList { + private static final Log LOGGER = LogFactory.getLog(CustomExportList.class); private final EventList> list; private final SortedList> sorted; - private final Map formats = new TreeMap<>(); - private static final Log LOGGER = LogFactory.getLog(CustomExportList.class); + private final Map formats = new TreeMap<>(); public CustomExportList(Comparator> comp) { diff --git a/src/main/java/org/jabref/preferences/CustomImportList.java b/src/main/java/org/jabref/preferences/CustomImportList.java index ea64100cf4b..34202085dcf 100644 --- a/src/main/java/org/jabref/preferences/CustomImportList.java +++ b/src/main/java/org/jabref/preferences/CustomImportList.java @@ -18,10 +18,10 @@ */ public class CustomImportList extends TreeSet { - private final JabRefPreferences prefs; - private static final Log LOGGER = LogFactory.getLog(CustomImportList.class); + private final JabRefPreferences prefs; + public CustomImportList(JabRefPreferences prefs) { super(); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 48ac595fc42..bc3da5e2829 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -38,6 +38,7 @@ import org.jabref.JabRefMain; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.entryeditor.EntryEditorTabList; +import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.preftabs.ImportSettingsTab; import org.jabref.logic.autocompleter.AutoCompletePreferences; import org.jabref.logic.bibtex.FieldContentParserPreferences; @@ -79,7 +80,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -public class JabRefPreferences { +public class JabRefPreferences implements PreferencesService { // Push to application preferences public static final String EMACS_PATH = "emacsPath"; @@ -250,8 +251,6 @@ public class JabRefPreferences { public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; public static final String CUSTOM_EXPORT_FORMAT = "customExportFormat"; public static final String CUSTOM_IMPORT_FORMAT = "customImportFormat"; - public static final String BINDINGS = "bindings"; - public static final String BIND_NAMES = "bindNames"; public static final String KEY_PATTERN_REGEX = "KeyPatternRegex"; public static final String KEY_PATTERN_REPLACEMENT = "KeyPatternReplacement"; public static final String CONSOLE_COMMAND = "consoleCommand"; @@ -274,8 +273,6 @@ public class JabRefPreferences { public static final String LAST_USED_EXPORT = "lastUsedExport"; public static final String FLOAT_MARKED_ENTRIES = "floatMarkedEntries"; public static final String CITE_COMMAND = "citeCommand"; - public static final String EXTERNAL_JOURNAL_LISTS = "externalJournalLists"; - public static final String PERSONAL_JOURNAL_LIST = "personalJournalList"; public static final String GENERATE_KEYS_BEFORE_SAVING = "generateKeysBeforeSaving"; public static final String EMAIL_SUBJECT = "emailSubject"; public static final String OPEN_FOLDERS_OF_ATTACHED_FILES = "openFoldersOfAttachedFiles"; @@ -296,7 +293,6 @@ public class JabRefPreferences { public static final String CUSTOM_TAB_FIELDS = "customTabFields_"; public static final String USE_UNIT_FORMATTER_ON_SEARCH = "useUnitFormatterOnSearch"; public static final String USE_CASE_KEEPER_ON_SEARCH = "useCaseKeeperOnSearch"; - public static final String USE_IEEE_ABRV = "useIEEEAbrv"; public static final String ASK_AUTO_NAMING_PDFS_AGAIN = "AskAutoNamingPDFsAgain"; public static final String CLEANUP_DOI = "CleanUpDOI"; public static final String CLEANUP_ISSN = "CleanUpISSN"; @@ -316,6 +312,14 @@ public class JabRefPreferences { public static final String NAME_FORMATER_KEY = "nameFormatterNames"; public static final String PUSH_TO_APPLICATION = "pushToApplication"; public static final String SHOW_RECOMMENDATIONS = "showRecommendations"; + // Dropped file handler + public static final String DROPPEDFILEHANDLER_RENAME = "DroppedFileHandler_RenameFile"; + public static final String DROPPEDFILEHANDLER_MOVE = "DroppedFileHandler_MoveFile"; + public static final String DROPPEDFILEHANDLER_COPY = "DroppedFileHandler_CopyFile"; + public static final String DROPPEDFILEHANDLER_LEAVE = "DroppedFileHandler_LeaveFileInDir"; + // Remote + public static final String USE_REMOTE_SERVER = "useRemoteServer"; + public static final String REMOTE_SERVER_PORT = "remoteServerPort"; /** * The OpenOffice/LibreOffice connection preferences are: * OO_PATH main directory for OO/LO installation, used to detect location on Win/OS X when using manual connect @@ -358,23 +362,19 @@ public class JabRefPreferences { // Prefs node for customized entry types public static final String CUSTOMIZED_BIBTEX_TYPES = "customizedBibtexTypes"; public static final String CUSTOMIZED_BIBLATEX_TYPES = "customizedBiblatexTypes"; + // Version public static final String VERSION_IGNORED_UPDATE = "versionIgnoreUpdate"; // User private static final String USER_ID = "userId"; - + private static final String EXTERNAL_JOURNAL_LISTS = "externalJournalLists"; + private static final String PERSONAL_JOURNAL_LIST = "personalJournalList"; + private static final String USE_IEEE_ABRV = "useIEEEAbrv"; + private static final String BINDINGS = "bindings"; + private static final String BIND_NAMES = "bindNames"; // Telemetry collection private static final String COLLECT_TELEMETRY = "collectTelemetry"; private static final String ALREADY_ASKED_TO_COLLECT_TELEMETRY = "askedCollectTelemetry"; - - // Dropped file handler - public static final String DROPPEDFILEHANDLER_RENAME = "DroppedFileHandler_RenameFile"; - public static final String DROPPEDFILEHANDLER_MOVE = "DroppedFileHandler_MoveFile"; - public static final String DROPPEDFILEHANDLER_COPY = "DroppedFileHandler_CopyFile"; - public static final String DROPPEDFILEHANDLER_LEAVE = "DroppedFileHandler_LeaveFileInDir"; - // Remote - public static final String USE_REMOTE_SERVER = "useRemoteServer"; - public static final String REMOTE_SERVER_PORT = "remoteServerPort"; private static final Log LOGGER = LogFactory.getLog(JabRefPreferences.class); private static final Class PREFS_BASE_CLASS = JabRefMain.class; private static final String DB_CONNECT_USERNAME = "dbConnectUsername"; @@ -408,13 +408,13 @@ public class JabRefPreferences { * Set with all custom {@link org.jabref.logic.importer.Importer}s */ public final CustomImportList customImports; - private final Preferences prefs; // The following field is used as a global variable during the export of a database. // By setting this field to the path of the database's default file directory, formatters // that should resolve external file paths can access this field. This is an ugly hack // to solve the problem of formatters not having access to any context except for the // string to be formatted and possible formatter arguments. public List fileDirForDatabase; + private final Preferences prefs; private GlobalBibtexKeyPattern keyPattern; // Object containing info about customized entry editor tabs. private EntryEditorTabList tabList; @@ -1223,7 +1223,7 @@ public List loadCustomEntryTypes(BibDatabaseMode bibDatabaseMod } private void clearAllCustomEntryTypes() throws BackingStoreException { - for(BibDatabaseMode mode :BibDatabaseMode.values()) { + for (BibDatabaseMode mode :BibDatabaseMode.values()) { clearCustomEntryTypes(mode); } } @@ -1429,7 +1429,7 @@ public JabRefPreferences storePreviewPreferences(PreviewPreferences previewPrefe return this; } - public PreviewPreferences getPreviewPreferences(){ + public PreviewPreferences getPreviewPreferences() { int cyclePos = getInt(CYCLE_PREVIEW_POS); List cycle = getStringList(CYCLE_PREVIEW); int panelHeight = getInt(PREVIEW_PANEL_HEIGHT); @@ -1493,6 +1493,7 @@ public void setProtectedTermsPreferences(ProtectedTermsLoader loader) { } + @Override public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { return new JournalAbbreviationPreferences(getStringList(EXTERNAL_JOURNAL_LISTS), get(PERSONAL_JOURNAL_LIST), getBoolean(USE_IEEE_ABRV), getDefaultEncoding()); @@ -1576,4 +1577,21 @@ public Boolean shouldAskToCollectTelemetry() { public void askedToCollectTelemetry() { putBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY, true); } + + @Override + public void storeKeyBindingRepository(KeyBindingRepository keyBindingRepository) { + putStringList(JabRefPreferences.BIND_NAMES, keyBindingRepository.getBindNames()); + putStringList(JabRefPreferences.BINDINGS, keyBindingRepository.getBindings()); + } + + @Override + public KeyBindingRepository getKeyBindingRepository() { + return new KeyBindingRepository(getStringList(BIND_NAMES), getStringList(BINDINGS)); + } + + @Override + public void storeJournalAbbreviationPreferences(JournalAbbreviationPreferences abbreviationsPreferences) { + putStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, abbreviationsPreferences.getExternalJournalLists()); + putBoolean(JabRefPreferences.USE_IEEE_ABRV, abbreviationsPreferences.useIEEEAbbreviations()); + } } diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java new file mode 100644 index 00000000000..6ea1a9d56dc --- /dev/null +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -0,0 +1,14 @@ +package org.jabref.preferences; + +import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.logic.journals.JournalAbbreviationPreferences; + +public interface PreferencesService { + JournalAbbreviationPreferences getJournalAbbreviationPreferences(); + + void storeKeyBindingRepository(KeyBindingRepository keyBindingRepository); + + KeyBindingRepository getKeyBindingRepository(); + + void storeJournalAbbreviationPreferences(JournalAbbreviationPreferences abbreviationsPreferences); +} diff --git a/src/main/java/org/jabref/preferences/PreviewPreferences.java b/src/main/java/org/jabref/preferences/PreviewPreferences.java index cab54ce4cb2..2a03b5d4fea 100644 --- a/src/main/java/org/jabref/preferences/PreviewPreferences.java +++ b/src/main/java/org/jabref/preferences/PreviewPreferences.java @@ -2,7 +2,6 @@ import java.util.List; - public class PreviewPreferences { private final List previewCycle; @@ -50,7 +49,6 @@ public Builder getBuilder() { return new Builder(this); } - public static class Builder { private List previewCycle; private int previeCyclePosition; diff --git a/src/main/java/org/jabref/preferences/SearchPreferences.java b/src/main/java/org/jabref/preferences/SearchPreferences.java index 5613b0c7ceb..53452b5d639 100644 --- a/src/main/java/org/jabref/preferences/SearchPreferences.java +++ b/src/main/java/org/jabref/preferences/SearchPreferences.java @@ -5,7 +5,6 @@ import org.jabref.gui.search.SearchDisplayMode; - public class SearchPreferences { private static final String SEARCH_GLOBAL = "searchGlobal"; diff --git a/src/main/java/org/jabref/shared/DBMSProcessor.java b/src/main/java/org/jabref/shared/DBMSProcessor.java index ee1329add77..9d10436e824 100644 --- a/src/main/java/org/jabref/shared/DBMSProcessor.java +++ b/src/main/java/org/jabref/shared/DBMSProcessor.java @@ -27,15 +27,15 @@ */ public abstract class DBMSProcessor { - protected static final Log LOGGER = LogFactory.getLog(DBMSProcessor.class); + public static final String PROCESSOR_ID = UUID.randomUUID().toString(); + + protected static final Log LOGGER = LogFactory.getLog(DBMSProcessor.class); protected final Connection connection; protected DBMSConnectionProperties connectionProperties; - public static final String PROCESSOR_ID = UUID.randomUUID().toString(); - protected DBMSProcessor(DBMSConnection dbmsConnection) { this.connection = dbmsConnection.getConnection(); @@ -511,7 +511,7 @@ public Map getSharedMetaData() { Map data = new HashMap<>(); try (ResultSet resultSet = connection.createStatement().executeQuery("SELECT * FROM " + escape("METADATA"))) { - while(resultSet.next()) { + while (resultSet.next()) { data.put(resultSet.getString("KEY"), resultSet.getString("VALUE")); } } catch (SQLException e) { diff --git a/src/main/java/org/jabref/shared/PostgreSQLProcessor.java b/src/main/java/org/jabref/shared/PostgreSQLProcessor.java index caa3bcc9656..a6443e4aa39 100644 --- a/src/main/java/org/jabref/shared/PostgreSQLProcessor.java +++ b/src/main/java/org/jabref/shared/PostgreSQLProcessor.java @@ -85,7 +85,6 @@ String escape(String expression) { return "\"" + expression + "\""; } - @Override public void startNotificationListener(DBMSSynchronizer dbmsSynchronizer) { // Disable cleanup output of ThreadedHousekeeper diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index 03bcff23388..5fc79f21a43 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -117,8 +117,6 @@ Attach_URL=Tilføj_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Forsøg_at_sætte_fil-link_automatisk_for_dine_poster._Dette_virker,_hvis_en_fil_i_dit_fil-bibliotek_eller_et_underbibliotek
har_navn_lignende_en_posts_BibTeX-nøgle,_plus_efternavn. -Auto=Auto - Autodetect_format=Autodetekter_format Autogenerate_BibTeX_keys=Autogenerer_BibTeX-nøgler @@ -732,8 +730,6 @@ Manage_custom_exports=Opsæt_eksterne_eksportfiltre Manage_custom_imports=Opsæt_eksterne_importfiltre Manage_external_file_types=Opsæt_eksterne_filtyper -Manage_journal_abbreviations=Opsæt_tidsskriftsforkortelser - Mark_entries=Mærk_poster Mark_entry=Mærk_post @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denne_ This_operation_requires_one_or_more_entries_to_be_selected.=Denne_operation_kræver,_at_en_eller_flere_poster_er_valgt. -Toggle_abbreviation=Forkort/ekspander Toggle_entry_preview=Vis/skjul_forhåndsvisning Toggle_groups_interface=Vis/skjul_grupperingspanel Try_different_encoding=Prøv_en_anden_tegnkodning @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopier_\\cite{BibTeX-nøgler} Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to=For_at_sætte_op,_gå_til Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ugyldig_DOI\:_'%0'. should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index e3dc2596def..81b745e144a 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -117,8 +117,6 @@ Attach_URL=URL_anfügen Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Versucht,_Datei-Links_für_die_Einträge_automatisch_zuzuordnen._Dies_funktioniert,_wenn_der_Name_einer_Datei_im_Datei-Verzeichnis_oder_einem_Unterverzeichnis
identisch_ist_mit_dem_BibTeX-Key_eines_Eintrags_(erweitert_um_die_jeweilige_Dateiendung). -Auto=Auto - Autodetect_format=Format_automatisch_erkennen Autogenerate_BibTeX_keys=BibTeX-Keys_automatisch_generieren @@ -732,8 +730,6 @@ Manage_custom_exports=Verwalte_externe_Exportfilter Manage_custom_imports=Verwalte_externe_Importfilter Manage_external_file_types=Externe_Dateitypen_verwalten -Manage_journal_abbreviations=Abkürzungen_der_Zeitschriften_verwalten - Mark_entries=Einträge_markieren Mark_entry=Eintrag_markieren @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Für_d This_operation_requires_one_or_more_entries_to_be_selected.=Für_diesen_Vorgang_muss_mindestens_ein_Eintrag_ausgewählt_sein. -Toggle_abbreviation=Abkürzung_an-/abschalten Toggle_entry_preview=Eintragsvorschau_ein-/ausblenden Toggle_groups_interface=Gruppenansicht_ein-/ausblenden Try_different_encoding=Versuchen_Sie_es_mit_einer_anderen_Kodierung @@ -1852,7 +1847,6 @@ Copy_title=Kopiere_Titel Copy_\\cite{BibTeX_key}=\\cite{BibTeX_key}_kopieren Copy_BibTeX_key_and_title=BibTeX-Key_und_Titel_kopieren File_rename_failed_for_%0_entries.=Dateiumbennung_schlug_ür_%0_Einträge_fehl. -To_set_up,_go_to=Einstellungen_unter Merged_BibTeX_source_code=BibTeX-Quelltext_zusammengeführt Invalid_DOI\:_'%0'.=Ungültiger_DOI\:_'%0'. should_start_with_a_name=sollte_mit_einem_Name_beginnen @@ -2357,7 +2351,7 @@ Locked=Gesperrt Show_document_viewer=Zeige_Dokumentenbetrachter Show_the_document_of_the_currently_selected_entry.=Zeige_das_Dokument_zum_selektierten_Eintrag. Show_this_document_until_unlocked.=Zeige_dieses_Dokument_solange_bis_es_entsperrt_wurde. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Sortiere_alle_Untergruppen_(rekursiv) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Sammle_und_teile_Telemetriedaten,_um_bei_der_Verbesserung_von_JabRef_zu_unterstützen. diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index bdcb49c9292..7057d932fc3 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -117,8 +117,6 @@ Attach_URL=Attach_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension. -Auto=Auto - Autodetect_format=Autodetect_format Autogenerate_BibTeX_keys=Autogenerate_BibTeX_keys @@ -732,8 +730,6 @@ Manage_custom_exports=Manage_custom_exports Manage_custom_imports=Manage_custom_imports Manage_external_file_types=Manage_external_file_types -Manage_journal_abbreviations=Manage_journal_abbreviations - Mark_entries=Mark_entries Mark_entry=Mark_entry @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=This_o This_operation_requires_one_or_more_entries_to_be_selected.=This_operation_requires_one_or_more_entries_to_be_selected. -Toggle_abbreviation=Toggle_abbreviation Toggle_entry_preview=Toggle_entry_preview Toggle_groups_interface=Toggle_groups_interface Try_different_encoding=Try_different_encoding @@ -1852,7 +1847,6 @@ Copy_title=Copy_title Copy_\\cite{BibTeX_key}=Copy_\\cite{BibTeX_key} Copy_BibTeX_key_and_title=Copy_BibTeX_key_and_title File_rename_failed_for_%0_entries.=File_rename_failed_for_%0_entries. -To_set_up,_go_to=To_set_up,_go_to Merged_BibTeX_source_code=Merged_BibTeX_source_code Invalid_DOI\:_'%0'.=Invalid_DOI\:_'%0'. should_start_with_a_name=should_start_with_a_name @@ -2357,7 +2351,7 @@ Locked=Locked Show_document_viewer=Show_document_viewer Show_the_document_of_the_currently_selected_entry.=Show_the_document_of_the_currently_selected_entry. Show_this_document_until_unlocked.=Show_this_document_until_unlocked. - +Set_current_user_name_as_owner.=Set_current_user_name_as_owner. Sort_all_subgroups_(recursively)=Sort_all_subgroups_(recursively) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Collect_and_share_telemetry_data_to_help_improve_JabRef. diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index dec18576d03..acf459078b7 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -40,7 +40,7 @@ Accept_change=Aceptar_cambio Action=Acción -What_is_Mr._DLib?= +What_is_Mr._DLib?=¿Qué_es_Mr._DLib? Add=Añadir @@ -50,7 +50,7 @@ The_path_need_not_be_on_the_classpath_of_JabRef.=La_ruta_no_debe_estar_en_la_cla Add_a_(compiled)_custom_Importer_class_from_a_ZIP-archive.=Añadir_una_clase_personalizada_(compilada)_Importer_desde_un_archivo_ZIP. The_ZIP-archive_need_not_be_on_the_classpath_of_JabRef.=El_archivo_ZIP_no_tiene_por_qué_estar_en_la_classpath_de_JabRef. -Add_selected_entries_to_this_group= +Add_selected_entries_to_this_group=Añadir_entradas_seleccionadas_a_este_grupo Add_from_folder=Añadir_desde_carpeta @@ -62,7 +62,7 @@ Add_new=Añadir_nuevo Add_subgroup=Añadir_subgrupo -Loading_Recommendations_for= +Loading_Recommendations_for=Cargando_recomendaciones_para Add_to_group=Añadir_a_grupo @@ -94,9 +94,9 @@ any_field_that_matches_the_regular_expression_%0=cualquier_campo_que_sati Appearance=Aspecto Append=Añadir -Append_contents_from_a_BibTeX_library_into_the_currently_viewed_library=Agregar_contenidos_desde_una_base_de_datos_BibTeX_a_la_base_de_datos_actual +Append_contents_from_a_BibTeX_library_into_the_currently_viewed_library=Agregar_contenidos_desde_una_biblioteca_BibTeX_a_la_biblioteca_actual -Append_library=Agregar_base_de_datos +Append_library=Agregar_biblioteca Append_the_selected_text_to_BibTeX_field=Agregar_el_texto_seleccionado_a_la_clave_BibTeX Application=Aplicación @@ -117,8 +117,6 @@ Attach_URL=Adjuntar_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Intentar_establecer_automáticamente_archivo_enlaces_para_sus_entradas._El_establecimiento_automático_funciona_si_un_archivo_en_la_carpeta_archivo_o_un_subdirectrio_
_tiene_nombre_idéntico_a_una_entrada_BibTeX_más_la_extensión. -Auto=Auto - Autodetect_format=Autodetectar_formato Autogenerate_BibTeX_keys=Autogenerar_claves_BibTeX @@ -211,11 +209,11 @@ Close_all=Cerrar_todos Close_dialog=Cerrar_diálogo -Close_the_current_library=Cerrar_la_base_de_datos_actual +Close_the_current_library=Cerrar_la_biblioteca_actual Close_window=Cerrar_ventana -Closed_library=Base_de_datos_cerrada +Closed_library=Biblioteca_cerrada Color_codes_for_required_and_optional_fields=Códigos_de_color_para_campos_requeridos_y_opcionales @@ -234,11 +232,11 @@ Copied=Copiado Copied_cell_contents=Contenido_de_celda_copiado -Copied_title= +Copied_title=Título_copiado Copied_key=Clave_copiada -Copied_titles= +Copied_titles=Títulos_copiados Copied_keys=Claves_copiadas @@ -292,11 +290,11 @@ cut_entries=Cortar_entradas cut_entry=Cortar_entrada -Library_encoding=Codificación_de_la_Base_de_Datos +Library_encoding=Codificación_de_la_biblioteca -Library_properties=Propiedades_de_la_Base_de_Datos +Library_properties=Propiedades_de_la_biblioteca -Library_type= +Library_type=Tipo_de_biblioteca Date_format=Formato_de_fecha @@ -332,8 +330,8 @@ Delete_strings=Borrar_cadenas Deleted=Borrado Permanently_delete_local_file=Eliminar_archivo_local -Delete_file= -Delete_'%0'?= +Delete_file=Borrar_archivo +Delete_'%0'?=¿Borrar_'%0'? Delimit_fields_with_semicolon,_ex.=Delimitar_campos_con_punto_y_coma Descending=Descendiente @@ -414,7 +412,7 @@ Empty_BibTeX_key=Clave_BibTeXt_vacía Grouping_may_not_work_for_this_entry.=El_agrupamiento_puede_no_funcionar_para_esta_entrada. -empty_library=base_de_datos_vacía +empty_library=Biblioteca_vacía Enable_word/name_autocompletion=Permitir_autocompletado_de_palabra/nombre Enter_URL=Introducir_URL @@ -518,7 +516,7 @@ File_updated_externally=Archivo_actualizado_externamente filename=nombre_de_archivo -Filename= +Filename=Nombre_de_archivo Files_opened=Archivos_abiertos @@ -577,7 +575,7 @@ Generate_now=Generar_ahora Generated_BibTeX_key_for=Generar_clabe_BibTeX_para Generating_BibTeX_key_for=Generarando_clave_BibTeX_para -Get_fulltext= +Get_fulltext=Obtener_texto_completo Gray_out_entries_not_in_group_selection=Poner_en_gris_entradas_que_no_estén_en_el_grupo_de_selección @@ -599,12 +597,12 @@ Hide_non-hits=Esconder_los_no-aciertos Hierarchical_context=Contexto_jerárquico Highlight=Resaltar -Marking= -Underline= -Empty_Highlight= -Empty_Marking= -Empty_Underline= -The_marked_area_does_not_contain_any_legible_text!= +Marking=Marcado +Underline=Subrayado +Empty_Highlight=Resaltado_vacío +Empty_Marking=Marcado_vacío +Empty_Underline=Subrayado_vacío +The_marked_area_does_not_contain_any_legible_text!=¡El_área_marcada_no_contiente_ningún_texto_legible! Hint\:_To_search_specific_fields_only,_enter_for_example\:

author\=smith_and_title\=electrical=Pista_\:_Para_buscar_sólo_campos_específicos,_introduzca,_por_ejemplo,_\:_

author\=smith_and_title\=electrical @@ -644,7 +642,7 @@ Import_word_selector_definitions=Importar_definiciones_de_selector_de_palabras Imported_entries=Importar_entradas -Imported_from_library=Importado_desde_base_de_datos +Imported_from_library=Importado_desde_biblioteca Importer_class=Importar_formato_de_clase @@ -675,7 +673,7 @@ Invalid_URL=URL_no_válida Inverted=Invertido -Online_help= +Online_help=Ayuda_online JabRef_preferences=Preferencias_de_JabRef @@ -693,7 +691,7 @@ Key_generator_settings=Ajustes_del_generador_de_claves Key_pattern=Patrón_de_clave -keys_in_library=claves_en_la_base_de_datos +keys_in_library=claves_en_la_biblioteca Keyword=Palabra_clave @@ -707,7 +705,7 @@ LaTeX_AUX_file=Archivo_LaTeX_AUX Leave_file_in_its_current_directory=Dejar_el_archivo_en_su_directorio_actual Left=Dejar -Level= +Level=Nivelar Limit_to_fields=Limitar_a_los_campos @@ -732,8 +730,6 @@ Manage_custom_exports=Administrar_esportaciones_personalizadas Manage_custom_imports=Administrar_importaciones_personalizadas Manage_external_file_types=Administrar_tipos_de_archivo_externos -Manage_journal_abbreviations=Administrar_abreviaturas_de_revistas - Mark_entries=Marcar_entradas Mark_entry=Marcar_entrada @@ -786,12 +782,12 @@ new=new New_BibTeX_entry=Nueva_entrada_BibTeX -New_BibTeX_sublibrary=Nueva_base_de_datos_secundaria_BibTeX +New_BibTeX_sublibrary=Nueva_biblioteca_secundaria_BibTeX New_content=Nuevo_contenido -New_library_created.=Nueva_base_de_datos_creada. -New_%0_library=Nueva_base_de_datos_%0 +New_library_created.=Nueva_biblioteca_creada. +New_%0_library=Nueva_biblioteca_%0 New_field_value=Nuevo_valor_de_campo New_file_link_(INSERT)=Nuevo_enlace_a_archivo_(INSERTAR) @@ -806,7 +802,7 @@ No_actual_changes_found.=No_se_han_encontrado_cambios_actuales. no_base-BibTeX-file_specified=no_se_ha_especificado_archiv_base_BibTeX -no_library_generated=No_se_generó_base_de_datos +no_library_generated=No_se_generó_biblioteca No_entries_found._Please_make_sure_you_are_using_the_correct_import_filter.=No_se_han_encontrado_entradas._Asegúrese_de_que_está_usando_el_filtro_de_importación_correcto. @@ -824,7 +820,7 @@ No_journal_names_could_be_abbreviated.=No_se_pudieron_abreviar_nombres_de_revist No_journal_names_could_be_unabbreviated.=No_se_pudieron_expandir_nombres_de_revistas. No_PDF_linked=Ningún_PDF_enlazado -Open_PDF= +Open_PDF=Abrir_PDF No_URL_defined=Ninguna_URL_definida not=no @@ -847,23 +843,23 @@ One_or_more_keys_will_be_overwritten._Continue?=Una_o_claves_se_sobreescribirán Open=Abrir -Open_BibTeX_library=Abrir_base_de_datos_BIbTeX +Open_BibTeX_library=Abrir_biblioteca_BIbTeX -Open_library=Abrir_base_de_datos +Open_library=Abrir_biblioteca Open_editor_when_a_new_entry_is_created=Abrir_editor_al_crear_nueva_entrada Open_file=Abrir_archivo -Open_last_edited_libraries_at_startup=Abrir_las_últimas_bases_de_datos_editadas_al_arrancar +Open_last_edited_libraries_at_startup=Abrir_las_últimas_bibliotecas_editadas_al_arrancar -Connect_to_shared_database= +Connect_to_shared_database=Conectar_a_biblioteca_compartida Open_terminal_here=Open_terminal_here Open_URL_or_DOI=Abril_URL_o_DOI -Opened_library=Base_de_datos_abierta +Opened_library=Biblioteca_abierta Opening=Abriendo @@ -912,9 +908,9 @@ Path_to_LyX_pipe=Ruta_hasta_el_pipe_LyX PDF_does_not_exist=No_existe_el_PDF -File_has_no_attached_annotations= +File_has_no_attached_annotations=El_fichero_no_tiene_anotaciones_adjuntas -Reload_annotations= +Reload_annotations=Recargar_anotaciones Plain_text_import=Importar_texto_plano @@ -939,21 +935,21 @@ Preferences=Preferencias Preferences_recorded.=Preferencias_guardadas. Preview=Vista_previa -Citation_Style= -Current_Preview= -Cannot_generate_preview_based_on_selected_citation_style.= -Bad_character_inside_entry= -Error_while_generating_citation_style= -Preview_style_changed_to\:_%0= -Next_preview_layout= -Previous_preview_layout= +Citation_Style=Estilo_de_cita +Current_Preview=Vista_previa_actual +Cannot_generate_preview_based_on_selected_citation_style.=No_se_puede_generar_vista_previa_basada_en_el_estilo_de_cita_seleccionado +Bad_character_inside_entry=Carácter_inapropiado_en_la_entrada +Error_while_generating_citation_style=Error_al_generar_el_estilo_de_cita +Preview_style_changed_to\:_%0=Cambiado_estilo_de_previsualización_a\:%0 +Next_preview_layout=Plantilla_de_previsualización_previa +Previous_preview_layout=Plantilla_de_previsualización_previa Previous_entry=Entrada_anterior Primary_sort_criterion=Criterio_de_ordenación_primario Problem_with_parsing_entry=Problemas_analizando_entradas Processing_%0=Procesando_%0 -Pull_changes_from_shared_database= +Pull_changes_from_shared_database=Obtener_cambios_desde_biblioteca_compartida Pushed_citations_to_%0=Se_han_enviado_las_citas_a_%0 @@ -967,7 +963,7 @@ Rearrange_tabs_alphabetically_by_title=Disponer_las_pestañas_alfabéticamente_p Redo=Rehacer -Reference_library=Base_de_datos_de_referencia +Reference_library=Biblioteca_de_referencia %0_references_found._Number_of_references_to_fetch?=Referencias_encontradas\:_%0._¿Número_de_apariciones_a_recuperar? @@ -975,7 +971,7 @@ Refine_supergroup\:_When_selected,_view_entries_contained_in_both_this_group_and regular_expression=Expresión_Regular -Related_articles= +Related_articles=Artículos_relacionados Remote_operation=Operación_remota @@ -989,7 +985,7 @@ Remove_all_subgroups_of_"%0"?=¿Eliminar_todos_los_subrgrupos_de_"%0"? Remove_entry_from_import=Eliminar_entrada_importada -Remove_selected_entries_from_this_group= +Remove_selected_entries_from_this_group=Eliminar_las_entradas_seleccionadas_de_este_grupo Remove_entry_type=Eliminar_tipo_de_entrada Remove_file_link_(DELETE)=Eliminar_enlace_a_archivo_(BORRAR) @@ -1052,12 +1048,12 @@ Right=Derecha Save=Guardar Save_all_finished.=Guardar_todos_los_finalizados -Save_all_open_libraries=Guardar_todas_las_bases_de_datos_abiertas +Save_all_open_libraries=Guardar_todas_las_bibliotecas_abiertas Save_before_closing=Guardar_antres_de_cerrar -Save_library=Guardar_base_de_datos -Save_library_as...=Guardar_base_de_datos_como... +Save_library=Guardar_biblioteca +Save_library_as...=Guardar_biblioteca_como... Save_entries_in_their_original_order=Guardar_entradas_en_el_orden_original @@ -1067,14 +1063,14 @@ Save_failed_during_backup_creation=Error_durante_el_guardado_mientras_se_creaba_ Save_selected_as...=Guardar_seleccionado_como... -Saved_library=Base_de_datos_guardada +Saved_library=Biblioteca_guardada Saved_selected_to_'%0'.=Guardar_seleccionados_a_'%0'. Saving=Guardando -Saving_all_libraries...=Guardando_todas_las_bases_de_datos... +Saving_all_libraries...=Guardando_todas_las_bibliotecas... -Saving_library=Guardando_base_de_datos +Saving_library=Guardando_biblioteca Search=Buscar @@ -1175,9 +1171,9 @@ Stored_entry=Entrada_almacenada Strings=Cadenas -Strings_for_library=Cadenas_para_base_de_datos +Strings_for_library=Cadenas_para_biblioteca -Sublibrary_from_AUX=Base_de_datos_secundaria_desde_AUX +Sublibrary_from_AUX=Biblioteca_secundaria_desde_AUX Switches_between_full_and_abbreviated_journal_name_if_the_journal_name_is_known.=Cambia_entre_nombre_completo_y_abreviatura_de_la_revista_si_se_conoce_en_nombe_de_la_revista. @@ -1221,7 +1217,7 @@ The_label_of_the_string_cannot_contain_the_'\#'_character.=La_etiqueta_de_la_cad The_output_option_depends_on_a_valid_import_option.=La_opción_de_salida_depende_de_una_opción_de_importación_válida. The_PDF_contains_one_or_several_BibTeX-records.=El_PDF_contiene_uno_o_más_registros_BibTeX. -Do_you_want_to_import_these_as_new_entries_into_the_current_library?=¿Desea_importarlos_como_nuevas_entradas_en_la_base_de_datos_actual? +Do_you_want_to_import_these_as_new_entries_into_the_current_library?=¿Desea_importarlos_como_nuevas_entradas_en_la_biblioteca_actual? The_regular_expression_%0_is_invalid\:=La_expresión_regular_%0_no_es_válida\: @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Esta_o This_operation_requires_one_or_more_entries_to_be_selected.=Esta_operación_requiere_seleccionar_una_o_más_entradas. -Toggle_abbreviation=Usar_abreviatura_si/no Toggle_entry_preview=Usar_vista_previa_de_la_entrada_si/no Toggle_groups_interface=Usar_interfaz_de_grupos_si/no Try_different_encoding=Probar_una_codificación_diferente @@ -1332,7 +1327,7 @@ Write_BibTeXEntry_as_XMP-metadata_to_PDF.=Escribir_entrada_BibTeX_como_metadatos Write_XMP=Escribir_XMP Write_XMP-metadata=Escribir_metadatos_XMP -Write_XMP-metadata_for_all_PDFs_in_current_library?=¿Escribir_metadatos_XMP_para_todos_los_PDF_en_la_base_de_datos_actual? +Write_XMP-metadata_for_all_PDFs_in_current_library?=¿Escribir_metadatos_XMP_para_todos_los_PDF_en_la_biblioteca_actual? Writing_XMP-metadata...=Escribiendo_metadatos_XMP Writing_XMP-metadata_for_selected_entries...=Escribiendo_metadatos_XMP_para_las_entradas_seleccionadas... @@ -1371,16 +1366,16 @@ Error_while_fetching_from_%0=Error_al_recuperar_desde_%0 Please_enter_a_valid_number=Por_favor,_introduzca_un_número_válido Show_search_results_in_a_window=Mostrar_los_resultados_de_la_búsqueda_en_una_ventana -Show_global_search_results_in_a_window= -Search_in_all_open_libraries= +Show_global_search_results_in_a_window=Mostrar_resultados_de_búsqueda_global_en_una_ventana +Search_in_all_open_libraries=Buscar_en_todos_los_archivos_abiertos Move_file_to_file_directory?=¿Mover_archivo_a_la_carpeta_de_archivos? You_have_changed_the_menu_and_label_font_size.=Ha_cambiado_el_tamaño_de_tipo_de_letra_para_el_menu_y_etiqueta. -Library_is_protected._Cannot_save_until_external_changes_have_been_reviewed.=La_base_de_datos_está_protegida._No_se_puede_guardar_hasta_que_los_cambios_externos_hayan_sido_revisados. -Protected_library=Base_de_datos_protegida -Refuse_to_save_the_library_before_external_changes_have_been_reviewed.=Rechazar_guadar_la_base_de_datos_antes_qde_que_los_cambios_externos_hayan_sido_revisado. -Library_protection=Proteccion_de_la_base_de_datos -Unable_to_save_library=No_es_posible_guardar_la_base_de_datos +Library_is_protected._Cannot_save_until_external_changes_have_been_reviewed.=La_biblioteca_está_protegida._No_se_puede_guardar_hasta_que_los_cambios_externos_hayan_sido_revisados. +Protected_library=Biblioteca_protegida +Refuse_to_save_the_library_before_external_changes_have_been_reviewed.=Rechazar_guadar_la_biblioteca_antes_qde_que_los_cambios_externos_hayan_sido_revisado. +Library_protection=Proteccion_de_la_biblioteca +Unable_to_save_library=No_es_posible_guardar_la_biblioteca BibTeX_key_generator=Generador_de_claves_BibTeX Unable_to_open_link.=No_es_posible_abrir_el_enlace. @@ -1398,8 +1393,8 @@ The_Guide_to_Computing_Literature=The_Guide_to_Computing_Literature When_opening_file_link,_search_for_matching_file_if_no_link_is_defined=Al_abrir_el_enlace_al_archivo,_buscar_por_archivo_coincidente_si_no_hay_enlace_definido Settings_for_%0=Ajustes_para_%0 -Mark_entries_imported_into_an_existing_library=Marcar_entradas_importadas_en_una_base_de_datos_existente -Unmark_all_entries_before_importing_new_entries_into_an_existing_library=Desmarcar_todas_las_entradas_antes_de_importar_nuevas_entradas_en_una_base_de_datos_existente +Mark_entries_imported_into_an_existing_library=Marcar_entradas_importadas_en_una_biblioteca_existente +Unmark_all_entries_before_importing_new_entries_into_an_existing_library=Desmarcar_todas_las_entradas_antes_de_importar_nuevas_entradas_en_una_biblioteca_existente Forward=Adelante Back=Atrás @@ -1409,7 +1404,7 @@ Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Línea_%0\:_Se_ha_e Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Línea_%0\:_Se_ha_encontrado_clave_BibTeX_corrupta_(falta_coma). Full_text_document_download_failed=Falló_la_descarga_del_texto_completo_del_artículo Update_to_current_column_order=Actualizar_al_orden_de_columnas_actual -Download_from_URL= +Download_from_URL=Descargar_desde_URL Rename_field=Renombrar_campo Set/clear/rename_fields=Establecer/limpiar/renombrar_campos Rename_field_to=Renombrar_campo_a @@ -1422,10 +1417,10 @@ Cannot_use_port_%0_for_remote_operation;_another_application_may_be_using_it._Tr Looking_for_full_text_document...=Buscando_texto_completo_de_documento... Autosave=Autoguardado -A_local_copy_will_be_opened.= -Autosave_local_libraries= -Automatically_save_the_library_to= -Please_enter_a_valid_file_path.= +A_local_copy_will_be_opened.=Se_abrirá_una_copia_local +Autosave_local_libraries=Autoguardado_de_biblitecas_locales +Automatically_save_the_library_to=Guardar_la_biblioteca_automáticamente_en +Please_enter_a_valid_file_path.=Por_favor,_introduzca_una_ruta_de_archivo_válida Export_in_current_table_sort_order=Exportar_con_el_criterio_de_ordenación_actual @@ -1464,7 +1459,7 @@ Optional_fields_2=Campos_opcionales_2 Waiting_for_save_operation_to_finish=Esperando_a_que_acabe_la_operación_de_guardado Resolving_duplicate_BibTeX_keys...=Resolviendo_claves_BibTeX_duplicadas... Finished_resolving_duplicate_BibTeX_keys._%0_entries_modified.=Resolución_de_claves_BibTeX_duplicadas_finalizada._%0_entradas_modificadas. -This_library_contains_one_or_more_duplicated_BibTeX_keys.=Esta_base_de_datos_contiene_una_o_más_claves_BibTeX_duplicadas. +This_library_contains_one_or_more_duplicated_BibTeX_keys.=Esta_biblioteca_contiene_una_o_más_claves_BibTeX_duplicadas. Do_you_want_to_resolve_duplicate_keys_now?=¿Quiere_resolver_las_claves_duplicadas_ahora? Find_and_remove_duplicate_BibTeX_keys=Encontrar_y_eliminar_entradas_BibTeX_duplicadas @@ -1544,7 +1539,7 @@ Connected_to_document=Conectado_al_documento Insert_a_citation_without_text_(the_entry_will_appear_in_the_reference_list)=Insertar_una_cita_sin_texto_(la_entrada_aparecerá_en_la_lista_de_referencias) Cite_selected_entries_with_extra_information=Citar_los_papeles_seleccionados_con_información_extra Ensure_that_the_bibliography_is_up-to-date=Asegurar_que_la_bibliografía_está_actualizada -Your_OpenOffice/LibreOffice_document_references_the_BibTeX_key_'%0',_which_could_not_be_found_in_your_current_library.=Su_documento_OpenOffice/LibreOffice_hace_referencia_a_la_clave_BibTeX_'%0'_que_no_puede_ser_encontrada_en_la_base_de_datos_actual. +Your_OpenOffice/LibreOffice_document_references_the_BibTeX_key_'%0',_which_could_not_be_found_in_your_current_library.=Su_documento_OpenOffice/LibreOffice_hace_referencia_a_la_clave_BibTeX_'%0'_que_no_puede_ser_encontrada_en_la_biblioteca_actual. Unable_to_synchronize_bibliography=No_es_posible_sincronizar_la_bibliografía Combine_pairs_of_citations_that_are_separated_by_spaces_only=Combinar_pares_de_citas_que_están_separadas_únicamente_por_espacios Autodetection_failed=Falló_la_autodetección @@ -1559,7 +1554,7 @@ The_paragraph_format_is_controlled_by_the_property_'ReferenceParagraphFormat'_or The_character_format_is_controlled_by_the_citation_property_'CitationCharacterFormat'_in_the_style_file.=El_formato_de_tipo_de_letra_está_controlado_por_la_propiedad_de_la_cita_'CitationCharacterFormat0_en_el_archivo_de_estilo. Automatically_sync_bibliography_when_inserting_citations=Sincronizar_automáticamente_la_bibliografía_al_insertar_citas Look_up_BibTeX_entries_in_the_active_tab_only=Buscar_entradas_BibTeX_sólo_en_la_pestaña_activa -Look_up_BibTeX_entries_in_all_open_libraries=Buscar_entradas_BibTeX_en_todas_las_bases_de_datos_abiertas +Look_up_BibTeX_entries_in_all_open_libraries=Buscar_entradas_BibTeX_en_todas_las_bibliotecas_abiertas Autodetecting_paths...=Autodetectando_rutas... Could_not_find_OpenOffice/LibreOffice_installation=No_se_encuentra_la_instalación_de_OpenOffice/LibreOffice Found_more_than_one_OpenOffice/LibreOffice_executable.=Se_ha_encontrado_más_de_un_ejecutable_OpenOffice/LibreOffice. @@ -1580,8 +1575,8 @@ OpenOffice/LibreOffice_connection=Conexión_OpenOffice/LibreOffice You_must_select_either_a_valid_style_file,_or_use_one_of_the_default_styles.=Debe_seleccionar_un_archivo_de_estilo_válido_o_usar_uno_de_los_estilos_por_defecto. This_is_a_simple_copy_and_paste_dialog._First_load_or_paste_some_text_into_the_text_input_area.
After_that,_you_can_mark_text_and_assign_it_to_a_BibTeX_field.=Este_es_un_diálogo_de_copia-pega_simple._Primero,_cargue_o_pegue_algo_de_texto_en_el_área_de_entrada_de_texto.
Posteriormente,_puede_marcar_texto_y_asignarlo_a_un_campo_BibTeX. -This_feature_generates_a_new_library_based_on_which_entries_are_needed_in_an_existing_LaTeX_document.=Esta_funcionalidad_genera_una_nueva_base_de_datos_basada_en_las_entradas_que_se_necesitan_en_un_documento_LaTeX_existente. -You_need_to_select_one_of_your_open_libraries_from_which_to_choose_entries,_as_well_as_the_AUX_file_produced_by_LaTeX_when_compiling_your_document.=Necesita_seleccionar_una_de_sus_bases_de_datos_abiertas_desde_la_que_se_escogerán_entradas,_así_como_el_archivo_AUX_generado_por_LaTeX_al_compilar_su_documento. +This_feature_generates_a_new_library_based_on_which_entries_are_needed_in_an_existing_LaTeX_document.=Esta_funcionalidad_genera_una_nueva_biblioteca_basada_en_las_entradas_que_se_necesitan_en_un_documento_LaTeX_existente. +You_need_to_select_one_of_your_open_libraries_from_which_to_choose_entries,_as_well_as_the_AUX_file_produced_by_LaTeX_when_compiling_your_document.=Necesita_seleccionar_una_de_sus_bibliotecas_abiertas_desde_la_que_se_escogerán_entradas,_así_como_el_archivo_AUX_generado_por_LaTeX_al_compilar_su_documento. First_select_entries_to_clean_up.=Seleccione_las_entradas_a_limpiar_en_primer_lugar. Cleanup_entry=Limpiar_entradas @@ -1610,7 +1605,7 @@ One_entry_needed_a_clean_up=Sólo_una_entrada_necesitó_limpieza Remove_selected=Eliminar_seleccionados -Group_tree_could_not_be_parsed._If_you_save_the_BibTeX_library,_all_groups_will_be_lost.=El_arbol_de_grupo_no_puede_ser_examinado._Si_guarda_la_base_de_datos_BibTeX,_todos_los_grupos_se_perderán. +Group_tree_could_not_be_parsed._If_you_save_the_BibTeX_library,_all_groups_will_be_lost.=El_arbol_de_grupo_no_puede_ser_examinado._Si_guarda_la_biblioteca_BibTeX,_todos_los_grupos_se_perderán. Attach_file=Adjuntar_archivo Setting_all_preferences_to_default_values.=Estableciendo_todas_las_preferencias_a_los_valores_por_defecto. Resetting_preference_key_'%0'=Reestableciendo_la_preferencia_con_clave_'%0' @@ -1631,10 +1626,10 @@ Create_directory_based_keywords=Crear_palabras_clave_basadas_en_carpeta Creates_keywords_in_created_entrys_with_directory_pathnames=Crea_palabras_clave_en_entradas_creadas_con_nombres_de_ruta_de_carpeta. Select_a_directory_where_the_search_shall_start.=Seleccione_el_directorio_donde_debería_comenzar_la_búsqueda. Select_file_type\:=Seleccione_el_tipo_de_archivo\: -These_files_are_not_linked_in_the_active_library.=Estos_archivos_no_están_enlazados_en_la__base_de_datos_activa. +These_files_are_not_linked_in_the_active_library.=Estos_archivos_no_están_enlazados_en_la_biblioteca_activa. Entry_type_to_be_created\:=Tipo_de_entrada_a_crear\: Searching_file_system...=Buscando_en_el_sistema_de_archivos... -Importing_into_Library...=Importando_en_base_de_datos... +Importing_into_Library...=Importando_en_biblioteca... Select_directory=Seleccionar_carpeta Select_files=Seleccionar_archivos BibTeX_entry_creation=Creación_de_entrada_BibTeX @@ -1686,7 +1681,7 @@ You_have_changed_settings_for_special_fields.=Ha_cambiado_los_ajustes_para_campo %0_entries_found._To_reduce_server_load,_only_%1_will_be_downloaded.=%0_entradas_encontradas._Para_reducir_la_carga_del_servidor,_sólo_%1_será(n)_descargada(s). A_string_with_that_label_already_exists=Una_cadena_con_esa_etiqueta_ya_existe Connection_to_OpenOffice/LibreOffice_has_been_lost._Please_make_sure_OpenOffice/LibreOffice_is_running,_and_try_to_reconnect.=La_conexión_con_OpenOffice/LibreOffice_se_ha_perdido._Asegúrese_de_que_OpenOffice/LibreOffice_está_ejecutándose_e_intente_reconectar. -JabRef_will_send_at_least_one_request_per_entry_to_a_publisher.= +JabRef_will_send_at_least_one_request_per_entry_to_a_publisher.=JabRed_enviará_al_menos_una_solicitud_por_entrada_al_editor Correct_the_entry,_and_reopen_editor_to_display/edit_source.=Corregir_la_entrada_y_reabrir_el_editor_para_mostrar/editar_fuente. Could_not_connect_to_a_running_gnuserv_process._Make_sure_that_Emacs_or_XEmacs_is_running,
and_that_the_server_has_been_started_(by_running_the_command_'server-start'/'gnuserv-start').=No_se_puede_conectar_con_un_proceso_gnuserv_ejecutándose._Asegúrese_de_que_Emacs_o_XEmacs_está_ejecutándose,
y_que_el_servidor_se_ha_arrancado_(ejecutando_el_comando_'server-start'/'gnuserv-start'). Could_not_connect_to_running_OpenOffice/LibreOffice.=No_se_puede_conectar_a_un_OpenOffice/LibreOffice_en_ejecución. @@ -1710,7 +1705,7 @@ Confirm_selection=Confirmar_selección Add_{}_to_specified_title_words_on_search_to_keep_the_correct_case=Añadir_{}_para_especificar_las_palabras_del_título_para_mantener_mayúsculas/minúsculas_correctamente Import_conversions=Importar_conversiones Please_enter_a_search_string=Introduzca_una_cadena_de_búsqueda,_por_favor -Please_open_or_start_a_new_library_before_searching=Abra_o_cree_una_nueva_base_de_datos_antes_de_buscar,_por_favor +Please_open_or_start_a_new_library_before_searching=Abra_o_cree_una_nueva_biblioteca_antes_de_buscar,_por_favor Canceled_merging_entries=Cancelar_fusionado_de_entradas @@ -1793,8 +1788,8 @@ Unable_to_find_the_requested_look_and_feel_and_thus_the_default_one_is_used.=No_ Opens_JabRef's_GitHub_page=Abrir_la_página_de_JabRef_en_GitHub Could_not_open_browser.=No_se_puede_abrir_el_explorador. -Please_open_%0_manually.= -The_link_has_been_copied_to_the_clipboard.= +Please_open_%0_manually.=Por_favor,_abra_%0_manualmente +The_link_has_been_copied_to_the_clipboard.=El_enlace_se_ha_copiado_al_portapapeles Open_%0_file=Abrir_archivo_%0 @@ -1829,7 +1824,7 @@ Select_export_format=Seleccionar_formato_para_exportar Return_to_JabRef=Volver_a_JabRef Please_move_the_file_manually_and_link_in_place.=Por_favor,_mueva_el_fichero_manualmente_y_enlance_en_el_destino Could_not_connect_to_%0=No_se_puede_conectar_a_%0 -Warning\:_%0_out_of_%1_entries_have_undefined_title.= +Warning\:_%0_out_of_%1_entries_have_undefined_title.=Atención\:_%0_de_%1_entradas_tienen_el_título_sin_definir Warning\:_%0_out_of_%1_entries_have_undefined_BibTeX_key.=Atención:_%0_de_un_total_de_%1_entradas_tienen_clave_BibTex_indefinida. occurrence=incidencia Added_new_'%0'_entry.=Añadida_la_nueva_entrada_'%0' @@ -1846,13 +1841,12 @@ No_problems_found.=No_se_encontraron_problemas. %0_problem(s)_found=%0_problema(s)_encontrado(s) Save_changes=Guardar_cambios Discard_changes=Descartar_cambios -Library_'%0'_has_changed.=La_base_de_datos_'%0'_ha_cambiado. +Library_'%0'_has_changed.=La_biblioteca_'%0'_ha_cambiado. Print_entry_preview=Imprimir_vista_previa_de_la_entrada -Copy_title= +Copy_title=Copiar_título Copy_\\cite{BibTeX_key}=Copiar_\\cite{clave_BibTeX} Copy_BibTeX_key_and_title=Copiar_clave_y_título_BibTeX File_rename_failed_for_%0_entries.=Ha_fallado_el_renombrado_para_%0_entradas. -To_set_up,_go_to=Para_configurar,_vaya_a Merged_BibTeX_source_code=Código_fuente_BibTex_fusionado Invalid_DOI\:_'%0'.=DOI_no_válida\:_'%0'. should_start_with_a_name=debería_comenzar_por_un_nombre @@ -1866,8 +1860,8 @@ Filled=Relleno Field_is_missing=No_se_encuentra_el_campo Search_%0=Buscar_en_%0 -Search_results_in_all_libraries_for_%0=Resultados_para_%0_en_todas_las_bases_de_datos -Search_results_in_library_%0_for_%1=Resultados_para_%1_en_la_base_de_datos_&0 +Search_results_in_all_libraries_for_%0=Resultados_para_%0_en_todas_las_bibliotecas +Search_results_in_library_%0_for_%1=Resultados_para_%1_en_la_biblioteca_&0 Search_globally=Buscar_globalmente. No_results_found.=No_se_encontraron_resultados. Found_%0_results.=Se_encontraron_%0_resultados. @@ -1880,10 +1874,10 @@ This_search_contains_entries_in_which=Esta_búsqueda_contiene_entradas_en_las_cu Unable_to_autodetect_OpenOffice/LibreOffice_installation._Please_choose_the_installation_directory_manually.=No_se_puede_autodetectar_OpenOffice/LibreOffice._Por_favor,_escoja_el_directorio_de_instalación_manualmente. JabRef_no_longer_supports_'ps'_or_'pdf'_fields.
File_links_are_now_stored_in_the_'file'_field_and_files_are_stored_in_an_external_file_directory.
To_make_use_of_this_feature,_JabRef_needs_to_upgrade_file_links.

=Jabref_ya_no_soporta_los_campos_'ps'_o_'pdf'.
Ahora_los_enlaces_a_archivo_se_guardan_en_el_campo_'archivo'_y_los_archivos_se_guardan_en_un_directorio_externo.
Para_hacer_uso_de_esta_característica,_JabRef_necesita_actualizar_los_enlaces.

-This_library_uses_outdated_file_links.=Esta_base_de_datos_usa_enlaces_obsoletos +This_library_uses_outdated_file_links.=Esta_biblioteca_usa_enlaces_obsoletos Clear_search=Limpiar_búsqueda -Close_library=Cerrar_base_de_datos +Close_library=Cerrar_biblioteca Close_entry_editor=Cerrar_editor_de_entradas Decrease_table_font_size=Disminuir_tamaño_de_tipo_de_letra_de_tabla Entry_editor,_next_entry=Editor_de_entradas,_siguiente_entrada @@ -1896,8 +1890,8 @@ Entry_editor,_store_field=Editor_de_entradas,_guardar_campo File_list_editor,_move_entry_down=Editor_de_lista_de_archivos,_mover_entrada_hacia_abajo File_list_editor,_move_entry_up=Editor_de_lista_de_archivos,_mover_entrada_hacia_arriba Focus_entry_table=Enfocar_tabla_de_entradas -Import_into_current_library=Importar_a_la_base_de_datos_actual -Import_into_new_library=Importar_a_una_nueva_base_de_datos +Import_into_current_library=Importar_a_la_biblioteca_actual +Import_into_new_library=Importar_a_una_nueva_biblioteca Increase_table_font_size=Incrementar_tamaño_de_tipo_de_letra_de_tabla New_article=Nuevo_artículo New_book=Nuevo_libro @@ -1927,7 +1921,7 @@ No_meta_data_present_in_BIB_file._Cannot_regenerate_BibTeX_keys=No_hay_metadatos Regenerate_all_keys_for_the_entries_in_a_BibTeX_file=Regenerar_todas_las_claves_para_las_entradas_de_un_archivo_BibTeX Show_debug_level_messages=Mostrar_mensajes_de_nivel_de_depuración Default_bibliography_mode=Modo_de_bibliografía_por_defecto -New_%0_library_created.=Creada_la_nueva_base_de_datos_%0 +New_%0_library_created.=Creada_la_nueva_biblioteca_%0 Show_only_preferences_deviating_from_their_default_value=Mostrar_sólo_preferencias_derivadas_de_su_valor_por_defecto default=defecto key=clave @@ -1945,19 +1939,19 @@ abbreviation_detected=abreviatura_detectada wrong_entry_type_as_proceedings_has_page_numbers=tipo_de_entrada_incorrecto,_ya_que_proceedings_tiene_números_de_página Abbreviate_journal_names=Abreviar_nombres_de_publicación Abbreviating...=Abreviando... -Abbreviation_%s_for_journal_%s_already_defined.= -Abbreviation_cannot_be_empty= -Duplicated_Journal_Abbreviation= -Duplicated_Journal_File= -Error_Occurred= -Journal_file_%s_already_added= -Name_cannot_be_empty= +Abbreviation_%s_for_journal_%s_already_defined.=La_abreviatura_%s_para_la_revista_%s_ya_está_definido +Abbreviation_cannot_be_empty=La_abreviatura_no_puede_estar_vacía +Duplicated_Journal_Abbreviation=Abreviatura_de_revista_duplicada +Duplicated_Journal_File=Fichero_de_revista_duplicado +Error_Occurred=Ha_ocurrido_un_error +Journal_file_%s_already_added=El_fichero_de_revista_%s_ya_está_añadido +Name_cannot_be_empty=El_nombre_no_puede_estar_vacío Adding_fetched_entries=Añadiendo_las_entradas_recuperadas Display_keywords_appearing_in_ALL_entries=Mostrar_palabras_clave_que_aparezcan_en_TODAS_las_entradas Display_keywords_appearing_in_ANY_entry=Mostrar_palabras_clave_que_aparezcan_en_ALGUNA_entrada Fetching_entries_from_Inspire=Recuperando_entradas_desde_Inspire -None_of_the_selected_entries_have_titles.= +None_of_the_selected_entries_have_titles.=Ninguna_de_las_entradas_seleccionadas_tiene_título None_of_the_selected_entries_have_BibTeX_keys.=Ninguna_de_las_entradas_seleccionadas_tiene_clave_BibTeX Unabbreviate_journal_names=Eliminar_abreviatura_de_nombres_de_publicación Unabbreviating...=Eliminando_abreviaturas... @@ -1996,7 +1990,7 @@ Changes_all_letters_to_upper_case.=Cambia_todas_las_letras_a_mayúscula Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_to_lower_case.=Cambia_la_primera_letra_de_todas_las_palabras_a_mayúscula_y_el_resto_a_minúscula Cleans_up_LaTeX_code.=Limpia_el_código_LaTeX Converts_HTML_code_to_LaTeX_code.=Convierte_código_HTML_a_código_LaTeX -Converts_HTML_code_to_Unicode.= +Converts_HTML_code_to_Unicode.=Convierte_HTML_a_Unicode Converts_LaTeX_encoding_to_Unicode_characters.=Convierte_codificación_LaTeX_a_caracteres_Unicode Converts_Unicode_characters_to_LaTeX_encoding.=Conviert_caracteres_Unicode_a_codificación_LaTeX Converts_ordinals_to_LaTeX_superscripts.=Convierte_ordinales_LaTeX_a_superíndices @@ -2039,14 +2033,14 @@ Mixed_names=Nombres_mixtos Neuter_name=Nombre_neutro Neuter_names=Nombres_neutros -Determined_%0_for_%1_entries= -Look_up_%0= -Looking_up_%0..._-_entry_%1_out_of_%2_-_found_%3= +Determined_%0_for_%1_entries=Se_ha_determinado_%0_para_%1_entradas +Look_up_%0=Buscar_%0 +Looking_up_%0..._-_entry_%1_out_of_%2_-_found_%3=Buscando_%0_-_Entrada_%1_de_%2_-_encontrado_%0 Audio_CD=Audio_CD British_patent=Patente_británica British_patent_request=Solicitud_de_patente_británica -Candidate_thesis= +Candidate_thesis=Tesis_de_Candidato Collaborator=Colaborador Column=Columna Compiler=Compilador @@ -2061,7 +2055,7 @@ French_patent_request=Solicitud_de_patente_francesa German_patent=Patente_alemana German_patent_request=Solicitud_de_patente_alemana Line=Línea -Master's_thesis=Tesis de máster +Master's_thesis=Tesis_de_máster Page=Página Paragraph=Párrafo Patent=Patente @@ -2085,10 +2079,10 @@ Show_diff=Mostrar_diff character=carácter word=palabra Show_symmetric_diff=Mostrar_diff_simétrico -Copy_Version= -Developers= -Authors= -License= +Copy_Version=Copiar_versión +Developers=Desarrolladores +Authors=Autores +License=Licencia HTML_encoded_character_found=Se_han_encontrado_caracteres_codificados_HTML booktitle_ends_with_'conference_on'=El_título_del_libro_acaba_con_'conference_on' @@ -2105,8 +2099,8 @@ BibTeX_key=Clave_BibTeX Message=Mensaje -MathSciNet_Review= -Reset_Bindings= +MathSciNet_Review=Revisión_MathSciNet +Reset_Bindings=Reiniciar_combinaciones Decryption_not_supported.=Desencriptación_no_soportada @@ -2130,12 +2124,12 @@ Online_help_forum=Foro_de_ayuda_online Custom=Personalizado Export_cited=Exportar_citados -Unable_to_generate_new_library=No_se_puede_generar_la_nueva_base_de_datos +Unable_to_generate_new_library=No_se_puede_generar_la_nueva_biblioteca Open_console=Abrir_consola Use_default_terminal_emulator=Usar_emulador_de_consola_por_defecto Execute_command=Ejecutar_comando -Note\:_Use_the_placeholder_%0_for_the_location_of_the_opened_library_file.=Nota\:usar_el_marcador_%0_para_la_ubicación_de_la_base_de_datos_abierta +Note\:_Use_the_placeholder_%0_for_the_location_of_the_opened_library_file.=Nota\:usar_el_marcador_%0_para_la_ubicación_de_la_biblioteca_abierta Executing_command_\"%0\"...=Ejecutando_el_comando_\"%0"\... Error_occured_while_executing_the_command_\"%0\".=Error_durante_la_ejecución_del_comando_\"%0"\. Reformat_ISSN=Reformatear_ISSN @@ -2171,36 +2165,36 @@ Entry_from_%0=Entrada_desde_%0 Merge_entry_with_%0_information=Fusionar_entrada_con_informaciçon_%0 Updated_entry_with_info_from_%0=Entrada_actualizada_con_información_del_%0 -Add_existing_file= -Create_new_list= -Remove_list= -Full_journal_name= -Abbreviation_name= +Add_existing_file=Añadir_fichero_existente +Create_new_list=Crear_nueva_lista +Remove_list=Eliminar_lista +Full_journal_name=Nombre_completo_de_revista +Abbreviation_name=Nombre_de_abreviatura -No_abbreviation_files_loaded= +No_abbreviation_files_loaded=No_se_cargaron_ficheros_de_abreviaturas -Loading_built_in_lists= +Loading_built_in_lists=Cargando_listas_preinstaladas -JabRef_built_in_list= -IEEE_built_in_list= +JabRef_built_in_list=Lista_preinstalada_de_JabRef +IEEE_built_in_list=Lista_preinstalada_de_IEEE -Event_log= -We_now_give_you_insight_into_the_inner_workings_of_JabRef\'s_internals._This_information_might_be_helpful_to_diagnose_the_root_cause_of_a_problem._Please_feel_free_to_inform_the_developers_about_an_issue.= -Log_copied_to_clipboard.= -Copy_Log= -Clear_Log= -Report_Issue= -Issue_on_GitHub_successfully_reported.= -Issue_report_successful= -Your_issue_was_reported_in_your_browser.= -The_log_and_exception_information_was_copied_to_your_clipboard.= -Please_paste_this_information_(with_Ctrl+V)_in_the_issue_description.= +Event_log=Registro_de_eventos +We_now_give_you_insight_into_the_inner_workings_of_JabRef\'s_internals._This_information_might_be_helpful_to_diagnose_the_root_cause_of_a_problem._Please_feel_free_to_inform_the_developers_about_an_issue.=Esta_es_una_visión_de_las_interioridades_de_JabRef._Esta_información_puede_ser_útil_para_diagnosticar_la_causa_principal_del_problema._Puede_informar_a_los_desarrolladores_acerca_del_problema_si_lo_desea. +Log_copied_to_clipboard.=Registro_copiado_al_portapapeles +Copy_Log=Copiar_registro +Clear_Log=Limpiar_registro +Report_Issue=Comunicar_problema +Issue_on_GitHub_successfully_reported.=Problema_comunicado_correctamente_en_GitHub +Issue_report_successful=Comunicación_de_problema_satisfactoria +Your_issue_was_reported_in_your_browser.=Su_problema_fue_comunicado_a_través_del_navegador +The_log_and_exception_information_was_copied_to_your_clipboard.=La_información_de_excepción_y_registro_fue_copiada_a_su_portapapeles +Please_paste_this_information_(with_Ctrl+V)_in_the_issue_description.=Por_favor,_pegue_esta_información_(con_Ctrl+V)_en_la_descripción_del_problema. Connection=Conexión Connecting...=Conectando... Host=Host Port=Puerto -Library=Base_de_datos +Library=Biblioteca User=Usuario Connect=Conectar Connection_error=Error_de_conexión @@ -2250,9 +2244,9 @@ There_was_one_file_that_could_not_be_imported.=No_se_pudo_importar_un_archivo. There_were_%0_files_which_could_not_be_imported.=No_se_pudieron_importar_%0_archivos. Migration_help_information=Información_de_ayuda_para_la_migración -Entered_database_has_obsolete_structure_and_is_no_longer_supported.=La_base_de_datos_introducida_tiene_una_estructura_obsoleta_y_no_se_soporta. -However,_a_new_database_was_created_alongside_the_pre-3.6_one.=En_todo_caso,_una_nueva_base_de_datos_ha_sido_creada_junto_a_la_previa_a_la_versión_3.6. -Click_here_to_learn_about_the_migration_of_pre-3.6_databases.=Haga_click_aquí_para_aprender_sobre_la_migración_de_bases_de_datos_de_versiones_previas_a_la_3.6 +Entered_database_has_obsolete_structure_and_is_no_longer_supported.=La_biblioteca_introducida_tiene_una_estructura_obsoleta_y_no_se_soporta. +However,_a_new_database_was_created_alongside_the_pre-3.6_one.=En_todo_caso,_una_nueva_biblioteca_ha_sido_creada_junto_a_la_previa_a_la_versión_3.6. +Click_here_to_learn_about_the_migration_of_pre-3.6_databases.=Haga_click_aquí_para_aprender_sobre_la_migración_de_bibliotecas_de_versiones_previas_a_la_3.6 Opens_JabRef's_Facebook_page=Abrir_Facebook_de_JabRef Opens_JabRef's_blog=Abrir_el_blog_de_JabRef Opens_JabRef's_website=Abrir_el_sitio_web_de_JabRef @@ -2265,21 +2259,21 @@ Look_up_full_text_documents=Buscar_textos_completos You_are_about_to_look_up_full_text_documents_for_%0_entries.=Está_a_punto_de_buscar_textos_completos_para_%0_entradas last_four_nonpunctuation_characters_should_be_numerals=los_últimos_caracteres_de_no-puntuación_deberían_ser_números. -Author= -Date= -File_annotations= -Show_file_annotations= -Adobe_Acrobat_Reader= -Sumatra_Reader= +Author=Autor +Date=Fecha +File_annotations=Anotaciones_de_fichero +Show_file_annotations=Mostrar_anotaciones_de_fichero +Adobe_Acrobat_Reader=Adobe_Acrobat_Reader +Sumatra_Reader=Sumatra_Reader shared=compartido should_contain_an_integer_or_a_literal=debería_contener_un_entero_o_un_literal should_have_the_first_letter_capitalized=debería_tener_la_primera_letra_mayúscula -Tools= -What\'s_new_in_this_version?= -Want_to_help?= -Make_a_donation= -get_involved= -Used_libraries= +Tools=Herramientas +What\'s_new_in_this_version?=¿Qué_hay_de_nuevo_en_esta_versión? +Want_to_help?=¿Desea_ayudar? +Make_a_donation=Haga_una_donación +get_involved=participe +Used_libraries=Librerías_usadas Existing_file=Fichero_existente ID=ID @@ -2306,62 +2300,62 @@ Unable_to_get_PubMed_IDs=No_se_pudieron_obtener_las_ID_PubMed Backup_found=Encontrada_copia_de_seguridad A_backup_file_for_'%0'_was_found.=Una_copia_de_seguridad_para_'%0'_ha_sido_encontrada. This_could_indicate_that_JabRef_did_not_shut_down_cleanly_last_time_the_file_was_used.=Esto_puede_indicar_que_JabRef_no_se_cerró_correctamente_la_última_vez_que_se_usó_ese_archivo. -Do_you_want_to_recover_the_library_from_the_backup_file?=¿Quiere_recuperar_la_base_de_datos_desde_la_copia_de_seguridad? +Do_you_want_to_recover_the_library_from_the_backup_file?=¿Quiere_recuperar_la_biblioteca_desde_la_copia_de_seguridad? Firstname_Lastname=Nombre_Apellido Recommended_for_%0=Recomendado_para_%0 -Show_recommendations= +Show_recommendations=Mostrar_recomendaciones This_might_be_caused_by_reaching_the_traffic_limitation_of_Google_Scholar_(see_'Help'_for_details).=Esto_puede_ser_debido_a_alcanzar_el_límite_de_tráfico_de_GoogleScholar_(vea_la_'Ayuda'_para_más_detalles) -Could_not_open_website.= -Problem_downloading_from_%1= - -File_directory_pattern= -Update_with_bibliographic_information_from_the_web= - -Could_not_find_any_bibliographic_information.= -BibTeX_key_deviates_from_generated_key= -DOI_%0_is_invalid= - -Select_all_customized_types_to_be_stored_in_local_preferences= -Currently_unknown= -Different_customization,_current_settings_will_be_overwritten= - -Entry_type_%0_is_only_defined_for_Biblatex_but_not_for_BibTeX= -Jump_to_entry= - -Copied_%0_citations.= -Copying...= - -journal_not_found_in_abbreviation_list= -Unhandled_exception_occurred.= - -strings_included= -Color_for_disabled_icons= -Color_for_enabled_icons= -Size_of_large_icons= -Size_of_small_icons= -Default_table_font_size= -Escape_underscores= -Color= -Please_also_add_all_steps_to_reproduce_this_issue,_if_possible.= -Fit_width= -Fit_a_single_page= -Zoom_in= -Zoom_out= -Previous_page= -Next_page= -Document_viewer= -Live= -Locked= -Show_document_viewer= -Show_the_document_of_the_currently_selected_entry.= -Show_this_document_until_unlocked.= - - -Sort_all_subgroups_(recursively)= -Collect_and_share_telemetry_data_to_help_improve_JabRef.= -Don't_share= -Share_anonymous_statistics= -Telemetry\:_Help_make_JabRef_better= -To_improve_the_user_experience,_we_would_like_to_collect_anonymous_statistics_on_the_features_you_use._We_will_only_record_what_features_you_access_and_how_often_you_do_it._We_will_neither_collect_any_personal_data_nor_the_content_of_bibliographic_items._If_you_choose_to_allow_data_collection,_you_can_later_disable_it_via_Options_->_Preferences_->_General.= +Could_not_open_website.=No_se_puede_abrir_el_sitio_web +Problem_downloading_from_%1=Problemas_descargando_desde_%1 + +File_directory_pattern=Patrón_de_carpetas +Update_with_bibliographic_information_from_the_web=Actualizar_con_información_bibliográfica_desde_la_web + +Could_not_find_any_bibliographic_information.=No_se_puede_encontrar_información_bibliográfica +BibTeX_key_deviates_from_generated_key=La_clave_BibTeX_difiere_de_la_generada +DOI_%0_is_invalid=El_DOI_%0_no_es_válido + +Select_all_customized_types_to_be_stored_in_local_preferences=Seleccione_todos_los_tipos_personalizados_a_ser_almacenados_en_las_preferencias_locales +Currently_unknown=Actualmente_desconocido +Different_customization,_current_settings_will_be_overwritten=Diferente_personalización,_se_sobreescribirán_los_ajustes_actuales + +Entry_type_%0_is_only_defined_for_Biblatex_but_not_for_BibTeX=El_tipo_de_entrada_%0_está_definido_para_BibLaTeX_pero_no_para_BibTeX +Jump_to_entry=Saltar_a_la_entrada + +Copied_%0_citations.=Se_copiaron_%0_citas +Copying...=Copiando... + +journal_not_found_in_abbreviation_list=No_se_encuentra_la_revista_en_la_lista_de_abreviaturas +Unhandled_exception_occurred.=Ocurrió_una_excepción_no_manejada + +strings_included=cadenas_incluidas +Color_for_disabled_icons=Color_para_iconos_deshabilitados +Color_for_enabled_icons=Color_para_iconos_habilitados +Size_of_large_icons=Tamaño_de_iconos_grandes +Size_of_small_icons=Tamaño_de_iconos_pequeños +Default_table_font_size=Tamaño_de_fuente_por_defecto_para_tabla +Escape_underscores=Escapar_guiones_bajos +Color=Color +Please_also_add_all_steps_to_reproduce_this_issue,_if_possible.=Por_favor,_añada_los_pasos_para_reproducir_el_problema_si_fuera_posible +Fit_width=Ajustar_ancho +Fit_a_single_page=Ajustar_a_una_página +Zoom_in=Aumentar +Zoom_out=Disminuir +Previous_page=Página_anterior +Next_page=Página_siguiente +Document_viewer=Visor_de_Documentos +Live=En_vivo +Locked=Bloqueado +Show_document_viewer=Mostrar_el_visor_de_documentos +Show_the_document_of_the_currently_selected_entry.=Mostrar_el_documento_de_la_entrada_seleccionada +Show_this_document_until_unlocked.=Mostrar_este_documento_hasta_desbloqueo +Set_current_user_name_as_owner.= + +Sort_all_subgroups_(recursively)=Ordenar_todos_los_subgrupos_(recursivamente) +Collect_and_share_telemetry_data_to_help_improve_JabRef.=Recopilar_y_compartir_datos_de_telemetría_para_ayudar_a_la_mejora_de_JabRef +Don't_share=No_compartir +Share_anonymous_statistics=Compartir_estadísticas_anónimas +Telemetry\:_Help_make_JabRef_better=Telemetría:\_Ayude_a_mejorar_JabRef +To_improve_the_user_experience,_we_would_like_to_collect_anonymous_statistics_on_the_features_you_use._We_will_only_record_what_features_you_access_and_how_often_you_do_it._We_will_neither_collect_any_personal_data_nor_the_content_of_bibliographic_items._If_you_choose_to_allow_data_collection,_you_can_later_disable_it_via_Options_->_Preferences_->_General.=Para_mejorar_la_experiencia_de_usuario,_nos_gustaría_recopilar_estadísitcas_anónimas_sobre_las_funcionalidades_de_JabRef_que_usa._Sólo_se_registrará_qué_funcionalidades_emplea_y_con_qué_frecuencia._No_se_recopilará_ningún_dato_personal_ni_el_contenido_de_los_elementos_bibliográficos._Si_decide_permitir_la_recopilación_de_datos,_podrá_deshabilitarlo_posteriormente_en_Opciones_->_Preferencias_->General diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 814a5c82390..8e11a887f24 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -117,8 +117,6 @@ Attach_URL= Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.= -Auto= - Autodetect_format= Autogenerate_BibTeX_keys= @@ -732,8 +730,6 @@ Manage_custom_exports= Manage_custom_imports= Manage_external_file_types= -Manage_journal_abbreviations= - Mark_entries= Mark_entry= @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.= This_operation_requires_one_or_more_entries_to_be_selected.= -Toggle_abbreviation= Toggle_entry_preview= Toggle_groups_interface= Try_different_encoding= @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}= Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to= Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.= should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index de264d67d0a..c7feba1801c 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -117,8 +117,6 @@ Attach_URL=Attacher_l'URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Cela_tente_de_définir_automatiquement_les_liens_fichier_de_vos_entrées.
La_définition_automatique_fonctionne_si_un_fichier_dans_votre_répertoire_fichier
ou_dans_un_sous-répertoire_porte_le_même_nom_que_la_clef_d'une_entrée_BibTeX,
_l'extension_en_plus. -Auto=Auto - Autodetect_format=Détection_automatique_du_format Autogenerate_BibTeX_keys=Création_automatique_des_clefs_BibTeX @@ -732,8 +730,6 @@ Manage_custom_exports=Gérer_les_exportations_personnalisées Manage_custom_imports=Gérer_les_importations_personnalisées Manage_external_file_types=Gérer_les_types_de_fichiers_externes -Manage_journal_abbreviations=Gérer_les_abréviations_de_journaux - Mark_entries=Etiqueter_ces_entrées Mark_entry=Etiqueter_l'entrée @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Cette_ This_operation_requires_one_or_more_entries_to_be_selected.=Cette_opération_nécessite_qu'une_ou_plusieurs_entrées_soient_sélectionnées. -Toggle_abbreviation=Afficher/Masquer_l'abréviation Toggle_entry_preview=Afficher/Masquer_l'aperçu Toggle_groups_interface=Afficher/Masquer_l'interface_des_groupes Try_different_encoding=Essayer_un_encodage_différent @@ -1852,7 +1847,6 @@ Copy_title=Copier_le_titre Copy_\\cite{BibTeX_key}=Copier_\\cite{clé_BibTeX} Copy_BibTeX_key_and_title=Copier_la_clef_BibTeX_et_le_titre File_rename_failed_for_%0_entries.=Le_renommage_des_fichiers_a_échoué_pour_%0_entrées. -To_set_up,_go_to=Pour_configurer,_voir Merged_BibTeX_source_code=Code_source_BibTeX_fusionné Invalid_DOI\:_'%0'.=DOI_invalide_\:_'%0'. should_start_with_a_name=devrait_débuter_par_un_nom @@ -2357,7 +2351,7 @@ Locked=Vérrouillé Show_document_viewer=Ouvre_l'afficheur_de_document Show_the_document_of_the_currently_selected_entry.=Affiche_le_document_de_l'entrée_sélectionnée. Show_this_document_until_unlocked.=Affiche_le_document_jusqu'à_déverrouillage. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Trier_les_sous-groupes_(récursivement) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Collecter_et_partager_les_données_de_télémétrie_pour_contribuer_à_l'amélioration_de_JabRef diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 7a876aad0e1..243c97c2dba 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -117,8 +117,6 @@ Attach_URL=Lampirkan_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Mencoba_atur_otomatis_berkas_tautan_untuk_entri_anda._Pengaturan_otomatis_berfungsi_jika_berkas_di_folder_berkas_atau_subfolder
diberi_nama_sama_dengan_kunci_BibTeX,_tambah_ekstensi. -Auto=Otomatis - Autodetect_format=Deteksi_format_otomatis Autogenerate_BibTeX_keys=Kunci_BibTeX_dibuat_otomatis @@ -732,8 +730,6 @@ Manage_custom_exports=Mengatur_ekspor_atursendiri Manage_custom_imports=Mengatur_impor_atursendiri Manage_external_file_types=Pengaturan_program_eksternal -Manage_journal_abbreviations=Pengaturan_singkatan_jurnal - Mark_entries=Tandai_entri Mark_entry=Tandai_entri @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Operas This_operation_requires_one_or_more_entries_to_be_selected.=Operasi_ini_memerlukan_satu_atau_lebih_entri_yang_dipilih. -Toggle_abbreviation=Gunakan_singkatan Toggle_entry_preview=Gunakan_pratampilan_entri Toggle_groups_interface=Gunakan_antarmuka_grup Try_different_encoding=Coba_enkoding_lain @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Salin_\\cite{kunci_BibTeX} Copy_BibTeX_key_and_title=Salin_kunci_BibTeX_dan_judul File_rename_failed_for_%0_entries.=Perubahan_nama_berkas_gagal_untuk_%0_entri. -To_set_up,_go_to=Untuk_mengatur,_dari Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_salah\:_'%0'. should_start_with_a_name=harus_bermula_dengan_nama @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 2de9f8d33c5..bf45c4ca725 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -117,8 +117,6 @@ Attach_URL=Allega_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Tentativo_di_definire_automaticamente_collegamenti_a_file_per_le_tue_voci._La_definizione_avviene_automaticamente_se_un_file_nella_cartella_file_o_sottocartella
ha_lo_stesso_nome_della_chiave_di_una_voce_BibTeX,_a_meno_dell'estensione. -Auto=Auto - Autodetect_format=Rivelamento_automatico_del_formato Autogenerate_BibTeX_keys=Generazione_automatica_delle_chiavi_BibTeX @@ -732,8 +730,6 @@ Manage_custom_exports=Gestione_delle_esportazioni_personalizzate Manage_custom_imports=Gestione_delle_importazioni_personalizzate Manage_external_file_types=Gestione_dei_tipi_di_file_esterni -Manage_journal_abbreviations=Gestione_delle_abbreviazioni_delle_riviste - Mark_entries=Contrassegna_voci Mark_entry=Contrassegna_voce @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Per_qu This_operation_requires_one_or_more_entries_to_be_selected.=Per_questa_operazione_una_o_più_voci_devono_essere_selezionate -Toggle_abbreviation=Mostra/Nascondi_l'abbreviazione Toggle_entry_preview=Mostra/Nascondi_l'anteprima Toggle_groups_interface=Mostra/Nascondi_l'interfaccia_dei_gruppi Try_different_encoding=Prova_codifiche_differenti @@ -1852,7 +1847,6 @@ Copy_title=Copia_titolo Copy_\\cite{BibTeX_key}=Copia_\\cite{chiave_BibTeX} Copy_BibTeX_key_and_title=Copia_la_chiave_BibTeX_ed_il_titolo File_rename_failed_for_%0_entries.=Rinominazione_dei_file_fallita_per_%0_voci. -To_set_up,_go_to=Per_configurare_vedi Merged_BibTeX_source_code=Codice_sorgente_BibTeX_accorpato Invalid_DOI\:_'%0'.=DOI_non_valido\:_'%0'. should_start_with_a_name=deve_cominciare_con_un_nome @@ -2357,7 +2351,7 @@ Locked=bloccato Show_document_viewer=Mostra_il_visualizzatore_del_documento Show_the_document_of_the_currently_selected_entry.=Mostra_il_documento_della_voce_attualmente_selezionata. Show_this_document_until_unlocked.=Mostra_questo_documento_finché_non_viene_sbloccato. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Ordina_tutti_i_sottogruppi_(ricorsivamente) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Registra_e_condividi_i_dati_di_telemetria_per_aiutare_a_migliorare_JabRef. diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index 3616656d132..f8cd4da1d3b 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -117,8 +117,6 @@ Attach_URL=URLを添付 Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=これは、使用中の項目のファイルリンクを自動設定します。自動設定は、ファイルディレクトリないし下層ディレクトリの
ファイルが、項目のBibTeX鍵と同一名+拡張子として命名されているときのみ、機能します。 -Auto=自動 - Autodetect_format=書式を自動検出 Autogenerate_BibTeX_keys=BibTeX鍵を自動生成 @@ -732,8 +730,6 @@ Manage_custom_exports=ユーザー書出の管理 Manage_custom_imports=ユーザー読込の管理 Manage_external_file_types=外部ファイル型の管理 -Manage_journal_abbreviations=学術誌名短縮形の管理 - Mark_entries=項目を標識 Mark_entry=項目を標識 @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=この This_operation_requires_one_or_more_entries_to_be_selected.=この操作を行うには、1つ以上の項目が選択されている必要があります。 -Toggle_abbreviation=短縮形/非短縮形の切替 Toggle_entry_preview=項目プレビューを入切 Toggle_groups_interface=グループ制御面を入切 Try_different_encoding=別のエンコーディングを試す @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=\\cite{BibTeX鍵}をコピー Copy_BibTeX_key_and_title=BibTeX鍵とタイトルをコピー File_rename_failed_for_%0_entries.=%0項目のファイル名変更が失敗しました。 -To_set_up,_go_to=設定するには、 Merged_BibTeX_source_code=統合後のBibTeXソースコード Invalid_DOI\:_'%0'.=無効なDOIです\:_'%0'. should_start_with_a_name=始まりは名前でなくてはなりません @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index 08a22e88951..13f8e0b2273 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -117,8 +117,6 @@ Attach_URL=URL_bijvoegen Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Poging_om_bestand_snelkoppelingen_voor_jouw_entries_automatisch_in_te_stellen._Automatisch_instellen_werkt_als_een_bestand_in_jouw_bestand_map_of_een_submap
een_identieke_naam_heeft_als_een_BibTeX-sleutel_van_een_entry,_plus_extensie. -Auto=Auto - Autodetect_format=Formaat_automatisch_detecteren Autogenerate_BibTeX_keys=BibTeX-sleutels_automatisch_genereren @@ -732,8 +730,6 @@ Manage_custom_exports=Beheer_externe_exportfilters Manage_custom_imports=Beheer_externe_importfilters Manage_external_file_types= -Manage_journal_abbreviations=Beheer_tijdschrift_afkortingen - Mark_entries=Markeer_entries Mark_entry=Markeer_entry @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Deze_o This_operation_requires_one_or_more_entries_to_be_selected.=Deze_operatie_vereist_dat_een_of_meer_entries_geselecteerd_zijn. -Toggle_abbreviation=Toon_afkorting Toggle_entry_preview=Toon_entry_voorbeeld Toggle_groups_interface=Toon_groepenvenster Try_different_encoding=Probeer_een_andere_encodering @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopieer_\\cite{BibTeX-sleutel} Copy_BibTeX_key_and_title=Kopieer_BibTeX_sleutel_en_titel File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Om_in_te_stellen,_ga_naar Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ongeldig_DOI\:_'%0'. should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index bd1304bcc4d..3a306127dc2 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -117,8 +117,6 @@ Attach_URL=Tilordne_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Pr\u00f8v_\u00e5_sette_fil-linker_automatisk_for_dine_enheter._Dette_virker_dersom_en_fil_i_fil-katalogen_din_eller_en_underkatalog
har_navn_likt_en_enhets_BibTeX-n\u00f8kkel,_pluss_etternavn. -Auto=Auto - Autodetect_format=Autodetekter_format Autogenerate_BibTeX_keys=Autogenerer_BibTeX-n\u00f8kler @@ -732,8 +730,6 @@ Manage_custom_exports=Sett_opp_eksterne_eksportfiltre Manage_custom_imports=Sett_opp_eksterne_importfiltre Manage_external_file_types=Sett_opp_eksterne_filtyper -Manage_journal_abbreviations=Sett_opp_journalforkortelser - Mark_entries=Merk_enheter Mark_entry=Merk_enhet @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denne_ This_operation_requires_one_or_more_entries_to_be_selected.=Denne_operasjonen_krever_at_en_eller_flere_enheter_er_valgt. -Toggle_abbreviation=Forkort/ekspander Toggle_entry_preview=Vis/skjul_forh\u00e5ndsvisning Toggle_groups_interface=Vis/skjul_grupperingskontroll Try_different_encoding=Pr\u00f8v_en_annen_tegnkoding @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopier_\\cite{BibTeX-n\u00f8kkel} Copy_BibTeX_key_and_title=Kopier_BibTeX-n\u00f8kkel_og_tittel File_rename_failed_for_%0_entries.= -To_set_up,_go_to=For_\u00e5_sette_opp,_g\u00e5_til Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ugyldig_DOI\:_'%0'. should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index cba314df7f1..ee61cacbcb4 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -117,8 +117,6 @@ Attach_URL=Anexar_a_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Tentativa_de_definir_automaticamente_links_de_arquivos_para_suas_referências._A_definição_automática_funciona_se_um_arquivo_em_seu_diretório_arquivo_ou_um_subdiretório
tem_o_mesmo_nome_de_uma_chave_BibTeX_de_uma_referência,_mais_sua_extensão. -Auto=Auto - Autodetect_format=Detecção_automática_de_formato Autogenerate_BibTeX_keys=Geração_automática_de_chaves_BibTeX @@ -732,8 +730,6 @@ Manage_custom_exports=Gerenciar_exportações_personalizadas Manage_custom_imports=Gerenciar_importações_personalizadas Manage_external_file_types=Gerenciar_tipos_de_arquivo_externos -Manage_journal_abbreviations=Gerenciar_abreviações_de_periódicos - Mark_entries=Marcar_referências Mark_entry=Marcar_referências @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Esta_o This_operation_requires_one_or_more_entries_to_be_selected.=Esta_operação_exige_que_uma_ou_mais_referências_sejam_selecionadas -Toggle_abbreviation=Habilitar/Desabilitar_abreviação Toggle_entry_preview=Habilitar/Desabilitar_previsualização_da_referência Toggle_groups_interface=Habilitar/Desabilitar_interface_de_grupos Try_different_encoding=Tente_uma_codificação_diferente @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Copiar_como_\\cite{chave_BibTeX} Copy_BibTeX_key_and_title=Copiar_chave_BibTeX_e_título File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Para_configurar,_acesse_o_menu Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_inválida\:_'%0'. should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index a656aee692c..fc215ce6f8b 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -117,8 +117,6 @@ Attach_URL=Добавить_URL-адрес Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Попытка_автоопределения_ссылок_файл_для_записей._Автоопределение_возможно_если_файл_находящийся_в_каталоге_файлов_файл_или_его_подкаталоге
имеет_имя,_идентичное_имени_ключа_BibTeX_для_записи,_с_соответствующим_разрешением. -Auto=Авто - Autodetect_format=Автоопределение_формата Autogenerate_BibTeX_keys=Автосоздание_ключей_BibTeX @@ -732,8 +730,6 @@ Manage_custom_exports=Управление_пользовательским_эк Manage_custom_imports=Управление_пользовательским_импортом Manage_external_file_types=Управление_внешними_типами_файлов -Manage_journal_abbreviations=Управление_сокращениями_для_журналов - Mark_entries=Метки_записей Mark_entry=Метка_записи @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Для This_operation_requires_one_or_more_entries_to_be_selected.=Для_этой_операции_необходимо_выбрать_одну_или_несколько_записей. -Toggle_abbreviation=Показать/скрыть_сокращения Toggle_entry_preview=Показать/скрыть_просмотр_записи Toggle_groups_interface=Показать/скрыть_интерфейс_групп Try_different_encoding=Используйте_другую_кодировку @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Копировать_\\цитировать{ключ_BibTeX} Copy_BibTeX_key_and_title=Копировать_ключ_и_заголовок_BibTeX File_rename_failed_for_%0_entries.=Ошибка_переименования_файла_для_%0_записи. -To_set_up,_go_to=Для_настройки_перейдите\: Merged_BibTeX_source_code=Объединенный_исходный_код_BibTeX Invalid_DOI\:_'%0'.=Недопустимый_DOI-адрес\:_'%0'. should_start_with_a_name=должно_начинаться_с_имени @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index f5524ab121a..a25c1558934 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -117,8 +117,6 @@ Attach_URL=Lägg_till_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.= -Auto=Automatiskt - Autodetect_format=Bestäm_format_automatiskt Autogenerate_BibTeX_keys=Generera_BibTeX-nycklar_automatiskt @@ -732,8 +730,6 @@ Manage_custom_exports=Hantera_egna_exporterare Manage_custom_imports=Hantera_egna_importerare Manage_external_file_types=Hantera_externa_filetyper -Manage_journal_abbreviations=Hantera_tidskriftsförkortningar - Mark_entries=Markera_poster Mark_entry=Markera_post @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denna_ This_operation_requires_one_or_more_entries_to_be_selected.=Den_här_operationen_kräver_att_en_eller_flera_poster_är_valda. -Toggle_abbreviation=Växla_förkortning Toggle_entry_preview=Växla_postvisning Toggle_groups_interface=Växla_grupphantering Try_different_encoding=Prova_en_annan_teckenkodning @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopiera_\\cite{BibTeX-nyckel} Copy_BibTeX_key_and_title=Kopiera_BibTeX-nyckel_och_titel File_rename_failed_for_%0_entries.=Döpa_om_filen_misslyckades_för_%0_poster. -To_set_up,_go_to=För_att_ställa_in,_gå_till Merged_BibTeX_source_code=Kombinerad_BibTeX-källkod Invalid_DOI\:_'%0'.=Ogiltig_DOI\:_'%0'. should_start_with_a_name=ska_börja_med_ett_namn @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index 42ea786a800..76331dcd6fd 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -117,8 +117,6 @@ Attach_URL=URL_ekle Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Girdileriniz_için_dosya_link_otokurma_girişiminde_bulunuluyor._Otokur,_eğer_dosya_dizinindeki_ya_da_bir_
_altdizinindeki_dosyası_bir_BibTeX_anahtarıyla_özdeş_adlandırılmış_artı_uzantılandılılmışsa_çalışır. -Auto=Oto - Autodetect_format=Biçemi_otomatik_tanı Autogenerate_BibTeX_keys=BibTeX_anahtarlarını_otomatik_oluştur @@ -732,8 +730,6 @@ Manage_custom_exports=Özel_dışa_aktarımları_yönet Manage_custom_imports=Özel_içe_aktarımları_yönet Manage_external_file_types=Harici_dosya_türlerini_yönet -Manage_journal_abbreviations=Degi_kısaltmalarını_yönet - Mark_entries=Girdileri_işaretle Mark_entry=Girdiyi_işaretle @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Bu_iş This_operation_requires_one_or_more_entries_to_be_selected.=Bu_işlem,_bir_ya_da_daha_çok_girdinin_seçili_olmasını_gerektirir. -Toggle_abbreviation=Kısaltmayı_aç/kapat Toggle_entry_preview=Girdi_önizlemeyi_aç/kapat Toggle_groups_interface=Grup_arayüzünü_aç/kapat Try_different_encoding=Başka_kodlama_deneyin @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=\\cite{BibTeX_anahtarı}'nı_kopyala Copy_BibTeX_key_and_title=BibTeX_anahtarı_ve_başlığını_kopyala File_rename_failed_for_%0_entries.=%0_girdide_dosya_yeniden_adlandırma_başarısız. -To_set_up,_go_to=Kurmak_için,_şuraya_git Merged_BibTeX_source_code=Birleşik_BibTeX_kaynak_kodu Invalid_DOI\:_'%0'.=Geçersiz_DOI\:_'%0'. should_start_with_a_name=bir_isimle_başlamalı @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index d6242c98d32..750378c4674 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -117,8 +117,6 @@ Attach_URL=Gắn_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Cố_gắng_thiết_lập_tự_động_tập_tin_liên_kết_vào_các_mục._Thiết_lập_tự_động_chạy_được_nếu_một_tập_tin_ở_trong_thư_mục_hoặc_thư_mục_con_tập_tin_của_bạn
được_đặt_tên_giống_hệt_một_khóa_BibTeX_của_mục,_cộng_với_phần_mở_rộng. -Auto=Tự_động - Autodetect_format=Tự_động_phát_hiện_định_dạng Autogenerate_BibTeX_keys=Tự_động_tạo_các_khóa_BibTeX @@ -732,8 +730,6 @@ Manage_custom_exports=Quản_lý_các_phép_xuất_tùy_chọn Manage_custom_imports=Quản_lý_các_phép_nhập_tùy_chọn Manage_external_file_types=Quản_lý_các_kiểu_tập_tin_ngoài -Manage_journal_abbreviations=Quản_lý_các_viết_tắt_tên_tạp_chí - Mark_entries=Đánh_dấu_các_mục Mark_entry=Đánh_dấu_mục @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Lệnh This_operation_requires_one_or_more_entries_to_be_selected.=Lệnh_này_yêu_cầu_phải_chọn_trước_một_hoặc_nhiều_mục. -Toggle_abbreviation=Bật/tắt_viết_tắt Toggle_entry_preview=Bật/tắt_xem_trước_mục Toggle_groups_interface=Bật/tắt_giao_diện_nhóm Try_different_encoding=Thử_mã_hóa_khác @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Chép\\trích_dẫn{khóa_BibTeX} Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Để_cài_đặt,_chọn Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_không_hợp_lệ\:_'%0'. should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 9e5a315fb8e..6b3e141e750 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -117,8 +117,6 @@ Attach_URL=附加_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=尝试为您的记录自动设置_文件_链接,该操作要求和记录_BibTeX_键同名的_文件存在于您的_文件_目录或者子目录中。 -Auto=自动 - Autodetect_format=自动检测格式 Autogenerate_BibTeX_keys=自动生成_BibTeX_键 @@ -732,8 +730,6 @@ Manage_custom_exports=管理自定义导出器 Manage_custom_imports=管理自定义导入器 Manage_external_file_types=管理外部文件类型 -Manage_journal_abbreviations=管理期刊名称缩写 - Mark_entries=高亮标记多条记录 Mark_entry=高亮标记该记录 @@ -1252,7 +1248,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=此操 This_operation_requires_one_or_more_entries_to_be_selected.=这个操作要求选中一条或多条记录。 -Toggle_abbreviation=打开/关闭名称缩写 Toggle_entry_preview=打开/关闭记录预览 Toggle_groups_interface=打开/关闭组界面 Try_different_encoding=尝试其它编码 @@ -1852,7 +1847,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=复制_\\cite{BibTeX_键值} Copy_BibTeX_key_and_title=复制_BibTeX_键值和标题 File_rename_failed_for_%0_entries.= -To_set_up,_go_to=要设置的话,请到 Merged_BibTeX_source_code=已合并_BibTeX_源代码 Invalid_DOI\:_'%0'.=不合法的_DOI\: should_start_with_a_name= @@ -2357,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/Menu_es.properties b/src/main/resources/l10n/Menu_es.properties index 32dd529c97f..9dfc17687fc 100644 --- a/src/main/resources/l10n/Menu_es.properties +++ b/src/main/resources/l10n/Menu_es.properties @@ -5,16 +5,16 @@ Abbreviate_journal_names_(ISO)=Abreviar_nombres_de_revistas_(ISO) Abbreviate_journal_names_(MEDLINE)=Abreviar_nombres_de_revista_(MEDLINE) About_JabRef=&Acerca_de_JabRef -Append_library=&A\u00f1adir_base_de_datos +Append_library=&A\u00f1adir_biblioteca Autogenerate_BibTeX_keys=&Autogenerar_claves_de_BibTeX -Close_library=&Cerrar_base_de_datos +Close_library=&Cerrar_biblioteca Copy=C&opiar -Copy_title= +Copy_title=Copiar_título Copy_\\cite{BibTeX_key}=Copiar_\\c&ite{clave_BibTeX} Copy_BibTeX_key=Copiar_clave_&BibTeX Customize_entry_types=&Personalizar_tipos_de_entrada Cut=&Cortar -Library_properties=&Propiedades_de_la_base_de_datos +Library_properties=&Propiedades_de_la_biblioteca Edit=&Editar # Bibtex Edit_entry=&Editar_registro @@ -29,7 +29,7 @@ Find_duplicates=&Buscar_duplicados Help=&Ayuda # Help -Online_help= +Online_help=Ayuda_online Donate_to_JabRef=Donar_a_JabRef Manage_content_selectors=Administrar_selectores_de_&contenido Manage_custom_exports=Administrar_&exportaciones_personalizadas @@ -37,17 +37,17 @@ Manage_custom_imports=Administrar_&importaciones_personalizadas Manage_journal_abbreviations=Administrar_abreviaturas_de_publicaciones Mark_entries=&Marcar_registros # File menu -New_%0_library=Nueva_base_de_datos_%0 +New_%0_library=Nueva_biblioteca_%0 # Menu BibTeX (BibTeX) New_entry=Nu&evo_registro New_entry_by_type...=&Nuevo_registro... New_entry_from_plain_text=Nue&vo_registro_desde_texto_sin_formato -New_sublibrary_based_on_AUX_file=Nueva_sub-base_de_datos_a_partir_de_archivo_AU&X +New_sublibrary_based_on_AUX_file=Nueva_sub-biblioteca_a_partir_de_archivo_AU&X # View Next_tab=Pestaña_&siguiente -Open_library=&Abrir_base_de_datos +Open_library=&Abrir_biblioteca Open_URL_or_DOI=Abrir_&URL_o_DOI -Connect_to_shared_database= +Connect_to_shared_database=Conectar_a_biblioteca_compartida Open_terminal_here=Abrir_terminal_aquí Options=&Opciones Paste=&Pegar @@ -55,20 +55,20 @@ Paste=&Pegar Preferences=&Preferencias Previous_tab=&Pestaña_anterior Quit=&Salir -Recent_libraries=Bases_de_datos_&recientes +Recent_libraries=bibliotecas_&recientes Redo=&Rehacer Replace_string=&Reemplazar_cadena -Save_library=&Guardar_base_de_datos -Save_library_as...=Gu&ardar_base_de_datos_como... +Save_library=&Guardar_biblioteca +Save_library_as...=Gu&ardar_biblioteca_como... Save_selected_as...=Guardar_se&leccionados_como... # Tools Search=&Buscar Select_all=Seleccionar_&todos Set_up_general_fields=Establecer_&campos_generales -View_event_log= +View_event_log=Ver_visor_de_eventos Sort_tabs=&Ordenar_pestañas -Next_preview_layout= -Previous_preview_layout= +Next_preview_layout=Plantilla_de_previsualización_siguiente +Previous_preview_layout=Plantilla_de_previsualización_previa # Export menu Toggle_entry_preview=A&ctivar/Desactivar_previsualización_de_registro Toggle_groups_interface=Activar/Desactivar_ventana_de_&grupos @@ -80,12 +80,12 @@ Mark_specific_color=Color_espec\u00edfico_de_la_marca Unmark_all=Anular_selección_de_todos_los_registros Unmark_entries=Anular_selecció&n__de_registros View=&Ver -Import_into_new_library=Importar_a_una_nueva_base_de_datos -Import_into_current_library=Importar_a_la_base_de_datos_actual +Import_into_new_library=Importar_a_una_nueva_biblioteca +Import_into_current_library=Importar_a_la_biblioteca_actual Switch_to_%0_mode=Cambiar_a_modo_%0 Push_entries_to_external_application_(%0)=Agregar_registros_a_aplicación_externa_(%0) -Pull_changes_from_shared_database= +Pull_changes_from_shared_database=Recuperar_cambios_desde_biblioteca_compartida Write_XMP-metadata_to_PDFs=Escribir_metadatos_XMP_a_PDF Export_selected_entries=Exportar_registros_seleccionados @@ -103,8 +103,8 @@ Decrease_table_font_size=&Disminuir_tama\u00f1o_de_fuente_en_tabla Forward=Avanzar Back=Retroceder -Look_up_document_identifier...= -Look_up_full_text_documents= +Look_up_document_identifier...=Bloquear_identificador_de_documento +Look_up_full_text_documents=Bloquear_documentos_con_texto_completo Set/clear/rename_fields=Establecer/limpiar/renombrar_campos Resolve_duplicate_BibTeX_keys=Resolver_claves_BibTeX_duplicadas @@ -135,6 +135,6 @@ View_change_log=Ver_registro_de_cambios Copy_BibTeX_key_and_link=Copiar_clave_BibTeX_y_enlace Copy_DOI_url=Copiar_la_url_del_DOI -Copy_citation= -Default_table_font_size= -Show_document_viewer= +Copy_citation=Copiar_cita +Default_table_font_size=Tamaño_de_fuente_por_defecto_para_tabla +Show_document_viewer=Mostrar_visor_de_documentos diff --git a/src/test/java/org/jabref/ArchitectureTests.java b/src/test/java/org/jabref/MainArchitectureTests.java similarity index 94% rename from src/test/java/org/jabref/ArchitectureTests.java rename to src/test/java/org/jabref/MainArchitectureTests.java index 0430481b600..ea72ed250ab 100644 --- a/src/test/java/org/jabref/ArchitectureTests.java +++ b/src/test/java/org/jabref/MainArchitectureTests.java @@ -20,17 +20,15 @@ import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -public class ArchitectureTests { +public class MainArchitectureTests { + public static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals"; private static final String PACKAGE_JAVAX_SWING = "javax.swing"; private static final String PACKAGE_JAVA_AWT = "java.awt"; private static final String PACKAGE_JAVA_FX = "javafx"; - private static final String PACKAGE_ORG_JABREF_GUI = "org.jabref.gui"; private static final String PACKAGE_ORG_JABREF_LOGIC = "org.jabref.logic"; private static final String PACKAGE_ORG_JABREF_MODEL = "org.jabref.model"; - private static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals"; - private static final String EXCEPTION_PACKAGE_JAVA_AWT_GEOM = "java.awt.geom"; private static final String EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS = "javafx.collections"; private static final String EXCEPTION_PACKAGE_JAVA_FX_BEANS = "javafx.beans"; @@ -40,7 +38,7 @@ public class ArchitectureTests { private final String secondPackage; private Map> exceptions; - public ArchitectureTests(String firstPackage, String secondPackage) { + public MainArchitectureTests(String firstPackage, String secondPackage) { this.firstPackage = firstPackage; this.secondPackage = secondPackage; @@ -60,8 +58,7 @@ public ArchitectureTests(String firstPackage, String secondPackage) { modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS); modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_BEANS); - exceptions.put(PACKAGE_ORG_JABREF_LOGIC, - logicExceptions); + exceptions.put(PACKAGE_ORG_JABREF_LOGIC, logicExceptions); exceptions.put(PACKAGE_ORG_JABREF_MODEL, modelExceptions); } diff --git a/src/test/java/org/jabref/TestArchitectureTests.java b/src/test/java/org/jabref/TestArchitectureTests.java new file mode 100644 index 00000000000..955d731f8c8 --- /dev/null +++ b/src/test/java/org/jabref/TestArchitectureTests.java @@ -0,0 +1,76 @@ +package org.jabref; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.jabref.MainArchitectureTests.CLASS_ORG_JABREF_GLOBALS; + +@RunWith(Parameterized.class) +public class TestArchitectureTests { + + private static final String CLASS_ORG_JABREF_PREFERENCES = "org.jabref.preferences.JabRefPreferences"; + private static final String CLASS_ORG_JABREF_PREFERENCES_TEST = "JabRefPreferencesTest"; + + private final String forbiddenPackage; + + private List exceptions; + + public TestArchitectureTests(String forbiddenPackage) { + this.forbiddenPackage = forbiddenPackage; + + // Add exceptions for the architectural test here + // Note that bending the architectural constraints should not be done inconsiderately + exceptions = new ArrayList<>(); + exceptions.add(CLASS_ORG_JABREF_PREFERENCES_TEST); + } + + @Parameterized.Parameters(name = "tests independent of {0}?") + public static Iterable data() { + return Arrays.asList( + new Object[][]{ + {CLASS_ORG_JABREF_PREFERENCES}, + {CLASS_ORG_JABREF_GLOBALS} + } + ); + } + + @Test + public void testsAreIndependent() throws IOException { + Predicate isForbiddenPackage = (s) -> s.startsWith("import " + forbiddenPackage); + Predicate isExceptionClass = (s) -> exceptions.stream().anyMatch(exception -> s.startsWith("public class " + exception)); + + List files = Files.walk(Paths.get("src/test/")) + .filter(p -> p.toString().endsWith(".java")) + .filter(p -> { + try { + return Files.readAllLines(p, StandardCharsets.UTF_8).stream().noneMatch(isExceptionClass); + } catch (IOException e) { + return false; + } + }) + .filter(p -> { + try { + return Files.readAllLines(p, StandardCharsets.UTF_8).stream().anyMatch(isForbiddenPackage); + } catch (IOException e) { + return false; + } + }).collect(Collectors.toList()); + + Assert.assertEquals("The following classes are not allowed to depend on " + forbiddenPackage, + Collections.emptyList(), files); + } +} diff --git a/src/test/java/org/jabref/cli/AuxCommandLineTest.java b/src/test/java/org/jabref/cli/AuxCommandLineTest.java index 524d55dd489..a2f81aa0392 100644 --- a/src/test/java/org/jabref/cli/AuxCommandLineTest.java +++ b/src/test/java/org/jabref/cli/AuxCommandLineTest.java @@ -8,23 +8,34 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Paths; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; public class AuxCommandLineTest { + private ImportFormatPreferences importFormatPreferences; + + @Before + public void setUp() throws Exception { + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + } + @Test public void test() throws URISyntaxException, IOException { InputStream originalStream = AuxCommandLineTest.class.getResourceAsStream("origin.bib"); File auxFile = Paths.get(AuxCommandLineTest.class.getResource("paper.aux").toURI()).toFile(); try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(originalReader); + ParserResult result = new BibtexParser(importFormatPreferences).parse(originalReader); AuxCommandLine auxCommandLine = new AuxCommandLine(auxFile.getAbsolutePath(), result.getDatabase()); BibDatabase newDB = auxCommandLine.perform(); diff --git a/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java b/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java index 133052f1d9e..d6415ab89cb 100644 --- a/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java +++ b/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java @@ -9,13 +9,12 @@ import java.util.ArrayList; import java.util.List; -import org.jabref.Globals; import org.jabref.logic.importer.ImportDataTest; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.GUITests; import org.junit.Assert; @@ -24,13 +23,15 @@ import org.junit.Test; import org.junit.experimental.categories.Category; +import static org.mockito.Mockito.mock; + @Category(GUITests.class) public class EntryFromFileCreatorManagerTest { // Needed to initialize ExternalFileTypes @Before public void setUp() { - Globals.prefs = JabRefPreferences.getInstance(); + } @Test @@ -49,7 +50,7 @@ public void testGetCreator() { public void testAddEntrysFromFiles() throws FileNotFoundException, IOException { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { - ParserResult result = new BibtexParser(Globals.prefs.getImportFormatPreferences()).parse(reader); + ParserResult result = new BibtexParser(mock(ImportFormatPreferences.class)).parse(reader); BibDatabase database = result.getDatabase(); List files = new ArrayList<>(); diff --git a/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java b/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java index e477f64709c..6bfda070754 100644 --- a/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java +++ b/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java @@ -3,12 +3,10 @@ import java.io.File; import java.util.Optional; -import org.jabref.Globals; import org.jabref.JabRefGUI; import org.jabref.gui.JabRefFrame; import org.jabref.logic.importer.ImportDataTest; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.GUITests; import org.junit.Assert; @@ -27,7 +25,6 @@ public class EntryFromPDFCreatorTest { @Before public void setUp() { - Globals.prefs = JabRefPreferences.getInstance(); // Needed to initialize ExternalFileTypes entryCreator = new EntryFromPDFCreator(); // Needed for PdfImporter - still not enough diff --git a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java index 3cf9176f4ba..9716581818a 100644 --- a/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java +++ b/src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java @@ -20,7 +20,8 @@ import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.Abbreviation; import org.jabref.logic.journals.JournalAbbreviationLoader; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.logic.journals.JournalAbbreviationPreferences; +import org.jabref.preferences.PreferencesService; import org.assertj.core.util.Files; import org.junit.Assert; @@ -39,28 +40,29 @@ public class ManageJournalAbbreviationsViewModelTest { - private ManageJournalAbbreviationsViewModel viewModel; - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - @ClassRule public static CatchExceptionsFromThread catchExceptions = new CatchExceptionsFromThread(); - + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + private ManageJournalAbbreviationsViewModel viewModel; private Path emptyTestFile; private Path testFile1Entries; private Path testFile3Entries; private Path testFile4Entries; private Path testFile5EntriesWithDuplicate; - private JabRefPreferences preferences; + private JournalAbbreviationPreferences abbreviationPreferences; private DialogService dialogService; @Before public void setUpViewModel() throws Exception { - preferences = mock(JabRefPreferences.class); + abbreviationPreferences = mock(JournalAbbreviationPreferences.class); + PreferencesService preferences = mock(PreferencesService.class); + when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences); + dialogService = mock(DialogService.class); TaskExecutor taskExecutor = new CurrentThreadTaskExecutor(); - viewModel = new ManageJournalAbbreviationsViewModel(preferences, dialogService, taskExecutor); + JournalAbbreviationLoader journalAbbreviationLoader = mock(JournalAbbreviationLoader.class); + viewModel = new ManageJournalAbbreviationsViewModel(preferences, dialogService, taskExecutor, journalAbbreviationLoader); emptyTestFile = createTemporaryTestFile("emptyTestFile.txt", ""); testFile1Entries = createTemporaryTestFile("testFile1Entries.txt", "Test Entry = TE" + NEWLINE + ""); testFile3Entries = createTemporaryTestFile("testFile3Entries.txt", @@ -203,7 +205,7 @@ public void testMixedFileUsage() throws Exception { @Test public void testBuiltInListsIncludeAllBuiltInAbbreviations() { - when(preferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV)).thenReturn(false); + when(abbreviationPreferences.useIEEEAbbreviations()).thenReturn(false); viewModel.addBuiltInLists(); Assert.assertEquals(2, viewModel.journalFilesProperty().getSize()); viewModel.currentFileProperty().set(viewModel.journalFilesProperty().get(0)); @@ -218,7 +220,7 @@ public void testBuiltInListsIncludeAllBuiltInAbbreviations() { @Test public void testBuiltInListsStandardIEEEIncludesAllBuiltIEEEAbbreviations() throws Exception { - when(preferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV)).thenReturn(true); + when(abbreviationPreferences.useIEEEAbbreviations()).thenReturn(true); viewModel.addBuiltInLists(); viewModel.selectLastJournalFile(); Assert.assertEquals(2, viewModel.journalFilesProperty().getSize()); @@ -440,7 +442,7 @@ public void testSaveExternalFilesListToPreferences() throws Exception { addFourTestFileToViewModelAndPreferences(); List expected = Stream.of(testFile1Entries, testFile3Entries, testFile4Entries, testFile5EntriesWithDuplicate) .map(Path::toString).collect(Collectors.toList()); - verify(preferences).putStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, expected); + verify(abbreviationPreferences).setExternalJournalLists(expected); } private Path createTemporaryTestFile(String name, String content) throws Exception { @@ -468,7 +470,7 @@ private void addFourTestFileToViewModelAndPreferences() throws Exception { viewModel.addNewFile(); when(dialogService.showFileSaveDialog(any())).thenReturn(Optional.of(testFile5EntriesWithDuplicate)); viewModel.addNewFile(); - viewModel.saveExternalFilesList(); + viewModel.saveEverythingAndUpdateAutoCompleter(); } /** diff --git a/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java b/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java index b599ee9f759..b5a1bb7bae0 100644 --- a/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java +++ b/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java @@ -5,7 +5,7 @@ import javafx.scene.input.KeyEvent; import org.jabref.gui.DialogService; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.preferences.PreferencesService; import org.junit.Before; import org.junit.Ignore; @@ -23,18 +23,14 @@ public class KeyBindingsDialogViewModelTest { private KeyBindingsDialogViewModel model; - private KeyBindingPreferences keyBindingsPreferences; private KeyBindingRepository keyBindingRepository ; private DialogService dialogService; - @Before public void setUp() { - JabRefPreferences mockedPreferences = mock(JabRefPreferences.class); - keyBindingsPreferences = new KeyBindingPreferences(mockedPreferences); - keyBindingRepository = new KeyBindingRepository(keyBindingsPreferences.getKeyBindings()); + keyBindingRepository = new KeyBindingRepository(); dialogService = mock(DialogService.class); - model = new KeyBindingsDialogViewModel(keyBindingsPreferences, dialogService); + model = new KeyBindingsDialogViewModel(keyBindingRepository, dialogService, mock(PreferencesService.class)); } @Test @@ -42,12 +38,12 @@ public void testInvalidKeyBindingIsNotSaved() { setKeyBindingViewModel(KeyBinding.COPY); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "Q", "Q", KeyCode.Q, false, false, false, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); KeyCombination combination = KeyCombination.keyCombination(keyBindingRepository.get(KeyBinding.COPY).get()); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(combination, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent)); model.saveKeyBindings(); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent)); } @Test @@ -56,18 +52,18 @@ public void testSpecialKeysValidKeyBindingIsSaved() { setKeyBindingViewModel(KeyBinding.IMPORT_INTO_NEW_DATABASE); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "F1", "F1", KeyCode.F1, false, false, false, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.IMPORT_INTO_NEW_DATABASE, + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.IMPORT_INTO_NEW_DATABASE, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); KeyCombination combination = KeyCombination .keyCombination(keyBindingRepository.get(KeyBinding.IMPORT_INTO_NEW_DATABASE).get()); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(combination, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent)); model.saveKeyBindings(); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.IMPORT_INTO_NEW_DATABASE, + assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.IMPORT_INTO_NEW_DATABASE, shortcutKeyEvent)); } @@ -76,7 +72,7 @@ public void testKeyBindingCategory() { KeyBindingViewModel bindViewModel = new KeyBindingViewModel(keyBindingRepository, KeyBindingCategory.FILE); model.selectedKeyBindingProperty().set(bindViewModel); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "M", "M", KeyCode.M, true, true, true, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); assertNull(model.selectedKeyBindingProperty().get().getKeyBinding()); } @@ -86,26 +82,26 @@ public void testKeyBindingCategory() { public void testRandomNewKeyKeyBindingInRepository() { setKeyBindingViewModel(KeyBinding.CLEANUP); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "K", "K", KeyCode.K, true, true, true, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); KeyCombination combination = KeyCombination.keyCombination(keyBindingRepository.get(KeyBinding.CLEANUP).get()); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(combination, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent)); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); } @Test public void testSaveNewKeyBindingsToPreferences() { setKeyBindingViewModel(KeyBinding.ABBREVIATE); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "J", "J", KeyCode.J, true, true, true, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); model.saveKeyBindings(); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); } @Test @@ -114,12 +110,12 @@ public void testSaveNewSpecialKeysKeyBindingsToPreferences() { KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "F1", "F1", KeyCode.F1, true, false, false, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.UNMARK_ENTRIES, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.UNMARK_ENTRIES, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); model.saveKeyBindings(); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.UNMARK_ENTRIES, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.UNMARK_ENTRIES, shortcutKeyEvent)); } @Test @@ -128,17 +124,17 @@ public void testSetAllKeyBindingsToDefault() { setKeyBindingViewModel(KeyBinding.ABBREVIATE); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "C", "C", KeyCode.C, true, true, true, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); model.saveKeyBindings(); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); keyBindingRepository.resetToDefault(); model.saveKeyBindings(); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); } @Test @@ -148,17 +144,17 @@ public void testSetSingleKeyBindingToDefault() { model.selectedKeyBindingProperty().set(viewModel); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "C", "C", KeyCode.C, true, true, true, false); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); model.saveKeyBindings(); - assertTrue(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertTrue(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); viewModel.resetToDefault(); model.saveKeyBindings(); - assertFalse(keyBindingsPreferences.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); + assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); } private KeyBindingViewModel setKeyBindingViewModel(KeyBinding binding) { diff --git a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java index 797e859d5c8..82549d7c678 100644 --- a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java @@ -13,22 +13,23 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; -import org.jabref.preferences.JabRefPreferences; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class AuxParserTest { private ImportFormatPreferences importFormatPreferences; @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @After diff --git a/src/test/java/org/jabref/logic/bibtex/BibEntryAssert.java b/src/test/java/org/jabref/logic/bibtex/BibEntryAssert.java index 549bef8fabc..957d951392e 100644 --- a/src/test/java/org/jabref/logic/bibtex/BibEntryAssert.java +++ b/src/test/java/org/jabref/logic/bibtex/BibEntryAssert.java @@ -12,13 +12,16 @@ import java.util.Collections; import java.util.List; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Importer; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; public class BibEntryAssert { @@ -61,7 +64,7 @@ public static void assertEquals(Class clazz, String resourceName, List getListFromInputStream(InputStream is) throws IOException { ParserResult result; try (Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { - BibtexParser parser = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()); + BibtexParser parser = new BibtexParser(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); result = parser.parse(reader); } Assert.assertNotNull(result); diff --git a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java index 8e8902aa4e6..017522753fa 100644 --- a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java +++ b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java @@ -12,13 +12,14 @@ import org.jabref.logic.util.OS; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class BibEntryWriterTest { @@ -27,9 +28,9 @@ public class BibEntryWriterTest { @Before public void setUpWriter() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); - writer = new BibEntryWriter( - new LatexFieldFormatter(JabRefPreferences.getInstance().getLatexFieldFormatterPreferences()), true); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + LatexFieldFormatterPreferences latexFieldFormatterPreferences = mock(LatexFieldFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); + writer = new BibEntryWriter(new LatexFieldFormatter(latexFieldFormatterPreferences), true); } @Test diff --git a/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java b/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java index be5be454be9..c9c6c7ce63f 100644 --- a/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java +++ b/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java @@ -3,12 +3,13 @@ import java.util.Collections; import org.jabref.logic.util.OS; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class LatexFieldFormatterTests { @@ -16,7 +17,7 @@ public class LatexFieldFormatterTests { @Before public void setUp() { - this.formatter = new LatexFieldFormatter(JabRefPreferences.getInstance().getLatexFieldFormatterPreferences()); + this.formatter = new LatexFieldFormatter(mock(LatexFieldFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java index 8b7da969d6a..623374e3201 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java @@ -7,13 +7,14 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.mock; public class BibtexKeyPatternUtilTest { @@ -43,7 +44,7 @@ public class BibtexKeyPatternUtilTest { @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test diff --git a/src/test/java/org/jabref/logic/bst/TestVM.java b/src/test/java/org/jabref/logic/bst/TestVM.java index 58ad4ca4890..9f48c9d46b6 100644 --- a/src/test/java/org/jabref/logic/bst/TestVM.java +++ b/src/test/java/org/jabref/logic/bst/TestVM.java @@ -10,14 +10,17 @@ import org.jabref.logic.bst.VM.BstEntry; import org.jabref.logic.bst.VM.StackFunction; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.antlr.runtime.RecognitionException; import org.junit.Assert; import org.junit.Test; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; public class TestVM { @@ -640,7 +643,7 @@ public void testVMSwap() throws RecognitionException { } private static BibEntry bibtexString2BibtexEntry(String s) throws IOException { - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(new StringReader(s)); + ParserResult result = new BibtexParser(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)).parse(new StringReader(s)); Collection c = result.getDatabase().getEntries(); Assert.assertEquals(1, c.size()); return c.iterator().next(); diff --git a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java index aa3d6408122..c81b39cbdb1 100644 --- a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java +++ b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java @@ -15,7 +15,7 @@ import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import org.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; -import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.protectedterms.ProtectedTermsPreferences; import org.jabref.model.Defaults; @@ -29,7 +29,6 @@ import org.jabref.model.entry.LinkedFile; import org.jabref.model.metadata.FileDirectoryPreferences; import org.jabref.model.metadata.MetaData; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; @@ -61,12 +60,10 @@ public void setUp() throws IOException { FileDirectoryPreferences fileDirPrefs = mock(FileDirectoryPreferences.class); when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(true); //Biblocation as Primary overwrites all other dirs - JabRefPreferences prefs = JabRefPreferences.getInstance(); - worker = new CleanupWorker(context, - new CleanupPreferences(JabRefPreferences.getInstance().get(JabRefPreferences.IMPORT_FILENAMEPATTERN), + new CleanupPreferences("\\bibtexkey", "", //empty fileDirPattern for backwards compatibility - prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)), + mock(LayoutFormatterPreferences.class), fileDirPrefs)); } diff --git a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java index 31a3d41f867..3b698f85a11 100644 --- a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.Optional; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.model.Defaults; import org.jabref.model.database.BibDatabase; @@ -15,12 +14,12 @@ import org.jabref.model.entry.LinkedFile; import org.jabref.model.metadata.FileDirectoryPreferences; import org.jabref.model.metadata.MetaData; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -32,13 +31,12 @@ public class RenamePdfCleanupTest { public TemporaryFolder testFolder = new TemporaryFolder(); private BibDatabaseContext context; private BibEntry entry; - private JabRefPreferences prefs; private FileDirectoryPreferences fileDirPrefs; + private LayoutFormatterPreferences layoutFormatterPreferences; @Before public void setUp() throws Exception { - prefs = JabRefPreferences.getInstance(); MetaData metaData = new MetaData(); context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults()); context.setDatabaseFile(testFolder.newFile("test.bib")); @@ -48,6 +46,7 @@ public void setUp() throws Exception { entry = new BibEntry(); entry.setCiteKey("Toot"); + layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); } /** @@ -113,7 +112,7 @@ public void cleanupRenamePdfRenamesFileInSameFolder() throws IOException { entry.setField("title", "test title"); RenamePdfCleanup cleanup = new RenamePdfCleanup(false, context, fileNamePattern, - prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)), + layoutFormatterPreferences, fileDirPrefs); cleanup.cleanup(entry); @@ -129,7 +128,7 @@ public void cleanupSingleField() throws IOException { entry.setField("file", FileFieldWriter.getStringRepresentation(fileField)); entry.setField("title", "test title"); RenamePdfCleanup cleanup = new RenamePdfCleanup(false, context, fileNamePattern, - prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)), + layoutFormatterPreferences, fileDirPrefs, fileField); cleanup.cleanup(entry); @@ -145,7 +144,7 @@ public void cleanupGetTargetFilename() throws IOException { testFolder.newFile("Toot.pdf"); LinkedFile fileField = new LinkedFile("", "Toot.pdf", "PDF"); RenamePdfCleanup cleanup = new RenamePdfCleanup(false, context, fileNamePattern, - prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)), + layoutFormatterPreferences, fileDirPrefs); entry.setField("file", FileFieldWriter.getStringRepresentation(fileField)); entry.setField("title", "test title"); diff --git a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java b/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java index 97bae559290..1c0fc05a526 100644 --- a/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java @@ -13,10 +13,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; @@ -27,12 +27,15 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; import org.xmlunit.diff.DefaultNodeMatcher; import org.xmlunit.diff.ElementSelectors; import org.xmlunit.matchers.CompareMatcher; +import static org.mockito.Mockito.mock; + @RunWith(Parameterized.class) public class BibTeXMLExporterTestFiles { @@ -64,7 +67,7 @@ public void setUp() throws Exception { charset = StandardCharsets.UTF_8; bibtexmlExportFormat = new BibTeXMLExportFormat(); tempFile = testFolder.newFile(); - testImporter = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + testImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java index 468ef220f22..140474f094e 100644 --- a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java +++ b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java @@ -19,6 +19,7 @@ import org.jabref.model.EntryTypes; import org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern; import org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern; +import org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern; import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabase; @@ -34,13 +35,14 @@ import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.metadata.MetaData; import org.jabref.model.metadata.SaveOrderConfig; -import org.jabref.preferences.JabRefPreferences; import com.google.common.base.Charsets; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class BibtexDatabaseWriterTest { @@ -49,19 +51,16 @@ public class BibtexDatabaseWriterTest { private MetaData metaData; private BibDatabaseContext bibtexContext; private ImportFormatPreferences importFormatPreferences; - private JabRefPreferences prefs; @Before public void setUp() { - prefs = JabRefPreferences.getInstance(); - // Write to a string instead of to a file databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new); database = new BibDatabase(); metaData = new MetaData(); bibtexContext = new BibDatabaseContext(database, metaData, new Defaults(BibDatabaseMode.BIBTEX)); - importFormatPreferences = prefs.getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test(expected = NullPointerException.class) @@ -160,7 +159,7 @@ public void writeEpilogueAndEncoding() throws Exception { @Test public void writeMetadata() throws Exception { - DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(prefs.getKeyPattern()); + DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class)); bibtexKeyPattern.setDefaultValue("test"); metaData.setCiteKeyPattern(bibtexKeyPattern); @@ -173,7 +172,7 @@ public void writeMetadata() throws Exception { @Test public void writeMetadataAndEncoding() throws Exception { SavePreferences preferences = new SavePreferences().withEncoding(Charsets.US_ASCII); - DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(prefs.getKeyPattern()); + DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class)); bibtexKeyPattern.setDefaultValue("test"); metaData.setCiteKeyPattern(bibtexKeyPattern); @@ -441,7 +440,7 @@ public void writeSaveOrderConfig() throws Exception { @Test public void writeCustomKeyPattern() throws Exception { - AbstractBibtexKeyPattern pattern = new DatabaseBibtexKeyPattern(prefs.getKeyPattern()); + AbstractBibtexKeyPattern pattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class)); pattern.setDefaultValue("test"); pattern.addBibtexKeyPattern("article", "articleTest"); metaData.setCiteKeyPattern(pattern); diff --git a/src/test/java/org/jabref/logic/exporter/ExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/ExportFormatTest.java index 90d61f3e07c..c44af983fb9 100644 --- a/src/test/java/org/jabref/logic/exporter/ExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/ExportFormatTest.java @@ -6,14 +6,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import com.google.common.base.Charsets; import org.junit.Before; @@ -24,6 +23,7 @@ import org.junit.runners.Parameterized; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; @RunWith(Parameterized.class) public class ExportFormatTest { @@ -75,14 +75,10 @@ public void testExportingNullEntriesThrowsNPE() throws Exception { @Parameterized.Parameters(name = "{index}: {1}") public static Collection exportFormats() { Collection result = new ArrayList<>(); - JabRefPreferences prefs = JabRefPreferences.getInstance(); - JournalAbbreviationLoader journalAbbreviationLoader = new JournalAbbreviationLoader(); - - Map customFormats = prefs.customExports.getCustomExportFormats(prefs, - journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = prefs - .getLayoutFormatterPreferences(journalAbbreviationLoader); - SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs); + + Map customFormats = new HashMap<>(); + LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class); + SavePreferences savePreferences = mock(SavePreferences.class); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); for (IExportFormat format : ExportFormats.getExportFormats().values()) { diff --git a/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java index f9e1cb1fbce..1901812a1fa 100644 --- a/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/HtmlExportFormatTest.java @@ -4,14 +4,13 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import com.google.common.base.Charsets; import org.junit.After; @@ -19,8 +18,10 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class HtmlExportFormatTest { private IExportFormat exportFormat; @@ -33,12 +34,9 @@ public class HtmlExportFormatTest { @Before public void setUp() { - JabRefPreferences prefs = JabRefPreferences.getInstance(); - JournalAbbreviationLoader journalAbbreviationLoader = new JournalAbbreviationLoader(); - Map customFormats = prefs.customExports.getCustomExportFormats(prefs, - journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = prefs.getLayoutFormatterPreferences(journalAbbreviationLoader); - SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs); + Map customFormats = new HashMap<>(); + LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); + SavePreferences savePreferences = mock(SavePreferences.class); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); exportFormat = ExportFormats.getExportFormat("html"); diff --git a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java index 1e7e2a22ea5..b49ba27c409 100644 --- a/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/MSBibExportFormatTestFiles.java @@ -13,10 +13,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Rule; @@ -26,6 +26,7 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; import org.xmlunit.diff.DefaultNodeMatcher; @@ -33,6 +34,7 @@ import org.xmlunit.matchers.CompareMatcher; import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; @RunWith(Parameterized.class) public class MSBibExportFormatTestFiles { @@ -66,7 +68,7 @@ public void setUp() throws Exception { charset = StandardCharsets.UTF_8; msBibExportFormat = new MSBibExportFormat(); tempFile = testFolder.newFile(); - testImporter = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + testImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java index 3386e1c99b5..112e7354915 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java @@ -9,16 +9,19 @@ import java.util.Collections; import java.util.List; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; public class ModsExportFormatTest { @@ -39,15 +42,14 @@ public void setUp() throws Exception { databaseContext = new BibDatabaseContext(); charset = StandardCharsets.UTF_8; modsExportFormat = new ModsExportFormat(); - bibtexImporter = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + bibtexImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); tempFile = testFolder.newFile(); importFile = Paths.get(ModsExportFormatTest.class.getResource("ModsExportFormatTestAllFields.bib").toURI()); } @Test(expected = SaveException.class) public final void testPerformExportTrowsSaveException() throws Exception { - List entries = bibtexImporter.importDatabase(importFile, charset).getDatabase() - .getEntries(); + List entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries(); modsExportFormat.performExport(databaseContext, "", charset, entries); } diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java index febd1a74460..bd774557ea9 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java @@ -12,11 +12,11 @@ import java.util.stream.Stream; import org.jabref.logic.bibtex.BibEntryAssert; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.logic.importer.fileformat.ModsImporter; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; @@ -27,12 +27,15 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.mockito.Answers; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; import org.xmlunit.diff.DefaultNodeMatcher; import org.xmlunit.diff.ElementSelectors; import org.xmlunit.matchers.CompareMatcher; +import static org.mockito.Mockito.mock; + @RunWith(Parameterized.class) public class ModsExportFormatTestFiles { @@ -68,7 +71,7 @@ public void setUp() throws Exception { charset = StandardCharsets.UTF_8; modsExportFormat = new ModsExportFormat(); tempFile = testFolder.newFile(); - bibtexImporter = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + bibtexImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); modsImporter = new ModsImporter(); } diff --git a/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java b/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java index d254d3991b1..a72d250cb60 100644 --- a/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java +++ b/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java @@ -7,12 +7,13 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class BibDatabaseTestsWithFiles { @@ -20,7 +21,7 @@ public class BibDatabaseTestsWithFiles { @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test diff --git a/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java b/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java index 44ba9f9d533..adc7349521a 100644 --- a/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java +++ b/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java @@ -8,11 +8,13 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; /** * @author Nosh&Dan @@ -31,7 +33,7 @@ public class DatabaseFileLookupTest { public void setUp() throws Exception { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(reader); + ParserResult result = new BibtexParser(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)).parse(reader); database = result.getDatabase(); entries = database.getEntries(); diff --git a/src/test/java/org/jabref/logic/importer/ImportFormatReaderIntegrationTest.java b/src/test/java/org/jabref/logic/importer/ImportFormatReaderIntegrationTest.java index 5a5fc48675b..fc979f008f7 100644 --- a/src/test/java/org/jabref/logic/importer/ImportFormatReaderIntegrationTest.java +++ b/src/test/java/org/jabref/logic/importer/ImportFormatReaderIntegrationTest.java @@ -1,19 +1,23 @@ package org.jabref.logic.importer; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.logic.xmp.XMPPreferences; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; @RunWith(Parameterized.class) public class ImportFormatReaderIntegrationTest { @@ -35,8 +39,9 @@ public ImportFormatReaderIntegrationTest(String resource, String format, int cou @Before public void setUp() { reader = new ImportFormatReader(); - reader.resetImportFormats(JabRefPreferences.getInstance().getImportFormatPreferences(), - JabRefPreferences.getInstance().getXMPPreferences()); + ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8); + reader.resetImportFormats(importFormatPreferences, mock(XMPPreferences.class)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java b/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java index 7aa4026cb1d..479cef9eb0f 100644 --- a/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java +++ b/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java @@ -1,14 +1,18 @@ package org.jabref.logic.importer; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.logic.xmp.XMPPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class ImportFormatReaderTestParameterless { @@ -17,8 +21,9 @@ public class ImportFormatReaderTestParameterless { @Before public void setUp() { reader = new ImportFormatReader(); - reader.resetImportFormats(JabRefPreferences.getInstance().getImportFormatPreferences(), - JabRefPreferences.getInstance().getXMPPreferences()); + ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8); + reader.resetImportFormats(importFormatPreferences, mock(XMPPreferences.class)); } @Test(expected = ImportException.class) diff --git a/src/test/java/org/jabref/logic/importer/ImporterTest.java b/src/test/java/org/jabref/logic/importer/ImporterTest.java index 2e9e9e2e4ac..aed59c010e8 100644 --- a/src/test/java/org/jabref/logic/importer/ImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/ImporterTest.java @@ -24,7 +24,6 @@ import org.jabref.logic.importer.fileformat.RisImporter; import org.jabref.logic.importer.fileformat.SilverPlatterImporter; import org.jabref.logic.xmp.XMPPreferences; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Test; @@ -34,6 +33,7 @@ import org.junit.runners.Parameterized.Parameters; import org.mockito.Mockito; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith(Parameterized.class) @@ -75,7 +75,7 @@ public void getIdDoesNotContainWhitespace() { @Test public void getIdStripsSpecialCharactersAndConvertsToLowercase() { - Importer importer = Mockito.mock(Importer.class, Mockito.CALLS_REAL_METHODS); + Importer importer = mock(Importer.class, Mockito.CALLS_REAL_METHODS); when(importer.getName()).thenReturn("*Test-Importer"); Assert.assertEquals("testimporter", importer.getId()); } @@ -90,8 +90,8 @@ public static Collection instancesToTest() { // all classes implementing {@link Importer} // sorted alphabetically - ImportFormatPreferences importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); - XMPPreferences xmpPreferences = JabRefPreferences.getInstance().getXMPPreferences(); + ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class); + XMPPreferences xmpPreferences = mock(XMPPreferences.class); // @formatter:off return Arrays.asList( new Object[]{new BiblioscapeImporter()}, diff --git a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java index 614669c68bf..e4d3d2701b7 100644 --- a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java +++ b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java @@ -11,11 +11,14 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class OpenDatabaseTest { @@ -40,7 +43,8 @@ public OpenDatabaseTest() throws URISyntaxException { @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8); } @Test diff --git a/src/test/java/org/jabref/logic/importer/ParsedBibEntryTests.java b/src/test/java/org/jabref/logic/importer/ParsedBibEntryTests.java index 30fb678620a..79c80fec9ee 100644 --- a/src/test/java/org/jabref/logic/importer/ParsedBibEntryTests.java +++ b/src/test/java/org/jabref/logic/importer/ParsedBibEntryTests.java @@ -3,11 +3,13 @@ import java.util.Optional; import org.jabref.logic.importer.fileformat.BibtexParser; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; public class ParsedBibEntryTests { @@ -17,7 +19,7 @@ public class ParsedBibEntryTests { @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java b/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java index fc85d11080d..dac41c42c83 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java @@ -72,7 +72,7 @@ public void setUp() throws Exception { famaeyMcGaughEntry.setField("journal", "Living Reviews in Relativity"); famaeyMcGaughEntry.setField("year", "2012"); famaeyMcGaughEntry.setField("volume", "15"); - famaeyMcGaughEntry.setField("month", "#dec#"); + famaeyMcGaughEntry.setField("month", "#sep#"); famaeyMcGaughEntry.setField("archiveprefix", "arXiv"); famaeyMcGaughEntry.setField("doi", "10.12942/lrr-2012-10"); famaeyMcGaughEntry.setField("eid", "10"); @@ -142,7 +142,7 @@ public void testGetName() { @Test public void searchByQueryFindsEntry() throws Exception { - List fetchedEntries = fetcher.performSearch("Diez slice theorem"); + List fetchedEntries = fetcher.performSearch("Diez slice theorem Lie"); assertEquals(Collections.singletonList(diezSliceTheoremEntry), fetchedEntries); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java b/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java index 67c6d25b573..ef075780195 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java @@ -3,17 +3,19 @@ import java.util.Optional; import org.jabref.logic.help.HelpFile; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class DiVATest { @@ -22,7 +24,7 @@ public class DiVATest { @Before public void setUp() { - fetcher = new DiVA(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new DiVA(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java index 3bf222b3ee1..5c6efa24e76 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java @@ -3,17 +3,19 @@ import java.util.Optional; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class DoiFetcherTest { @@ -23,7 +25,7 @@ public class DoiFetcherTest { @Before public void setUp() { - fetcher = new DoiFetcher(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new DoiFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); bibEntryBurd2011 = new BibEntry(); bibEntryBurd2011.setType(BiblatexEntryTypes.BOOK); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java index 3774a88e985..8f77ecd98c9 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java @@ -3,17 +3,19 @@ import java.util.Optional; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class IsbnFetcherTest { @@ -23,7 +25,7 @@ public class IsbnFetcherTest { @Before public void setUp() { - fetcher = new IsbnFetcher(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new IsbnFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); bibEntry = new BibEntry(); bibEntry.setType(BiblatexEntryTypes.BOOK); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java index 4ee3b955b34..f1dd10f016c 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java @@ -3,17 +3,19 @@ import java.util.Optional; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class IsbnViaChimboriFetcherTest extends AbstractIsbnFetcherTest { @@ -31,7 +33,7 @@ public void setUp() { bibEntry.setField("url", "https://www.amazon.com/Effective-Java-Joshua-Bloch-ebook/dp/B00B8V09HY?SubscriptionId=0JYN1NVW651KCA56C102&tag=techkie-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00B8V09HY"); - fetcher = new IsbnViaChimboriFetcher(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new IsbnViaChimboriFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcherTest.java index 593c414cdac..5cc1606de18 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcherTest.java @@ -3,16 +3,18 @@ import java.util.Optional; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class IsbnViaEbookDeFetcherTest extends AbstractIsbnFetcherTest { @@ -32,7 +34,7 @@ public void setUp() { bibEntry.setField("pagetotal", "384"); bibEntry.setField("url", "http://www.ebook.de/de/product/6441328/joshua_bloch_effective_java.html"); - fetcher = new IsbnViaEbookDeFetcher(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new IsbnViaEbookDeFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java index 23441555d00..ad5ebf1538a 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java @@ -3,16 +3,18 @@ import java.util.Optional; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import org.jabref.testutils.category.FetcherTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; @Category(FetcherTests.class) public class TitleFetcherTest { @@ -22,7 +24,7 @@ public class TitleFetcherTest { @Before public void setUp() { - fetcher = new TitleFetcher(JabRefPreferences.getInstance().getImportFormatPreferences()); + fetcher = new TitleFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); bibEntryBischof2009 = new BibEntry(); bibEntryBischof2009.setType(BiblatexEntryTypes.INPROCEEDINGS); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java index 673448a743c..58df1830dcc 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java @@ -8,15 +8,17 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.util.FileExtensions; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; /** * This class tests the BibtexImporter. @@ -33,7 +35,7 @@ public class BibtexImporterTest { @Before public void setUp() { - importer = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + importer = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java index 89013c0ed58..d2124b9473f 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -35,15 +35,17 @@ import org.jabref.model.groups.RegexKeywordGroup; import org.jabref.model.groups.WordKeywordGroup; import org.jabref.model.metadata.SaveOrderConfig; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Test the BibtexParser @@ -56,7 +58,8 @@ public class BibtexParserTest { @Before public void setUp() { - importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + when(importFormatPreferences.getKeywordSeparator()).thenReturn(','); parser = new BibtexParser(importFormatPreferences); } @@ -1159,9 +1162,11 @@ public void parseConvertsMultipleTabsToSpace() throws IOException { * @author Andrei Haralevich */ @Test - public void parsePreservesMultipleSpacesInFileField() throws IOException { + public void parsePreservesMultipleSpacesInNonWrappableField() throws IOException { + when(importFormatPreferences.getFieldContentParserPreferences().getNonWrappableFields()) + .thenReturn(Collections.singletonList("file")); ParserResult result = parser - .parse(new StringReader("@article{canh05,file = {ups sala}}")); + .parse(new StringReader("@article{canh05,file = {ups sala}}"), importFormatPreferences); Collection c = result.getDatabase().getEntries(); BibEntry e = c.iterator().next(); @@ -1413,7 +1418,7 @@ public void integrationTestCustomKeyPattern() throws IOException { .parse(new StringReader("@comment{jabref-meta: keypattern_article:articleTest;}" + OS.NEWLINE + "@comment{jabref-meta: keypatterndefault:test;}"), importFormatPreferences); - GlobalBibtexKeyPattern pattern = JabRefPreferences.getInstance().getKeyPattern(); + GlobalBibtexKeyPattern pattern = mock(GlobalBibtexKeyPattern.class); AbstractBibtexKeyPattern bibtexKeyPattern = result.getMetaData().getCiteKeyPattern(pattern); AbstractBibtexKeyPattern expectedPattern = new DatabaseBibtexKeyPattern(pattern); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/EndnoteImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/EndnoteImporterTest.java index c2204447f1e..233c5d9a6b5 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/EndnoteImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/EndnoteImporterTest.java @@ -12,16 +12,18 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.util.FileExtensions; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class EndnoteImporterTest { @@ -30,7 +32,7 @@ public class EndnoteImporterTest { @Before public void setUp() { - importer = new EndnoteImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + importer = new EndnoteImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/FreeCiteImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/FreeCiteImporterTest.java index 23534d1488e..7af17740dda 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/FreeCiteImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/FreeCiteImporterTest.java @@ -6,14 +6,15 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.util.FileExtensions; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class FreeCiteImporterTest { @@ -22,7 +23,7 @@ public class FreeCiteImporterTest { @Before public void setUp() { - importer = new FreeCiteImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + importer = new FreeCiteImporter(mock(ImportFormatPreferences.class)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java index a32138acce2..792ea6c75bb 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java @@ -7,14 +7,15 @@ import java.util.Collections; import java.util.List; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.util.FileExtensions; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class PdfContentImporterTest { @@ -23,7 +24,7 @@ public class PdfContentImporterTest { @Before public void setUp() { - importer = new PdfContentImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + importer = new PdfContentImporter(mock(ImportFormatPreferences.class)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java index a8aa7bffee4..c23e067503a 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java @@ -10,8 +10,8 @@ import java.util.List; import org.jabref.logic.bibtex.BibEntryAssert; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,6 +19,8 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import static org.mockito.Mockito.mock; + @RunWith(Parameterized.class) public class PdfContentImporterTestFiles { @@ -43,8 +45,7 @@ public static Collection fileNames() { public void correctContent() throws IOException, URISyntaxException { String pdfFileName = fileName + ".pdf"; String bibFileName = fileName + ".bib"; - PdfContentImporter importer = new PdfContentImporter( - JabRefPreferences.getInstance().getImportFormatPreferences()); + PdfContentImporter importer = new PdfContentImporter(mock(ImportFormatPreferences.class)); Path pdfFile = Paths.get(PdfContentImporter.class.getResource(pdfFileName).toURI()); List result = importer.importDatabase(pdfFile, StandardCharsets.UTF_8).getDatabase().getEntries(); BibEntryAssert.assertEquals(PdfContentImporterTest.class, bibFileName, result); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java index 32242c61d5c..b4cf96accd2 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java @@ -11,8 +11,8 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.util.FileExtensions; +import org.jabref.logic.xmp.XMPPreferences; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; @@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class PdfXmpImporterTest { @@ -29,7 +30,7 @@ public class PdfXmpImporterTest { @Before public void setUp() { - importer = new PdfXmpImporter(JabRefPreferences.getInstance().getXMPPreferences()); + importer = new PdfXmpImporter(mock(XMPPreferences.class)); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/RepecNepImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/RepecNepImporterTest.java index 691d93cf256..03084a88464 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/RepecNepImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/RepecNepImporterTest.java @@ -10,14 +10,17 @@ import java.util.List; import org.jabref.logic.bibtex.BibEntryAssert; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.util.FileExtensions; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class RepecNepImporterTest { private RepecNepImporter testImporter; @@ -25,7 +28,9 @@ public class RepecNepImporterTest { @Before public void setUp() { - testImporter = new RepecNepImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); + ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class); + when(importFormatPreferences.getKeywordSeparator()).thenReturn(','); + testImporter = new RepecNepImporter(importFormatPreferences); } @Test @@ -52,8 +57,7 @@ public final void testIsNotRecognizedFormat() throws IOException, URISyntaxExcep public final void testImportEntries1() throws IOException, URISyntaxException { Path file = Paths.get(RepecNepImporter.class.getResource("RepecNepImporterTest1.txt").toURI()); try (InputStream bibIn = RepecNepImporter.class.getResourceAsStream("RepecNepImporterTest1.bib")) { - List entries = testImporter.importDatabase(file, StandardCharsets.UTF_8).getDatabase() - .getEntries(); + List entries = testImporter.importDatabase(file, StandardCharsets.UTF_8).getDatabase().getEntries(); Assert.assertEquals(1, entries.size()); BibEntryAssert.assertEquals(bibIn, entries.get(0)); } diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java index b2471496ac3..a6e1b39226f 100644 --- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java +++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java @@ -18,8 +18,8 @@ import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.InternalBibtexFields; +import org.jabref.model.metadata.FileDirectoryPreferences; import org.jabref.model.metadata.MetaData; -import org.jabref.preferences.JabRefPreferences; import org.junit.Rule; import org.junit.Test; @@ -29,6 +29,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; public class IntegrityCheckTest { @@ -207,7 +208,7 @@ public void testJournalIsKnownInAbbreviationList() { @Test public void testFileChecks() { - MetaData metaData = Mockito.mock(MetaData.class); + MetaData metaData = mock(MetaData.class); Mockito.when(metaData.getDefaultFileDirectory()).thenReturn(Optional.of(".")); Mockito.when(metaData.getUserFileDirectory(any(String.class))).thenReturn(Optional.empty()); // FIXME: must be set as checkBibtexDatabase only activates title checker based on database mode @@ -337,7 +338,7 @@ public void testEntryIsUnchangedAfterChecks() { BibDatabaseContext context = new BibDatabaseContext(bibDatabase, new Defaults()); new IntegrityCheck(context, - JabRefPreferences.getInstance().getFileDirectoryPreferences(), + mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))) .checkBibtexDatabase(); @@ -375,7 +376,7 @@ private BibDatabaseContext createContext(String field, String value) { private void assertWrong(BibDatabaseContext context) { List messages = new IntegrityCheck(context, - JabRefPreferences.getInstance().getFileDirectoryPreferences(), + mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))) .checkBibtexDatabase(); @@ -384,7 +385,7 @@ private void assertWrong(BibDatabaseContext context) { private void assertCorrect(BibDatabaseContext context) { List messages = new IntegrityCheck(context, - JabRefPreferences.getInstance().getFileDirectoryPreferences(), + mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW")) ).checkBibtexDatabase(); diff --git a/src/test/java/org/jabref/logic/journals/AbbreviationsTest.java b/src/test/java/org/jabref/logic/journals/AbbreviationsTest.java index ed2a904bb99..641cc83c5b8 100644 --- a/src/test/java/org/jabref/logic/journals/AbbreviationsTest.java +++ b/src/test/java/org/jabref/logic/journals/AbbreviationsTest.java @@ -23,7 +23,7 @@ public void setUp() throws Exception { @Test public void getNextAbbreviationAbbreviatesIEEEJournalTitle() { - when(prefs.isUseIEEEAbbreviations()).thenReturn(true); + when(prefs.useIEEEAbbreviations()).thenReturn(true); assertEquals("#IEEE_J_PROC#", abbreviations.getRepository(prefs) @@ -32,7 +32,7 @@ public void getNextAbbreviationAbbreviatesIEEEJournalTitle() { @Test public void getNextAbbreviationExpandsIEEEAbbreviation() { - when(prefs.isUseIEEEAbbreviations()).thenReturn(true); + when(prefs.useIEEEAbbreviations()).thenReturn(true); assertEquals("Proceedings of the IEEE", abbreviations.getRepository(prefs) diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java index 52bdb1e755b..cc73fe68728 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java @@ -43,37 +43,6 @@ public void allFilesMustHaveSameKeys() { } } - - private static class DuplicationDetectionProperties extends Properties { - - private static final long serialVersionUID = 1L; - - private final List duplicates = new LinkedList<>(); - - - public DuplicationDetectionProperties() { - super(); - } - - /** - * Overriding the HashTable put() so we can check for duplicates - */ - @Override - public synchronized Object put(Object key, Object value) { - // Have we seen this key before? - if (containsKey(key)) { - duplicates.add(String.valueOf(key)); - } - - return super.put(key, value); - } - - public List getDuplicates() { - return duplicates; - } - } - - @Test public void ensureNoDuplicates() { for (String bundle : Arrays.asList("JabRef", "Menu")) { @@ -135,8 +104,7 @@ public void findMissingLocalizationKeys() throws IOException { @Test public void findMissingMenuLocalizationKeys() throws IOException { - List missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU).stream() - .collect(Collectors.toList()); + Set missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU); assertEquals("DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH MENU FILE\n" + "1. PASTE THESE INTO THE ENGLISH MENU FILE\n" + @@ -144,7 +112,7 @@ public void findMissingMenuLocalizationKeys() throws IOException { missingKeys.parallelStream() .map(key -> String.format("%s=%s", key.getKey(), key.getKey())) .collect(Collectors.toList()), - Collections.emptyList(), missingKeys); + Collections.emptySet(), missingKeys); } @Test @@ -188,4 +156,33 @@ public void localizationParameterMustIncludeAString() throws IOException { } } + private static class DuplicationDetectionProperties extends Properties { + + private static final long serialVersionUID = 1L; + + private final List duplicates = new LinkedList<>(); + + + public DuplicationDetectionProperties() { + super(); + } + + /** + * Overriding the HashTable put() so we can check for duplicates + */ + @Override + public synchronized Object put(Object key, Object value) { + // Have we seen this key before? + if (containsKey(key)) { + duplicates.add(String.valueOf(key)); + } + + return super.put(key, value); + } + + public List getDuplicates() { + return duplicates; + } + } + } diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java index a02bee4d0eb..45e63d302cc 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java @@ -61,7 +61,7 @@ public static SortedSet findObsolete(LocalizationBundleForTest type) thr } englishKeys.removeAll(keysInFiles); - return englishKeys.stream().collect(Collectors.toCollection(TreeSet::new)); + return new TreeSet<>(englishKeys); } private static Set findLocalizationEntriesInFiles(LocalizationBundleForTest type) throws IOException { @@ -195,9 +195,14 @@ public boolean containsKey(String key) { } }; + PlatformImpl.startup(() -> { + }); try { - PlatformImpl.startup(() -> {}); FXMLLoader loader = new FXMLLoader(path.toUri().toURL(), registerUsageResourceBundle); + // We don't want to initialize controller + loader.setControllerFactory(controllerType -> null); + // Don't check if root is null (needed for custom controls, where the root value is normally set in the FXMLLoader) + loader.impl_setStaticLoad(true); loader.load(); } catch (IOException ignore) { ignore.printStackTrace(); diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java index 81c509ea7ae..8f9f6496064 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java @@ -2,8 +2,6 @@ import java.util.Locale; -import org.jabref.preferences.JabRefPreferences; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,7 +21,6 @@ public void storeDefaultLocale() { public void restoreDefaultLocale() { Locale.setDefault(locale); javax.swing.JComponent.setDefaultLocale(locale); - Localization.setLanguage(JabRefPreferences.getInstance().get(JabRefPreferences.LANGUAGE)); } @Test diff --git a/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java b/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java index 59b928e17e1..b20af305c10 100644 --- a/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java +++ b/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java @@ -3,9 +3,7 @@ import java.io.IOException; import java.io.StringReader; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; @@ -74,9 +72,7 @@ public void setUp() { public String layout(String layoutFile, BibEntry entry) throws IOException { StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); - Layout layout = new LayoutHelper(sr, - JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class))) - .getLayoutFromText(); + Layout layout = new LayoutHelper(sr, mock(LayoutFormatterPreferences.class)).getLayoutFromText(); return layout.doLayout(entry, null); } diff --git a/src/test/java/org/jabref/logic/layout/LayoutTest.java b/src/test/java/org/jabref/logic/layout/LayoutTest.java index fe230707ca9..5f123da8efd 100644 --- a/src/test/java/org/jabref/logic/layout/LayoutTest.java +++ b/src/test/java/org/jabref/logic/layout/LayoutTest.java @@ -6,30 +6,31 @@ import java.util.Collection; import java.util.Collections; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; -import org.jabref.logic.journals.JournalAbbreviationLoader; -import org.jabref.logic.journals.JournalAbbreviationPreferences; import org.jabref.logic.layout.format.FileLinkPreferences; -import org.jabref.logic.layout.format.NameFormatterPreferences; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class LayoutTest { - private LayoutFormatterPreferences prefs; + private static ImportFormatPreferences importFormatPreferences; + private LayoutFormatterPreferences layoutFormatterPreferences; /** * Initialize Preferences. */ @Before public void setUp() { - prefs = JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); + layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } /** @@ -45,7 +46,7 @@ public String t1BibtexString() { } public static BibEntry bibtexString2BibtexEntry(String s) throws IOException { - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(new StringReader(s)); + ParserResult result = new BibtexParser(importFormatPreferences).parse(new StringReader(s)); Collection c = result.getDatabase().getEntries(); Assert.assertEquals(1, c.size()); return c.iterator().next(); @@ -54,8 +55,7 @@ public static BibEntry bibtexString2BibtexEntry(String s) throws IOException { public String layout(String layoutFile, String entry) throws IOException { BibEntry be = LayoutTest.bibtexString2BibtexEntry(entry); StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); - Layout layout = new LayoutHelper(sr, prefs) - .getLayoutFromText(); + Layout layout = new LayoutHelper(sr, layoutFormatterPreferences).getLayoutFromText(); return layout.doLayout(be, null); } @@ -103,7 +103,6 @@ public void testHTMLCharDoubleLineBreak() throws IOException { */ @Test public void testLayout() throws IOException { - String layoutText = layout( "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", t1BibtexString()); @@ -116,12 +115,12 @@ public void testLayout() throws IOException { @Test // Test for http://discourse.jabref.org/t/the-wrapfilelinks-formatter/172 (the example in the help files) public void testWrapFileLinksLayout() throws IOException { - prefs = new LayoutFormatterPreferences(mock(NameFormatterPreferences.class), - mock(JournalAbbreviationPreferences.class), - new FileLinkPreferences(Collections.emptyList(), Collections.singletonList("src/test/resources/pdfs/")), - mock(JournalAbbreviationLoader.class)); + when(layoutFormatterPreferences.getFileLinkPreferences()).thenReturn( + new FileLinkPreferences(Collections.emptyList(), Collections.singletonList("src/test/resources/pdfs/"))); + String layoutText = layout("\\begin{file}\\format[WrapFileLinks(\\i. \\d (\\p))]{\\file}\\end{file}", "@other{bla, file={Test file:encrypted.pdf:PDF}}"); + Assert.assertEquals( "1. Test file (" + new File("src/test/resources/pdfs/encrypted.pdf").getCanonicalPath() + ")", layoutText); diff --git a/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java b/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java index abf5939e9a3..4876f79c20b 100644 --- a/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java +++ b/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java @@ -1,12 +1,12 @@ package org.jabref.logic.layout.format; import org.jabref.logic.layout.ParamLayoutFormatter; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class FileLinkTest { @@ -14,7 +14,7 @@ public class FileLinkTest { private FileLinkPreferences prefs; @Before public void setUp() throws Exception { - prefs = JabRefPreferences.getInstance().getFileLinkPreferences(); + prefs = mock(FileLinkPreferences.class); } @Test diff --git a/src/test/java/org/jabref/logic/net/URLDownloadTest.java b/src/test/java/org/jabref/logic/net/URLDownloadTest.java index 8af5396a089..0f17db0851c 100644 --- a/src/test/java/org/jabref/logic/net/URLDownloadTest.java +++ b/src/test/java/org/jabref/logic/net/URLDownloadTest.java @@ -3,10 +3,9 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; -import org.jabref.preferences.JabRefPreferences; - import org.junit.Assert; import org.junit.Test; @@ -24,7 +23,7 @@ public void testStringDownload() throws IOException { URLDownload dl = new URLDownload(new URL("http://www.google.com")); Assert.assertTrue("google.com should contain google", - dl.asString(JabRefPreferences.getInstance().getDefaultEncoding()).contains("Google")); + dl.asString(StandardCharsets.UTF_8).contains("Google")); } @Test diff --git a/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java b/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java index f182e3bc568..286ceb28895 100644 --- a/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java +++ b/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java @@ -14,18 +14,18 @@ import java.util.Set; import org.jabref.JabRefMain; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Importer; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.Layout; import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -35,11 +35,12 @@ public class OOBibStyleTest { private LayoutFormatterPreferences layoutFormatterPreferences; + private ImportFormatPreferences importFormatPreferences; @Before public void setUp() { - layoutFormatterPreferences = JabRefPreferences.getInstance() - .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); + layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test @@ -61,8 +62,7 @@ public void testAuthorYearAsFile() throws URISyntaxException, IOException { File defFile = Paths.get(JabRefMain.class.getResource(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH).toURI()) .toFile(); - OOBibStyle style = new OOBibStyle(defFile, layoutFormatterPreferences, - JabRefPreferences.getInstance().getDefaultEncoding()); + OOBibStyle style = new OOBibStyle(defFile, layoutFormatterPreferences, StandardCharsets.UTF_8); assertTrue(style.isValid()); assertFalse(style.isFromResource()); assertFalse(style.isBibtexKeyCiteMarkers()); @@ -139,7 +139,7 @@ public void testGetCitProperty() throws IOException { @Test public void testGetCitationMarker() throws IOException { Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib"); - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8)); + ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8)); OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences); Map entryDBMap = new HashMap<>(); @@ -160,7 +160,7 @@ public void testGetCitationMarker() throws IOException { @Test public void testLayout() throws IOException { Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib"); - ParserResult result = new BibtexParser(JabRefPreferences.getInstance().getImportFormatPreferences()).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8)); + ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8)); OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences); BibDatabase db = result.getDatabase(); diff --git a/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java b/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java index ed35f45eb2c..2cd65802de0 100644 --- a/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java +++ b/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java @@ -2,23 +2,25 @@ import java.net.URISyntaxException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.LayoutFormatterPreferences; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class StyleLoaderTest { @@ -32,10 +34,9 @@ public class StyleLoaderTest { @Before public void setUp() { - preferences = new OpenOfficePreferences(JabRefPreferences.getInstance()); - layoutPreferences = JabRefPreferences.getInstance() - .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); - encoding = JabRefPreferences.getInstance().getDefaultEncoding(); + preferences = mock(OpenOfficePreferences.class, Answers.RETURNS_DEEP_STUBS); + layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); + encoding = StandardCharsets.UTF_8; } @@ -46,9 +47,8 @@ public void throwNPEWithNullPreferences() { } @Test(expected = NullPointerException.class) - public void throwNPEWithNullRepository() { - loader = new StyleLoader(mock(OpenOfficePreferences.class), - JabRefPreferences.getInstance().getLayoutFormatterPreferences(null), mock(Charset.class)); + public void throwNPEWithNullLayoutPreferences() { + loader = new StyleLoader(mock(OpenOfficePreferences.class), null, mock(Charset.class)); fail(); } @@ -90,7 +90,7 @@ public void testAddInvalidStyleLeadsToNoMoreStyle() { public void testInitalizeWithOneExternalFile() throws URISyntaxException { String filename = Paths.get(StyleLoader.class.getResource(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH).toURI()) .toFile().getPath(); - preferences.setExternalStyles(Collections.singletonList(filename)); + when(preferences.getExternalStyles()).thenReturn(Collections.singletonList(filename)); loader = new StyleLoader(preferences, layoutPreferences, encoding); assertEquals(numberOfInternalStyles + 1, loader.getStyles().size()); } @@ -107,7 +107,7 @@ public void testInitalizeWithIncorrectExternalFile() { public void testInitalizeWithOneExternalFileRemoveStyle() throws URISyntaxException { String filename = Paths.get(StyleLoader.class.getResource(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH).toURI()) .toFile().getPath(); - preferences.setExternalStyles(Collections.singletonList(filename)); + when(preferences.getExternalStyles()).thenReturn(Collections.singletonList(filename)); loader = new StyleLoader(preferences, layoutPreferences, encoding); List toremove = new ArrayList<>(); @@ -125,10 +125,11 @@ public void testInitalizeWithOneExternalFileRemoveStyle() throws URISyntaxExcept } @Test + @Ignore("This tests the preferences that are mocked away") public void testInitalizeWithOneExternalFileRemoveStyleUpdatesPreferences() throws URISyntaxException { String filename = Paths.get(StyleLoader.class.getResource(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH).toURI()) .toFile().getPath(); - preferences.setExternalStyles(Collections.singletonList(filename)); + when(preferences.getExternalStyles()).thenReturn(Collections.singletonList(filename)); loader = new StyleLoader(preferences, layoutPreferences, encoding); List toremove = new ArrayList<>(); @@ -165,6 +166,7 @@ public void testAddNullStyleThrowsNPE() { @Test public void testGetDefaultUsedStyleWhenEmpty() { + when(preferences.getCurrentStyle()).thenReturn(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH); preferences.clearCurrentStyle(); loader = new StyleLoader(preferences, layoutPreferences, encoding); OOBibStyle style = loader.getUsedStyle(); @@ -175,7 +177,7 @@ public void testGetDefaultUsedStyleWhenEmpty() { @Test public void testGetStoredUsedStyle() { - preferences.setCurrentStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH); + when(preferences.getCurrentStyle()).thenReturn(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH); loader = new StyleLoader(preferences, layoutPreferences, encoding); OOBibStyle style = loader.getUsedStyle(); assertTrue(style.isValid()); @@ -184,8 +186,9 @@ public void testGetStoredUsedStyle() { } @Test + @Ignore("This tests the preferences that are mocked away") public void testGtDefaultUsedStyleWhenIncorrect() { - preferences.setCurrentStyle("ljlkjlkjnljnvdlsjniuhwelfhuewfhlkuewhfuwhelu"); + when(preferences.getCurrentStyle()).thenReturn("ljlkjlkjnljnvdlsjniuhwelfhuewfhlkuewhfuwhelu"); loader = new StyleLoader(preferences, layoutPreferences, encoding); OOBibStyle style = loader.getUsedStyle(); assertTrue(style.isValid()); diff --git a/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java b/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java index 80a54d4d58e..280d24630c2 100644 --- a/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java +++ b/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java @@ -1,35 +1,17 @@ package org.jabref.logic.util.io; -import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; -import org.jabref.preferences.JabRefPreferences; - -import org.junit.After; -import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; public class FileHistoryTest { - private JabRefPreferences prefs; - private List oldFileNames; - - @Before - public void setUp() { - prefs = JabRefPreferences.getInstance(); - oldFileNames = prefs.getStringList(JabRefPreferences.RECENT_DATABASES); - } - - @After - public void restore() { - prefs.putStringList(JabRefPreferences.RECENT_DATABASES, oldFileNames); - } - @Test public void testFileHistory() { - FileHistory fh = prefs.getFileHistory(); + FileHistory fh = new FileHistory(new ArrayList<>()); fh.newFile("aa"); assertEquals("aa", fh.getFileName(0)); @@ -63,9 +45,8 @@ public void testFileHistory() { fh.removeItem("cc"); fh.removeItem("cc"); fh.removeItem("aa"); - prefs.storeFileHistory(fh); - assertArrayEquals(new String[] {"ii", "hh", "gg"}, - prefs.getStringList(JabRefPreferences.RECENT_DATABASES).toArray(new String[0])); + + assertEquals(Arrays.asList("ii", "hh", "gg"), fh.getHistory()); } } diff --git a/src/test/java/org/jabref/logic/util/io/FileUtilTest.java b/src/test/java/org/jabref/logic/util/io/FileUtilTest.java index 2739f3c1804..63e57cdcb18 100644 --- a/src/test/java/org/jabref/logic/util/io/FileUtilTest.java +++ b/src/test/java/org/jabref/logic/util/io/FileUtilTest.java @@ -11,16 +11,15 @@ import java.util.List; import java.util.Optional; -import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.layout.LayoutFormatterPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.util.FileHelper; -import org.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Answers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -36,12 +35,14 @@ public class FileUtilTest { private final Path nonExistingTestPath = Paths.get("nonExistingTestPath"); private Path existingTestFile; private Path otherExistingTestFile; + private LayoutFormatterPreferences layoutFormatterPreferences; @Before public void setUpViewModel() throws IOException { existingTestFile = createTemporaryTestFile("existingTestFile.txt"); otherExistingTestFile = createTemporaryTestFile("otherExistingTestFile.txt"); otherTemporaryFolder.create(); + layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); } @Test @@ -65,8 +66,7 @@ public void testGetLinkedFileNameDefault() { entry.setField("title", "mytitle"); assertEquals("1234 - mytitle", - FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, JabRefPreferences.getInstance() - .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); + FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, layoutFormatterPreferences)); } @Test @@ -79,7 +79,7 @@ public void testGetLinkedFileNameBibTeXKey() { assertEquals("1234", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, - mock(LayoutFormatterPreferences.class))); + layoutFormatterPreferences)); } @Test @@ -90,7 +90,7 @@ public void testGetLinkedFileNameNoPattern() { entry.setField("title", "mytitle"); assertEquals("1234", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, - mock(LayoutFormatterPreferences.class))); + layoutFormatterPreferences)); } @Test @@ -100,7 +100,7 @@ public void testGetDefaultFileNameNoPatternNoBibTeXKey() { entry.setField("title", "mytitle"); assertEquals("default", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, - mock(LayoutFormatterPreferences.class))); + layoutFormatterPreferences)); } @Test @@ -111,7 +111,7 @@ public void testGetLinkedFileNameGetKeyIfEmptyField() { entry.setCiteKey("1234"); assertEquals("1234", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, - JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); + layoutFormatterPreferences)); } @Test @@ -121,7 +121,7 @@ public void testGetLinkedFileNameGetDefaultIfEmptyFieldNoKey() { BibEntry entry = new BibEntry(); assertEquals("default", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, - JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); + layoutFormatterPreferences)); } @Test diff --git a/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java b/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java index 5885b3a603b..6f65bab0b64 100644 --- a/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java +++ b/src/test/java/org/jabref/logic/xmp/XMPUtilTest.java @@ -31,6 +31,7 @@ import org.jabref.cli.XMPUtilMain; import org.jabref.logic.bibtex.BibEntryWriter; import org.jabref.logic.bibtex.LatexFieldFormatter; +import org.jabref.logic.bibtex.LatexFieldFormatterPreferences; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; @@ -38,7 +39,6 @@ import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.jabref.preferences.JabRefPreferences; import com.google.common.io.CharStreams; import org.apache.jempbox.xmp.XMPMetadata; @@ -52,12 +52,15 @@ import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.common.PDMetadata; import org.apache.pdfbox.util.XMLUtil; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Answers; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Limitations: The test suite only handles UTF8. Not UTF16. @@ -71,12 +74,6 @@ public class XMPUtilTest { */ private File pdfFile; - private JabRefPreferences prefs; - - private boolean use; - - private List privacyFilters; - private XMPPreferences xmpPreferences; @@ -140,7 +137,7 @@ public void writeManually(File tempFile, String xmpString) throws IOException, C } } - public static BibEntry bibtexString2BibtexEntry(String s, ImportFormatPreferences importFormatPreferences) + private static BibEntry bibtexString2BibtexEntry(String s, ImportFormatPreferences importFormatPreferences) throws IOException { ParserResult result = new BibtexParser(importFormatPreferences).parse(new StringReader(s)); Collection c = result.getDatabase().getEntries(); @@ -148,14 +145,14 @@ public static BibEntry bibtexString2BibtexEntry(String s, ImportFormatPreference return c.iterator().next(); } - public static String bibtexEntry2BibtexString(BibEntry e, JabRefPreferences preferences) throws IOException { + private static String bibtexEntry2BibtexString(BibEntry e) throws IOException { StringWriter sw = new StringWriter(); - new BibEntryWriter(new LatexFieldFormatter(preferences.getLatexFieldFormatterPreferences()), + new BibEntryWriter(new LatexFieldFormatter(mock(LatexFieldFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS)), false).write(e, sw, BibDatabaseMode.BIBTEX); return sw.getBuffer().toString(); } - public String t1BibtexString() { + private String t1BibtexString() { return "@article{canh05,\n" + " author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.},\n" + " title = {Effective work practices for floss development: A model and propositions},\n" + " booktitle = {Hawaii International Conference On System Sciences (HICSS)},\n" + " year = {2005},\n" @@ -163,11 +160,11 @@ public String t1BibtexString() { + " url = {http://james.howison.name/publications.html}}\n"; } - public BibEntry t1BibtexEntry() throws IOException { + private BibEntry t1BibtexEntry() throws IOException { return XMPUtilTest.bibtexString2BibtexEntry(t1BibtexString(), importFormatPreferences); } - public String t2XMP() { + private String t2XMP() { return "\n" + "YeKis03 - Towards.pdf\n" + "\n"; } - public String t2BibtexString() throws IOException { - return XMPUtilTest.bibtexEntry2BibtexString(t2BibtexEntry(), prefs); + private String t2BibtexString() throws IOException { + return XMPUtilTest.bibtexEntry2BibtexString(t2BibtexEntry()); } - public BibEntry t2BibtexEntry() { + private BibEntry t2BibtexEntry() { BibEntry e = new BibEntry(BibtexEntryTypes.INCOLLECTION.getName()); e.setField("title", "�pt�mz�t��n"); e.setField("bibtexkey", "OezbekC06"); @@ -190,7 +187,7 @@ public BibEntry t2BibtexEntry() { return e; } - public BibEntry t3BibtexEntry() { + private BibEntry t3BibtexEntry() { BibEntry e = new BibEntry(); e.setType(BibtexEntryTypes.INPROCEEDINGS); e.setField("title", "Hypersonic ultra-sound"); @@ -209,7 +206,7 @@ public BibEntry t3BibtexEntry() { } public String t3BibtexString() throws IOException { - return XMPUtilTest.bibtexEntry2BibtexString(t3BibtexEntry(), prefs); + return XMPUtilTest.bibtexEntry2BibtexString(t3BibtexEntry()); } public String t3XMP() { @@ -239,23 +236,13 @@ public void setUp() throws IOException, COSVisitorException { pdf.save(pdfFile.getAbsolutePath()); } - // Store Privacy Settings - prefs = JabRefPreferences.getInstance(); - - use = prefs.getBoolean(JabRefPreferences.USE_XMP_PRIVACY_FILTER); - privacyFilters = prefs.getStringList(JabRefPreferences.XMP_PRIVACY_FILTERS); - + importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8); + xmpPreferences = mock(XMPPreferences.class); // The code assumes privacy filters to be off - prefs.putBoolean("useXmpPrivacyFilter", false); - - importFormatPreferences = prefs.getImportFormatPreferences(); - xmpPreferences = prefs.getXMPPreferences(); - } + when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(false); - @After - public void tearDown() { - prefs.putBoolean(JabRefPreferences.USE_XMP_PRIVACY_FILTER, use); - prefs.putStringList(JabRefPreferences.XMP_PRIVACY_FILTERS, privacyFilters); + when(xmpPreferences.getKeywordSeparator()).thenReturn(','); } /** @@ -316,34 +303,14 @@ public void testReadXMPUTF8() throws COSVisitorException, IOException { */ @Test public void testPrivacyFilter() throws IOException, TransformerException { - - { - BibEntry e = t1BibtexEntry(); - - prefs.putBoolean("useXmpPrivacyFilter", true); - prefs.putStringList(JabRefPreferences.XMP_PRIVACY_FILTERS, Arrays.asList("author", "title", "note")); - - XMPUtil.writeXMP(pdfFile, e, null, prefs.getXMPPreferences()); - - List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), prefs.getXMPPreferences()); - Assert.assertEquals(1, l.size()); - BibEntry x = l.get(0); - - Set expectedFields = new HashSet<>( - Arrays.asList("bibtexkey", "booktitle", "owner", "timestamp", "url", "year")); - - Assert.assertEquals(expectedFields, x.getFieldNames()); - } - // First set: - prefs.putBoolean("useXmpPrivacyFilter", true); - prefs.putStringList(JabRefPreferences.XMP_PRIVACY_FILTERS, - Arrays.asList("author;title;note;booktitle;year;owner;timestamp")); + when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(true); + when(xmpPreferences.getXmpPrivacyFilter()).thenReturn(Arrays.asList("author;title;note;booktitle;year;owner;timestamp")); BibEntry e = t1BibtexEntry(); - XMPUtil.writeXMP(pdfFile, e, null, prefs.getXMPPreferences()); + XMPUtil.writeXMP(pdfFile, e, null, xmpPreferences); - List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), prefs.getXMPPreferences()); + List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), xmpPreferences); Assert.assertEquals(1, l.size()); BibEntry x = l.get(0); Set ts = x.getFieldNames(); @@ -353,7 +320,25 @@ public void testPrivacyFilter() throws IOException, TransformerException { Assert.assertTrue(ts.contains("bibtexkey")); Assert.assertTrue(ts.contains("year")); Assert.assertTrue(ts.contains("url")); + } + + @Test + public void testPrivacyFilter2() throws Exception { + BibEntry e = t1BibtexEntry(); + + when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(true); + when(xmpPreferences.getXmpPrivacyFilter()).thenReturn(Arrays.asList("author", "title", "note")); + + XMPUtil.writeXMP(pdfFile, e, null, xmpPreferences); + + List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), xmpPreferences); + Assert.assertEquals(1, l.size()); + BibEntry x = l.get(0); + + Set expectedFields = new HashSet<>( + Arrays.asList("bibtexkey", "booktitle", "owner", "timestamp", "url", "year")); + Assert.assertEquals(expectedFields, x.getFieldNames()); } /**