diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index c6501ec7da9..7d4900ab67a 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -190,7 +190,6 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService, externalFileTypes); frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview); - } @Subscribe @@ -464,11 +463,12 @@ private void copyTitle() { output(Localization.lang("None of the selected entries have titles.")); return; } - Globals.clipboardManager.setContent(String.join("\n", titles)); + final String copiedTitles = String.join("\n", titles); + Globals.clipboardManager.setContent(copiedTitles); if (titles.size() == selectedBibEntries.size()) { // All entries had titles. - output((selectedBibEntries.size() > 1 ? Localization.lang("Copied titles") : Localization.lang("Copied title")) + '.'); + output(Localization.lang("Copied") + " '" + JabRefDialogService.shortenDialogMessage(copiedTitles) + "'."); } else { output(Localization.lang("Warning: %0 out of %1 entries have undefined title.", Integer.toString(selectedBibEntries.size() - titles.size()), Integer.toString(selectedBibEntries.size()))); } @@ -488,15 +488,15 @@ private void copyCiteKey() { return; } - String sb = String.join(",", keys); String citeCommand = Optional.ofNullable(Globals.prefs.get(JabRefPreferences.CITE_COMMAND)) .filter(cite -> cite.contains("\\")) // must contain \ .orElse("\\cite"); - Globals.clipboardManager.setContent(citeCommand + "{" + sb + '}'); + final String copiedCiteCommand = citeCommand + "{" + String.join(",", keys) + '}'; + Globals.clipboardManager.setContent(copiedCiteCommand); if (keys.size() == bes.size()) { // All entries had keys. - output(bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key") + '.'); + output(Localization.lang("Copied") + " '" + JabRefDialogService.shortenDialogMessage(copiedCiteCommand) + "'."); } else { output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.", Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size()))); } @@ -516,11 +516,12 @@ private void copyKey() { return; } - Globals.clipboardManager.setContent(String.join(",", keys)); + final String copiedKeys = String.join(",", keys); + Globals.clipboardManager.setContent(copiedKeys); if (keys.size() == bes.size()) { // All entries had keys. - output((bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.'); + output(Localization.lang("Copied") + " '" + JabRefDialogService.shortenDialogMessage(copiedKeys) + "'."); } else { output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.", Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size()))); } @@ -557,11 +558,12 @@ private void copyKeyAndTitle() { return; } - Globals.clipboardManager.setContent(sb.toString()); + final String copiedKeysAndTitles = sb.toString(); + Globals.clipboardManager.setContent(copiedKeysAndTitles); if (copied == bes.size()) { // All entries had keys. - output((bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.'); + output(Localization.lang("Copied") + " '" + JabRefDialogService.shortenDialogMessage(copiedKeysAndTitles) + "'."); } else { output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.", Integer.toString(bes.size() - copied), Integer.toString(bes.size()))); } @@ -952,7 +954,7 @@ public void entryEditorClosing(EntryEditor editor) { */ public void ensureNotShowingBottomPanel(BibEntry entry) { if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry)) - || ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) { + || ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) { closeBottomPane(); } } diff --git a/src/main/java/org/jabref/gui/FXDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java similarity index 96% rename from src/main/java/org/jabref/gui/FXDialogService.java rename to src/main/java/org/jabref/gui/JabRefDialogService.java index 579b4de8bdd..ca3f0deec4c 100644 --- a/src/main/java/org/jabref/gui/FXDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -55,15 +55,16 @@ * rather than complex windows. For more complex dialogs it is * advised to rather create a new sub class of {@link FXDialog}. */ -public class FXDialogService implements DialogService { +public class JabRefDialogService implements DialogService { + // Snackbar dialog maximum size + public static final int DIALOG_SIZE_LIMIT = 300; private static final Duration TOAST_MESSAGE_DISPLAY_TIME = Duration.millis(3000); - private static final Logger LOGGER = LoggerFactory.getLogger(FXDialogService.class); - + private static final Logger LOGGER = LoggerFactory.getLogger(JabRefDialogService.class); private final Window mainWindow; private final JFXSnackbar statusLine; - public FXDialogService(Window mainWindow, Pane mainPane) { + public JabRefDialogService(Window mainWindow, Pane mainPane) { this.mainWindow = mainWindow; this.statusLine = new JFXSnackbar(mainPane); } @@ -109,6 +110,13 @@ protected Node createDetailsButton() { return alert; } + public static String shortenDialogMessage(String dialogMessage) { + if (dialogMessage.length() < JabRefDialogService.DIALOG_SIZE_LIMIT) { + return dialogMessage.trim(); + } + return (dialogMessage.substring(0, Math.min(dialogMessage.length(), JabRefDialogService.DIALOG_SIZE_LIMIT)) + "...").trim(); + } + @Override public Optional showChoiceDialogAndWait(String title, String content, String okButtonLabel, T defaultChoice, Collection choices) { ChoiceDialog choiceDialog = new ChoiceDialog<>(defaultChoice, choices); @@ -118,7 +126,6 @@ public Optional showChoiceDialogAndWait(String title, String content, Str choiceDialog.setTitle(title); choiceDialog.setContentText(content); return choiceDialog.showAndWait(); - } @Override diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index abc4abf83a2..9b2a792ec93 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -175,7 +175,7 @@ public class JabRefFrame extends BorderPane { public JabRefFrame(Stage mainStage) { this.mainStage = mainStage; - this.dialogService = new FXDialogService(mainStage, this); + this.dialogService = new JabRefDialogService(mainStage, this); } /** diff --git a/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java b/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java index 49c8a5f46ec..9c6b1e21f4a 100644 --- a/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java +++ b/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java @@ -5,6 +5,7 @@ import org.jabref.JabRefGUI; import org.jabref.gui.ClipBoardManager; +import org.jabref.gui.JabRefDialogService; import org.jabref.gui.maintable.MainTable; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.l10n.Localization; @@ -46,14 +47,14 @@ public void action() throws Exception { sb.append(url.isEmpty() ? key : String.format("%s", url, key)); sb.append(OS.NEWLINE); } - - DefaultTaskExecutor.runInJavaFXThread(() -> clipboardManager.setHtmlContent(sb.toString())); + final String keyAndLink = sb.toString(); + DefaultTaskExecutor.runInJavaFXThread(() -> clipboardManager.setHtmlContent(keyAndLink)); int copied = entriesWithKey.size(); int toCopy = entries.size(); if (copied == toCopy) { // All entries had keys. - JabRefGUI.getMainFrame().getDialogService().notify((entries.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.'); + JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Copied") + " '" + JabRefDialogService.shortenDialogMessage(keyAndLink) + "'."); } else { JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.", Long.toString(toCopy - copied), Integer.toString(toCopy))); diff --git a/src/main/java/org/jabref/gui/worker/CitationStyleToClipboardWorker.java b/src/main/java/org/jabref/gui/worker/CitationStyleToClipboardWorker.java index 6308ce55d7a..21b272eaff2 100644 --- a/src/main/java/org/jabref/gui/worker/CitationStyleToClipboardWorker.java +++ b/src/main/java/org/jabref/gui/worker/CitationStyleToClipboardWorker.java @@ -54,7 +54,6 @@ public CitationStyleToClipboardWorker(BasePanel basePanel, CitationStyleOutputFo } public void copyCitationStyleToClipboard(TaskExecutor taskExecutor) { - dialogService.notify(Localization.lang("Copying...")); BackgroundTask.wrap(this::generateCitations) .onFailure(ex -> LOGGER.error("Error while copying citations to the clipboard", ex)) .onSuccess(this::setClipBoardContent) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 88eae71f20a..e7ea9515206 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -355,7 +355,6 @@ public class JabRefPreferences implements PreferencesService { // Id Entry Generator Preferences public static final String ID_ENTRY_GENERATOR = "idEntryGenerator"; - //File linking Options for entry editor public static final String ENTRY_EDITOR_DRAG_DROP_PREFERENCE_TYPE = "DragDropPreferenceType"; diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 7398d8fc491..e13a18398fd 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -154,13 +154,6 @@ Content=Content Copied=Copied -Copied\ title=Copied title - -Copied\ key=Copied key - -Copied\ titles=Copied titles - -Copied\ keys=Copied keys Copy=Copy @@ -1869,7 +1862,6 @@ Different\ customization,\ current\ settings\ will\ be\ overwritten=Different cu Entry\ type\ %0\ is\ only\ defined\ for\ Biblatex\ but\ not\ for\ BibTeX=Entry type %0 is only defined for Biblatex but not for BibTeX Copied\ %0\ citations.=Copied %0 citations. -Copying...=Copying... journal\ not\ found\ in\ abbreviation\ list=journal not found in abbreviation list Unhandled\ exception\ occurred.=Unhandled exception occurred.