diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 8d63b8f60fe..2279e25e27f 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -1920,8 +1920,6 @@ private class RedoAction implements BaseAction { @Override public void action() { try { - - JComponent focused = Globals.getFocusListener().getFocused(); getUndoManager().redo(); markBaseChanged(); frame.output(Localization.lang("Redo")); diff --git a/src/main/java/org/jabref/gui/IconTheme.java b/src/main/java/org/jabref/gui/IconTheme.java index 7c1526701de..cade39ed2ce 100644 --- a/src/main/java/org/jabref/gui/IconTheme.java +++ b/src/main/java/org/jabref/gui/IconTheme.java @@ -51,19 +51,9 @@ public class IconTheme { private static final Map KEY_TO_ICON = readIconThemeFile( IconTheme.class.getResource("/images/Icons.properties"), "/images/external/"); - // Christmas edition - //public static final Color DEFAULT_COLOR = new Color(0x155115); - //public static final Color DEFAULT_DISABLED_COLOR = new Color(0x990000); - private static Font FONT_16; - private static javafx.scene.text.Font FX_FONT; - static { try (InputStream stream = getMaterialDesignIconsStream()) { FONT = Font.createFont(Font.TRUETYPE_FONT, stream); - FONT_16 = FONT.deriveFont(Font.PLAIN, 16f); - try (InputStream stream2 = getMaterialDesignIconsStream()) { - FX_FONT = javafx.scene.text.Font.loadFont(stream2, JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_LARGE)); - } } catch (FontFormatException | IOException e) { LOGGER.warn("Error loading font", e); } @@ -92,14 +82,14 @@ public static Image getJabRefImageFX() { return getImageFX("jabrefIcon48"); } - /** + /* * Constructs an {@link Image} for the image representing the given function, in the resource * file listing images. * * @param name The name of the icon, such as "open", "save", "saveAs" etc. * @return The {@link Image} for the function. */ - public static Image getImageFX(String name) { + private static Image getImageFX(String name) { return new Image(getIconUrl(name).toString()); } diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java index 3ee754dae4d..0d6858d47ee 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java @@ -31,7 +31,6 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexString; -import org.jabref.model.metadata.MetaData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +42,6 @@ public class ChangeScanner implements Runnable { private final File file; private final Path tempFile; private final BibDatabaseContext databaseInMemory; - private final MetaData metadataInMemory; private final BasePanel panel; private final JabRefFrame frame; @@ -62,7 +60,6 @@ public ChangeScanner(JabRefFrame frame, BasePanel bp, File file, Path tempFile) this.panel = bp; this.frame = frame; this.databaseInMemory = bp.getDatabaseContext(); - this.metadataInMemory = bp.getBibDatabaseContext().getMetaData(); this.file = file; this.tempFile = tempFile; } @@ -136,7 +133,7 @@ public void run() { // Start looking at changes. BibDatabaseDiff differences = BibDatabaseDiff.compare(databaseInTemp, databaseOnDisk); differences.getMetaDataDifferences().ifPresent(diff -> { - changes.add(new MetaDataChangeViewModel(metadataInMemory, diff)); + changes.add(new MetaDataChangeViewModel(diff)); diff.getGroupDifferences().ifPresent(groupDiff -> changes.add(new GroupChangeViewModel(groupDiff))); }); differences.getPreambleDifferences().ifPresent(diff -> changes.add(new PreambleChangeViewModel(databaseInMemory.getDatabase().getPreamble().orElse(""), diff))); diff --git a/src/main/java/org/jabref/gui/collab/MetaDataChangeViewModel.java b/src/main/java/org/jabref/gui/collab/MetaDataChangeViewModel.java index 307fba9f4a0..7418ff1695f 100644 --- a/src/main/java/org/jabref/gui/collab/MetaDataChangeViewModel.java +++ b/src/main/java/org/jabref/gui/collab/MetaDataChangeViewModel.java @@ -10,19 +10,14 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.metadata.MetaData; -/** - * - */ class MetaDataChangeViewModel extends ChangeViewModel { private final InfoPane infoPane = new InfoPane(); private final JScrollPane sp = new JScrollPane(infoPane); - private final MetaData originalMetaData; private final MetaData newMetaData; - public MetaDataChangeViewModel(MetaData originalMetaData, MetaDataDiff metaDataDiff) { + public MetaDataChangeViewModel(MetaDataDiff metaDataDiff) { super(Localization.lang("Metadata change")); - this.originalMetaData = originalMetaData; this.newMetaData = metaDataDiff.getNewMetaData(); infoPane.setText("" + Localization.lang("Metadata change") + ""); diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java index 5bf822128fa..ceb03d4a35f 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java @@ -1,7 +1,5 @@ package org.jabref.gui.fieldeditors; -import java.util.Optional; - import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Parent; @@ -18,9 +16,10 @@ public class JournalEditor extends HBox implements FieldEditorFX { - @FXML private JournalEditorViewModel viewModel; - @FXML private EditorTextArea textArea; - private Optional entry; + @FXML + private JournalEditorViewModel viewModel; + @FXML + private EditorTextArea textArea; public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbreviationLoader, JabRefPreferences preferences, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { this.viewModel = new JournalEditorViewModel(fieldName, suggestionProvider, journalAbbreviationLoader, preferences.getJournalAbbreviationPreferences(), fieldCheckers); @@ -41,7 +40,6 @@ public JournalEditorViewModel getViewModel() { @Override public void bindToEntry(BibEntry entry) { - this.entry = Optional.of(entry); viewModel.bindToEntry(entry); } @@ -51,7 +49,7 @@ public Parent getNode() { } @FXML - private void toggleAbbreviation(ActionEvent event) { + private void toggleAbbreviation(ActionEvent unused) { viewModel.toggleAbbreviation(); } } diff --git a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java index d6cd64833c1..0201d148e03 100644 --- a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java +++ b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java @@ -73,7 +73,7 @@ public class FileListEntryEditor { private final JComboBox types; private final JProgressBar prog = new JProgressBar(SwingConstants.HORIZONTAL); private final JLabel downloadLabel = new JLabel(Localization.lang("Downloading...")); - private JDialog diag; + private JDialog dialog; //Do not make this variable final, as then the lambda action listener will fail on compile private JabRefFrame frame; private boolean showSaveDialog; @@ -142,7 +142,7 @@ public FileListEntryEditor(LinkedFile entry, boolean showProgressBar, boolean sh return; } } - diag.dispose(); + dialog.dispose(); storeSettings(FileListEntryEditor.this.entry); okPressed = true; }; @@ -198,7 +198,7 @@ public FileListEntryEditor(LinkedFile entry, boolean showProgressBar, boolean sh @Override public void actionPerformed(ActionEvent e) { - diag.dispose(); + dialog.dispose(); } }; cancel.addActionListener(cancelAction); @@ -228,13 +228,13 @@ public void changedUpdate(DocumentEvent documentEvent) { }); - diag = new JDialog(); - diag.setTitle(Localization.lang("Select files")); - diag.setModal(true); - diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); - diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); - diag.pack(); - diag.addWindowListener(new WindowAdapter() { + dialog = new JDialog(); + dialog.setTitle(Localization.lang("Select files")); + dialog.setModal(true); + dialog.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); + dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); + dialog.pack(); + dialog.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { @@ -314,12 +314,12 @@ public void setVisible(boolean visible, boolean openBrowse) { } else { title = Localization.lang("Select files"); } - diag.setTitle(title); - diag.setVisible(visible); + dialog.setTitle(title); + dialog.setVisible(visible); } public boolean isVisible() { - return (diag != null) && diag.isVisible(); + return (dialog != null) && dialog.isVisible(); } private void setValues(LinkedFile entry) { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 0ad63a4c994..14874771dd8 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -25,7 +25,6 @@ import org.jabref.gui.StateManager; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.l10n.Localization; -import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.groups.AbstractGroup; @@ -139,7 +138,7 @@ public void addNewSubgroup(GroupNodeViewModel parent) { SwingUtilities.invokeLater(() -> { Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialog()); newGroup.ifPresent(group -> { - GroupTreeNode newGroupNode = parent.addSubgroup(group); + parent.addSubgroup(group); // TODO: Add undo //UndoableAddOrRemoveGroup undo = new UndoableAddOrRemoveGroup(parent, new GroupTreeNodeViewModel(newGroupNode), UndoableAddOrRemoveGroup.ADD_NODE); @@ -176,7 +175,7 @@ public void editGroup(GroupNodeViewModel oldGroup) { boolean removePreviousAssignents = (oldGroup.getGroupNode().getGroup() instanceof ExplicitGroup) && (group instanceof ExplicitGroup); - List addChange = oldGroup.getGroupNode().setGroup( + oldGroup.getGroupNode().setGroup( group, keepPreviousAssignments, removePreviousAssignents, @@ -262,7 +261,7 @@ public void removeGroupAndSubgroups(GroupNodeViewModel group) { } void removeGroupsAndSubGroupsFromEntries(GroupNodeViewModel group) { - for (GroupNodeViewModel child: group.getChildren()) { + for (GroupNodeViewModel child : group.getChildren()) { removeGroupsAndSubGroupsFromEntries(child); } @@ -278,7 +277,7 @@ public void addSelectedEntries(GroupNodeViewModel group) { // if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(node.getNode().getGroup(), panel.frame())) { // return; // user aborted operation - List addChange = group.getGroupNode().addEntriesToGroup(stateManager.getSelectedEntries()); + group.getGroupNode().addEntriesToGroup(stateManager.getSelectedEntries()); // TODO: Add undo // NamedCompound undoAll = new NamedCompound(Localization.lang("change assignment of entries")); @@ -306,7 +305,7 @@ public void removeSelectedEntries(GroupNodeViewModel group) { // if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(mNode.getNode().getGroup(), mPanel.frame())) { // return; // user aborted operation - List removeChange = group.getGroupNode().removeEntriesFromGroup(stateManager.getSelectedEntries()); + group.getGroupNode().removeEntriesFromGroup(stateManager.getSelectedEntries()); // TODO: Add undo // if (!undo.isEmpty()) { @@ -315,6 +314,5 @@ public void removeSelectedEntries(GroupNodeViewModel group) { public void sortAlphabeticallyRecursive(GroupNodeViewModel group) { group.getGroupNode().sortChildren(compAlphabetIgnoreCase, true); - } } diff --git a/src/main/java/org/jabref/gui/groups/UndoableModifyGroup.java b/src/main/java/org/jabref/gui/groups/UndoableModifyGroup.java deleted file mode 100644 index c4b67ddc683..00000000000 --- a/src/main/java/org/jabref/gui/groups/UndoableModifyGroup.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.jabref.gui.groups; - -import java.util.List; - -import org.jabref.gui.undo.AbstractUndoableJabRefEdit; -import org.jabref.logic.l10n.Localization; -import org.jabref.model.groups.AbstractGroup; -import org.jabref.model.groups.GroupTreeNode; - -class UndoableModifyGroup extends AbstractUndoableJabRefEdit { - - private final GroupSidePane groupSidePane; - private final AbstractGroup m_oldGroupBackup; - private final AbstractGroup m_newGroupBackup; - private final GroupTreeNode m_groupsRootHandle; - private final List m_pathToNode; - - - /** - * @param node - * The node which still contains the old group. - * @param newGroup - * The new group to replace the one currently stored in node - * . - */ - public UndoableModifyGroup(GroupSidePane gs, GroupTreeNodeViewModel groupsRoot, - GroupTreeNodeViewModel node, AbstractGroup newGroup) { - groupSidePane = gs; - m_oldGroupBackup = node.getNode().getGroup().deepCopy(); - m_newGroupBackup = newGroup.deepCopy(); - m_pathToNode = node.getNode().getIndexedPathFromRoot(); - m_groupsRootHandle = groupsRoot.getNode(); - } - - @Override - public String getPresentationName() { - return Localization.lang("modify group"); - } - - @Override - public void undo() { - super.undo(); - //TODO: NULL - m_groupsRootHandle.getDescendant(m_pathToNode).get().setGroup( - m_oldGroupBackup.deepCopy()); - } - - @Override - public void redo() { - super.redo(); - m_groupsRootHandle.getDescendant(m_pathToNode).get().setGroup( - m_newGroupBackup.deepCopy()); - } -} 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 4f9d592cfc9..a59979a8a2f 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/OAI2Fetcher.java @@ -33,14 +33,12 @@ import org.xml.sax.helpers.DefaultHandler; /** - * * This class can be used to access any archive offering an OAI2 interface. By * default it will access ArXiv.org * - * @see - * * @author Ulrich Stärk * @author Christian Kopf + * @see */ public class OAI2Fetcher implements EntryFetcher { @@ -49,40 +47,30 @@ public class OAI2Fetcher implements EntryFetcher { private static final String OAI2_ARXIV_HOST = "export.arxiv.org"; private static final String OAI2_ARXIV_SCRIPT = "oai2"; private static final String OAI2_ARXIV_METADATAPREFIX = "arXiv"; - private static final String OAI2_ARXIV_ARCHIVENAME = "ArXiv.org"; private static final String OAI2_IDENTIFIER_FIELD = "oai2identifier"; private SAXParser saxParser; private final String oai2Host; private final String oai2Script; private final String oai2MetaDataPrefix; private final String oai2PrefixIdentifier; - private final String oai2ArchiveName; private boolean shouldContinue = true; private long waitTime = -1; private Date lastCall; /** - * - * - * @param oai2Host - * the host to query without leading http:// and without trailing / - * @param oai2Script - * the relative location of the oai2 interface without leading - * and trailing / - * @param oai2Metadataprefix - * the urlencoded metadataprefix - * @param oai2Prefixidentifier - * the urlencoded prefix identifier - * @param waitTimeMs - * Time to wait in milliseconds between query-requests. + * @param oai2Host the host to query without leading http:// and without trailing / + * @param oai2Script the relative location of the oai2 interface without leading + * and trailing / + * @param oai2Metadataprefix the urlencoded metadataprefix + * @param oai2Prefixidentifier the urlencoded prefix identifier + * @param waitTimeMs Time to wait in milliseconds between query-requests. */ public OAI2Fetcher(String oai2Host, String oai2Script, String oai2Metadataprefix, String oai2Prefixidentifier, - String oai2ArchiveName, long waitTimeMs) { + long waitTimeMs) { this.oai2Host = oai2Host; this.oai2Script = oai2Script; this.oai2MetaDataPrefix = oai2Metadataprefix; this.oai2PrefixIdentifier = oai2Prefixidentifier; - this.oai2ArchiveName = oai2ArchiveName; this.waitTime = waitTimeMs; try { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); @@ -94,19 +82,16 @@ public OAI2Fetcher(String oai2Host, String oai2Script, String oai2Metadataprefix /** * Default Constructor. The archive queried will be ArXiv.org - * */ public OAI2Fetcher() { this(OAI2Fetcher.OAI2_ARXIV_HOST, OAI2Fetcher.OAI2_ARXIV_SCRIPT, OAI2Fetcher.OAI2_ARXIV_METADATAPREFIX, - OAI2Fetcher.OAI2_ARXIV_PREFIXIDENTIFIER, OAI2Fetcher.OAI2_ARXIV_ARCHIVENAME, 20000L); + OAI2Fetcher.OAI2_ARXIV_PREFIXIDENTIFIER, 20000L); } /** * Construct the query URL * - * @param key - * The key of the OAI2 entry that the url should point to. - * + * @param key The key of the OAI2 entry that the url should point to. * @return a String denoting the query URL */ public String constructUrl(String key) { @@ -154,12 +139,11 @@ public static String fixKey(String key) { * Import an entry from an OAI2 archive. The BibEntry provided has to * have the field OAI2_IDENTIFIER_FIELD set to the search string. * - * @param key - * The OAI2 key to fetch from ArXiv. + * @param key The OAI2 key to fetch from ArXiv. * @return The imported BibEntry or null if none. */ protected BibEntry importOai2Entry(String key) throws IOException, SAXException { - /** + /* * Fix for problem reported in mailing-list: * https://sourceforge.net/forum/message.php?msg_id=4087158 */ @@ -252,7 +236,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); } @@ -273,8 +257,8 @@ public boolean processQuery(String query, ImportInspector dialog, OutputPrinter return true; } catch (IOException | InterruptedException e) { LOGGER.error("Error while fetching from " + getTitle(), e); - ((ImportInspectionDialog)dialog).showErrorMessage(this.getTitle(), e.getLocalizedMessage()); - } + ((ImportInspectionDialog) dialog).showErrorMessage(this.getTitle(), e.getLocalizedMessage()); + } return false; } diff --git a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java index 38496ae4108..09824d81494 100644 --- a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java @@ -2,7 +2,6 @@ import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -96,7 +95,6 @@ class StyleSelectDialog { private PreviewPanel preview; private ActionListener removeAction; - private final Rectangle toRect = new Rectangle(0, 0, 1, 1); private final JButton ok = new JButton(Localization.lang("OK")); private final JButton cancel = new JButton(Localization.lang("Cancel")); private final BibEntry prevEntry; @@ -106,13 +104,11 @@ class StyleSelectDialog { private final OpenOfficePreferences preferences; public StyleSelectDialog(JabRefFrame frame, OpenOfficePreferences preferences, StyleLoader loader) { - this.frame = Objects.requireNonNull(frame); this.preferences = Objects.requireNonNull(preferences); this.loader = Objects.requireNonNull(loader); prevEntry = TestEntry.getTestEntry(); init(); - } private void init() { @@ -128,7 +124,6 @@ private void init() { } }); updateStyles(); - }); addButton.setToolTipText(Localization.lang("Add style file")); @@ -295,7 +290,6 @@ private void setupPopupMenu() { LOGGER.warn("Problem with style file '" + style.getPath() + "'", e); } })); - } public void setVisible(boolean visible) { @@ -358,6 +352,7 @@ public Optional getStyle() { /** * Get the currently selected style. + * * @return the selected style, or empty if no style is selected. */ private Optional getSelectedStyle() { @@ -537,6 +532,5 @@ public Optional getFileName() { public void setDirectoryPath(String path) { this.newFile.setText(path); } - } } diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java index 305bb340aa6..72a90329e4b 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java @@ -7,15 +7,11 @@ import java.util.Optional; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * A repository for all journal abbreviations, including add and find methods. */ public class JournalAbbreviationRepository { - private static final Logger LOGGER = LoggerFactory.getLogger(JournalAbbreviationRepository.class); private final Set abbreviations = new HashSet<>(16000); // We have over 15.000 abbreviations in the built-in lists public JournalAbbreviationRepository(Abbreviation... abbreviations) { diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 81c2ae2cda0..30c6a8066f9 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -31,8 +31,6 @@ private PreferencesMigrations() { * Migrate all preferences from net/sf/jabref to org/jabref */ public static void upgradePrefsToOrgJabRef() { - - JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); try { if (mainPrefsNode.childrenNames().length != 0) { @@ -173,7 +171,6 @@ public static void upgradeLabelPatternToBibtexKeyPattern() { prefs.put(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN, oldDefault); LOGGER.info("Upgraded old default key generator pattern '" + oldDefault + "' to new version."); } - } //Pref node already exists do not migrate from previous version if (mainPrefsNode.nodeExists(JabRefPreferences.BIBTEX_KEY_PATTERNS_NODE)) { @@ -198,16 +195,16 @@ public static void upgradeLabelPatternToBibtexKeyPattern() { * Migrate Import File Name and Directory name Patterns from versions <=4.0 to new BracketedPatterns */ private static void migrateFileImportPattern(String oldStylePattern, String newStylePattern, - JabRefPreferences prefs, Preferences mainPrefsNode) { + JabRefPreferences prefs, Preferences mainPrefsNode) { String preferenceFileNamePattern = mainPrefsNode.get(JabRefPreferences.IMPORT_FILENAMEPATTERN, null); if (preferenceFileNamePattern != null && - oldStylePattern.equals(preferenceFileNamePattern)) { + oldStylePattern.equals(preferenceFileNamePattern)) { // Upgrade the old-style File Name pattern to new one: mainPrefsNode.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, newStylePattern); LOGGER.info("migrated old style " + JabRefPreferences.IMPORT_FILENAMEPATTERN + - " value \"" + oldStylePattern + "\" to new value \"" + - newStylePattern + "\" in the preference file"); + " value \"" + oldStylePattern + "\" to new value \"" + + newStylePattern + "\" in the preference file"); if (prefs.hasKey(JabRefPreferences.IMPORT_FILENAMEPATTERN)) { // Update also the key in the current application settings, if necessary: @@ -215,8 +212,8 @@ private static void migrateFileImportPattern(String oldStylePattern, String newS if (oldStylePattern.equals(fileNamePattern)) { prefs.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, newStylePattern); LOGGER.info("migrated old style " + JabRefPreferences.IMPORT_FILENAMEPATTERN + - " value \"" + oldStylePattern + "\" to new value \"" + - newStylePattern + "\" in the running application"); + " value \"" + oldStylePattern + "\" to new value \"" + + newStylePattern + "\" in the running application"); } } } @@ -231,9 +228,9 @@ public static void upgradeImportFileAndDirePatterns() { // Check for prefs node for Version <= 4.0 if (mainPrefsNode.get(JabRefPreferences.IMPORT_FILENAMEPATTERN, null) != null) { - String[] oldStylePatterns = new String[] {"\\bibtexkey", + String[] oldStylePatterns = new String[]{"\\bibtexkey", "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; - String[] newStylePatterns = new String[] {"[bibtexkey]", + String[] newStylePatterns = new String[]{"[bibtexkey]", "[bibtexkey] - [fulltitle]"}; for (int i = 0; i < oldStylePatterns.length; i++) { migrateFileImportPattern(oldStylePatterns[i], newStylePatterns[i], prefs, mainPrefsNode); @@ -257,7 +254,6 @@ public static void upgradeKeyBindingsToJavaFX() { List keys = prefs.getStringList(JabRefPreferences.BINDINGS); keys.replaceAll(replaceKeys); prefs.putStringList(JabRefPreferences.BINDINGS, keys); - } public static void addCrossRefRelatedFieldsForAutoComplete() { @@ -286,7 +282,7 @@ public static void upgradeObsoleteLookAndFeels() { JabRefPreferences prefs = Globals.prefs; String currentLandF = prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); if ("com.jgoodies.looks.windows.WindowsLookAndFeel".equals(currentLandF) || - "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel".equals(currentLandF) ) { + "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel".equals(currentLandF)) { if (OS.WINDOWS) { String windowsLandF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, windowsLandF); @@ -298,5 +294,4 @@ public static void upgradeObsoleteLookAndFeels() { } } } - } diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index c9c844d61f9..b6efc53008b 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -715,8 +715,6 @@ Modified\ string=Modified string Modify=Modify -modify\ group=modify group - Move\ down=Move down Move\ external\ links\ to\ 'file'\ field=Move external links to 'file' field diff --git a/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java b/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java index 451be0e80b0..47152884ce5 100644 --- a/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java +++ b/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java @@ -25,7 +25,6 @@ private TextFlow createDescription(String query, boolean caseSensitive, boolean @Test public void testSimpleQueryCaseSensitiveRegex() { - double textSize = 13; String query = "a=b"; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(". "), @@ -37,7 +36,6 @@ public void testSimpleQueryCaseSensitiveRegex() { @Test public void testSimpleQueryCaseSensitive() { - double textSize = 13; String query = "a=b"; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(". "), @@ -49,7 +47,6 @@ public void testSimpleQueryCaseSensitive() { @Test public void testSimpleQuery() { - double textSize = 13; String query = "a=b"; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(". "), @@ -61,7 +58,6 @@ public void testSimpleQuery() { @Test public void testSimpleQueryRegex() { - double textSize = 13; String query = "a=b"; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(". "), @@ -73,7 +69,6 @@ public void testSimpleQueryRegex() { @Test public void testComplexQueryCaseSensitiveRegex() { - double textSize = 13; String query = "not a=b and c=e or e=\"x\""; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("not "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" and "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("c", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), @@ -86,7 +81,6 @@ public void testComplexQueryCaseSensitiveRegex() { @Test public void testComplexQueryRegex() { - double textSize = 13; String query = "not a=b and c=e or e=\"x\""; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("not "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" and "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("c", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the regular expression "), @@ -99,7 +93,6 @@ public void testComplexQueryRegex() { @Test public void testComplexQueryCaseSensitive() { - double textSize = 13; String query = "not a=b and c=e or e=\"x\""; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("not "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" and "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("c", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("e", TooltipTextUtil.TextType.BOLD), @@ -111,7 +104,6 @@ public void testComplexQueryCaseSensitive() { @Test public void testComplexQuery() { - double textSize = 13; String query = "not a=b and c=e or e=\"x\""; List expectedTexts = Arrays.asList(TooltipTextUtil.createText("This search contains entries in which "), TooltipTextUtil.createText("not "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("a", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("b", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" and "), TooltipTextUtil.createText("the field "), TooltipTextUtil.createText("c", TooltipTextUtil.TextType.BOLD), TooltipTextUtil.createText(" contains the term "), TooltipTextUtil.createText("e", TooltipTextUtil.TextType.BOLD), diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java index 011c0139144..017cc32cabc 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTest.java @@ -27,21 +27,19 @@ public class ModsExportFormatTest { public Charset charset; private ModsExporter modsExportFormat; private BibDatabaseContext databaseContext; - private BibtexImporter bibtexImporter; private Path tempFile; @Rule public TemporaryFolder testFolder = new TemporaryFolder(); - private Path importFile; @Before public void setUp() throws Exception { databaseContext = new BibDatabaseContext(); charset = StandardCharsets.UTF_8; modsExportFormat = new ModsExporter(); - bibtexImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor()); + new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor()); tempFile = testFolder.newFile().toPath(); - importFile = Paths.get(ModsExportFormatTest.class.getResource("ModsExportFormatTestAllFields.bib").toURI()); + Paths.get(ModsExportFormatTest.class.getResource("ModsExportFormatTestAllFields.bib").toURI()); } @Test diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java index a01e31f1bdc..58f3d4bd751 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java @@ -20,41 +20,40 @@ public void setUp() { @Test public void spacesReplacedCorrectly() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); + RegexFormatter.setRegex(regexInput); assertEquals("replace-all-spaces", formatter.format("replace all spaces")); } @Test public void protectedSpacesNotReplacedInSingleProtectedBlock() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); + RegexFormatter.setRegex(regexInput); assertEquals("replace-spaces-{not these ones}", formatter.format("replace spaces {not these ones}")); } @Test public void protectedSpacesNotReplacedInTwoProtectedBlocks() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); + RegexFormatter.setRegex(regexInput); assertEquals("replace-spaces-{not these ones}-{or these ones}-but-these-ones", formatter.format("replace spaces {not these ones} {or these ones} but these ones")); } @Test public void escapedBracesAreNotReplaced() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); + RegexFormatter.setRegex(regexInput); assertEquals("replace-spaces-\\{-these-ones\\}-and-these-ones", formatter.format("replace spaces \\{ these ones\\} and these ones")); } @Test public void escapedBracesAreNotReplacedInTwoCases() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); + RegexFormatter.setRegex(regexInput); assertEquals("replace-spaces-\\{-these-ones\\},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces \\{ these ones\\}, these ones, and \\{ these ones\\}")); } @Test public void escapedBracesAreNotReplacedAndProtectionStillWorks() { - String regexInput = "(\" \",\"-\")"; assertEquals("replace-spaces-{not these ones},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces {not these ones}, these ones, and \\{ these ones\\}")); } @@ -62,6 +61,4 @@ public void escapedBracesAreNotReplacedAndProtectionStillWorks() { public void formatExample() { assertEquals("Please-replace-the-spaces", formatter.format(formatter.getExampleInput())); } - - }