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

Add disable/enable calculation of items in group (2) #6244

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
72c022e
Adjusted GroupNodeViewModel.java.
Gena928 Apr 5, 2020
1f4e4ad
Adjusted GroupNodeViewModel.
Gena928 Apr 6, 2020
ebd6284
Update GroupNodeViewModel.java
Gena928 Apr 6, 2020
c0990dc
Injected PreferencesService using a constructor call.
Gena928 Apr 11, 2020
1b5d16d
Merge branch 'master' into 6042(2)
tobiasdiez Apr 28, 2020
f6c12f4
Update GroupNodeViewModel.java
tobiasdiez Apr 28, 2020
3f368e9
Fixed an issue where a new entry is not shown in the library if a fil…
nsmt09 May 1, 2020
c8da256
Partial fix for issue 5891
May 8, 2020
ce33357
Added more tests
May 8, 2020
3df1342
Added more tests
May 9, 2020
5454a09
Added more tests
May 9, 2020
e066958
Merge branch 'fix-for-issue-5891' of https://github.com/silverhorse/j…
May 12, 2020
40541ad
Small update to resolve GIT conflict
Gena928 May 22, 2020
9287490
Return true in action helper if file is online link
Siedlerchr May 22, 2020
d4f23fa
fix checkstyle
Siedlerchr May 22, 2020
b1e899a
Adjusted fix by using StateManager for clearing search bar
nsmt09 May 22, 2020
a9eeb05
Merge branch 'master' into fix-for-issue-6297
Siedlerchr May 22, 2020
7748940
Update ActionHelper.java
tobiasdiez May 22, 2020
c8344be
Merge branch 'master' into 6042(2)
tobiasdiez May 22, 2020
dffcf78
Merge pull request #6511 from JabRef/fixActionHelperWithOnlineLink
Siedlerchr May 22, 2020
2c1a69e
Refactored tableColumnsTab and tableTab, changed to PreferencesService
calixtus May 22, 2020
9882c6d
Fix help file tests
tobiasdiez May 23, 2020
e277c0c
Remove Grobid also from tests
tobiasdiez May 23, 2020
e76a92c
Extend the bib file for better screenshots
tobiasdiez May 23, 2020
03e3663
Refactor externalprefs (#6509)
calixtus May 23, 2020
3e96170
Merge pull request #6513 from JabRef/fetcherHelp
Siedlerchr May 24, 2020
737af75
Add javadoc and fix the preview update issue
leitianjian May 24, 2020
2a5717c
Merged entry table tabs
calixtus May 24, 2020
ab50ca8
Refactored MainTableNameFormatter
calixtus May 24, 2020
cb6804e
CHANGELOG.md
calixtus May 24, 2020
fa5f879
Merge pull request #6514 from JabRef/extendBib
Siedlerchr May 24, 2020
c8949bd
Added cache and comments
calixtus May 24, 2020
ead191e
Merge remote-tracking branch 'upstream/master' into refactor_tableprefs
calixtus May 24, 2020
8d468cb
Bump flexmark-ext-gfm-tasklist from 0.61.30 to 0.61.32
dependabot-preview[bot] May 25, 2020
4f75f57
Bump flexmark from 0.61.30 to 0.61.32
dependabot-preview[bot] May 25, 2020
196f937
Bump archunit-junit5-api from 0.13.1 to 0.14.1
dependabot-preview[bot] May 25, 2020
20c70a9
Merge pull request #6520 from JabRef/dependabot/gradle/com.vladsch.fl…
Siedlerchr May 25, 2020
7d3bd7b
Merge pull request #6521 from JabRef/dependabot/gradle/com.vladsch.fl…
Siedlerchr May 25, 2020
59361fc
Bump flexmark-ext-gfm-strikethrough from 0.61.30 to 0.61.32
dependabot-preview[bot] May 25, 2020
43262c3
Merge pull request #6522 from JabRef/dependabot/gradle/com.vladsch.fl…
Siedlerchr May 25, 2020
bc1e341
Merge pull request #6523 from JabRef/dependabot/gradle/com.tngtech.ar…
Siedlerchr May 25, 2020
d01f370
Fixed main table refresh
calixtus May 25, 2020
b86800c
Revert to old switch expression for checkstyle compatibility
calixtus May 25, 2020
0bd2fd2
Revert more switch expressions for checkstyle compatibility
calixtus May 25, 2020
25bd506
CHANGELOG.md
calixtus May 25, 2020
6f34de3
Merge pull request #6407 from nsmt09/fix-for-issue-6297
Siedlerchr May 25, 2020
86b04a7
Merge pull request #6516 from leitianjian/entry-preview-content-update
Siedlerchr May 25, 2020
0d7156b
Fixes missing library properties context menu on library tab (#6508)
Oltman-B May 26, 2020
861e61e
Allow entrytype as sorting criterion
Siedlerchr May 27, 2020
56b0cee
update changelog
Siedlerchr May 27, 2020
104f697
checkstyle argh
Siedlerchr May 27, 2020
bb19d29
Merge pull request #6531 from JabRef/fixEntryTypeMissing
Siedlerchr May 27, 2020
47846bf
Enable users to simultaneously search all SearchBasedFetchers (#6504)
DominikVoigt May 27, 2020
c119ca2
Add markdown checks (and fix some markdown issues) (#6524)
koppor May 27, 2020
4b997f8
updating text for checkbox
May 28, 2020
5668049
reverting change from other properties files
May 28, 2020
62a6961
Merge branch 'master' of https://github.com/JabRef/jabref into fix-fo…
May 28, 2020
08eccb6
Fixes generated bibtex key and display of institute authors (#6479)
k3KAW8Pnf7mkmdSMPHz27 May 28, 2020
62f3038
Merge remote-tracking branch 'upstream/master' into refactor_tableprefs
calixtus May 28, 2020
3135197
Extracted JabRefPrefences out of PersistenceVisualStateTable
calixtus May 28, 2020
526ba89
Fix links in the readme
tobiasdiez May 28, 2020
0ce7c8f
updating text
May 28, 2020
6a1940f
updating text
May 28, 2020
ffa07cd
Merge pull request #6451 from silverhorse/fix-for-issue-5891
Siedlerchr May 28, 2020
d43bcfa
Switch to upstream version of markdow-lint (#6544)
koppor May 28, 2020
c1867e5
Fixed merge error
calixtus May 28, 2020
41678ce
Merge pull request #6518 from JabRef/refactor_tableprefs
Siedlerchr May 28, 2020
ad8ac9d
Bump flexmark from 0.61.32 to 0.62.0
dependabot-preview[bot] May 28, 2020
4eb2316
Bump flexmark-ext-gfm-tasklist from 0.61.32 to 0.62.0
dependabot-preview[bot] May 28, 2020
cab28ab
Bump bcprov-jdk15on from 1.65 to 1.65.01
dependabot-preview[bot] May 28, 2020
8ff20f1
Merge pull request #6550 from JabRef/dependabot/gradle/org.bouncycast…
Siedlerchr May 29, 2020
a852963
Merge pull request #6547 from JabRef/dependabot/gradle/com.vladsch.fl…
Siedlerchr May 29, 2020
5cb139c
Merge pull request #6548 from JabRef/dependabot/gradle/com.vladsch.fl…
Siedlerchr May 29, 2020
8b35b69
Restructure first paragraph
koppor May 29, 2020
2c30f20
Fix html
koppor May 29, 2020
9742ee1
Bump flexmark-ext-gfm-strikethrough from 0.61.32 to 0.62.0 (#6546)
dependabot-preview[bot] May 29, 2020
53e8c36
Add authors
koppor May 29, 2020
68f90c0
Merge branch '6042(2)' of git://github.com/Gena928/jabref into Gena92…
calixtus May 29, 2020
684abf6
Adjusted GroupNodeViewModel.java.
Gena928 Apr 5, 2020
58e5492
Adjusted GroupNodeViewModel.
Gena928 Apr 6, 2020
2155917
Update GroupNodeViewModel.java
Gena928 Apr 6, 2020
30cb675
Injected PreferencesService using a constructor call.
Gena928 Apr 11, 2020
5c1998f
Update GroupNodeViewModel.java
tobiasdiez Apr 28, 2020
2da0d06
Merge branch '6042(2)' of https://github.com/Gena928/jabref into 6042(2)
calixtus May 29, 2020
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
35 changes: 22 additions & 13 deletions src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.jabref.model.groups.GroupEntryChanger;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.PreferencesService;

import com.google.common.base.Enums;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
Expand All @@ -57,13 +58,15 @@ public class GroupNodeViewModel {
private final TaskExecutor taskExecutor;
private final CustomLocalDragboard localDragBoard;
private final ObservableList<BibEntry> entriesList;
private final PreferencesService preferencesService;

public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, GroupTreeNode groupNode, CustomLocalDragboard localDragBoard) {
public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, GroupTreeNode groupNode, CustomLocalDragboard localDragBoard, PreferencesService preferencesService) {
this.databaseContext = Objects.requireNonNull(databaseContext);
this.taskExecutor = Objects.requireNonNull(taskExecutor);
this.stateManager = Objects.requireNonNull(stateManager);
this.groupNode = Objects.requireNonNull(groupNode);
this.localDragBoard = Objects.requireNonNull(localDragBoard);
this.preferencesService = preferencesService;

displayName = new LatexToUnicodeFormatter().format(groupNode.getName());
isRoot = groupNode.isRoot();
Expand Down Expand Up @@ -94,16 +97,16 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
allSelectedEntriesMatched = BindingsHelper.all(selectedEntriesMatchStatus, matched -> matched);
}

public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, AbstractGroup group, CustomLocalDragboard localDragboard) {
this(databaseContext, stateManager, taskExecutor, new GroupTreeNode(group), localDragboard);
public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, AbstractGroup group, CustomLocalDragboard localDragboard, PreferencesService preferencesService) {
this(databaseContext, stateManager, taskExecutor, new GroupTreeNode(group), localDragboard, preferencesService);
}

static GroupNodeViewModel getAllEntriesGroup(BibDatabaseContext newDatabase, StateManager stateManager, TaskExecutor taskExecutor, CustomLocalDragboard localDragBoard) {
return new GroupNodeViewModel(newDatabase, stateManager, taskExecutor, DefaultGroupsFactory.getAllEntriesGroup(), localDragBoard);
static GroupNodeViewModel getAllEntriesGroup(BibDatabaseContext newDatabase, StateManager stateManager, TaskExecutor taskExecutor, CustomLocalDragboard localDragBoard, PreferencesService preferencesService) {
return new GroupNodeViewModel(newDatabase, stateManager, taskExecutor, DefaultGroupsFactory.getAllEntriesGroup(), localDragBoard, preferencesService);
}

private GroupNodeViewModel toViewModel(GroupTreeNode child) {
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, child, localDragBoard);
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, child, localDragBoard, preferencesService);
}

public List<FieldChange> addEntriesToGroup(List<BibEntry> entries) {
Expand Down Expand Up @@ -250,13 +253,19 @@ private void updateMatchedEntries() {
// We calculate the new hit value
// We could be more intelligent and try to figure out the new number of hits based on the entry change
// for example, a previously matched entry gets removed -> hits = hits - 1
BackgroundTask
.wrap(() -> groupNode.findMatches(databaseContext.getDatabase()))
.onSuccess(entries -> {
matchedEntries.clear();
matchedEntries.addAll(entries);
})
.executeWith(taskExecutor);
if (preferencesService.getDisplayGroupCount()) {
BackgroundTask
.wrap(() -> groupNode.calculateNumberOfMatches(databaseContext.getDatabase()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this duplication of the code is a result from a merge conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like yes, this is a conflict.
the second BackgroundTask is not mine. My code is:

    private void calculateNumberOfMatches() {
        // We calculate the new hit value
        // We could be more intelligent and try to figure out the new number of hits based on the entry change
        // for example, a previously matched entry gets removed -> hits = hits - 1
        if (preferencesService.getDisplayGroupCount()) {
            BackgroundTask
                    .wrap(() -> groupNode.calculateNumberOfMatches(databaseContext.getDatabase()))
                    .onSuccess(hits::setValue)
                    .executeWith(taskExecutor);
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I haven't worked with conflicts yet.
Looks like this is your correction as of 11.04.2020. Can I do something to resolve this GIT conflict?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! I also often have problems with git ;-)

Here the solution is relatively simple. Just edit the code and remove the part that is duplicated / not correct. Then commit and push.

.onSuccess(hits::setValue)
.executeWith(taskExecutor);
BackgroundTask
.wrap(() -> groupNode.findMatches(databaseContext.getDatabase()))
.onSuccess(entries -> {
matchedEntries.clear();
matchedEntries.addAll(entries);
})
.executeWith(taskExecutor);
}
}

public GroupTreeNode addSubgroup(AbstractGroup subgroup) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ private void onActiveDatabaseChanged(Optional<BibDatabaseContext> newDatabase) {
GroupNodeViewModel newRoot = newDatabase
.map(BibDatabaseContext::getMetaData)
.flatMap(MetaData::getGroups)
.map(root -> new GroupNodeViewModel(newDatabase.get(), stateManager, taskExecutor, root, localDragboard))
.orElse(GroupNodeViewModel.getAllEntriesGroup(newDatabase.get(), stateManager, taskExecutor, localDragboard));
.map(root -> new GroupNodeViewModel(newDatabase.get(), stateManager, taskExecutor, root, localDragboard, preferences))
.orElse(GroupNodeViewModel.getAllEntriesGroup(newDatabase.get(), stateManager, taskExecutor, localDragboard, preferences));

rootGroup.setValue(newRoot);
selectedGroups.setAll(
stateManager.getSelectedGroup(newDatabase.get()).stream()
.map(selectedGroup -> new GroupNodeViewModel(newDatabase.get(), stateManager, taskExecutor, selectedGroup, localDragboard))
.map(selectedGroup -> new GroupNodeViewModel(newDatabase.get(), stateManager, taskExecutor, selectedGroup, localDragboard, preferences))
.collect(Collectors.toList()));
} else {
rootGroup.setValue(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jabref.model.groups.GroupHierarchyType;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.groups.WordKeywordGroup;
import org.jabref.preferences.PreferencesService;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -159,18 +160,18 @@ void entriesAreAddedCorrectly() {
BibEntry entry = new BibEntry();
databaseContext.getDatabase().insertEntry(entry);

GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard());
GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard(), mock(PreferencesService.class));
model.addEntriesToGroup(databaseContext.getEntries());

assertEquals(databaseContext.getEntries(), model.getGroupNode().getEntriesInGroup(databaseContext.getEntries()));
assertEquals(groupName, entry.getField(StandardField.GROUPS).get());
}

private GroupNodeViewModel getViewModelForGroup(AbstractGroup group) {
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard());
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard(), mock(PreferencesService.class));
}

private GroupNodeViewModel getViewModelForGroup(GroupTreeNode group) {
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard());
return new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard(), mock(PreferencesService.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void setUp() throws Exception {
@Test
void rootGroupIsAllEntriesByDefault() throws Exception {
AllEntriesGroup allEntriesGroup = new AllEntriesGroup("All entries");
assertEquals(new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, allEntriesGroup, new CustomLocalDragboard()), groupTree.rootGroupProperty().getValue());
assertEquals(new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, allEntriesGroup, new CustomLocalDragboard(), mock(PreferencesService.class)), groupTree.rootGroupProperty().getValue());
}

@Test
Expand All @@ -49,7 +49,7 @@ void explicitGroupsAreRemovedFromEntriesOnDelete() {
BibEntry entry = new BibEntry();
databaseContext.getDatabase().insertEntry(entry);

GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard());
GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard(), mock(PreferencesService.class));
model.addEntriesToGroup(databaseContext.getEntries());
groupTree.removeGroupsAndSubGroupsFromEntries(model);

Expand All @@ -63,7 +63,7 @@ void keywordGroupsAreNotRemovedFromEntriesOnDelete() {
BibEntry entry = new BibEntry();
databaseContext.getDatabase().insertEntry(entry);

GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard());
GroupNodeViewModel model = new GroupNodeViewModel(databaseContext, stateManager, taskExecutor, group, new CustomLocalDragboard(), mock(PreferencesService.class));
model.addEntriesToGroup(databaseContext.getEntries());
groupTree.removeGroupsAndSubGroupsFromEntries(model);

Expand Down