From 6907f80598d16d5d0b9a4dc36f296c429c022a0d Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:28:32 +0100 Subject: [PATCH] Introduced UiCommands to replace clumsy gui interface --- build.gradle | 6 +- .../org/jabref/cli/ArgumentProcessor.java | 35 ++-- src/main/java/org/jabref/cli/Launcher.java | 13 +- src/main/java/org/jabref/gui/JabRefFrame.java | 128 ++++++++++++++ src/main/java/org/jabref/gui/JabRefGUI.java | 163 +----------------- src/main/java/org/jabref/gui/LibraryTab.java | 2 +- .../java/org/jabref/gui/MainApplication.java | 13 +- .../jabref/gui/remote/CLIMessageHandler.java | 13 +- src/main/java/org/jabref/logic/UiCommand.java | 15 ++ .../jabref/logic/importer/ParserResult.java | 9 - 10 files changed, 189 insertions(+), 208 deletions(-) create mode 100644 src/main/java/org/jabref/logic/UiCommand.java diff --git a/build.gradle b/build.gradle index 594caf871c1..8705f41aaf0 100644 --- a/build.gradle +++ b/build.gradle @@ -41,15 +41,15 @@ group = "org.jabref" version = project.findProperty('projVersion') ?: '100.0.0' java { - sourceCompatibility = JavaVersion.VERSION_19 - targetCompatibility = JavaVersion.VERSION_19 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 // Workaround needed for Eclipse, probably because of https://github.com/gradle/gradle/issues/16922 // Should be removed as soon as Gradle 7.0.1 is released ( https://github.com/gradle/gradle/issues/16922#issuecomment-828217060 ) modularity.inferModulePath.set(false) toolchain { // If this is updated, also update .devcontainer/devcontainer.json#L34 - languageVersion = JavaLanguageVersion.of(20) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/src/main/java/org/jabref/cli/ArgumentProcessor.java b/src/main/java/org/jabref/cli/ArgumentProcessor.java index 580cd5870df..7016b397cde 100644 --- a/src/main/java/org/jabref/cli/ArgumentProcessor.java +++ b/src/main/java/org/jabref/cli/ArgumentProcessor.java @@ -16,6 +16,7 @@ import org.jabref.gui.externalfiles.AutoSetFileLinksUtil; import org.jabref.gui.undo.NamedCompound; import org.jabref.logic.JabRefException; +import org.jabref.logic.UiCommand; import org.jabref.logic.bibtex.FieldPreferences; import org.jabref.logic.citationkeypattern.CitationKeyGenerator; import org.jabref.logic.exporter.AtomicFileWriter; @@ -64,28 +65,31 @@ import org.slf4j.LoggerFactory; public class ArgumentProcessor { - private static final Logger LOGGER = LoggerFactory.getLogger(ArgumentProcessor.class); - private final JabRefCLI cli; - // Written once by processArguments() - private List parserResults = List.of(); + public enum Mode { INITIAL_START, REMOTE_START } + + private final JabRefCLI cli; private final Mode startupMode; + private final PreferencesService preferencesService; private final FileUpdateMonitor fileUpdateMonitor; private final BibEntryTypesManager entryTypesManager; + private boolean noGUINeeded; + private final List uiCommands = new ArrayList<>(); /** * First call the constructor, then call {@link #processArguments()}. - * Afterward, you can access the {@link #getParserResults()} and other getters. + * Afterward, you can access the {@link #getUiCommands()}. */ public ArgumentProcessor(String[] args, Mode startupMode, PreferencesService preferencesService, FileUpdateMonitor fileUpdateMonitor, - BibEntryTypesManager entryTypesManager) throws org.apache.commons.cli.ParseException { + BibEntryTypesManager entryTypesManager) + throws org.apache.commons.cli.ParseException { this.cli = new JabRefCLI(args); this.startupMode = startupMode; this.preferencesService = preferencesService; @@ -185,11 +189,10 @@ private Optional importFile(Path file, String importFormat) { } } - public List getParserResults() { - return parserResults; - } - public void processArguments() { + uiCommands.clear(); + noGUINeeded = false; + if ((startupMode == Mode.INITIAL_START) && cli.isShowVersion()) { cli.displayVersion(); } @@ -197,7 +200,6 @@ public void processArguments() { if ((startupMode == Mode.INITIAL_START) && cli.isHelp()) { JabRefCLI.printUsage(preferencesService); noGUINeeded = true; - this.parserResults = Collections.emptyList(); return; } @@ -221,7 +223,6 @@ public void processArguments() { if (cli.isExportMatches()) { if (!loaded.isEmpty()) { if (!exportMatches(loaded)) { - this.parserResults = Collections.emptyList(); return; } } else { @@ -281,7 +282,9 @@ public void processArguments() { jumpToKey(loaded, cli.getJumpToKey()); } - this.parserResults = loaded; + if (!cli.isBlank() && !loaded.isEmpty()) { + uiCommands.add(new UiCommand.OpenDatabases(loaded)); + } } private void writeMetadataToPdf(List loaded, @@ -781,7 +784,7 @@ private void jumpToKey(List loaded, String citationKey) { for (ParserResult parserResult : loaded) { Optional entry = parserResult.getDatabase().getEntryByCitationKey(citationKey); if (entry.isPresent()) { - parserResult.setEntryToFocus(entry.get()); + uiCommands.add(new UiCommand.JumpToEntryKey(parserResult, entry.get())); return; } } @@ -796,7 +799,7 @@ public boolean shouldShutDown() { return cli.isDisableGui() || cli.isShowVersion() || noGUINeeded; } - public enum Mode { - INITIAL_START, REMOTE_START + public List getUiCommands() { + return uiCommands; } } diff --git a/src/main/java/org/jabref/cli/Launcher.java b/src/main/java/org/jabref/cli/Launcher.java index a49ea92e865..6ec7a99f644 100644 --- a/src/main/java/org/jabref/cli/Launcher.java +++ b/src/main/java/org/jabref/cli/Launcher.java @@ -6,11 +6,14 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Comparator; +import java.util.List; import java.util.Map; import org.jabref.gui.Globals; import org.jabref.gui.MainApplication; +import org.jabref.logic.UiCommand; import org.jabref.logic.journals.JournalAbbreviationLoader; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.ProxyAuthenticator; @@ -100,7 +103,15 @@ public static void main(String[] args) { System.exit(0); } - MainApplication.main(argumentProcessor.getParserResults(), argumentProcessor.isBlank(), preferences, fileUpdateMonitor, ARGUMENTS); + List uiCommands = new ArrayList<>(argumentProcessor.getUiCommands()); + List lastFiles = preferences.getGuiPreferences().getLastFilesOpened(); + if (!argumentProcessor.isBlank() && preferences.getWorkspacePreferences().shouldOpenLastEdited() && !lastFiles.isEmpty()) { + for (String file : lastFiles) { + uiCommands.add(new UiCommand.OpenDatabaseFromPath(Path.of(file))); + } + } + + MainApplication.main(uiCommands, preferences, fileUpdateMonitor, ARGUMENTS); } catch (ParseException e) { LOGGER.error("Problem parsing arguments", e); JabRefCLI.printUsage(preferences); diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 3dff38bafbb..c34a1bd6278 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -44,6 +45,7 @@ import org.jabref.gui.help.HelpAction; import org.jabref.gui.importer.ImportEntriesDialog; import org.jabref.gui.importer.NewEntryAction; +import org.jabref.gui.importer.ParserResultWarningDialog; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; @@ -57,11 +59,15 @@ import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.gui.util.TaskExecutor; +import org.jabref.logic.UiCommand; import org.jabref.logic.help.HelpFile; import org.jabref.logic.importer.ImportCleanup; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; import org.jabref.logic.shared.DatabaseLocation; +import org.jabref.logic.shared.DatabaseNotSupportedException; +import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; +import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.undo.AddUndoableActionEvent; import org.jabref.logic.undo.UndoChangeEvent; import org.jabref.logic.undo.UndoRedoEvent; @@ -958,6 +964,128 @@ public Stage getMainStage() { return mainStage; } + public void handleUiCommands(List uiCommands) { + for (UiCommand uiCommand : uiCommands) { + switch (uiCommand) { + case UiCommand.OpenDatabaseFromPath command -> + getOpenDatabaseAction().openFile(command.path()); + case UiCommand.JumpToEntryKey jumpToEntryKey -> { + Optional libraryTab = getLibraryTabs().stream() + .filter(tab -> tab.getDatabase() + .equals(jumpToEntryKey.parserResult() + .getDatabase())) + .findFirst(); + libraryTab.ifPresent(tab -> { + tab.clearAndSelect(jumpToEntryKey.bibEntry()); + showLibraryTab(tab); + }); + } + case UiCommand.OpenDatabases command -> + openDatabases(command.parserResults()); + } + } + } + + private void openDatabases(List parserResults) { + final List toOpenTab = new ArrayList<>(); + + // Remove invalid databases + List invalidDatabases = parserResults.stream() + .filter(ParserResult::isInvalid) + .toList(); + final List failed = new ArrayList<>(invalidDatabases); + parserResults.removeAll(invalidDatabases); + + // passed file (we take the first one) should be focused + Path focusedFile = parserResults.stream() + .findFirst() + .flatMap(ParserResult::getPath) + .orElse(prefs.getGuiPreferences() + .getLastFocusedFile()) + .toAbsolutePath(); + + // Add all bibDatabases databases to the frame: + boolean first = false; + for (ParserResult pr : parserResults) { + // Define focused tab + if (pr.getPath().filter(path -> path.toAbsolutePath().equals(focusedFile)).isPresent()) { + first = true; + } + + if (pr.getDatabase().isShared()) { + try { + OpenDatabaseAction.openSharedDatabase( + pr, + this, + dialogService, + prefs, + stateManager, + entryTypesManager, + fileUpdateMonitor, + undoManager, + Globals.TASK_EXECUTOR); + } catch ( + SQLException | + DatabaseNotSupportedException | + InvalidDBMSConnectionPropertiesException | + NotASharedDatabaseException e) { + + LOGGER.error("Connection error", e); + dialogService.showErrorDialogAndWait( + Localization.lang("Connection error"), + Localization.lang("A local copy will be opened."), + e); + toOpenTab.add(pr); + } + } else if (pr.toOpenTab()) { + // things to be appended to an opened tab should be done after opening all tabs + // add them to the list + toOpenTab.add(pr); + } else { + addTab(pr, first); + first = false; + } + } + + // finally add things to the currently opened tab + for (ParserResult parserResult : toOpenTab) { + addTab(parserResult, first); + first = false; + } + + for (ParserResult pr : failed) { + String message = Localization.lang("Error opening file '%0'", + pr.getPath().map(Path::toString).orElse("(File name unknown)")) + "\n" + + pr.getErrorMessage(); + + dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), message); + } + + // Display warnings, if any + int tabNumber = 0; + for (ParserResult pr : parserResults) { + ParserResultWarningDialog.showParserResultWarningDialog(pr, this, tabNumber++); + } + + // After adding the databases, go through each and see if + // any post open actions need to be done. For instance, checking + // if we found new entry types that can be imported, or checking + // if the database contents should be modified due to new features + // in this version of JabRef. + // Note that we have to check whether i does not go over getBasePanelCount(). + // This is because importToOpen might have been used, which adds to + // loadedDatabases, but not to getBasePanelCount() + + for (int i = 0; (i < parserResults.size()) && (i < getBasePanelCount()); i++) { + ParserResult pr = parserResults.get(i); + LibraryTab libraryTab = getLibraryTabAt(i); + + OpenDatabaseAction.performPostOpenActions(libraryTab, pr); + } + + LOGGER.debug("Finished adding panels"); + } + /** * The action concerned with closing the window. */ diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index a4ee050527e..efca0cb8bfa 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -1,13 +1,8 @@ package org.jabref.gui; -import java.nio.file.Path; -import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; -import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.input.KeyEvent; import javafx.stage.Screen; @@ -15,17 +10,11 @@ import org.jabref.gui.help.VersionWorker; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.importer.ParserResultWarningDialog; -import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.TextInputKeyBindings; -import org.jabref.logic.importer.ParserResult; +import org.jabref.logic.UiCommand; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.ProxyRegisterer; -import org.jabref.logic.shared.DatabaseNotSupportedException; -import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; -import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.util.WebViewStore; -import org.jabref.model.entry.BibEntry; import org.jabref.model.strings.StringUtil; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.GuiPreferences; @@ -45,19 +34,14 @@ public class JabRefGUI { private final PreferencesService preferencesService; private final FileUpdateMonitor fileUpdateMonitor; - private final List parserResults; - private final boolean isBlank; + private final List uiCommands; private boolean correctedWindowPos; - private final List failed = new ArrayList<>(); - private final List toOpenTab = new ArrayList<>(); public JabRefGUI(Stage mainStage, - List databases, - boolean isBlank, + List uiCommands, PreferencesService preferencesService, FileUpdateMonitor fileUpdateMonitor) { - this.parserResults = databases; - this.isBlank = isBlank; + this.uiCommands = uiCommands; this.preferencesService = preferencesService; this.fileUpdateMonitor = fileUpdateMonitor; this.correctedWindowPos = false; @@ -167,7 +151,7 @@ private void openWindow(Stage mainStage) { event.consume(); } }); - Platform.runLater(this::openDatabases); + mainFrame.handleUiCommands(uiCommands); if (!(fileUpdateMonitor.isActive())) { getMainFrame().getDialogService() @@ -177,133 +161,6 @@ private void openWindow(Stage mainStage) { } } - /** - * ToDo: This should be part of JabRefFrame - */ - private void openDatabases() { - // If the option is enabled, open the last edited libraries, if any. - if (!isBlank && preferencesService.getWorkspacePreferences().shouldOpenLastEdited()) { - openLastEditedDatabases(); - } - - // From here on, the libraries provided by command line arguments are treated - - // Remove invalid databases - List invalidDatabases = parserResults.stream() - .filter(ParserResult::isInvalid) - .toList(); - failed.addAll(invalidDatabases); - parserResults.removeAll(invalidDatabases); - - // passed file (we take the first one) should be focused - Path focusedFile = parserResults.stream() - .findFirst() - .flatMap(ParserResult::getPath) - .orElse(preferencesService.getGuiPreferences() - .getLastFocusedFile()) - .toAbsolutePath(); - // check whether there is a jump to entry and need to focus different file - boolean focusDifferent = false; - Optional focusedEntry = Optional.empty(); - for (ParserResult parserResult : parserResults) { - // Make sure this parser result is its own library instead of imported BibTeX entries - if (parserResult.getEntryToFocus().isPresent() && !parserResult.toOpenTab()) { - focusDifferent = true; - focusedEntry = parserResult.getEntryToFocus(); - break; - } - } - - // Add all bibDatabases databases to the frame: - boolean first = false; - for (ParserResult parserResult : parserResults) { - // Define focused tab - if (parserResult.getPath().filter(path -> path.toAbsolutePath().equals(focusedFile)).isPresent() && !focusDifferent) { - first = true; - } - if (parserResult.getEntryToFocus().isPresent() && focusDifferent) { - first = true; - focusDifferent = false; - } - - if (parserResult.getDatabase().isShared()) { - try { - OpenDatabaseAction.openSharedDatabase( - parserResult, - mainFrame, - mainFrame.getDialogService(), - preferencesService, - Globals.stateManager, - Globals.entryTypesManager, - fileUpdateMonitor, - mainFrame.getUndoManager(), - Globals.TASK_EXECUTOR); - } catch (SQLException | - DatabaseNotSupportedException | - InvalidDBMSConnectionPropertiesException | - NotASharedDatabaseException e) { - - LOGGER.error("Connection error", e); - mainFrame.getDialogService().showErrorDialogAndWait( - Localization.lang("Connection error"), - Localization.lang("A local copy will be opened."), - e); - toOpenTab.add(parserResult); - } - } else if (parserResult.toOpenTab()) { - // things to be appended to an opened tab should be done after opening all tabs - // add them to the list - toOpenTab.add(parserResult); - } else { - mainFrame.addTab(parserResult, first); - first = false; - } - } - - // finally add things to the currently opened tab - for (ParserResult parserResult : toOpenTab) { - mainFrame.addTab(parserResult, first); - first = false; - } - - for (ParserResult pr : failed) { - String message = Localization.lang("Error opening file '%0'", - pr.getPath().map(Path::toString).orElse("(File name unknown)")) + "\n" + - pr.getErrorMessage(); - - mainFrame.getDialogService().showErrorDialogAndWait(Localization.lang("Error opening file"), message); - } - - // Display warnings, if any - int tabNumber = 0; - for (ParserResult pr : parserResults) { - ParserResultWarningDialog.showParserResultWarningDialog(pr, mainFrame, tabNumber++); - } - - // After adding the databases, go through each and see if - // any post open actions need to be done. For instance, checking - // if we found new entry types that can be imported, or checking - // if the database contents should be modified due to new features - // in this version of JabRef. - // Note that we have to check whether i does not go over getBasePanelCount(). - // This is because importToOpen might have been used, which adds to - // loadedDatabases, but not to getBasePanelCount() - - for (int i = 0; (i < parserResults.size()) && (i < mainFrame.getBasePanelCount()); i++) { - ParserResult pr = parserResults.get(i); - LibraryTab libraryTab = mainFrame.getLibraryTabAt(i); - - OpenDatabaseAction.performPostOpenActions(libraryTab, pr); - } - // focus a particular entry if CLI has received a jump to entry key command - if (focusedEntry.isPresent()) { - mainFrame.getCurrentLibraryTab().clearAndSelect(focusedEntry.get()); - mainFrame.showLibraryTab(mainFrame.getCurrentLibraryTab()); - } - - LOGGER.debug("Finished adding panels"); - } - private void saveWindowState(Stage mainStage) { GuiPreferences preferences = preferencesService.getGuiPreferences(); preferences.setPositionX(mainStage.getX()); @@ -343,16 +200,6 @@ private boolean isWindowPositionOutOfBounds() { preferencesService.getGuiPreferences().getPositionY()); } - private void openLastEditedDatabases() { - List lastFiles = preferencesService.getGuiPreferences().getLastFilesOpened(); - if (lastFiles.isEmpty()) { - return; - } - - List filesToOpen = lastFiles.stream().map(Path::of).collect(Collectors.toList()); - getMainFrame().getOpenDatabaseAction().openFiles(filesToOpen); - } - public static JabRefFrame getMainFrame() { return mainFrame; } diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index 4d51e1817d0..eac9c68a564 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -224,7 +224,7 @@ public void onDatabaseLoadingStarted() { getMainTable().placeholderProperty().setValue(loadingLayout); // don't raise panel by default as one tab will already be raised. // See org.jabref.gui.JabRefGui.openDatabases() and org.jabref.gui.importer.actions.OpenDatabasesAction.openFiles() - frame.addTab(this, false); + frame.addTab(this, true); } public void onDatabaseLoadingSucceed(ParserResult result) { diff --git a/src/main/java/org/jabref/gui/MainApplication.java b/src/main/java/org/jabref/gui/MainApplication.java index a187843977d..5f49d28d83d 100644 --- a/src/main/java/org/jabref/gui/MainApplication.java +++ b/src/main/java/org/jabref/gui/MainApplication.java @@ -6,7 +6,7 @@ import javafx.stage.Stage; import org.jabref.gui.openoffice.OOBibBaseConnect; -import org.jabref.logic.importer.ParserResult; +import org.jabref.logic.UiCommand; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.JabRefPreferences; @@ -14,18 +14,15 @@ * JabRef's main class to process command line options and to start the UI */ public class MainApplication extends Application { - private static List parserResults; - private static boolean isBlank; + private static List uiCommands; private static JabRefPreferences preferences; private static FileUpdateMonitor fileUpdateMonitor; - public static void main(List parserResults, - boolean blank, + public static void main(List uiCommands, JabRefPreferences preferences, FileUpdateMonitor fileUpdateMonitor, String[] args) { - MainApplication.parserResults = parserResults; - MainApplication.isBlank = blank; + MainApplication.uiCommands = uiCommands; MainApplication.preferences = preferences; MainApplication.fileUpdateMonitor = fileUpdateMonitor; launch(args); @@ -35,7 +32,7 @@ public static void main(List parserResults, public void start(Stage mainStage) { FallbackExceptionHandler.installExceptionHandler(); Globals.startBackgroundTasks(); - new JabRefGUI(mainStage, parserResults, isBlank, preferences, fileUpdateMonitor); + new JabRefGUI(mainStage, uiCommands, preferences, fileUpdateMonitor); } @Override diff --git a/src/main/java/org/jabref/gui/remote/CLIMessageHandler.java b/src/main/java/org/jabref/gui/remote/CLIMessageHandler.java index 272d84fd600..8073847ee4f 100644 --- a/src/main/java/org/jabref/gui/remote/CLIMessageHandler.java +++ b/src/main/java/org/jabref/gui/remote/CLIMessageHandler.java @@ -1,12 +1,9 @@ package org.jabref.gui.remote; -import java.util.List; - import javafx.application.Platform; import org.jabref.cli.ArgumentProcessor; import org.jabref.gui.JabRefGUI; -import org.jabref.logic.importer.ParserResult; import org.jabref.logic.remote.server.RemoteMessageHandler; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.util.FileUpdateMonitor; @@ -39,15 +36,7 @@ public void handleCommandLineArguments(String[] message) { fileUpdateMonitor, entryTypesManager); argumentProcessor.processArguments(); - List loaded = argumentProcessor.getParserResults(); - for (int i = 0; i < loaded.size(); i++) { - ParserResult pr = loaded.get(i); - boolean focusPanel = i == 0; - Platform.runLater(() -> - // Need to run this on the JavaFX thread - JabRefGUI.getMainFrame().addTab(pr, focusPanel) - ); - } + Platform.runLater(() -> JabRefGUI.getMainFrame().handleUiCommands(argumentProcessor.getUiCommands())); } catch (ParseException e) { LOGGER.error("Error when parsing CLI args", e); } diff --git a/src/main/java/org/jabref/logic/UiCommand.java b/src/main/java/org/jabref/logic/UiCommand.java new file mode 100644 index 00000000000..e574a4a8e6e --- /dev/null +++ b/src/main/java/org/jabref/logic/UiCommand.java @@ -0,0 +1,15 @@ +package org.jabref.logic; + +import java.nio.file.Path; +import java.util.List; + +import org.jabref.logic.importer.ParserResult; +import org.jabref.model.entry.BibEntry; + +public sealed interface UiCommand { + record JumpToEntryKey(ParserResult parserResult, BibEntry bibEntry) implements UiCommand { } + + record OpenDatabases(List parserResults) implements UiCommand { } + + record OpenDatabaseFromPath(Path path) implements UiCommand { } +} diff --git a/src/main/java/org/jabref/logic/importer/ParserResult.java b/src/main/java/org/jabref/logic/importer/ParserResult.java index a700696ebb9..2f134224562 100644 --- a/src/main/java/org/jabref/logic/importer/ParserResult.java +++ b/src/main/java/org/jabref/logic/importer/ParserResult.java @@ -26,7 +26,6 @@ public class ParserResult { private boolean invalid; private boolean toOpenTab; private boolean changedOnMigration = false; - private BibEntry entryToFocus; public ParserResult() { this(Collections.emptyList()); @@ -100,14 +99,6 @@ public void setPath(Path path) { file = path; } - public Optional getEntryToFocus() { - return Optional.ofNullable(entryToFocus); - } - - public void setEntryToFocus(BibEntry bibEntry) { - entryToFocus = bibEntry; - } - /** * Add a parser warning. *