Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converts integrity check dialog to JavaFX #4559

Merged
merged 4 commits into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.geometry.Orientation;
import javafx.scene.Node;
Expand Down Expand Up @@ -693,11 +694,12 @@ public void insertEntry(final BibEntry bibEntry) {
}
}

public void editEntryByIdAndFocusField(final String entryId, final String fieldName) {
bibDatabaseContext.getDatabase().getEntryById(entryId).ifPresent(entry -> {
clearAndSelect(entry);
showAndEdit(entry);
public void editEntryAndFocusField(BibEntry entry, String fieldName) {
showAndEdit(entry);
Platform.runLater(() -> {
// Focus field and entry in main table (async to give entry editor time to load)
entryEditor.setFocusToField(fieldName);
clearAndSelect(entry);
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/DialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ Optional<ButtonType> showCustomButtonDialogAndWait(Alert.AlertType type, String
/**
* Constructs and shows a canceable {@link ProgressDialog}. Clicking cancel will cancel the underlying service and close the dialog
*
* @param title title of the dialog
* @param content message to show above the progress bar
* @param task The {@link Task} which executes the work and for which to show the dialog
*/
<V> void showCanceableProgressDialogAndWait(Task<V> task);
<V> void showProgressDialogAndWait(String title, String content, Task<V> task);

/**
* Notify the user in an non-blocking way (i.e., in form of toast in a snackbar).
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/jabref/gui/FXDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import javafx.scene.layout.Region;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.stage.Window;

import org.jabref.JabRefGUI;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -226,8 +228,13 @@ public <R> Optional<R> showCustomDialogAndWait(Dialog<R> dialog) {
}

@Override
public <V> void showCanceableProgressDialogAndWait(Task<V> task) {
public <V> void showProgressDialogAndWait(String title, String content, Task<V> task) {
ProgressDialog progressDialog = new ProgressDialog(task);
progressDialog.setHeaderText(null);
progressDialog.setTitle(title);
progressDialog.setContentText(content);
progressDialog.setGraphic(null);
((Stage) progressDialog.getDialogPane().getScene().getWindow()).getIcons().add(IconTheme.getJabRefImageFX());
progressDialog.setOnCloseRequest(evt -> task.cancel());
DialogPane dialogPane = progressDialog.getDialogPane();
dialogPane.getButtonTypes().add(ButtonType.CANCEL);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import org.jabref.gui.actions.DatabasePropertiesAction;
import org.jabref.gui.actions.EditExternalFileTypesAction;
import org.jabref.gui.actions.ErrorConsoleAction;
import org.jabref.gui.actions.IntegrityCheckAction;
import org.jabref.gui.actions.LookupIdentifierAction;
import org.jabref.gui.actions.ManageCustomExportsAction;
import org.jabref.gui.actions.ManageCustomImportsAction;
Expand Down Expand Up @@ -94,6 +93,7 @@
import org.jabref.gui.importer.ImportCommand;
import org.jabref.gui.importer.ImportInspectionDialog;
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.gui.integrity.IntegrityCheckAction;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.menus.FileHistoryMenu;
import org.jabref.gui.mergeentries.MergeEntriesAction;
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/org/jabref/gui/actions/CopyFilesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public CopyFilesAction(JabRefFrame frame) {
this.dialogService = frame.getDialogService();
}

private void startServiceAndshowProgessDialog(Task<List<CopyFilesResultItemViewModel>> exportService) {

dialogService.showCanceableProgressDialogAndWait(exportService);

exportService.run();
exportService.setOnSucceeded((e) -> {
showDialog(exportService.getValue());
});
}

private void showDialog(List<CopyFilesResultItemViewModel> data) {
if (data.isEmpty()) {
dialogService.showInformationDialogAndWait(Localization.lang("Copy linked files to folder..."), Localization.lang("No linked files found for export."));
Expand All @@ -64,7 +54,12 @@ public void execute() {
databaseContext = frame.getCurrentBasePanel().getBibDatabaseContext();

Task<List<CopyFilesResultItemViewModel>> exportTask = new CopyFilesTask(databaseContext, entries, path);
startServiceAndshowProgessDialog(exportTask);
dialogService.showProgressDialogAndWait(
Localization.lang("Copy linked files to folder..."),
Localization.lang("Copy linked files to folder..."),
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
exportTask);
Globals.TASK_EXECUTOR.execute(exportTask);
exportTask.setOnSucceeded((e) -> showDialog(exportTask.getValue()));
});

}
Expand Down
202 changes: 0 additions & 202 deletions src/main/java/org/jabref/gui/actions/IntegrityCheckAction.java

This file was deleted.

Loading