Skip to content

Commit

Permalink
defect #1855187: proper fix for total number of items in mywork
Browse files Browse the repository at this point in the history
  • Loading branch information
pikachugb committed Jun 21, 2022
1 parent 732911c commit 4f9bef1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void init() {
entityListData.addDataChangedHandler(entityList -> {
entityTypeSelectorComposite
.setEntityTypeCount(
countEntitiesByType(entityListData.getEntityList()));
countEntitiesByType(entityListData.getOriginalEntityList()));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class EntityTypeSelectorComposite extends Composite {
private List<Runnable> selectionListeners = new ArrayList<>();
private Label totalCountLbl;
private Color backgroundColor = SWTResourceManager.getColor(SWT.COLOR_TRANSPARENT);
private List<Entity> sortedEntityTypes;

/**
* Create the composite.
Expand All @@ -55,7 +56,7 @@ public EntityTypeSelectorComposite(Composite parent, int style, Entity... suppor
rowLayout.spacing = 7;
setLayout(rowLayout);

List<Entity> sortedEntityTypes = Arrays
sortedEntityTypes = Arrays
.stream(supportedEntityTypes)
.sorted(new PredefinedEntityComparator())
.collect(Collectors.toList());
Expand Down Expand Up @@ -91,7 +92,13 @@ public void setEntityTypeCount(Map<Entity, Integer> entityTypeCount) {
checkBox.setText("0");
}
});
totalCountLbl.setText("Total: " + entityTypeCount.values().stream().mapToInt(i -> i.intValue()).sum());

List<Integer> entityTypeCountValues = entityTypeCount.entrySet()
.stream()
.filter(e -> sortedEntityTypes.contains(e.getKey()))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
totalCountLbl.setText("Total: " + entityTypeCountValues.stream().mapToInt(i -> i.intValue()).sum());
}

public Set<Entity> getCheckedEntityTypes() {
Expand Down

0 comments on commit 4f9bef1

Please sign in to comment.