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

Number of items found in ImportEntriesDialog #6248

Merged
merged 6 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We updated EditionChecker to permit edition to start with a number. [#6144](https://github.com/JabRef/jabref/issues/6144)
- We added tooltips for most fields in the entry editor containing a short description. [#5847](https://github.com/JabRef/jabref/issues/5847)
- We added support for basic markdown in custom formatted previews [#6194](https://github.com/JabRef/jabref/issues/6194)
- We now show the number of items found and selected to import in the online search dialog. [#6248](https://github.com/JabRef/jabref/pull/6248)

### Changed

Expand Down
37 changes: 28 additions & 9 deletions src/main/java/org/jabref/gui/importer/ImportEntriesDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,42 @@
<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>

<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<?import org.controlsfx.control.CheckListView?>
<DialogPane xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="org.jabref.gui.importer.ImportEntriesDialog"
prefHeight="700.0" prefWidth="1000.0">

<DialogPane prefHeight="700.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/10.0.2-internal"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.importer.ImportEntriesDialog">
<content>
<VBox spacing="10">
<VBox spacing="10.0">
<Label text="%Select the entries to be imported:"/>
<CheckListView fx:id="entriesListView" VBox.vgrow="ALWAYS"/>
<HBox>
<Button text="%Select all new entries" styleClass="text-button" onAction="#selectAllNewEntries"/>
<Button text="%Unselect all" styleClass="text-button" onAction="#unselectAll"/>
<HBox spacing="4">
<Button onAction="#selectAllNewEntries" styleClass="text-button" text="%Select all new entries"/>
<Button onAction="#unselectAll" styleClass="text-button" text="%Unselect all"/>
<HBox HBox.hgrow="ALWAYS" />
<GridPane hgap="4.0" vgap="4.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="30" halignment="RIGHT"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0"/>
<RowConstraints minHeight="10.0"/>
</rowConstraints>
<Label styleClass="info-section" text="%Total items found:"/>
<Label fx:id="totalItems" GridPane.columnIndex="1"/>
<Label styleClass="info-section" text="%Selected items:" GridPane.rowIndex="1"/>
<Label fx:id="selectedItems" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
</GridPane>
</HBox>
</VBox>
</content>
<ButtonType fx:id="importButton" text="%Import entries" buttonData="OK_DONE"/>
<ButtonType fx:id="importButton" buttonData="OK_DONE" text="%Import entries"/>
<ButtonType fx:constant="CANCEL"/>
</DialogPane>
11 changes: 7 additions & 4 deletions src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class ImportEntriesDialog extends BaseDialog<Void> {

public CheckListView<BibEntry> entriesListView;
public ButtonType importButton;
public Label totalItems;
public Label selectedItems;
private final BackgroundTask<ParserResult> task;
private ImportEntriesViewModel viewModel;
@Inject private TaskExecutor taskExecutor;
Expand All @@ -67,7 +69,6 @@ public class ImportEntriesDialog extends BaseDialog<Void> {
public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserResult> task) {
this.database = database;
this.task = task;

ViewLoader.view(this)
.load()
.setAsDialogPane(this);
Expand All @@ -90,7 +91,6 @@ public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserRes
@FXML
private void initialize() {
viewModel = new ImportEntriesViewModel(task, taskExecutor, database, dialogService, undoManager, preferences, stateManager, fileUpdateMonitor);

Label placeholder = new Label();
placeholder.textProperty().bind(viewModel.messageProperty());
entriesListView.setPlaceholder(placeholder);
Expand Down Expand Up @@ -126,18 +126,21 @@ private void initialize() {
}).executeWith(Globals.TASK_EXECUTOR);

/*
inserted the if-statement here, since a Platforn.runLater() call did not work.
inserted the if-statement here, since a Platform.runLater() call did not work.
also tried to move it to the end of the initialize method, but it did not select the entry.
*/
if (entriesListView.getItems().size() == 1) {
selectAllNewEntries();
}
}

return container;
})
.withOnMouseClickedEvent((entry, event) -> entriesListView.getCheckModel().toggleCheckState(entry))
.withPseudoClass(entrySelected, entriesListView::getItemBooleanProperty)
.install(entriesListView);

selectedItems.textProperty().bind(Bindings.size(entriesListView.getCheckModel().getCheckedItems()).asString());
totalItems.textProperty().bind(Bindings.size(entriesListView.getItems()).asString());
entriesListView.setSelectionModel(new NoSelectionModel<>());
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,8 @@ Cancel\ import=Cancel import
Continue\ with\ import=Continue with import
Import\ canceled=Import canceled
Select\ all\ new\ entries=Select all new entries
Total\ items\ found\:=Total items found:
Selected\ items\:=Selected items:
Select\ the\ entries\ to\ be\ imported\:=Select the entries to be imported\:
Add\ new\ String=Add new String
Remove\ selected\ Strings=Remove selected Strings
Expand Down