Skip to content

Commit

Permalink
Issue JabRef#6042 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gena928 committed Apr 1, 2020
1 parent 7df02e4 commit 2862f2a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We made the filters more easily accessible in the integrity check dialog. [#5955](https://github.com/JabRef/jabref/pull/5955)
- We reimplemented and improved the dialog "Customize entry types". [#4719](https://github.com/JabRef/jabref/issues/4719)
- We added an [American Physical Society](https://journals.aps.org/) fetcher. [#818](https://github.com/JabRef/jabref/issues/818)
- We added possibility to enable/disable items quantity in groups. [#6042](https://github.com/JabRef/jabref/issues/6042)

### Fixed

Expand Down
47 changes: 26 additions & 21 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.groups.AllEntriesGroup;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreferencesService;

import org.controlsfx.control.textfield.CustomTextField;
Expand Down Expand Up @@ -71,13 +72,15 @@ public class GroupTreeView {

private GroupTreeViewModel viewModel;
private CustomLocalDragboard localDragboard;
private JabRefPreferences preferences;

private DragExpansionHandler dragExpansionHandler;

@FXML
public void initialize() {
this.localDragboard = stateManager.getLocalDragboard();
viewModel = new GroupTreeViewModel(stateManager, dialogService, preferencesService, taskExecutor, localDragboard);
preferences = JabRefPreferences.getInstance();

// Set-up groups tree
groupTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Expand Down Expand Up @@ -120,27 +123,29 @@ public void initialize() {
.withTooltip(GroupNodeViewModel::getDescription)
.install(mainColumn);

// Number of hits
PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
new ViewModelTreeTableCellFactory<GroupNodeViewModel>()
.withGraphic(group -> {
final StackPane node = new StackPane();
node.getStyleClass().setAll("hits");
if (!group.isRoot()) {
BindingsHelper.includePseudoClassWhen(node, anySelected,
group.anySelectedEntriesMatchedProperty());
BindingsHelper.includePseudoClassWhen(node, allSelected,
group.allSelectedEntriesMatchedProperty());
}
Text text = new Text();
text.textProperty().bind(group.getHits().asString());
text.getStyleClass().setAll("text");
node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
return node;
})
.install(numberColumn);
// Number of hits (only if user wants to see them)
if (preferences.getBoolean(JabRefPreferences.DISPLAY_GROUP_QUANTITY)) {
PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
new ViewModelTreeTableCellFactory<GroupNodeViewModel>()
.withGraphic(group -> {
final StackPane node = new StackPane();
node.getStyleClass().setAll("hits");
if (!group.isRoot()) {
BindingsHelper.includePseudoClassWhen(node, anySelected,
group.anySelectedEntriesMatchedProperty());
BindingsHelper.includePseudoClassWhen(node, allSelected,
group.allSelectedEntriesMatchedProperty());
}
Text text = new Text();
text.textProperty().bind(group.getHits().asString());
text.getStyleClass().setAll("text");
node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
return node;
})
.install(numberColumn);
}

// Arrow indicating expanded status
new ViewModelTreeTableCellFactory<GroupNodeViewModel>()
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/preferences/GroupsTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<RadioButton fx:id="groupViewModeUnion" text="%Display all entries belonging to one or more of the selected groups"
toggleGroup="$groupViewMode"/>
<CheckBox fx:id="autoAssignGroup" text="%Automatically assign new entry to selected groups"/>
<CheckBox fx:id="displayGroupQuantity" text="%Display quantity of items in group"/>

<Label styleClass="sectionHeader" text="%Dynamic groups"/>
<GridPane hgap="10.0" vgap="4.0">
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/preferences/GroupsTabView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class GroupsTabView extends AbstractPreferenceTabView<GroupsTabViewModel>
@FXML private RadioButton groupViewModeIntersection;
@FXML private RadioButton groupViewModeUnion;
@FXML private CheckBox autoAssignGroup;
@FXML private CheckBox displayGroupQuantity;
@FXML private TextField defaultGroupingField;
@FXML private TextField keywordSeparator;

Expand All @@ -37,6 +38,7 @@ public void initialize() {
groupViewModeIntersection.selectedProperty().bindBidirectional(viewModel.groupViewModeIntersectionProperty());
groupViewModeUnion.selectedProperty().bindBidirectional(viewModel.groupViewModeUnionProperty());
autoAssignGroup.selectedProperty().bindBidirectional(viewModel.autoAssignGroupProperty());
displayGroupQuantity.selectedProperty().bindBidirectional(viewModel.displayGroupQuantity());
defaultGroupingField.textProperty().bindBidirectional(viewModel.defaultGroupingFieldProperty());
keywordSeparator.textProperty().bindBidirectional(viewModel.keywordSeparatorProperty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class GroupsTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty groupViewModeIntersectionProperty = new SimpleBooleanProperty();
private final BooleanProperty groupViewModeUnionProperty = new SimpleBooleanProperty();
private final BooleanProperty autoAssignGroupProperty = new SimpleBooleanProperty();
private final BooleanProperty displayGroupQuantityProperty = new SimpleBooleanProperty();
private final StringProperty defaultGroupingFieldProperty = new SimpleStringProperty("");
private final StringProperty keywordSeparatorProperty = new SimpleStringProperty("");

Expand All @@ -43,6 +44,7 @@ public void setValues() {
break;
}
autoAssignGroupProperty.setValue(preferences.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
displayGroupQuantityProperty.setValue(preferences.getBoolean(JabRefPreferences.DISPLAY_GROUP_QUANTITY));

defaultGroupingFieldProperty.setValue(preferences.get(JabRefPreferences.GROUPS_DEFAULT_FIELD));
keywordSeparatorProperty.setValue(preferences.get(JabRefPreferences.KEYWORD_SEPARATOR));
Expand All @@ -57,6 +59,7 @@ public void storeSettings() {
preferences.setGroupViewMode(GroupViewMode.UNION);
}
preferences.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroupProperty.getValue());
preferences.putBoolean(JabRefPreferences.DISPLAY_GROUP_QUANTITY, displayGroupQuantityProperty.getValue());

preferences.put(JabRefPreferences.GROUPS_DEFAULT_FIELD, defaultGroupingFieldProperty.getValue().trim());
preferences.put(JabRefPreferences.KEYWORD_SEPARATOR, keywordSeparatorProperty.getValue());
Expand All @@ -76,6 +79,8 @@ public void storeSettings() {

public BooleanProperty autoAssignGroupProperty() { return autoAssignGroupProperty; }

public BooleanProperty displayGroupQuantity() { return displayGroupQuantityProperty;}

public StringProperty defaultGroupingFieldProperty() { return defaultGroupingFieldProperty; }

public StringProperty keywordSeparatorProperty() { return keywordSeparatorProperty; }
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public class JabRefPreferences implements PreferencesService {

public static final String KEYWORD_SEPARATOR = "groupKeywordSeparator";
public static final String AUTO_ASSIGN_GROUP = "autoAssignGroup";
public static final String DISPLAY_GROUP_QUANTITY = "displayGroupQuantity";
public static final String EXTRA_FILE_COLUMNS = "extraFileColumns";
public static final String OVERRIDE_DEFAULT_FONT_SIZE = "overrideDefaultFontSize";
public static final String MAIN_FONT_SIZE = "mainFontSize";
Expand Down Expand Up @@ -520,6 +521,7 @@ private JabRefPreferences() {
defaults.put(AUTOCOMPLETER_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref;related;entryset");
defaults.put(GROUPS_DEFAULT_FIELD, StandardField.KEYWORDS.getName());
defaults.put(AUTO_ASSIGN_GROUP, Boolean.TRUE);
defaults.put(DISPLAY_GROUP_QUANTITY, Boolean.TRUE);
defaults.put(GROUP_INTERSECT_UNION_VIEW_MODE, GroupViewMode.INTERSECTION.name());
defaults.put(KEYWORD_SEPARATOR, ", ");
defaults.put(DEFAULT_ENCODING, StandardCharsets.UTF_8.name());
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ Main\ layout\ file=Hoved-layoutfil
Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Tilføj altid bogstav (a, b, ...) til genererede nøgler
Default\ pattern=Standardmønster
Display\ quantity\ of\ items\ in\ group=
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,7 @@ Unable\ to\ open\ ShortScience.=Unable to open ShortScience.
Shared\ database=Shared database
Lookup=Lookup
Display\ quantity\ of\ items\ in\ group=Display quantity of items in group (restart required)
Please\ enter\ a\ field\ name\ to\ search\ for\ keywords.=Please enter a field name to search for keywords.
Access\ date\ of\ the\ address\ specified\ in\ the\ url\ field.=Access date of the address specified in the url field.
Additional\ information\ related\ to\ the\ resource\ indicated\ by\ the\ eprint\ field.=Additional information related to the resource indicated by the eprint field.
Expand Down

0 comments on commit 2862f2a

Please sign in to comment.