Skip to content

Commit

Permalink
Add disable/enable calculation of items in group (#6233)
Browse files Browse the repository at this point in the history
* Init changes

* Init changes

* Восстановлено исходное состояние мастера

* Просто коммит

* Issue #6042 fixed

* Issue #6042 fixed
Corrected resources file after not passing the test

* - Added new property to PreferencesService and JabRefPreferences
- Used this property in GroupsTabView
- DisplayGroupQuantity renamed into DisplayGroupCount in GroupsTabView & GroupsTabViewModel

* - removed line from JabRef_en.properties

* Updated Properties file
- removed line from ...da.properties;
- added line to ...en.properties;

* Changed GroupTreeView according to comments from Tobiasdiez
Main task - disable calling "group.getHits()" method to avoid calculation of items in group.

* Remove empty line

Co-authored-by: Tobias Diez <[email protected]>
  • Loading branch information
Gena928 and tobiasdiez authored Apr 5, 2020
1 parent 5cef762 commit efc69be
Show file tree
Hide file tree
Showing 10 changed files with 1,669 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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
6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void initialize() {
.withTooltip(GroupNodeViewModel::getDescription)
.install(mainColumn);

// Number of hits
// Number of hits (only if user wants to see them)
PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
new ViewModelTreeTableCellFactory<GroupNodeViewModel>()
Expand All @@ -134,7 +134,9 @@ public void initialize() {
group.allSelectedEntriesMatchedProperty());
}
Text text = new Text();
text.textProperty().bind(group.getHits().asString());
if (preferencesService.getDisplayGroupCount()) {
text.textProperty().bind(group.getHits().asString());
}
text.getStyleClass().setAll("text");
node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
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="displayGroupCount" text="%Display count 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 displayGroupCount;
@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());
displayGroupCount.selectedProperty().bindBidirectional(viewModel.displayGroupCount());
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 displayGroupCountProperty = 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));
displayGroupCountProperty.setValue(preferences.getBoolean(JabRefPreferences.DISPLAY_GROUP_COUNT));

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_COUNT, displayGroupCountProperty.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 displayGroupCount() { return displayGroupCountProperty;}

public StringProperty defaultGroupingFieldProperty() { return defaultGroupingFieldProperty; }

public StringProperty keywordSeparatorProperty() { return keywordSeparatorProperty; }
Expand Down
7 changes: 7 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_COUNT = "displayGroupCount";
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_COUNT, 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 Expand Up @@ -2052,4 +2054,9 @@ public void storeTimestampPreferences(TimestampPreferences preferences) {
put(TIME_STAMP_FORMAT, preferences.getTimestampFormat());
putBoolean(OVERWRITE_TIME_STAMP, preferences.isOverwriteTimestamp());
}

@Override
public boolean getDisplayGroupCount() {
return getBoolean(JabRefPreferences.DISPLAY_GROUP_COUNT);
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/preferences/PreferencesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,6 @@ public interface PreferencesService {

void storeTimestampPreferences(TimestampPreferences preferences);

boolean getDisplayGroupCount();

}
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,5 @@ Default\ pattern=Standardmønster
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 @@ -2093,6 +2093,7 @@ Unable\ to\ open\ ShortScience.=Unable to open ShortScience.
Shared\ database=Shared database
Lookup=Lookup
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 Expand Up @@ -2157,3 +2158,4 @@ Year\ of\ publication.=Year of publication.
Remove\ formatter\ for\ %0=Remove formatter for %0
Remove\ formatter\ '%0'=Remove formatter '%0'
Display\ count\ of\ items\ in\ group=Display count of items in group
Loading

0 comments on commit efc69be

Please sign in to comment.