Skip to content

Commit

Permalink
Fix: refresh and select only if a new filter was created
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Feb 9, 2025
1 parent cca1d75 commit 37e5e42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ public void editCustomFilter()
}
}

public void createCustomFilter()
/**
* Opens a dialog to create a new custom filter. Optionally returns the
* newly created filter.
*/
public Optional<Item> createCustomFilter()
{
LabelProvider labelProvider = new LabelProvider()
{
Expand Down Expand Up @@ -241,14 +245,18 @@ public Image getImage(Object element)
newItem.label = label;

selectedItem = newItem;
customItems.addFirst(newItem);
customItems.add(newItem);

filterConfig.add(new Configuration(newItem.getId(), newItem.getLabel(), newItem.getUUIDs()));
client.touch();

listeners.forEach(l -> l.accept(newItem.filter));

return Optional.of(newItem);
}
}

return Optional.empty();
}

public static Optional<Item> buildItem(String id, String name, String uuids, Client client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,13 @@ private void addNewButton(ToolBarManager toolBar)
{
toolBar.add(new DropDown(Messages.MenuCreateAndManageClientFilter, Images.PLUS, SWT.NONE, manager -> {
manager.add(new LabelOnly(Messages.MenuCreateAndManageClientFilter));
manager.add(new SimpleAction(Messages.LabelClientFilterNew, a -> {
clientFilterMenu.createCustomFilter();
groupedAccounts.refresh();
// select the newly created account
groupedAccounts.setSelection(new StructuredSelection(items.getFirst()));
}));
manager.add(new SimpleAction(Messages.LabelClientFilterNew,
a -> clientFilterMenu.createCustomFilter().ifPresent(newItem -> {
groupedAccounts.refresh();
// select the newly created account
groupedAccounts.setSelection(new StructuredSelection(newItem));

})));
manager.add(new SimpleAction(Messages.LabelClientFilterManage, a -> {
clientFilterMenu.editCustomFilter();
groupedAccounts.refresh();
Expand Down Expand Up @@ -337,7 +338,7 @@ else if (o instanceof Account account)

groupedAccounts.addSelectionChangedListener(event -> {
Object treeItem = event.getStructuredSelection().getFirstElement();
setInformationPaneInput(treeItem);
setInformationPaneInput(treeItem);
});

setupDnD();
Expand Down

0 comments on commit 37e5e42

Please sign in to comment.