Skip to content

Commit 2f9811f

Browse files
committed
Refactored the code as suggested in review comments
1 parent a6d50e2 commit 2f9811f

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/main/java/org/jabref/gui/WelcomeTab.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,12 @@ private VBox createWelcomeRecentBox() {
153153
}
154154

155155
private void updateWelcomeRecentLibraries() {
156-
recentLibrariesBox.getChildren().clear();
157-
158156
if (fileHistoryMenu.getItems().isEmpty()) {
159-
Label noRecentLibrariesLabel = new Label(Localization.lang("No recent libraries"));
160-
noRecentLibrariesLabel.getStyleClass().add("welcome-no-recent-label");
161-
recentLibrariesBox.getChildren().add(noRecentLibrariesLabel);
162-
163-
fileHistoryMenu.disableProperty().unbind();
164-
fileHistoryMenu.setDisable(true);
157+
displayNoRecentLibrariesMessage();
165158
return;
166159
}
167160

161+
recentLibrariesBox.getChildren().clear();
168162
fileHistoryMenu.disableProperty().unbind();
169163
fileHistoryMenu.setDisable(false);
170164

@@ -176,6 +170,16 @@ private void updateWelcomeRecentLibraries() {
176170
}
177171
}
178172

173+
private void displayNoRecentLibrariesMessage() {
174+
recentLibrariesBox.getChildren().clear();
175+
Label noRecentLibrariesLabel = new Label(Localization.lang("No recent libraries"));
176+
noRecentLibrariesLabel.getStyleClass().add("welcome-no-recent-label");
177+
recentLibrariesBox.getChildren().add(noRecentLibrariesLabel);
178+
179+
fileHistoryMenu.disableProperty().unbind();
180+
fileHistoryMenu.setDisable(true);
181+
}
182+
179183
private VBox createVBoxContainer(Node... nodes) {
180184
VBox box = new VBox(5);
181185
box.setAlignment(Pos.TOP_LEFT);

src/main/java/org/jabref/gui/exporter/ExportCommand.java

+13-17
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,19 @@ private void export(Path file, FileChooser.ExtensionFilter selectedExtensionFilt
133133
return null; // can not use BackgroundTask.wrap(Runnable) because Runnable.run() can't throw Exceptions
134134
})
135135
.onSuccess(save -> {
136-
boolean currentTabIsLibraryTab = tabSupplier.get() != null;
137-
// libraryTab is null in case of Welcome Tab
138-
if (currentTabIsLibraryTab) {
139-
LibraryTab.DatabaseNotification notificationPane = tabSupplier.get().getNotificationPane();
140-
notificationPane.notify(
141-
IconTheme.JabRefIcons.FOLDER.getGraphicNode(),
142-
Localization.lang("Export operation finished successfully."),
143-
List.of(new Action(Localization.lang("Reveal in File Explorer"), event -> {
144-
try {
145-
NativeDesktop.openFolderAndSelectFile(file, preferences.getExternalApplicationsPreferences(), dialogService);
146-
} catch (IOException e) {
147-
LOGGER.error("Could not open export folder.", e);
148-
}
149-
notificationPane.hide();
150-
})),
151-
Duration.seconds(5));
152-
}
136+
LibraryTab.DatabaseNotification notificationPane = tabSupplier.get().getNotificationPane();
137+
notificationPane.notify(
138+
IconTheme.JabRefIcons.FOLDER.getGraphicNode(),
139+
Localization.lang("Export operation finished successfully."),
140+
List.of(new Action(Localization.lang("Reveal in File Explorer"), event -> {
141+
try {
142+
NativeDesktop.openFolderAndSelectFile(file, preferences.getExternalApplicationsPreferences(), dialogService);
143+
} catch (IOException e) {
144+
LOGGER.error("Could not open export folder.", e);
145+
}
146+
notificationPane.hide();
147+
})),
148+
Duration.seconds(5));
153149
})
154150
.onFailure(this::handleError)
155151
.executeWith(taskExecutor);

0 commit comments

Comments
 (0)