-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[WIP] Added number of items found #5740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
|
||
import javax.inject.Inject; | ||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.beans.binding.Bindings; | ||
import javafx.beans.binding.BooleanBinding; | ||
import javafx.css.PseudoClass; | ||
|
@@ -48,6 +47,8 @@ public class ImportEntriesDialog extends BaseDialog<Void> { | |
|
||
public CheckListView<BibEntry> entriesListView; | ||
public ButtonType importButton; | ||
public Label totalItems; | ||
public Label selectedItems; | ||
private final BackgroundTask<List<BibEntry>> task; | ||
private ImportEntriesViewModel viewModel; | ||
@Inject private TaskExecutor taskExecutor; | ||
|
@@ -61,7 +62,6 @@ public class ImportEntriesDialog extends BaseDialog<Void> { | |
public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<List<BibEntry>> task) { | ||
this.database = database; | ||
this.task = task; | ||
|
||
ViewLoader.view(this) | ||
.load() | ||
.setAsDialogPane(this); | ||
|
@@ -84,12 +84,12 @@ public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<List<BibE | |
@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); | ||
entriesListView.setItems(viewModel.getEntries()); | ||
|
||
totalItems.setText("0"); | ||
selectedItems.setText("0"); | ||
PseudoClass entrySelected = PseudoClass.getPseudoClass("entry-selected"); | ||
new ViewModelListCellFactory<BibEntry>() | ||
.withGraphic(entry -> { | ||
|
@@ -103,6 +103,19 @@ private void initialize() { | |
}); | ||
addToggle.getStyleClass().add("addEntryButton"); | ||
addToggle.selectedProperty().bindBidirectional(entriesListView.getItemBooleanProperty(entry)); | ||
addToggle.selectedProperty().addListener((observable, oldValue, newValue) -> { | ||
if(observable.getValue()){ | ||
++numberOfSelectedItems; | ||
selectedItems.setText(String.valueOf(numberOfSelectedItems)); | ||
}else | ||
if(numberOfSelectedItems == 0){ | ||
return; | ||
} | ||
else{ | ||
--numberOfSelectedItems; | ||
selectedItems.setText(String.valueOf(numberOfSelectedItems)); | ||
} | ||
}); | ||
HBox separator = new HBox(); | ||
HBox.setHgrow(separator, Priority.SOMETIMES); | ||
Node entryNode = getEntryNode(entry); | ||
|
@@ -125,13 +138,11 @@ private void initialize() { | |
*/ | ||
if (entriesListView.getItems().size() == 1) { | ||
selectAllNewEntries(); | ||
} | ||
|
||
} | ||
totalItems.textProperty().setValue(String.valueOf(entriesListView.getItems().size())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be possible to bind the text directly to the size: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually didn't work as you said, I just pushed some changes that were missing, I hope everything is ok. |
||
return container; | ||
}) | ||
.withOnMouseClickedEvent((entry, event) -> entriesListView.getCheckModel().toggleCheckState(entry)) | ||
.withPseudoClass(entrySelected, entriesListView::getItemBooleanProperty) | ||
.install(entriesListView); | ||
.withOnMouseClickedEvent((entry, event) -> entriesListView.getCheckModel().toggleCheckState(entry)).withPseudoClass(entrySelected, entriesListView::getItemBooleanProperty).install(entriesListView); | ||
entriesListView.setSelectionModel(new NoSelectionModel<>()); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow our code formatting guidelines. The auto formatter should add some spaces here.