use of org.metaborg.core.action.IAction in project spoofax by metaborg.
the class Menu method action.
@Override
@Nullable
public IAction action(String name) throws MetaborgException {
final List<IAction> actions = Lists.newLinkedList();
for (IMenuItem item : items) {
if (item instanceof IMenuAction && name.equals(item.name())) {
final IMenuAction menuAction = (IMenuAction) item;
final IAction action = menuAction.action();
actions.add(action);
}
}
final int size = actions.size();
if (size == 0) {
return null;
} else if (size > 1) {
final String message = String.format("Found multiple actions with name %s: %s", name, Joiner.on(", ").join(actions));
throw new MetaborgException(message);
}
return actions.get(0);
}
Aggregations