diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.css b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.css index 8e2948e5f46..86fe501eb2e 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.css +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.css @@ -1,8 +1,3 @@ -.custom-buttons { - -fx-margin-top: 10px; - -fx-padding: 5px; -} - .abbreviations-table { -fx-table-cell-border-color: transparent; } @@ -20,8 +15,3 @@ .table-row-cell:selected > .table-cell > .icon, .table-row-cell:pressed > .table-cell > .icon { -fx-fill: white; } - -.dialog-pane *.button-bar { - -fx-max-height: 0; - -fx-pref-height: 0; -} \ No newline at end of file diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.fxml b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.fxml index 93115e01b8e..9044de941dc 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.fxml +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviations.fxml @@ -1,7 +1,7 @@ - + @@ -9,57 +9,51 @@ - - -
- + - - - - + + + + - - - - -
- - - -
diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java index c6ded9668f3..42611dccbed 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java @@ -2,9 +2,9 @@ import javax.inject.Inject; -import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.ProgressIndicator; @@ -13,11 +13,11 @@ import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; -import javafx.stage.Stage; import org.jabref.gui.DialogService; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.util.BaseDialog; +import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.TaskExecutor; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.logic.journals.JournalAbbreviationLoader; @@ -34,12 +34,12 @@ public class ManageJournalAbbreviationsView extends BaseDialog { @FXML public Label loadingLabel; @FXML public ProgressIndicator progressIndicator; + @FXML private ButtonType saveButton; @FXML private TableView journalAbbreviationsTable; @FXML private TableColumn journalTableNameColumn; @FXML private TableColumn journalTableAbbreviationColumn; @FXML private TableColumn journalTableEditColumn; @FXML private TableColumn journalTableDeleteColumn; - @FXML private Button cancelButton; @FXML private ComboBox journalFilesBox; @FXML private Button addJournalFileButton; @FXML private Button addNewJournalFileButton; @@ -57,6 +57,8 @@ public ManageJournalAbbreviationsView() { ViewLoader.view(this) .load() .setAsDialogPane(this); + + ControlHelper.setAction(saveButton, getDialogPane(), event -> saveAbbreviationsAndCloseDialog()); } @FXML @@ -129,11 +131,7 @@ private void setUpTable() { private void setBindings() { journalAbbreviationsTable.itemsProperty().bindBidirectional(viewModel.abbreviationsProperty()); journalFilesBox.itemsProperty().bindBidirectional(viewModel.journalFilesProperty()); - - viewModel.currentFileProperty().addListener((observable, oldvalue, newvalue) -> - journalFilesBox.getSelectionModel().select(newvalue)); - journalFilesBox.getSelectionModel().selectedItemProperty() - .addListener((observable, oldvalue, newvalue) -> viewModel.currentFileProperty().set(newvalue)); + journalFilesBox.valueProperty().bindBidirectional(viewModel.currentFileProperty()); viewModel.currentAbbreviationProperty().addListener((observable, oldvalue, newvalue) -> journalAbbreviationsTable.getSelectionModel().select(newvalue)); @@ -185,24 +183,10 @@ private void removeAbbreviation() { viewModel.deleteAbbreviation(); } - @FXML - private void closeDialog() { - Stage stage = (Stage) cancelButton.getScene().getWindow(); - stage.close(); - } - @FXML private void saveAbbreviationsAndCloseDialog() { - Task task = new Task() { - - @Override - protected Void call() { - viewModel.saveEverythingAndUpdateAutoCompleter(); - return null; - } - }; - new Thread(task).start(); - closeDialog(); + viewModel.saveEverythingAndUpdateAutoCompleter(); + close(); } diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java index 46ceada6cfe..bce2327a58f 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java @@ -99,7 +99,7 @@ public ManageJournalAbbreviationsViewModel(PreferencesService preferences, Dialo } } }); - isLoading.bind(isLoadingBuiltIn.and(isLoadingBuiltIn)); + isLoading.bind(isLoadingBuiltIn.or(isLoadingIeee)); } public SimpleBooleanProperty isLoadingProperty() { @@ -121,6 +121,7 @@ void addBuiltInLists() { .onSuccess(result -> { isLoadingBuiltIn.setValue(false); addList(Localization.lang("JabRef built in list"), result); + selectLastJournalFile(); }) .onFailure(dialogService::showErrorDialogAndWait) .executeWith(taskExecutor); @@ -350,17 +351,19 @@ public void selectLastJournalFile() { * {@link JournalAbbreviationLoader#update(JournalAbbreviationPreferences)}. */ public void saveEverythingAndUpdateAutoCompleter() { - saveExternalFilesList(); + BackgroundTask.wrap(() -> { + saveExternalFilesList(); - if (shouldWriteLists) { - saveJournalAbbreviationFiles(); - shouldWriteLists = false; - } + if (shouldWriteLists) { + saveJournalAbbreviationFiles(); + shouldWriteLists = false; + } - // Update journal abbreviation loader - journalAbbreviationLoader.update(abbreviationsPreferences); + // Update journal abbreviation loader + journalAbbreviationLoader.update(abbreviationsPreferences); - preferences.storeJournalAbbreviationPreferences(abbreviationsPreferences); + preferences.storeJournalAbbreviationPreferences(abbreviationsPreferences); + }).executeWith(taskExecutor); } public SimpleListProperty journalFilesProperty() {