use of org.whole.lang.ui.menu.HierarchicalFillMenuStrategy in project whole by wholeplatform.
the class ActionsE4InterpreterVisitor method createFillMenuStrategy.
private IFillMenuStrategy createFillMenuStrategy(Hierarchical hierarchicalStrategy, String groupName) {
IMenuNameStrategy nameStrategy = Matcher.match(DistinctPrefix, hierarchicalStrategy.getNamingStrategy()) ? PrefixMenuNameStrategy.instance() : FullMenuNameStrategy.instance();
int splitSize = intEvaluate(hierarchicalStrategy.getSplitSize());
return new HierarchicalFillMenuStrategy(nameStrategy, splitSize, groupName);
}
use of org.whole.lang.ui.menu.HierarchicalFillMenuStrategy in project whole by wholeplatform.
the class ActionsE4InterpreterVisitor method visit.
@Override
public void visit(Actions entity) {
IItemContainer<IAction, ImageDescriptor> container = (IItemContainer<IAction, ImageDescriptor>) getBindings().wGetValue("itemContainer");
IFillMenuStrategy strategy = (IFillMenuStrategy) getBindings().wGetValue("fillMenuStrategy");
int size = entity.wSize();
List<IAction> contributions = new ArrayList<IAction>();
for (int i = 0; i < size; i++) {
Action action = (Action) entity.wGet(i);
if (Matcher.isAssignableAsIsFrom(GroupAction, action)) {
// FIXME, add a boolean modifier to GroupAction and SubGroupAction
if (strategy instanceof HierarchicalFillMenuStrategy)
Collections.sort(contributions, ActionsComparator.instance());
IAction[] actions = contributions.toArray(new IAction[contributions.size()]);
strategy.fillMenu(container, ActionSet.create(actions), 0, actions.length);
contributions.clear();
}
IEntity result = evaluate(action);
if (result == null)
continue;
IUpdatableAction updatableAction = (IUpdatableAction) result.wGetValue();
updatableAction.update();
if (updatableAction.isEnabled())
contributions.add(updatableAction);
}
// FIXME, add a sort boolean feature to GroupAction and SubGroupAction
if (strategy instanceof HierarchicalFillMenuStrategy)
Collections.sort(contributions, ActionsComparator.instance());
IAction[] actions = contributions.toArray(new IAction[contributions.size()]);
strategy.fillMenu(container, ActionSet.create(actions), 0, actions.length);
}
Aggregations