Skip to content

Commit

Permalink
Refactored creation of expand and collapse actions
Browse files Browse the repository at this point in the history
Issue: #4311
Co-authored-by: Alexander Ott <webmaster@nirus-online.de>
Co-authored-by: Andreas Buchen <andreas.buchen@gmail.com>
  • Loading branch information
buchen and Nirus2000 committed Nov 9, 2024
1 parent e143c41 commit c61d5c0
Showing 1 changed file with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import jakarta.inject.Inject;

import org.eclipse.e4.ui.services.IStylingEngine;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
Expand Down Expand Up @@ -389,29 +388,17 @@ private void addTreeActionsContextMenu(IMenuManager manager, Object obj)
if (obj == null)
return;

manager.add(new Action(Messages.LabelExpand)
manager.add(new SimpleAction(Messages.LabelExpand, a -> calculation.setExpandedState(obj, true))
{
@Override
public void run()
{
calculation.setExpandedState(obj, true);
}

@Override
public boolean isEnabled()
{
return calculation.isExpandable(obj) && !calculation.getExpandedState(obj);
}
});

manager.add(new Action(Messages.LabelCollapse)
manager.add(new SimpleAction(Messages.LabelCollapse, a -> calculation.setExpandedState(obj, false))
{
@Override
public void run()
{
calculation.setExpandedState(obj, false);
}

@Override
public boolean isEnabled()
{
Expand All @@ -421,23 +408,8 @@ public boolean isEnabled()

manager.add(new Separator());

manager.add(new Action(Messages.LabelExpandAll)
{
@Override
public void run()
{
calculation.expandAll();
}
});

manager.add(new Action(Messages.LabelCollapseAll)
{
@Override
public void run()
{
calculation.collapseAll();
}
});
manager.add(new SimpleAction(Messages.LabelExpandAll, a -> calculation.expandAll()));
manager.add(new SimpleAction(Messages.LabelCollapseAll, a -> calculation.collapseAll()));
}

private TableViewer createTransactionViewer(CTabFolder folder, String title)
Expand Down

0 comments on commit c61d5c0

Please sign in to comment.