use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.
the class EntityAssistCompositeContributionItem method createTextActions.
protected List<IAction> createTextActions(ILanguageKit lk, IEntity targetEntity) {
List<IAction> textActions = new ArrayList<IAction>();
IGEFEditorKit editorKit = (IGEFEditorKit) (targetEntity.wGetLanguageKit().equals(lk) ? ReflectionFactory.getEditorKit(targetEntity) : lk.getDefaultEditorKit());
for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
EntityDescriptor<?> ed = (EntityDescriptor<?>) textAction[1];
if (Matcher.matchImpl(ed, targetEntity)) {
@SuppressWarnings("unchecked") Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
try {
IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(contextProvider.getContext());
action.update();
if (action.isEnabled())
textActions.add(action);
} catch (Exception e) {
}
}
}
return textActions;
}
use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.
the class JFaceMenuBuilder method addAddEntityItem.
public void addAddEntityItem(EntityDescriptor<?> ed) {
IUpdatableAction action = actionRegistry.getAddEntityAction(ed);
actionsToUpdate.add(action);
addItem(action);
}
use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.
the class JFaceMenuBuilder method addReplaceEntityItem.
public void addReplaceEntityItem(EntityDescriptor<?> ed) {
IUpdatableAction action = actionRegistry.getReplaceEntityAction(ed);
actionsToUpdate.add(action);
addItem(action);
}
use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.
the class JFaceMenuBuilder method addNotationsItem.
public void addNotationsItem() {
IBindingManager bm = getBindings();
IMenuManager menu = createMenu(NOTATION_LABEL, getNotationsVisibleWhen());
addItem(menu);
if (!HandlersBehavior.isValidFocusEntityPart(bm))
return;
IEntity focusEntity = bm.wGet("focusEntity");
IEditorKit selectedEditorKit = focusEntity.wGetEditorKit();
for (IEditorKit editorKit : ReflectionFactory.getEditorKits(focusEntity.wGetLanguageKit().getURI())) {
if (!editorKit.canApply(focusEntity.wGetLanguageKit()))
continue;
IUpdatableAction action = actionRegistry.getSelectNotationAction(editorKit);
action.setChecked(editorKit == selectedEditorKit);
menu.add(action);
}
}
use of org.whole.lang.ui.actions.IUpdatableAction 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