diff --git a/CHANGELOG.md b/CHANGELOG.md index 646ffbe4bd9..be3982fb06c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added the ability change the column widths directly in the main table. [#4546](https://github.com/JabRef/jabref/issues/4546) - We added the ability to execute default action in dialog by using with Ctrl + Enter combination [#4496](https://github.com/JabRef/jabref/issues/4496) - We grouped and reordered the Main Menu (File, Edit, Library, Quality, Tools, and View tabs & icons). [#4666](https://github.com/JabRef/jabref/issues/4666) [#4667](https://github.com/JabRef/jabref/issues/4667) [#4668](https://github.com/JabRef/jabref/issues/4668) [#4669](https://github.com/JabRef/jabref/issues/4669) [#4670](https://github.com/JabRef/jabref/issues/4670) [#4671](https://github.com/JabRef/jabref/issues/4671) [#4672](https://github.com/JabRef/jabref/issues/4672) [#4673](https://github.com/JabRef/jabref/issues/4673) - +- We added additional modifiers (capitalize, titlecase and sentencecase) to the Bibtex key generator. [#1506](https://github.com/JabRef/jabref/issues/1506) diff --git a/build.gradle b/build.gradle index ea5d8e813b2..d08efe7b1a2 100644 --- a/build.gradle +++ b/build.gradle @@ -167,7 +167,7 @@ dependencies { testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2' - testCompile 'org.mockito:mockito-core:2.24.5' + testCompile 'org.mockito:mockito-core:2.25.0' testCompile 'com.github.tomakehurst:wiremock:2.21.0' testCompile 'org.assertj:assertj-swing-junit:3.9.2' testCompile 'org.reflections:reflections:0.9.11' diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 2e41bbc7e64..81290cfaab2 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -500,17 +500,8 @@ public boolean quit() { context.getDatabaseFile().map(File::getAbsolutePath).ifPresent(filenames::add); } - // Wait for save operations to finish - for (int i = 0; i < tabbedPane.getTabs().size(); i++) { - if (getBasePanelAt(i).isSaving()) { - // There is a database still being saved, so we need to wait. - WaitForSaveOperation w = new WaitForSaveOperation(this); - w.show(); // This method won't return until canceled or the save operation is done. - if (w.canceled()) { - return false; // The user clicked cancel. - } - } - } + WaitForSaveFinishedDialog waitForSaveFinishedDialog = new WaitForSaveFinishedDialog(dialogService); + waitForSaveFinishedDialog.showAndWait(getBasePanelList()); // Good bye! tearDownJabRef(filenames); diff --git a/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java new file mode 100644 index 00000000000..f8758ab8e1e --- /dev/null +++ b/src/main/java/org/jabref/gui/WaitForSaveFinishedDialog.java @@ -0,0 +1,43 @@ +package org.jabref.gui; + +import java.util.List; + +import javafx.concurrent.Task; + +import org.jabref.logic.l10n.Localization; + +/** + * Dialog shown when closing of application needs to wait for a save operation to finish. + */ +public class WaitForSaveFinishedDialog { + + private final DialogService dialogService; + + public WaitForSaveFinishedDialog(DialogService dialogService) { + this.dialogService = dialogService; + } + + public void showAndWait(List basePanels) { + if (basePanels.stream().anyMatch(BasePanel::isSaving)) { + Task waitForSaveFinished = new Task() { + @Override + protected Void call() throws Exception { + while (basePanels.stream().anyMatch(BasePanel::isSaving)) { + if (isCancelled()) { + return null; + } else { + Thread.sleep(100); + } + } + return null; + } + }; + + dialogService.showProgressDialogAndWait( + Localization.lang("Please wait..."), + Localization.lang("Waiting for save operation to finish") + "...", + waitForSaveFinished + ); + } + } +} diff --git a/src/main/java/org/jabref/gui/WaitForSaveOperation.java b/src/main/java/org/jabref/gui/WaitForSaveOperation.java deleted file mode 100644 index 86b2e0a2f8b..00000000000 --- a/src/main/java/org/jabref/gui/WaitForSaveOperation.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.jabref.gui; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JProgressBar; -import javax.swing.Timer; - -import org.jabref.logic.l10n.Localization; - -import com.jgoodies.forms.builder.ButtonBarBuilder; - -/** - * Dialog shown when closing of application needs to wait for a save operation to finish. - */ -public class WaitForSaveOperation implements ActionListener { - - private final JabRefFrame frame; - private final JDialog diag; - private final Timer t = new Timer(500, this); - private boolean canceled; - - - public WaitForSaveOperation(JabRefFrame frame) { - this.frame = frame; - - JButton cancel = new JButton(Localization.lang("Cancel")); - JProgressBar prog = new JProgressBar(0); - prog.setIndeterminate(true); - prog.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - diag = new JDialog((JFrame) null, Localization.lang("Please wait..."), true); - - ButtonBarBuilder bb = new ButtonBarBuilder(); - bb.addGlue(); - bb.addButton(cancel); - bb.addGlue(); - cancel.addActionListener(e -> { - canceled = true; - t.stop(); - diag.dispose(); - }); - - JLabel message = new JLabel(Localization.lang("Waiting for save operation to finish") + "..."); - message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - - diag.getContentPane().add(message, BorderLayout.NORTH); - diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); - diag.getContentPane().add(prog, BorderLayout.CENTER); - diag.pack(); - } - - public void show() { - t.start(); - diag.setVisible(true); - - } - - public boolean canceled() { - return canceled; - } - - @Override - public void actionPerformed(ActionEvent actionEvent) { - boolean anySaving = false; - for (BasePanel basePanel : frame.getBasePanelList()) { - if (basePanel.isSaving()) { - anySaving = true; - break; - } - } - if (!anySaving) { - t.stop(); - diag.dispose(); - } - } -} diff --git a/src/main/java/org/jabref/gui/WrapLayout.java b/src/main/java/org/jabref/gui/WrapLayout.java deleted file mode 100644 index 999c7abd3f0..00000000000 --- a/src/main/java/org/jabref/gui/WrapLayout.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.jabref.gui; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Insets; - -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; - -/** - * FlowLayout subclass that fully supports wrapping of components. - */ -public class WrapLayout extends FlowLayout { - /** - * Constructs a new WrapLayout with a left - * alignment and a default 5-unit horizontal and vertical gap. - */ - public WrapLayout() { - super(); - } - - /** - * Constructs a new FlowLayout with the specified - * alignment and a default 5-unit horizontal and vertical gap. - * The value of the alignment argument must be one of - * WrapLayout, WrapLayout, - * or WrapLayout. - * @param align the alignment value - */ - public WrapLayout(int align) { - super(align); - } - - /** - * Creates a new flow layout manager with the indicated alignment - * and the indicated horizontal and vertical gaps. - *

- * The value of the alignment argument must be one of - * WrapLayout, WrapLayout, - * or WrapLayout. - * @param align the alignment value - * @param hgap the horizontal gap between components - * @param vgap the vertical gap between components - */ - public WrapLayout(int align, int hgap, int vgap) { - super(align, hgap, vgap); - } - - /** - * Returns the preferred dimensions for this layout given the - * visible components in the specified target container. - * @param target the component which needs to be laid out - * @return the preferred dimensions to lay out the - * subcomponents of the specified container - */ - @Override - public Dimension preferredLayoutSize(Container target) { - return layoutSize(target, true); - } - - /** - * Returns the minimum dimensions needed to layout the visible - * components contained in the specified target container. - * @param target the component which needs to be laid out - * @return the minimum dimensions to lay out the - * subcomponents of the specified container - */ - @Override - public Dimension minimumLayoutSize(Container target) { - Dimension minimum = layoutSize(target, false); - minimum.width -= (getHgap() + 1); - return minimum; - } - - /** - * Returns the minimum or preferred dimension needed to layout the target - * container. - * - * @param target target to get layout size for - * @param preferred should preferred size be calculated - * @return the dimension to layout the target container - */ - private Dimension layoutSize(Container target, boolean preferred) { - synchronized (target.getTreeLock()) { - // Each row must fit with the width allocated to the container. - // When the container width = 0, the preferred width of the container - // has not yet been calculated so lets ask for the maximum. - - int targetWidth = target.getSize().width; - - if (targetWidth == 0) { - targetWidth = Integer.MAX_VALUE; - } - - int hgap = getHgap(); - int vgap = getVgap(); - Insets insets = target.getInsets(); - int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2); - int maxWidth = targetWidth - horizontalInsetsAndGap; - - // Fit components into the allowed width - - Dimension dim = new Dimension(0, 0); - int rowWidth = 0; - int rowHeight = 0; - - int nmembers = target.getComponentCount(); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - - if (m.isVisible()) { - Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize(); - - if (d != null) { - // Can't add the component to current row. Start a new row. - - if ((rowWidth + d.width) > maxWidth) { - addRow(dim, rowWidth, rowHeight); - rowWidth = 0; - rowHeight = 0; - } - - // Add a horizontal gap for all components after the first - - if (rowWidth != 0) { - rowWidth += hgap; - } - - rowWidth += d.width; - rowHeight = Math.max(rowHeight, d.height); - } - } - } - - addRow(dim, rowWidth, rowHeight); - - dim.width += horizontalInsetsAndGap; - dim.height += insets.top + insets.bottom + (vgap * 2); - - // When using a scroll pane or the DecoratedLookAndFeel we need to - // make sure the preferred size is less than the size of the - // target container so shrinking the container size works - // correctly. Removing the horizontal gap is an easy way to do this. - - Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target); - - if (scrollPane != null) { - dim.width -= (hgap + 1); - } - - return dim; - } - } - - /* - * A new row has been completed. Use the dimensions of this row - * to update the preferred size for the container. - * - * @param dim update the width and height when appropriate - * @param rowWidth the width of the row to add - * @param rowHeight the height of the row to add - */ - private void addRow(Dimension dim, int rowWidth, int rowHeight) { - dim.width = Math.max(dim.width, rowWidth); - - if (dim.height > 0) { - dim.height += getVgap(); - } - - dim.height += rowHeight; - } -} diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index b3b10e3aeaa..302bc7359bd 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -65,7 +65,7 @@ public enum StandardActions implements Action { NEW_LIBRARY_BIBLATEX(Localization.lang("New %0 library", BibDatabaseMode.BIBLATEX.getFormattedName())), OPEN_LIBRARY(Localization.lang("Open library"), IconTheme.JabRefIcons.OPEN, KeyBinding.OPEN_DATABASE), IMPORT(Localization.lang("Import"), IconTheme.JabRefIcons.IMPORT), - EXPORT(Localization.lang("Export"), IconTheme.JabRefIcons.EXPORT), + EXPORT(Localization.lang("Export"), IconTheme.JabRefIcons.EXPORT, KeyBinding.EXPORT), MERGE_DATABASE(Localization.lang("Append library"), Localization.lang("Append contents from a BibTeX library into the currently viewed library")), SAVE_LIBRARY(Localization.lang("Save library"), IconTheme.JabRefIcons.SAVE, KeyBinding.SAVE_DATABASE), SAVE_LIBRARY_AS(Localization.lang("Save library as..."), KeyBinding.SAVE_DATABASE_AS), @@ -74,7 +74,7 @@ public enum StandardActions implements Action { IMPORT_INTO_NEW_LIBRARY(Localization.lang("Import into new library"), KeyBinding.IMPORT_INTO_NEW_DATABASE), IMPORT_INTO_CURRENT_LIBRARY(Localization.lang("Import into current library"), KeyBinding.IMPORT_INTO_CURRENT_DATABASE), EXPORT_ALL(Localization.lang("Export all entries")), - EXPORT_SELECTED(Localization.lang("Export selected entries")), + EXPORT_SELECTED(Localization.lang("Export selected entries"), KeyBinding.EXPORT_SELECTED), CONNECT_TO_SHARED_DB(Localization.lang("Connect to shared database"), IconTheme.JabRefIcons.CONNECT_DB), PULL_CHANGES_FROM_SHARED_DB(Localization.lang("Pull changes from shared database"), KeyBinding.PULL_CHANGES_FROM_SHARED_DATABASE), CLOSE_LIBRARY(Localization.lang("Close library"), Localization.lang("Close the current library"), IconTheme.JabRefIcons.CLOSE, KeyBinding.CLOSE_DATABASE), diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java index 994452e5efa..e3796c623ee 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java +++ b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java @@ -15,6 +15,8 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; +import org.jabref.gui.actions.ActionFactory; +import org.jabref.gui.actions.StandardActions; import org.jabref.gui.help.HelpAction; import org.jabref.logic.help.HelpFile; import org.jabref.logic.l10n.Localization; @@ -34,7 +36,6 @@ public class BibtexKeyPatternPanel extends Pane { // default pattern protected final TextField defaultPat = new TextField(); - private final HelpAction help; private final int COLUMNS = 2; @@ -45,7 +46,6 @@ public class BibtexKeyPatternPanel extends Pane { public BibtexKeyPatternPanel(BasePanel panel) { this.panel = panel; - help = new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN); gridPane.setHgap(10); gridPane.setVgap(5); buildGUI(); @@ -93,7 +93,7 @@ private void buildGUI() { textFields.put(type.getName().toLowerCase(Locale.ROOT), textField); - if (columnIndex == COLUMNS - 1) { + if (columnIndex == (COLUMNS - 1)) { columnIndex = 0; rowIndex++; } else { @@ -103,9 +103,9 @@ private void buildGUI() { rowIndex++; - Button help1 = new Button("?"); - help1.setOnAction(e -> new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN).getHelpButton().doClick()); - gridPane.add(help1, 1, rowIndex); + ActionFactory factory = new ActionFactory(Globals.prefs.getKeyBindingRepository()); + Button help = factory.createIconButton(StandardActions.HELP, new HelpAction(Localization.lang("Help on key patterns"), HelpFile.BIBTEX_KEY_PATTERN).getCommand()); + gridPane.add(help, 1, rowIndex); Button btnDefaultAll1 = new Button(Localization.lang("Reset all")); btnDefaultAll1.setOnAction(e -> { @@ -118,7 +118,6 @@ private void buildGUI() { gridPane.add(btnDefaultAll1, 2, rowIndex); } - /** * fill the given LabelPattern by values generated from the text fields */ @@ -140,8 +139,7 @@ private void fillPatternUsingPanelData(AbstractBibtexKeyPattern keypatterns) { protected GlobalBibtexKeyPattern getKeyPatternAsGlobalBibtexKeyPattern() { GlobalBibtexKeyPattern res = GlobalBibtexKeyPattern.fromPattern( - JabRefPreferences.getInstance().get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN) - ); + JabRefPreferences.getInstance().get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)); fillPatternUsingPanelData(res); return res; } @@ -162,7 +160,7 @@ public void setValues(AbstractBibtexKeyPattern keyPattern) { setValue(entry.getValue(), entry.getKey(), keyPattern); } - if (keyPattern.getDefaultValue() == null || keyPattern.getDefaultValue().isEmpty()) { + if ((keyPattern.getDefaultValue() == null) || keyPattern.getDefaultValue().isEmpty()) { defaultPat.setText(""); } else { defaultPat.setText(keyPattern.getDefaultValue().get(0)); diff --git a/src/main/java/org/jabref/gui/help/HelpAction.java b/src/main/java/org/jabref/gui/help/HelpAction.java index ab7ae84e027..e8d410de343 100644 --- a/src/main/java/org/jabref/gui/help/HelpAction.java +++ b/src/main/java/org/jabref/gui/help/HelpAction.java @@ -1,11 +1,7 @@ package org.jabref.gui.help; -import java.awt.Color; -import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -14,7 +10,6 @@ import javax.swing.Action; import javax.swing.Icon; import javax.swing.JButton; -import javax.swing.JLabel; import javax.swing.KeyStroke; import org.jabref.Globals; @@ -91,20 +86,6 @@ public void setHelpFile(HelpFile urlPart) { this.helpPage = urlPart; } - public JLabel getHelpLabel(String labelText) { - JLabel helpLabel = new JLabel("" + labelText + ""); - helpLabel.setForeground(Color.BLUE); - helpLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); - helpLabel.addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - openHelpPage(helpPage); - } - }); - return helpLabel; - } - @Override public void actionPerformed(ActionEvent e) { openHelpPage(helpPage); diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java index 9a87333b386..67bd022cbc0 100644 --- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -35,7 +35,6 @@ import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.util.StandardFileType; -import org.jabref.migrations.FileLinksUpgradeWarning; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; @@ -53,9 +52,6 @@ public class OpenDatabaseAction extends SimpleCommand { // Migrations: // Warning for migrating the Review into the Comment field new MergeReviewIntoCommentAction(), - // External file handling system in version 2.3: - new FileLinksUpgradeWarning(), - // Check for new custom entry types loaded from the BIB file: new CheckForNewEntryTypesAction() ); diff --git a/src/main/java/org/jabref/gui/journals/JournalAbbreviationsUtil.java b/src/main/java/org/jabref/gui/journals/JournalAbbreviationsUtil.java deleted file mode 100644 index 86a284cd78f..00000000000 --- a/src/main/java/org/jabref/gui/journals/JournalAbbreviationsUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.jabref.gui.journals; - -import java.util.Collection; - -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; - -import org.jabref.logic.journals.Abbreviation; -import org.jabref.logic.l10n.Localization; - -public class JournalAbbreviationsUtil { - - private JournalAbbreviationsUtil() { - } - - public static TableModel getTableModel(Collection abbreviations) { - Object[][] cells = new Object[abbreviations.size()][2]; - int row = 0; - for (Abbreviation abbreviation : abbreviations) { - cells[row][0] = abbreviation.getName(); - cells[row][1] = abbreviation.getIsoAbbreviation(); - row++; - } - - return new DefaultTableModel(cells, new Object[] {Localization.lang("Full name"), - Localization.lang("Abbreviation")}) { - - @Override - public boolean isCellEditable(int row1, int column) { - return false; - } - }; - } -} diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java index b73fbc6b0c3..b1b2cbbb4b5 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java @@ -28,6 +28,8 @@ public enum KeyBinding { DEFAULT_DIALOG_ACTION("Execute default action in dialog", Localization.lang("Execute default action in dialog"), "ctrl+ENTER", KeyBindingCategory.VIEW), DOWNLOAD_FULL_TEXT("Look up full text documents", Localization.lang("Look up full text documents"), "alt+F7", KeyBindingCategory.QUALITY), EDIT_ENTRY("Edit entry", Localization.lang("Edit entry"), "ctrl+E", KeyBindingCategory.BIBTEX), + EXPORT("Export", Localization.lang("Export"), "ctrl+alt+e", KeyBindingCategory.FILE), + EXPORT_SELECTED("Export Selected", Localization.lang("Export selected entries"), "ctrl+shift+e", KeyBindingCategory.FILE), EDIT_STRINGS("Edit strings", Localization.lang("Edit strings"), "ctrl+T", KeyBindingCategory.BIBTEX), ENTRY_EDITOR_NEXT_ENTRY("Entry editor, next entry", Localization.lang("Entry editor, next entry"), "alt+DOWN", KeyBindingCategory.VIEW), ENTRY_EDITOR_NEXT_PANEL("Entry editor, next panel", Localization.lang("Entry editor, next panel"), "ctrl+TAB", KeyBindingCategory.VIEW), diff --git a/src/main/java/org/jabref/gui/preferences/AdvancedTab.java b/src/main/java/org/jabref/gui/preferences/AdvancedTab.java index 3fcd0516ce5..4a8dbf0a075 100644 --- a/src/main/java/org/jabref/gui/preferences/AdvancedTab.java +++ b/src/main/java/org/jabref/gui/preferences/AdvancedTab.java @@ -15,6 +15,8 @@ import org.jabref.Globals; import org.jabref.gui.DialogService; +import org.jabref.gui.actions.ActionFactory; +import org.jabref.gui.actions.StandardActions; import org.jabref.gui.help.HelpAction; import org.jabref.gui.remote.JabRefMessageHandler; import org.jabref.gui.util.DefaultTaskExecutor; @@ -76,9 +78,11 @@ public AdvancedTab(DialogService dialogService, JabRefPreferences prefs) { HBox p = new HBox(); p.getChildren().add(useRemoteServer); p.getChildren().add(remoteServerPort); - Button helpButton = new Button("?"); - helpButton.setOnAction(event -> new HelpAction(HelpFile.REMOTE).getHelpButton().doClick()); - p.getChildren().add(helpButton); + + ActionFactory factory = new ActionFactory(preferences.getKeyBindingRepository()); + Button help = factory.createIconButton(StandardActions.HELP, new HelpAction(HelpFile.REMOTE).getCommand()); + help.setMaxWidth(Double.MAX_VALUE); + p.getChildren().add(help); builder.add(p, 2, 9); builder.add(new Label(""), 1, 10); diff --git a/src/main/java/org/jabref/gui/preferences/ExternalTab.java b/src/main/java/org/jabref/gui/preferences/ExternalTab.java index 782a14fa11d..0328eaf4e1b 100644 --- a/src/main/java/org/jabref/gui/preferences/ExternalTab.java +++ b/src/main/java/org/jabref/gui/preferences/ExternalTab.java @@ -1,13 +1,6 @@ package org.jabref.gui.preferences; -import java.awt.BorderLayout; - -import javax.swing.JFileChooser; -import javax.swing.JPanel; - -import javafx.embed.swing.JFXPanel; import javafx.scene.Node; -import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -17,18 +10,19 @@ import javafx.scene.layout.GridPane; import org.jabref.Globals; +import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.customjfx.CustomJFXPanel; import org.jabref.gui.externalfiletype.ExternalFileTypeEditor; import org.jabref.gui.push.PushToApplication; import org.jabref.gui.push.PushToApplicationSettings; import org.jabref.gui.push.PushToApplicationSettingsDialog; import org.jabref.gui.push.PushToApplications; +import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.OS; import org.jabref.preferences.JabRefPreferences; -class ExternalTab extends JPanel implements PrefsTab { +class ExternalTab implements PrefsTab { private final JabRefPreferences prefs; private final TextField emailSubject; @@ -45,12 +39,15 @@ class ExternalTab extends JPanel implements PrefsTab { private final TextField adobeAcrobatReaderPath; private final TextField sumatraReaderPath; private final GridPane builder = new GridPane(); + private final DialogService dialogService; + private final FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().build(); public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPreferences prefs) { this.prefs = prefs; + dialogService = frame.getDialogService(); Button editFileTypes = new Button(Localization.lang("Manage external file types")); citeCommand = new TextField(); - editFileTypes.setOnAction(e->ExternalFileTypeEditor.getAction()); + editFileTypes.setOnAction(e -> ExternalFileTypeEditor.getAction()); defaultConsole = new RadioButton(Localization.lang("Use default terminal emulator")); executeConsole = new RadioButton(Localization.lang("Execute command") + ":"); consoleCommand = new TextField(); @@ -73,25 +70,25 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere final ToggleGroup consoleGroup = new ToggleGroup(); defaultConsole.setToggleGroup(consoleGroup); executeConsole.setToggleGroup(consoleGroup); - consoleOptionPanel.add(defaultConsole, 1, 1); - consoleOptionPanel.add(executeConsole, 1, 2); - consoleOptionPanel.add(consoleCommand, 2, 2); - consoleOptionPanel.add(browseButton, 3, 2); - consoleOptionPanel.add(commandDescription, 2, 3); + consoleOptionPanel.add(defaultConsole, 1, 1); + consoleOptionPanel.add(executeConsole, 1, 2); + consoleOptionPanel.add(consoleCommand, 2, 2); + consoleOptionPanel.add(browseButton, 3, 2); + consoleOptionPanel.add(commandDescription, 2, 3); GridPane pdfOptionPanel = new GridPane(); final ToggleGroup pdfReaderGroup = new ToggleGroup(); - pdfOptionPanel.add(adobeAcrobatReader, 1, 1); - pdfOptionPanel.add(adobeAcrobatReaderPath, 2, 1); + pdfOptionPanel.add(adobeAcrobatReader, 1, 1); + pdfOptionPanel.add(adobeAcrobatReaderPath, 2, 1); adobeAcrobatReader.setToggleGroup(pdfReaderGroup); - pdfOptionPanel.add(browseAdobeAcrobatReader, 3, 1); + pdfOptionPanel.add(browseAdobeAcrobatReader, 3, 1); if (OS.WINDOWS) { browseSumatraReader.setOnAction(e -> showSumatraChooser()); - pdfOptionPanel.add(sumatraReader, 1, 2); + pdfOptionPanel.add(sumatraReader, 1, 2); sumatraReader.setToggleGroup(pdfReaderGroup); - pdfOptionPanel.add(sumatraReaderPath, 2, 2); - pdfOptionPanel.add(browseSumatraReader, 3, 2); + pdfOptionPanel.add(sumatraReaderPath, 2, 2); + pdfOptionPanel.add(browseSumatraReader, 3, 2); } Label sendingOfEmails = new Label(Localization.lang("Sending of emails")); @@ -132,14 +129,13 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere Label openPdf = new Label(Localization.lang("Open PDF")); openPdf.getStyleClass().add("sectionHeader"); - builder.add(openPdf, 1, 12); + builder.add(openPdf, 1, 12); builder.add(pdfOptionPanel, 1, 13); - JFXPanel panel = CustomJFXPanel.wrap(new Scene(builder)); - setLayout(new BorderLayout()); - add(panel, BorderLayout.CENTER); + } + @Override public Node getBuilder() { return builder; } @@ -149,10 +145,10 @@ private void addSettingsButton(final PushToApplication application, GridPane pan Button button = new Button(Localization.lang("Settings for %0", application.getApplicationName())); button.setPrefSize(150, 20); button.setOnAction(e -> PushToApplicationSettingsDialog.showSettingsDialog(null, settings, index)); - if (index % 2 == 0) { - panel.add(button, 1, index / 2 + 1); + if ((index % 2) == 0) { + panel.add(button, 1, (index / 2) + 1); } else { - panel.add(button, 2, index / 2 + 1); + panel.add(button, 2, (index / 2) + 1); } } @@ -213,27 +209,15 @@ private void updateExecuteConsoleButtonAndFieldEnabledState() { } private void showConsoleChooser() { - JFileChooser consoleChooser = new JFileChooser(); - int answer = consoleChooser.showOpenDialog(ExternalTab.this); - if (answer == JFileChooser.APPROVE_OPTION) { - consoleCommand.setText(consoleChooser.getSelectedFile().getAbsolutePath()); - } + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> consoleCommand.setText(file.toAbsolutePath().toString())); } private void showAdobeChooser() { - JFileChooser adobeChooser = new JFileChooser(); - int answer = adobeChooser.showOpenDialog(ExternalTab.this); - if (answer == JFileChooser.APPROVE_OPTION) { - adobeAcrobatReaderPath.setText(adobeChooser.getSelectedFile().getAbsolutePath()); - } + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> adobeAcrobatReaderPath.setText(file.toAbsolutePath().toString())); } private void showSumatraChooser() { - JFileChooser adobeChooser = new JFileChooser(); - int answer = adobeChooser.showOpenDialog(ExternalTab.this); - if (answer == JFileChooser.APPROVE_OPTION) { - sumatraReaderPath.setText(adobeChooser.getSelectedFile().getAbsolutePath()); - } + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> sumatraReaderPath.setText(file.toAbsolutePath().toString())); } private void readerSelected() { diff --git a/src/main/java/org/jabref/gui/preferences/ImportSettingsTab.java b/src/main/java/org/jabref/gui/preferences/ImportSettingsTab.java index 3067882b2c2..80873eab063 100644 --- a/src/main/java/org/jabref/gui/preferences/ImportSettingsTab.java +++ b/src/main/java/org/jabref/gui/preferences/ImportSettingsTab.java @@ -9,24 +9,20 @@ import javafx.scene.control.Separator; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; -import javafx.scene.layout.Pane; import org.jabref.logic.l10n.Localization; import org.jabref.preferences.JabRefPreferences; -public class ImportSettingsTab extends Pane implements PrefsTab { +public class ImportSettingsTab implements PrefsTab { public static final String[] DEFAULT_FILENAMEPATTERNS = new String[] {"[bibtexkey]", - "[bibtexkey] - [title]"}; - - private static final String[] DEFAULT_FILENAMEPATTERNS_DISPLAY = new String[] {"bibtexkey", "bibtexkey - title",}; + "[bibtexkey] - [title]"}; private final JabRefPreferences prefs; private final GridPane builder = new GridPane(); private final TextField fileNamePattern; private final ComboBox selectFileNamePattern; - private final TextField fileDirPattern; public ImportSettingsTab(JabRefPreferences prefs) { @@ -35,8 +31,9 @@ public ImportSettingsTab(JabRefPreferences prefs) { fileNamePattern = new TextField(); fileDirPattern = new TextField(); selectFileNamePattern = new ComboBox<>(); - selectFileNamePattern.getItems().addAll(FXCollections.observableArrayList(DEFAULT_FILENAMEPATTERNS_DISPLAY)); + selectFileNamePattern.getItems().addAll(FXCollections.observableArrayList(DEFAULT_FILENAMEPATTERNS)); selectFileNamePattern.setValue(Localization.lang("Choose pattern")); + selectFileNamePattern.setOnAction(e -> { fileNamePattern.setText(selectFileNamePattern.getValue()); }); @@ -60,6 +57,7 @@ public ImportSettingsTab(JabRefPreferences prefs) { builder.add(fileDirPattern, 2, 10); } + @Override public Node getBuilder() { return builder; } diff --git a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java index cda929568d2..0de338a1f0f 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java +++ b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java @@ -31,9 +31,9 @@ * same style. Changing the output format is cheap. * @implNote The main function {@link #makeBibliography} will enforce * synchronized calling. The main CSL engine under the hood is not thread-safe. Since this class is usually called from - * a SwingWorker, the only other option would be to create several CSL instances which is wasting a lot of resources and very slow. + * a BackgroundTakk, the only other option would be to create several CSL instances which is wasting a lot of resources and very slow. * In the current scheme, {@link #makeBibliography} can be called as usual - * SwingWorker task and to the best of my knowledge, concurrent calls will pile up and processed sequentially. + * background task and to the best of my knowledge, concurrent calls will pile up and processed sequentially. */ public class CSLAdapter { @@ -63,7 +63,7 @@ public synchronized List makeBibliography(List bibEntries, Str * @throws IOException An error occurred in the underlying JavaScript framework */ private void initialize(String newStyle, CitationStyleOutputFormat newFormat) throws IOException { - if (cslInstance == null || !Objects.equals(newStyle, style)) { + if ((cslInstance == null) || !Objects.equals(newStyle, style)) { // lang and forceLang are set to the default values of other CSL constructors cslInstance = new CSL(dataProvider, new JabRefLocaleProvider(), newStyle, "en-US", false); style = newStyle; @@ -81,7 +81,7 @@ private void initialize(String newStyle, CitationStyleOutputFormat newFormat) th */ private static class JabRefItemDataProvider implements ItemDataProvider { - private ArrayList data = new ArrayList<>(); + private final ArrayList data = new ArrayList<>(); /** * Converts the {@link BibEntry} into {@link CSLItemData}. diff --git a/src/main/java/org/jabref/logic/formatter/Formatters.java b/src/main/java/org/jabref/logic/formatter/Formatters.java index 4e1d25f968f..9e867ac23ed 100644 --- a/src/main/java/org/jabref/logic/formatter/Formatters.java +++ b/src/main/java/org/jabref/logic/formatter/Formatters.java @@ -87,6 +87,12 @@ public static Optional getFormatterForModifier(String modifier) { return Optional.of(new LowerCaseFormatter()); case "upper": return Optional.of(new UpperCaseFormatter()); + case "capitalize": + return Optional.of(new CapitalizeFormatter()); + case "titlecase": + return Optional.of(new TitleCaseFormatter()); + case "sentencecase": + return Optional.of(new SentenceCaseFormatter()); } if (modifier.startsWith(RegexFormatter.KEY)) { diff --git a/src/main/java/org/jabref/logic/msbib/MsBibAuthor.java b/src/main/java/org/jabref/logic/msbib/MsBibAuthor.java index caad384ec22..8da1d4e49ca 100644 --- a/src/main/java/org/jabref/logic/msbib/MsBibAuthor.java +++ b/src/main/java/org/jabref/logic/msbib/MsBibAuthor.java @@ -48,7 +48,7 @@ public String getMiddleName() { } public String getLastName() { - return author.getLast().orElse(null); + return author.getLastOnly(); } public String getFirstLast() { diff --git a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java deleted file mode 100644 index eed9497457e..00000000000 --- a/src/main/java/org/jabref/migrations/FileLinksUpgradeWarning.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.jabref.migrations; - -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import org.jabref.Globals; -import org.jabref.gui.BasePanel; -import org.jabref.gui.DialogService; -import org.jabref.gui.FXDialogService; -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; -import org.jabref.model.FieldChange; -import org.jabref.model.database.BibDatabase; -import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FieldName; -import org.jabref.model.metadata.FilePreferences; -import org.jabref.preferences.JabRefPreferences; - -import com.jgoodies.forms.builder.FormBuilder; -import com.jgoodies.forms.layout.FormLayout; - -/** - * This class defines the warning that can be offered when opening a pre-2.3 - * JabRef file into a later version. This warning mentions the new external file - * link system in this version of JabRef, and offers to: - * - * * upgrade old-style PDF/PS links into the "file" field - * * modify General fields to show "file" instead of "pdf" / "ps" - * * modify table column settings to show "file" instead of "pdf" / "ps" - */ -public class FileLinksUpgradeWarning implements GUIPostOpenAction { - - private static final String[] FIELDS_TO_LOOK_FOR = new String[]{FieldName.PDF, FieldName.PS}; - - private boolean offerChangeSettings; - - private boolean offerChangeDatabase; - - private boolean offerSetFileDir; - - /** - * Collect file links from the given set of fields, and add them to the list contained in the field - * GUIGlobals.FILE_FIELD. - * - * @param database The database to modify. - * @return A CompoundEdit specifying the undo operation for the whole operation. - */ - private static NamedCompound upgradePdfPsToFile(BibDatabase database) { - NamedCompound ce = new NamedCompound(Localization.lang("Move external links to 'file' field")); - - UpgradePdfPsToFileCleanup cleanupJob = new UpgradePdfPsToFileCleanup(); - for (BibEntry entry : database.getEntries()) { - List changes = cleanupJob.cleanup(entry); - - for (FieldChange change : changes) { - ce.addEdit(new UndoableFieldChange(change)); - } - } - - ce.end(); - return ce; - } - - /** - * This method should be performed if the major/minor versions recorded in the ParserResult - * are less than or equal to 2.2. - * - * @return true if the file was written by a jabref version <=2.2 - */ - @Override - public boolean isActionNecessary(ParserResult pr) { - // Find out which actions should be offered: - // Only offer to change Preferences if file column is not already visible: - offerChangeSettings = !Globals.prefs.getBoolean(JabRefPreferences.FILE_COLUMN) || !showsFileInGenFields(); - // Only offer to upgrade links if the pdf/ps fields are used: - offerChangeDatabase = linksFound(pr.getDatabase(), FileLinksUpgradeWarning.FIELDS_TO_LOOK_FOR); - // If the "file" directory is not set, offer to migrate pdf/ps dir: - offerSetFileDir = !Globals.prefs.hasKey(FieldName.FILE + FilePreferences.DIR_SUFFIX) - && (Globals.prefs.hasKey(FieldName.PDF + FilePreferences.DIR_SUFFIX) - || Globals.prefs.hasKey(FieldName.PS + FilePreferences.DIR_SUFFIX)); - - // First check if this warning is disabled: - return Globals.prefs.getBoolean(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING) - && isThereSomethingToBeDone(); - } - - /* - * This method presents a dialog box explaining and offering to make the - * changes. If the user confirms, the changes are performed. - */ - @Override - public void performAction(BasePanel panel, ParserResult parserResult) { - - 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"), - offerChangeSettings); - 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); - JTextField fileDir = new JTextField(30); - JCheckBox doNotShowDialog = new JCheckBox(Localization.lang("Do not show these options in the future"), - false); - - JPanel message = new JPanel(); - FormBuilder formBuilder = FormBuilder.create().layout(new FormLayout("left:pref", "p")); - // Keep the formatting of these lines. Otherwise, strings have to be translated again. - // 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("Do you want JabRef to do the following operations?") + "")).xy(1, row); - - if (offerChangeSettings) { - formBuilder.appendRows("2dlu, p"); - row += 2; - formBuilder.add(changeSettings).xy(1, row); - } - if (offerChangeDatabase) { - formBuilder.appendRows("2dlu, p"); - row += 2; - formBuilder.add(changeDatabase).xy(1, row); - } - if (offerSetFileDir) { - if (Globals.prefs.hasKey(FieldName.PDF + FilePreferences.DIR_SUFFIX)) { - fileDir.setText(Globals.prefs.get(FieldName.PDF + FilePreferences.DIR_SUFFIX)); - } else { - fileDir.setText(Globals.prefs.get(FieldName.PS + FilePreferences.DIR_SUFFIX)); - } - JPanel builderPanel = new JPanel(); - 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())))); - builderPanel.add(browse); - formBuilder.appendRows("2dlu, p"); - row += 2; - formBuilder.add(builderPanel).xy(1, row); - } - formBuilder.appendRows("6dlu, p"); - formBuilder.add(doNotShowDialog).xy(1, row + 2); - - message.add(formBuilder.build()); - - int answer = JOptionPane.showConfirmDialog(null, - message, Localization.lang("Upgrade file"), JOptionPane.YES_NO_OPTION); - if (doNotShowDialog.isSelected()) { - Globals.prefs.putBoolean(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING, false); - } - - if (answer == JOptionPane.YES_OPTION) { - makeChanges(panel, parserResult, changeSettings.isSelected(), changeDatabase.isSelected(), - setFileDir.isSelected() ? fileDir.getText() : null); - } - } - - private boolean isThereSomethingToBeDone() { - return offerChangeSettings || offerChangeDatabase || offerSetFileDir; - } - - /** - * Check the database to find out whether any of a set of fields are used - * for any of the entries. - * - * @param database The BIB database. - * @param fields The set of fields to look for. - * @return true if at least one of the given fields is set in at least one entry, - * false otherwise. - */ - private boolean linksFound(BibDatabase database, String[] fields) { - for (BibEntry entry : database.getEntries()) { - for (String field : fields) { - if (entry.hasField(field)) { - return true; - } - } - } - return false; - } - - /** - * This method performs the actual changes. - * - * @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) { - - if (upgradeDatabase) { - // Update file links links in the database: - NamedCompound ce = upgradePdfPsToFile(pr.getDatabase()); - panel.getUndoManager().addEdit(ce); - panel.markBaseChanged(); - } - - if (fileDir != null) { - Globals.prefs.put(FieldName.FILE + FilePreferences.DIR_SUFFIX, fileDir); - } - - if (upgradePrefs) { - // Exchange table columns: - Globals.prefs.putBoolean(JabRefPreferences.FILE_COLUMN, Boolean.TRUE); - - // Modify General fields if necessary: - // If we don't find the file field, insert it at the bottom of the first tab: - if (!showsFileInGenFields()) { - String gfs = Globals.prefs.get(JabRefPreferences.CUSTOM_TAB_FIELDS + "0"); - StringBuilder sb = new StringBuilder(gfs); - if (!gfs.isEmpty()) { - sb.append(';'); - } - sb.append(FieldName.FILE); - Globals.prefs.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "0", sb.toString()); - Globals.prefs.updateEntryEditorTabList(); - } - panel.frame().setupAllTables(); - } - } - - private boolean showsFileInGenFields() { - for (List fields : Globals.prefs.getEntryEditorTabList().values()) { - for (String field : fields) { - if (field.equals(FieldName.FILE)) { - return true; - } - } - } - return false; - } -} diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index f0923915177..70a4357ef3b 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -237,10 +237,16 @@ static void upgradeImportFileAndDirePatterns(JabRefPreferences prefs, Preference String[] oldStylePatterns = new String[] {"\\bibtexkey", "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; String[] newStylePatterns = new String[] {"[bibtexkey]", - "[bibtexkey] - [fulltitle]"}; + "[bibtexkey] - [title]"}; + + String[] oldDisplayStylePattern = new String[] {"bibtexkey", "bibtexkey - title",}; + for (int i = 0; i < oldStylePatterns.length; i++) { migrateFileImportPattern(oldStylePatterns[i], newStylePatterns[i], prefs, mainPrefsNode); } + for (int i = 0; i < oldDisplayStylePattern.length; i++) { + migrateFileImportPattern(oldDisplayStylePattern[i], newStylePatterns[i], prefs, mainPrefsNode); + } } // Directory preferences are not yet migrated, since it is not quote clear how to parse and reinterpret // the user defined old-style patterns, and the default pattern is "". diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 8c0d5cedea9..b7f8e0dd5ea 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -137,8 +137,6 @@ Change\ of\ Grouping\ Method=Change of Grouping Method change\ preamble=change preamble -Change\ table\ column\ and\ General\ fields\ settings\ to\ use\ the\ new\ feature=Change table column and General fields settings to use the new feature - Changed\ language\ settings=Changed language settings Changed\ preamble=Changed preamble @@ -283,13 +281,10 @@ Do\ not\ import\ entry=Do not import entry Do\ not\ open\ any\ files\ at\ startup=Do not open any files at startup Do\ not\ overwrite\ existing\ keys=Do not overwrite existing keys -Do\ not\ show\ these\ options\ in\ the\ future=Do not show these options in the future Do\ not\ wrap\ the\ following\ fields\ when\ saving=Do not wrap the following fields when saving Do\ not\ write\ the\ following\ fields\ to\ XMP\ Metadata\:=Do not write the following fields to XMP Metadata: -Do\ you\ want\ JabRef\ to\ do\ the\ following\ operations?=Do you want JabRef to do the following operations? - Donate\ to\ JabRef=Donate to JabRef Down=Down @@ -439,8 +434,6 @@ Formatter\ name=Formatter name found\ in\ AUX\ file=found in AUX file -Full\ name=Full name - Further\ information\ about\ Mr\ DLib.\ for\ JabRef\ users.=Further information about Mr DLib. for JabRef users. General=General @@ -619,8 +612,6 @@ Modify=Modify Move\ down=Move down -Move\ external\ links\ to\ 'file'\ field=Move external links to 'file' field - move\ group=move group Move\ up=Move up @@ -918,8 +909,6 @@ Set\ fields=Set fields Set\ General\ Fields=Set General Fields -Set\ main\ external\ file\ directory=Set main external file directory - Settings=Settings Shortcut=Shortcut @@ -1062,8 +1051,6 @@ untitled=untitled Up=Up Upgrade\ external\ PDF/PS\ links\ to\ use\ the\ '%0'\ field.=Upgrade external PDF/PS links to use the '%0' field. -Upgrade\ file=Upgrade file -Upgrade\ old\ external\ file\ links\ to\ use\ the\ new\ feature=Upgrade old external file links to use the new feature usage=usage Use\ autocompletion\ for\ the\ following\ fields=Use autocompletion for the following fields @@ -1553,8 +1540,6 @@ This\ search\ contains\ entries\ in\ which\ any\ field\ contains\ the\ term\ This\ search\ contains\ entries\ in\ which=This search contains entries in which Unable\ to\ autodetect\ OpenOffice/LibreOffice\ installation.\ Please\ choose\ the\ installation\ directory\ manually.=Unable to autodetect OpenOffice/LibreOffice installation. Please choose the installation directory manually. -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 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.

-This\ library\ uses\ outdated\ file\ links.=This library uses outdated file links. Close\ library=Close library Decrease\ table\ font\ size=Decrease table font size diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 4ed5b5bb728..f09b091fb7e 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -1007,4 +1007,58 @@ public void generateKeyWithTwoModifiers() throws Exception { entry.setField("title", "The Interesting Title"); assertEquals("theinterestingtitle", BibtexKeyGenerator.generateKey(entry, "title:lower:(_)")); } + + @Test + public void generateKeyWithTitleCapitalizeModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("title", "the InTeresting title longer than THREE words"); + assertEquals("TheInterestingTitleLongerThanThreeWords", BibtexKeyGenerator.generateKey(entry, "title:capitalize")); + } + + @Test + public void generateKeyWithShortTitleCapitalizeModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("title", "the InTeresting title longer than THREE words"); + assertEquals("InterestingTitleLonger", BibtexKeyGenerator.generateKey(entry, "shorttitle:capitalize")); + } + + @Test + public void generateKeyWithTitleTitleCaseModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("title", "A title WITH some of The key words"); + assertEquals("ATitlewithSomeoftheKeyWords", BibtexKeyGenerator.generateKey(entry, "title:titlecase")); + } + + @Test + public void generateKeyWithShortTitleTitleCaseModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("title", "the InTeresting title longer than THREE words"); + assertEquals("InterestingTitleLonger", BibtexKeyGenerator.generateKey(entry, "shorttitle:titlecase")); + } + + @Test + public void generateKeyWithTitleSentenceCaseModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("title", "A title WITH some of The key words"); + assertEquals("Atitlewithsomeofthekeywords", BibtexKeyGenerator.generateKey(entry, "title:sentencecase")); + } + + @Test + public void generateKeyWithAuthUpperYearShortTitleCapitalizeModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("author", AUTHOR_STRING_FIRSTNAME_FULL_LASTNAME_FULL_COUNT_1); + entry.setField("year", "2019"); + entry.setField("title", "the InTeresting title longer than THREE words"); + assertEquals("NEWTON2019InterestingTitleLonger", BibtexKeyGenerator.generateKey(entry, "[auth:upper][year][shorttitle:capitalize]")); + } + + @Test + public void generateKeyWithYearAuthUpperTitleSentenceCaseModifier() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField("author", AUTHOR_STRING_FIRSTNAME_FULL_LASTNAME_FULL_COUNT_3); + entry.setField("year", "2019"); + entry.setField("title", "the InTeresting title longer than THREE words"); + assertEquals("NewtonMaxwellEtAl_2019_TheInterestingTitleLongerThanThreeWords", BibtexKeyGenerator.generateKey(entry, "[authors2]_[year]_[title:capitalize]")); + } + } diff --git a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java index cbb37c47408..8736b6542e1 100644 --- a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java +++ b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java @@ -44,4 +44,11 @@ public void testGetLastName() { MsBibAuthor msBibAuthor = new MsBibAuthor(author); assertEquals("Bach", msBibAuthor.getLastName()); } + + @Test + public void testGetVonAndLastName() { + Author author = new Author("John", null, "von", "Neumann", null); + MsBibAuthor msBibAuthor = new MsBibAuthor(author); + assertEquals("von Neumann", msBibAuthor.getLastName()); + } } diff --git a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java b/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java index c646bab55bb..6a2ee9bc5e8 100644 --- a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java +++ b/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java @@ -20,7 +20,7 @@ class PreferencesMigrationsTest { private final String[] oldStylePatterns = new String[]{"\\bibtexkey", "\\bibtexkey\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"}; private final String[] newStylePatterns = new String[]{"[bibtexkey]", - "[bibtexkey] - [fulltitle]"}; + "[bibtexkey] - [title]"}; @BeforeEach void setUp() {