From 9e42be75d602494760af31435f210329276d0a9e Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 12 Jan 2024 00:15:01 +0100 Subject: [PATCH] Add some comments and try to improve variable names --- src/main/java/org/jabref/gui/LibraryTab.java | 23 +++++++++---------- .../gui/autosaveandbackup/BackupManager.java | 2 +- .../org/jabref/gui/maintable/MainTable.java | 11 --------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index fbd701e5057..fe04b9dc45a 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -221,13 +221,12 @@ private void setDataLoadingTask(BackgroundTask dataLoadingTask) { } /** - * The layout to display in the tab when it's loading + * The layout to display in the tab when it is loading */ private Node createLoadingAnimationLayout() { ProgressIndicator progressIndicator = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); BorderPane pane = new BorderPane(); pane.setCenter(progressIndicator); - return pane; } @@ -241,7 +240,7 @@ private void onDatabaseLoadingSucceed(ParserResult result) { BibDatabaseContext context = result.getDatabaseContext(); OpenDatabaseAction.performPostOpenActions(result, dialogService); - feedData(context); + setDatabaseContext(context); if (preferencesService.getFilePreferences().shouldFulltextIndexLinkedFiles()) { try { @@ -261,30 +260,30 @@ private void onDatabaseLoadingFailed(Exception ex) { dialogService.showErrorDialogAndWait(title, content, ex); } - private void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { + private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) { if (this.getTabPane().getSelectionModel().selectedItemProperty().get().equals(this)) { // If you open an existing library, a library tab with a loading animation is added immediately. - // At that point, the library tab is given a temporary bibDatabaseContext with no entries. + // At that point, the library tab is given a temporary (TODO null?) bibDatabaseContext with no entries. // This line is necessary because, while there is already a binding that updates the active database when a new tab is added, // it doesn't handle the case when a library is loaded asynchronously. // See org.jabref.gui.LibraryTab.createLibraryTab for the asynchronous loading. - stateManager.setActiveDatabase(bibDatabaseContextFromParserResult); + stateManager.setActiveDatabase(bibDatabaseContext); } // Remove existing dummy BibDatabaseContext and add correct BibDatabaseContext from ParserResult to trigger changes in the openDatabases list in the stateManager Optional foundExistingBibDatabase = stateManager.getOpenDatabases().stream().filter(databaseContext -> databaseContext.equals(this.bibDatabaseContext)).findFirst(); foundExistingBibDatabase.ifPresent(databaseContext -> stateManager.getOpenDatabases().remove(databaseContext)); - this.bibDatabaseContext = Objects.requireNonNull(bibDatabaseContextFromParserResult); + this.bibDatabaseContext = Objects.requireNonNull(bibDatabaseContext); - stateManager.getOpenDatabases().add(bibDatabaseContextFromParserResult); + stateManager.getOpenDatabases().add(bibDatabaseContext); - bibDatabaseContextFromParserResult.getDatabase().registerListener(this); - bibDatabaseContextFromParserResult.getMetaData().registerListener(this); + bibDatabaseContext.getDatabase().registerListener(this); + bibDatabaseContext.getMetaData().registerListener(this); this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, stateManager); - citationStyleCache = new CitationStyleCache(bibDatabaseContextFromParserResult); - annotationCache = new FileAnnotationCache(bibDatabaseContextFromParserResult, preferencesService.getFilePreferences()); + citationStyleCache = new CitationStyleCache(bibDatabaseContext); + annotationCache = new FileAnnotationCache(bibDatabaseContext, preferencesService.getFilePreferences()); setupMainPanel(); setupAutoCompletion(); diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java index 1b9017f192f..dfb89701663 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java @@ -136,7 +136,7 @@ public static void shutdown(BibDatabaseContext bibDatabaseContext, Path backupDi * Checks whether a backup file exists for the given database file. If it exists, it is checked whether it is * newer and different from the original. * - * In case a discarded file is present, the method also returns false, See also {@link #discardBackup()}. + * In case a discarded file is present, the method also returns false, See also {@link #discardBackup(Path)}. * * @param originalPath Path to the file a backup should be checked for. Example: jabref.bib. * diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 21fac134607..7357cc32022 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -473,10 +473,6 @@ public MainTableDataModel getTableModel() { return model; } - public BibEntry getEntryAt(int row) { - return model.getEntriesFilteredAndSorted().get(row).getEntry(); - } - public List getSelectedEntries() { return getSelectionModel() .getSelectedItems() @@ -491,11 +487,4 @@ private Optional findEntry(BibEntry entry) { .filter(viewModel -> viewModel.getEntry().equals(entry)) .findFirst(); } - - public static List toColumnModels(List> columns) { - return columns.stream() - .filter(col -> col instanceof MainTableColumn) - .map(column -> ((MainTableColumn) column).getModel()) - .collect(Collectors.toList()); - } }