Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ooPanel
Browse files Browse the repository at this point in the history
* upstream/master:
  improve styling of preferences side menu (#4556)
  Cleanup interfaces (#4553)
  Bump fontbox from 2.0.12 to 2.0.13 (#4552)
  Bump pdfbox from 2.0.12 to 2.0.13 (#4551)
  Bump wiremock from 2.19.0 to 2.20.0 (#4550)
  Fixes that renaming a group did not change the group name in the interface (#4549)
  • Loading branch information
Siedlerchr committed Dec 28, 2018
2 parents ff8f419 + b936ba9 commit b5fdf0e
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the menu on Mac OS was not displayed in the usual Mac-specific way. https://github.com/JabRef/jabref/issues/3146
- We improved the integrity check for page numbers. [#4113](https://github.com/JabRef/jabref/issues/4113) and [feature request in the forum](http://discourse.jabref.org/t/pages-field-allow-use-of-en-dash/1199)
- We fixed an issue where the order of fields in customized entry types was not saved correctly. [#4033](http://github.com/JabRef/jabref/issues/4033)
- We fixed an issue where renaming a group did not change the group name in the interface. [#3189](https://github.com/JabRef/jabref/issues/3189)
- We fixed an issue where the groups tree of the last database was still shown even after the database was already closed.
- We fixed an issue where the "Open file dialog" may disappear behind other windows. https://github.com/JabRef/jabref/issues/3410
- We fixed an issue where the number of entries matched was not updated correctly upon adding or removing an entry. [#3537](https://github.com/JabRef/jabref/issues/3537)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ dependencies {
compile 'com.jgoodies:jgoodies-common:1.8.1'
compile 'com.jgoodies:jgoodies-forms:1.9.0'

compile 'org.apache.pdfbox:pdfbox:2.0.12'
compile 'org.apache.pdfbox:fontbox:2.0.12'
compile 'org.apache.pdfbox:pdfbox:2.0.13'
compile 'org.apache.pdfbox:fontbox:2.0.13'
compile 'org.apache.pdfbox:xmpbox:2.0.12'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
Expand Down Expand Up @@ -170,7 +170,7 @@ dependencies {
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1'
testCompile 'org.mockito:mockito-core:2.23.4'
testCompile 'com.github.tomakehurst:wiremock:2.19.0'
testCompile 'com.github.tomakehurst:wiremock:2.20.0'
testCompile 'org.assertj:assertj-swing-junit:3.8.0'
testCompile 'org.reflections:reflections:0.9.11'
testCompile 'org.xmlunit:xmlunit-core:2.6.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui.autocompleter;

public interface AutoCompletionStrategy {

public AutoCompletionInput analyze(String input);
AutoCompletionInput analyze(String input);
}
12 changes: 6 additions & 6 deletions src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
this.groupNode = Objects.requireNonNull(groupNode);
this.localDragBoard = Objects.requireNonNull(localDragBoard);

LatexToUnicodeFormatter formatter = new LatexToUnicodeFormatter();
displayName = formatter.format(groupNode.getName());
displayName = new LatexToUnicodeFormatter().format(groupNode.getName());
isRoot = groupNode.isRoot();
if (groupNode.getGroup() instanceof AutomaticGroup) {
AutomaticGroup automaticGroup = (AutomaticGroup) groupNode.getGroup();

children = automaticGroup.createSubgroups(databaseContext.getDatabase().getEntries()).stream()
.map(this::toViewModel)
.sorted((group1, group2) -> group1.getDisplayName().compareToIgnoreCase(group2.getDisplayName()))
.collect(Collectors.toCollection(FXCollections::observableArrayList));
children = automaticGroup.createSubgroups(this.databaseContext.getDatabase().getEntries())
.stream()
.map(this::toViewModel)
.sorted((group1, group2) -> group1.getDisplayName().compareToIgnoreCase(group2.getDisplayName()))
.collect(Collectors.toCollection(FXCollections::observableArrayList));
} else {
children = BindingsHelper.mapBacked(groupNode.getChildren(), this::toViewModel);
}
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ public void initialize() {

// Icon and group name
mainColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
mainColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
.withText(GroupNodeViewModel::getDisplayName)
.withIcon(GroupNodeViewModel::getIcon)
.withTooltip(GroupNodeViewModel::getDescription));
.withTooltip(GroupNodeViewModel::getDescription)
.install(mainColumn);

// Number of hits
PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
numberColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
.withGraphic(group -> {
final StackPane node = new StackPane();
node.getStyleClass().setAll("hits");
Expand All @@ -138,11 +139,12 @@ public void initialize() {
node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
return node;
}));
})
.install(numberColumn);

// Arrow indicating expanded status
disclosureNodeColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
disclosureNodeColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>()
.withGraphic(viewModel -> {
final StackPane disclosureNode = new StackPane();
disclosureNode.visibleProperty().bind(viewModel.hasChildrenProperty());
Expand All @@ -156,7 +158,8 @@ public void initialize() {
.withOnMouseClickedEvent(group -> event -> {
group.toggleExpansion();
event.consume();
}));
})
.install(disclosureNodeColumn);

// Set pseudo-classes to indicate if row is root or sub-item ( > 1 deep)
PseudoClass rootPseudoClass = PseudoClass.getPseudoClass("root");
Expand Down Expand Up @@ -316,6 +319,7 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) {
editGroup.setOnAction(event -> {
menu.hide();
viewModel.editGroup(group);
groupTree.refresh();
});

MenuItem addSubgroup = new MenuItem(Localization.lang("Add subgroup"));
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ public GroupTreeViewModel(StateManager stateManager, DialogService dialogService
EasyBind.subscribe(selectedGroups, this::onSelectedGroupChanged);

// Set-up bindings
filterPredicate
.bind(Bindings.createObjectBinding(() -> group -> group.isMatchedBy(filterText.get()), filterText));
filterPredicate.bind(Bindings.createObjectBinding(() -> group -> group.isMatchedBy(filterText.get()), filterText));

// Init
refresh();
}

private void refresh() {
onActiveDatabaseChanged(stateManager.activeDatabaseProperty().getValue());
}

Expand Down Expand Up @@ -166,13 +169,13 @@ public void editGroup(GroupNodeViewModel oldGroup) {
Localization.lang("Change of Grouping Method"),
Localization.lang("Assign the original group's entries to this group?"));
// WarnAssignmentSideEffects.warnAssignmentSideEffects(newGroup, panel.frame());
boolean removePreviousAssignents = (oldGroup.getGroupNode().getGroup() instanceof ExplicitGroup)
boolean removePreviousAssignments = (oldGroup.getGroupNode().getGroup() instanceof ExplicitGroup)
&& (group instanceof ExplicitGroup);

oldGroup.getGroupNode().setGroup(
group,
keepPreviousAssignments,
removePreviousAssignents,
removePreviousAssignments,
stateManager.getEntriesInCurrentDatabase());

// TODO: Add undo
Expand All @@ -194,6 +197,9 @@ public void editGroup(GroupNodeViewModel oldGroup) {

dialogService.notify(Localization.lang("Modified group \"%0\".", group.getName()));
writeGroupChangesToMetaData();

// This is ugly but we have no proper update mechanism in place to propagate the changes, so redraw everything
refresh();
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#sideMenu {
-fx-background-color: -jr-white;
-fx-border-color: -fx-outer-border;
-fx-border-width: 1;
}

#sideMenu > .virtual-flow > .clipped-container > .sheet > .list-cell {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/gui/preferences/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,21 @@ private void construct() {

VBox buttonContainer = new VBox();
buttonContainer.setAlignment(Pos.BOTTOM_LEFT);
buttonContainer.setSpacing(3.0);
Button importPreferences = new Button(Localization.lang("Import preferences"));
importPreferences.setTooltip(new Tooltip(Localization.lang("Import preferences from file")));
importPreferences.setOnAction(e -> importPreferences());
importPreferences.getStyleClass().add("text-button");
importPreferences.setMaxWidth(Double.MAX_VALUE);
Button exportPreferences = new Button(Localization.lang("Export preferences"));
exportPreferences.setTooltip(new Tooltip(Localization.lang("Export preferences to file")));
exportPreferences.setOnAction(e -> exportPreferences());
exportPreferences.getStyleClass().add("text-button");
exportPreferences.setMaxWidth(Double.MAX_VALUE);
Button showPreferences = new Button(Localization.lang("Show preferences"));
showPreferences.setOnAction(e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(prefs)).setVisible(true));
showPreferences.getStyleClass().add("text-button");
showPreferences.setMaxWidth(Double.MAX_VALUE);
Button resetPreferences = new Button(Localization.lang("Reset preferences"));
resetPreferences.setOnAction(e -> resetPreferences());
resetPreferences.getStyleClass().add("text-button");
resetPreferences.setMaxWidth(Double.MAX_VALUE);
buttonContainer.getChildren().addAll(
importPreferences,
exportPreferences,
Expand All @@ -138,6 +139,7 @@ private void construct() {
);

VBox spacer = new VBox();
spacer.setPrefHeight(10.0);
VBox.setVgrow(tabsList, Priority.ALWAYS);
VBox.setVgrow(spacer, Priority.SOMETIMES);
vBox.getChildren().addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ protected void updateItem(T item, boolean empty) {
}
};
}

public void install(TreeTableColumn<S, T> column) {
column.setCellFactory(this);
}
}
14 changes: 5 additions & 9 deletions src/main/java/org/jabref/model/groups/GroupTreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,19 @@ public GroupTreeNode copyNode() {
* @param entries list of entries to be searched
* @return number of hits
*/
public int calculateNumberOfMatches(List<BibEntry> entries) {
int hits = 0;
public long calculateNumberOfMatches(List<BibEntry> entries) {
SearchMatcher matcher = getSearchMatcher();
for (BibEntry entry : entries) {
if (matcher.isMatch(entry)) {
hits++;
}
}
return hits;
return entries.stream()
.filter(matcher::isMatch)
.count();
}

/**
* Determines the number of entries in the specified database which are matched by this group.
* @param database database to be searched
* @return number of hits
*/
public int calculateNumberOfMatches(BibDatabase database) {
public long calculateNumberOfMatches(BibDatabase database) {
return calculateNumberOfMatches(database.getEntries());
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/preferences/PreferencesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public interface PreferencesService {

void setCustomTabsNameAndFields(String name, String fields, int defNumber);

public void purgeSeries(String prefix, int number);
void purgeSeries(String prefix, int number);

public void updateEntryEditorTabList();
void updateEntryEditorTabList();

List<TemplateExporter> getCustomExportFormats(JournalAbbreviationLoader loader);

Expand Down

0 comments on commit b5fdf0e

Please sign in to comment.