From 57f210eea1b2d765fe96829a6ecc9f59988f7767 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 20 Dec 2020 18:52:48 +0100 Subject: [PATCH 01/71] [WIP] Refactor unlinked files create dialog in fxml and use a background task for import --- .../externalfiles/ExternalFilesDialog.fxml | 78 +++++++++++++++++++ .../FindUnlinkedFilesDialog.java | 4 +- .../gui/importer/ImportAsNewFilesTask.java | 13 ++++ .../org/jabref/gui/util/BackgroundTask.java | 10 +-- 4 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/jabref/gui/externalfiles/ExternalFilesDialog.fxml create mode 100644 src/main/java/org/jabref/gui/importer/ImportAsNewFilesTask.java diff --git a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesDialog.fxml b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesDialog.fxml new file mode 100644 index 00000000000..936c7eadc8b --- /dev/null +++ b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesDialog.fxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + @@ -39,9 +38,9 @@ - @@ -52,7 +51,7 @@ - + @@ -62,10 +61,10 @@ - +
- - - - - - diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index 8e32b369096..fd37847f822 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -16,7 +16,6 @@ import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TextField; import javafx.scene.control.TreeView; -import javafx.scene.layout.VBox; import javafx.stage.FileChooser; import org.jabref.gui.DialogService; @@ -39,7 +38,6 @@ public class UnlinkedFilesDialogView extends BaseDialog { @FXML private TextField directoryPathField; @FXML private ComboBox fileTypeSelection; @FXML private TreeView tree; - @FXML private VBox panelSearchProgress; @FXML private Button buttonScan; @FXML private ButtonType importButton; @FXML private Button buttonExport; @@ -103,14 +101,13 @@ private void initialize() { tree.setPrefWidth(Double.POSITIVE_INFINITY); viewModel.treeRoot().bindBidirectional(tree.rootProperty()); - viewModel.searchProgressPaneVisible().bindBidirectional(panelSearchProgress.visibleProperty()); viewModel.scanButtonDisabled().bindBidirectional(buttonScan.disableProperty()); viewModel.scanButtonDefaultButton().bindBidirectional(buttonScan.defaultButtonProperty()); viewModel.exportButtonDisabled().bindBidirectional(buttonExport.disableProperty()); viewModel.selectedExtension().bind(fileTypeSelection.valueProperty()); progressDisplay.progressProperty().bind(viewModel.progress()); - progressDisplay.visibleProperty().bind(viewModel.searchProgressPaneVisible()); + progressDisplay.managedProperty().bind(viewModel.searchProgressVisible()); progressText.textProperty().bind(viewModel.progressText()); viewModel.scanButtonDefaultButton().setValue(true); diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java index a3edf1e5701..73bd8e3f159 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java @@ -22,14 +22,13 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.scene.control.CheckBoxTreeItem; -import javafx.scene.control.ProgressBar; +import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TreeItem; import javafx.stage.FileChooser; import org.jabref.gui.DialogService; import org.jabref.gui.StateManager; import org.jabref.gui.externalfiletype.ExternalFileTypes; -import org.jabref.gui.importer.ImportFilesResultItemViewModel; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.gui.util.FileDialogConfiguration; @@ -59,7 +58,7 @@ public class UnlinkedFilesDialogViewModel { private final ObjectProperty> treeRoot = new SimpleObjectProperty<>(); private final BooleanProperty scanButtonDefaultButton = new SimpleBooleanProperty(); private final DoubleProperty progress = new SimpleDoubleProperty(0); - private final StringProperty progressText = new SimpleStringProperty(""); + private final StringProperty progressText = new SimpleStringProperty(); private final List fileFilterList = List.of( FileFilterConverter.ANY_FILE, @@ -100,7 +99,6 @@ public void startImport() { importFilesBackgroundTask = importHandler.importFilesInBackground(fileList) .onRunning(() -> { - // progressText.setValue(Localization.lang("Importing")); progress.bind(importFilesBackgroundTask.workDonePercentageProperty()); progressText.bind(importFilesBackgroundTask.messageProperty()); @@ -111,6 +109,8 @@ public void startImport() { .onFinished(() -> { searchProgressVisible.setValue(false); scanButtonDisabled.setValue(false); + progress.unbind(); + progressText.unbind(); }) .onSuccess(results -> { applyButtonDisabled.setValue(false); @@ -118,6 +118,8 @@ public void startImport() { scanButtonDefaultButton.setValue(false); searchProgressVisible.setValue(false); + progress.unbind(); + progressText.unbind(); new ImportResultsDialogView(results).showAndWait(); }); importFilesBackgroundTask.executeWith(taskExecutor); @@ -169,26 +171,31 @@ public void startSearch() { findUnlinkedFilesTask = new UnlinkedFilesCrawler(directory, selectedFileFilter, bibDatabasecontext, preferences.getFilePreferences()) .onRunning(() -> { - progress.set(ProgressBar.INDETERMINATE_PROGRESS); + progress.set(ProgressIndicator.INDETERMINATE_PROGRESS); progressText.setValue(Localization.lang("Searching the file system....")); searchProgressVisible.setValue(true); scanButtonDisabled.setValue(true); + applyButtonDisabled.set(true); treeRoot.setValue(null); }) .onFinished(() -> { - searchProgressVisible.setValue(false); scanButtonDisabled.setValue(false); applyButtonDisabled.setValue(false); + searchProgressVisible.set(false); + progressText.set(""); + progress.set(0); }) .onSuccess(root -> { treeRoot.setValue(root); root.setSelected(true); root.setExpanded(true); + progressText.set(""); + progress.set(0); - applyButtonDisabled.setValue(false); - exportButtonDisabled.setValue(false); - scanButtonDefaultButton.setValue(false); - + applyButtonDisabled.setValue(false); + exportButtonDisabled.setValue(false); + scanButtonDefaultButton.setValue(false); + searchProgressVisible.set(false); }); findUnlinkedFilesTask.executeWith(taskExecutor); } @@ -205,7 +212,7 @@ public ObjectProperty selectedExtension() { return this.selectedExtension; } - public BooleanProperty searchProgressPaneVisible() { + public BooleanProperty searchProgressVisible() { return this.searchProgressVisible; } From 98c6a7f71e2fab3dfa2d4b138e3d11244eacf740 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:10:54 +0100 Subject: [PATCH 21/71] preapre localization --- .../gui/externalfiles/ImportHandler.java | 19 +++++++++---------- .../externalfiles/UnlinkedFilesCrawler.java | 14 +++++++++----- .../UnlinkedFilesDialogViewModel.java | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java index a5906434eef..bb0c19ae8af 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java +++ b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java @@ -99,14 +99,14 @@ protected List call() throws Exception { List pdfEntriesInFile = pdfImporterResult.getDatabase().getEntries(); if (pdfImporterResult.hasWarnings()) { - addResultToList(file, false, "Error reading PDF content: " + pdfImporterResult.getErrorMessage()); + addResultToList(file, false, Localization.lang("Error reading PDF content: %0 ", pdfImporterResult.getErrorMessage())); } var xmpParserResult = contentImporter.importXMPContent(file); List xmpEntriesInFile = xmpParserResult.getDatabase().getEntries(); if (xmpParserResult.hasWarnings()) { - addResultToList(file, false, "Error reading XMP content: " + xmpParserResult.getErrorMessage()); + addResultToList(file, false, Localization.lang("Error reading XMP content: %0 ", xmpParserResult.getErrorMessage())); } // First try xmp import, if empty try pdf import, otherwise create empty entry @@ -117,13 +117,13 @@ protected List call() throws Exception { } else { entriesToAdd = xmpEntriesInFile; } - addResultToList(file, true, "Importing using XMP data"); + addResultToList(file, true, Localization.lang("Importing using XMP data...")); } else { if (!pdfEntriesInFile.isEmpty()) { entriesToAdd = pdfEntriesInFile; - addResultToList(file, true, "Importing using extracted PDF data"); + addResultToList(file, true, Localization.lang("Importing using extracted PDF data")); } else { - addResultToList(file, false, "No entry found. Creating empty entry with file link"); + addResultToList(file, false, Localization.lang("No metadata found. Creating empty entry with file link")); entriesToAdd = Collections.singletonList(createEmptyEntryWithLink(file)); } } @@ -133,20 +133,19 @@ protected List call() throws Exception { addResultToList(file, false, bibtexParserResult.getErrorMessage()); } - addResultToList(file, false, "Importing bib entry"); + addResultToList(file, false, Localization.lang("Importing bib entry")); entriesToAdd = bibtexParserResult.getDatabaseContext().getEntries(); } else { - addResultToList(file, false, "Importing bib entry"); - addResultToList(file, false, "No entry found. Creating empty entry with file link"); + addResultToList(file, false, Localization.lang("No bibtex data found. Creating empty entry with file link")); entriesToAdd = Collections.singletonList(createEmptyEntryWithLink(file)); } } catch (IOException ex) { LOGGER.error("Error importing", ex); - addResultToList(file, false, "Error importing " + ex.getLocalizedMessage()); + addResultToList(file, false, Localization.lang("Error from import: %0", ex.getLocalizedMessage())); - DefaultTaskExecutor.runInJavaFXThread(() -> updateMessage("Error")); + DefaultTaskExecutor.runInJavaFXThread(() -> updateMessage(Localization.lang("Error"))); } // We need to run the actual import on the FX Thread, otherwise we will get some deadlocks with the UIThreadList diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawler.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawler.java index b614acd0249..24350cb275a 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawler.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawler.java @@ -10,6 +10,7 @@ import javafx.scene.control.CheckBoxTreeItem; import org.jabref.gui.util.BackgroundTask; +import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; @@ -97,11 +98,14 @@ private CheckBoxTreeItem searchDirectory(File directory, Unlink root.getChildren().add(new CheckBoxTreeItem<>(new FileNodeWrapper(file.toPath()))); counter++; - if (counter == 1) { - updateMessage(Localization.lang("One file found")); - } else { - updateMessage(Localization.lang("%0 files found", Integer.toString(counter))); - } + DefaultTaskExecutor.runInJavaFXThread(() -> { + if (counter == 1) { + updateMessage(Localization.lang("One file found")); + } else { + updateMessage(Localization.lang("%0 files found", Integer.toString(counter))); + } + }); + } return root; diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java index 73bd8e3f159..20564cccf59 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java @@ -173,6 +173,8 @@ public void startSearch() { .onRunning(() -> { progress.set(ProgressIndicator.INDETERMINATE_PROGRESS); progressText.setValue(Localization.lang("Searching the file system....")); + progressText.bind(findUnlinkedFilesTask.messageProperty()); + searchProgressVisible.setValue(true); scanButtonDisabled.setValue(true); applyButtonDisabled.set(true); @@ -182,14 +184,12 @@ public void startSearch() { scanButtonDisabled.setValue(false); applyButtonDisabled.setValue(false); searchProgressVisible.set(false); - progressText.set(""); progress.set(0); }) .onSuccess(root -> { treeRoot.setValue(root); root.setSelected(true); root.setExpanded(true); - progressText.set(""); progress.set(0); applyButtonDisabled.setValue(false); From 6219364665caf03f81a39b02572c26679b5d0d54 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:19:14 +0100 Subject: [PATCH 22/71] fix typo --- docs/getting-into-the-code/code-howtos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index ddf725288fc..76a299c86f3 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -181,7 +181,7 @@ The tests check whether translation strings appear correctly in the resource bun ## Cleanup and Formatters -We try to build a cleanup mechanism based on formatters. The idea is that we can register these actions in arbitrary places, e.g., onSave, onImport, onExport, cleanup, etc. and apply them to different fields. The formatters themself are independent of any logic and therefore easy to test. +We try to build a cleanup mechanism based on formatters. The idea is that we can register these actions in arbitrary places, e.g., onSave, onImport, onExport, cleanup, etc. and apply them to different fields. The formatters themselves are independent of any logic and therefore easy to test. Example: [NormalizePagesFormatter](https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java) From f7222863c7b6dc6eaccf705c32a84453ab6c380e Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:20:32 +0100 Subject: [PATCH 23/71] fix md errors --- docs/getting-into-the-code/code-howtos.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index 77218efc9f5..2fdb27760fa 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -58,11 +58,11 @@ Many times there is a need to provide an object on many locations simultaneously ### Main principle -`EventBus` represents a communication line between multiple components. Objects can be passed through the bus and reach the listening method of another object which is registered on that `EventBus` instance. Hence the passed object is available as a parameter in the listening method. +`EventBus` represents a communication line between multiple components. Objects can be passed through the bus and reach the listening method of another object which is registered on that `EventBus` instance. Hence, the passed object is available as a parameter in the listening method. ### Register to the `EventBus` -Any listening method has to be annotated with `@Subscribe` keyword and must have only one accepting parameter. Furthermore the object which contains such listening method\(s\) has to be registered using the `register(Object)` method provided by `EventBus`. The listening methods can be overloaded by using different parameter types. +Any listening method has to be annotated with `@Subscribe` keyword and must have only one accepting parameter. Furthermore, the object which contains such listening method\(s\) has to be registered using the `register(Object)` method provided by `EventBus`. The listening methods can be overloaded by using different parameter types. ### Posting an object @@ -185,7 +185,7 @@ The tests check whether translation strings appear correctly in the resource bun 1. Add the new Language to the Language enum in [https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/l10n/Language.java](https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/l10n/Language.java) 2. Create an empty <locale code>.properties file -3. Configure the new language in [https://crowdin.com/project/jabref ](https://crowdin.com/project/jabref) +3. Configure the new language in [Crowdin](https://crowdin.com/project/jabref) If the language is a variant of a language `zh_CN` or `pt_BR` it is necessary to add a language mapping for Crowdin to the crowdin.yml file in the root. Of course the properties file also has to be named according to the language code and locale. From a1da3921a8ba7fbbc093abc9c99cda0ecb545024 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:22:16 +0100 Subject: [PATCH 24/71] fix l10n key --- src/main/java/org/jabref/gui/externalfiles/ImportHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java index bb0c19ae8af..7905b2d5208 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java +++ b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java @@ -99,14 +99,14 @@ protected List call() throws Exception { List pdfEntriesInFile = pdfImporterResult.getDatabase().getEntries(); if (pdfImporterResult.hasWarnings()) { - addResultToList(file, false, Localization.lang("Error reading PDF content: %0 ", pdfImporterResult.getErrorMessage())); + addResultToList(file, false, Localization.lang("Error reading PDF content: %0", pdfImporterResult.getErrorMessage())); } var xmpParserResult = contentImporter.importXMPContent(file); List xmpEntriesInFile = xmpParserResult.getDatabase().getEntries(); if (xmpParserResult.hasWarnings()) { - addResultToList(file, false, Localization.lang("Error reading XMP content: %0 ", xmpParserResult.getErrorMessage())); + addResultToList(file, false, Localization.lang("Error reading XMP content: %0", xmpParserResult.getErrorMessage())); } // First try xmp import, if empty try pdf import, otherwise create empty entry From e2fd3ba93a6a5ec2dc503adbb56373d3b4385181 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:36:06 +0100 Subject: [PATCH 25/71] add l10n --- .../jabref/gui/externalfiles/UnlinkedFilesDialog.fxml | 11 +++++++---- .../gui/externalfiles/UnlinkedFilesDialogView.java | 2 ++ src/main/resources/l10n/JabRef_en.properties | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml index 8133b7522dc..ce0ae096e8d 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml @@ -21,7 +21,7 @@ - @@ -58,7 +58,10 @@ diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index fd37847f822..bdf7d046c54 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -15,6 +15,7 @@ import javafx.scene.control.Label; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TextField; +import javafx.scene.control.Tooltip; import javafx.scene.control.TreeView; import javafx.stage.FileChooser; @@ -64,6 +65,7 @@ public UnlinkedFilesDialogView() { Button btnImport = (Button) this.getDialogPane().lookupButton(importButton); ControlHelper.setAction(importButton, getDialogPane(), evt-> viewModel.startImport()); btnImport.disableProperty().bindBidirectional(viewModel.applyButtonDisabled()); + btnImport.setTooltip(new Tooltip("Starts the import of BibTeX entries.")); setResultConverter(button -> { if (button == ButtonType.CANCEL) { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 7fa46947f7c..e464011609f 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2284,3 +2284,12 @@ Regular\ expression=Regular expression Error\ importing.\ See\ the\ error\ log\ for\ details.=Error importing. See the error log for details. +Error\ from\ import\:\ %0=Error from import\: %0 +Error\ reading\ PDF\ content\:\ %0=Error reading PDF content\: %0 +Error\ reading\ XMP\ content\:\ %0=Error reading XMP content\: %0 +Importing\ bib\ entry=Importing bib entry +Importing\ using\ XMP\ data...=Importing using XMP data... +Importing\ using\ extracted\ PDF\ data=Importing using extracted PDF data +No\ bibtex\ data\ found.\ Creating\ empty\ entry\ with\ file\ link=No bibtex data found. Creating empty entry with file link +No\ metadata\ found.\ Creating\ empty\ entry\ with\ file\ link=No metadata found. Creating empty entry with file link +Processing\ file\ %0\ of\ %1=Processing file %0 of %1 From bee42c6be6b188e560b306606470a5c585e49c8a Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Dec 2020 18:48:37 +0100 Subject: [PATCH 26/71] further l10n fixes --- .../org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml | 4 ++-- .../org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java | 2 +- src/main/resources/l10n/JabRef_en.properties | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml index ce0ae096e8d..3dcd393d259 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml @@ -38,12 +38,12 @@ - - diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index 653eac8c735..f2a4d3ebe52 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -17,8 +17,10 @@ import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; +import javafx.scene.control.TitledPane; import javafx.scene.control.Tooltip; import javafx.scene.control.TreeView; +import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.stage.FileChooser; @@ -49,14 +51,17 @@ public class UnlinkedFilesDialogView extends BaseDialog { @FXML private ButtonType importButton; @FXML private Button buttonExport; @FXML private Label progressText; - @FXML private Label treeDesc; @FXML private ProgressIndicator progressDisplay; + @FXML private VBox progressPane; @FXML private TableView tvResult; @FXML private TableColumn colStatus; @FXML private TableColumn colMessage; @FXML private TableColumn colFile; + @FXML private TitledPane filePane; + @FXML private TitledPane resultPane; + @Inject private PreferencesService preferencesService; @Inject private DialogService dialogService; @Inject private StateManager stateManager; @@ -119,14 +124,17 @@ private void initialize() { viewModel.exportButtonDisabled().bindBidirectional(buttonExport.disableProperty()); viewModel.selectedExtension().bind(fileTypeSelection.valueProperty()); - tvResult.visibleProperty().bind(viewModel.resultsTableVisible()); tvResult.setItems(viewModel.resultTableItems()); progressDisplay.progressProperty().bind(viewModel.progress()); - progressDisplay.managedProperty().bind(viewModel.searchProgressVisible()); - progressDisplay.visibleProperty().bind(viewModel.searchProgressVisible()); progressText.textProperty().bind(viewModel.progressText()); + progressPane.managedProperty().bind(viewModel.searchProgressVisible()); + progressPane.visibleProperty().bind(viewModel.searchProgressVisible()); + + viewModel.filePaneExpanded().bindBidirectional(filePane.expandedProperty()); + viewModel.resultPaneExpanded().bindBidirectional(resultPane.expandedProperty()); + viewModel.scanButtonDefaultButton().setValue(true); viewModel.scanButtonDisabled().setValue(true); viewModel.applyButtonDisabled().setValue(true); diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java index c0e85c99de0..f0d527237b3 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java @@ -61,7 +61,11 @@ public class UnlinkedFilesDialogViewModel { private final BooleanProperty scanButtonDefaultButton = new SimpleBooleanProperty(); private final DoubleProperty progress = new SimpleDoubleProperty(0); private final StringProperty progressText = new SimpleStringProperty(); - private final BooleanProperty resultsTableVisible = new SimpleBooleanProperty(); + + private final BooleanProperty filePaneExpanded = new SimpleBooleanProperty(); + private final BooleanProperty resultPaneExpanded = new SimpleBooleanProperty(); + + private final ObservableList resultList = FXCollections.observableArrayList(); private final List fileFilterList = List.of( @@ -94,11 +98,12 @@ public UnlinkedFilesDialogViewModel(DialogService dialogService, ExternalFileTyp public void startImport() { + + CheckBoxTreeItem root = (CheckBoxTreeItem) treeRoot.getValue(); final List fileList = getFileListFromNode(root); resultList.clear(); - resultsTableVisible.set(false); if (fileList.isEmpty()) { return; @@ -129,8 +134,9 @@ public void startImport() { progressText.unbind(); searchProgressVisible.setValue(false); + filePaneExpanded.setValue(false); + resultPaneExpanded.setValue(true); resultList.addAll(results); - resultsTableVisible.set(true); }); importFilesBackgroundTask.executeWith(taskExecutor); @@ -147,7 +153,6 @@ public void startExport() { if (fileList.isEmpty()) { return; } - resultsTableVisible.setValue(false); exportButtonDisabled.setValue(true); applyButtonDisabled.setValue(true); @@ -181,7 +186,9 @@ public void startSearch() { Path directory = this.getSearchDirectory(); FileFilter selectedFileFilter = FileFilterConverter.toFileFilter(selectedExtension.getValue()); - resultsTableVisible.setValue(false); + filePaneExpanded.setValue(true); + resultPaneExpanded.setValue(false); + progress.unbind(); progressText.unbind(); @@ -353,11 +360,15 @@ private void expandTree(TreeItem item, boolean expand) { } } - public BooleanProperty resultsTableVisible() { - return this.resultsTableVisible; - } - public ObservableList resultTableItems() { return this.resultList; } + + public BooleanProperty filePaneExpanded() { + return this.filePaneExpanded; + } + + public BooleanProperty resultPaneExpanded() { + return this.resultPaneExpanded; + } } From 3683a2ceced9e296635bcc4bf9448c3fb011e80c Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Tue, 29 Dec 2020 12:58:43 +0100 Subject: [PATCH 35/71] fix checkstyle --- .../UnlinkedFilesDialogViewModel.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java index f0d527237b3..bf8e9248967 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java @@ -61,11 +61,9 @@ public class UnlinkedFilesDialogViewModel { private final BooleanProperty scanButtonDefaultButton = new SimpleBooleanProperty(); private final DoubleProperty progress = new SimpleDoubleProperty(0); private final StringProperty progressText = new SimpleStringProperty(); - private final BooleanProperty filePaneExpanded = new SimpleBooleanProperty(); private final BooleanProperty resultPaneExpanded = new SimpleBooleanProperty(); - private final ObservableList resultList = FXCollections.observableArrayList(); private final List fileFilterList = List.of( @@ -98,8 +96,6 @@ public UnlinkedFilesDialogViewModel(DialogService dialogService, ExternalFileTyp public void startImport() { - - CheckBoxTreeItem root = (CheckBoxTreeItem) treeRoot.getValue(); final List fileList = getFileListFromNode(root); @@ -322,6 +318,24 @@ private List getFileListFromNode(CheckBoxTreeItem node) { return filesList; } + private List getFileListFromNode(CheckBoxTreeItem node) { + List filesList = new ArrayList<>(); + for (TreeItem childNode : node.getChildren()) { + CheckBoxTreeItem child = (CheckBoxTreeItem) childNode; + if (child.isLeaf()) { + if (child.isSelected()) { + Path nodeFile = child.getValue().path; + if ((nodeFile != null) && Files.isRegularFile(nodeFile)) { + filesList.add(nodeFile); + } + } + } else { + filesList.addAll(getFileListFromNode(child)); + } + } + return filesList; + } + public void selectAll() { CheckBoxTreeItem root = (CheckBoxTreeItem) treeRoot.getValue(); // Need to toggle a twice to make sure everything is selected From 78cf06ba89433586a93bc5fe0eb13973a6888bd8 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Tue, 29 Dec 2020 13:46:08 +0100 Subject: [PATCH 36/71] fix duplicate method --- .../UnlinkedFilesDialogViewModel.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java index bf8e9248967..9878ba6ab5f 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogViewModel.java @@ -318,24 +318,6 @@ private List getFileListFromNode(CheckBoxTreeItem node) { return filesList; } - private List getFileListFromNode(CheckBoxTreeItem node) { - List filesList = new ArrayList<>(); - for (TreeItem childNode : node.getChildren()) { - CheckBoxTreeItem child = (CheckBoxTreeItem) childNode; - if (child.isLeaf()) { - if (child.isSelected()) { - Path nodeFile = child.getValue().path; - if ((nodeFile != null) && Files.isRegularFile(nodeFile)) { - filesList.add(nodeFile); - } - } - } else { - filesList.addAll(getFileListFromNode(child)); - } - } - return filesList; - } - public void selectAll() { CheckBoxTreeItem root = (CheckBoxTreeItem) treeRoot.getValue(); // Need to toggle a twice to make sure everything is selected From b036f11b91709410bcb47fb553a64822c462edbe Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 2 Jan 2021 18:14:47 +0100 Subject: [PATCH 37/71] align browse button --- .../org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml index 4a9bf3d6f29..83c0b608850 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml @@ -26,10 +26,10 @@ - - - - + + diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index f2a4d3ebe52..ebe8632256f 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -9,6 +9,7 @@ import javafx.collections.FXCollections; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.control.Accordion; import javafx.scene.control.Button; import javafx.scene.control.ButtonType; import javafx.scene.control.ComboBox; @@ -51,6 +52,7 @@ public class UnlinkedFilesDialogView extends BaseDialog { @FXML private ButtonType importButton; @FXML private Button buttonExport; @FXML private Label progressText; + @FXML private Accordion accordion; @FXML private ProgressIndicator progressDisplay; @FXML private VBox progressPane; @@ -131,6 +133,7 @@ private void initialize() { progressPane.managedProperty().bind(viewModel.searchProgressVisible()); progressPane.visibleProperty().bind(viewModel.searchProgressVisible()); + accordion.disableProperty().bind(viewModel.searchProgressVisible()); viewModel.filePaneExpanded().bindBidirectional(filePane.expandedProperty()); viewModel.resultPaneExpanded().bindBidirectional(resultPane.expandedProperty()); From fe59fb97dd979c4944cffb082007de08b0b403bd Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage Date: Sun, 3 Jan 2021 22:13:38 +0100 Subject: [PATCH 40/71] Fixed accordion and l10n --- .../externalfiles/UnlinkedFilesDialog.fxml | 22 ++++++++++--------- .../UnlinkedFilesDialogView.java | 3 ++- src/main/resources/l10n/JabRef_en.properties | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml index 66c1c42477d..6827bfeb750 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml @@ -19,6 +19,7 @@ + @@ -26,10 +27,13 @@