use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.
the class ActionsCompositeContributionItem method getItems.
@Override
protected IContributionItem[] getItems() {
Object selection = contextProvider.getContext().get(ESelectionService.class).getSelection();
if (!(selection instanceof IBindingManager) || !((IBindingManager) selection).wIsSet("self"))
return new IContributionItem[0];
IBindingManager bm = (IBindingManager) selection;
String languageURI = bm.wGet("self").wGetLanguageKit().getURI();
Map<GuardedAction, String> actionsMap = new HashMap<GuardedAction, String>();
IResourceRegistry<Resource> registry = ActionsRegistry.instance();
for (IResource resource : registry.getResources(false)) {
LanguageActionFactory actionsModule = resource.getEntity();
URI targetLanguage = actionsModule.getTargetLanguage();
if (DataTypeUtils.getDataKind(targetLanguage).isString() && !languageURI.equals(targetLanguage.getValue()))
continue;
for (GuardedAction guardedAction : Matcher.findAll(ActionsEntityDescriptorEnum.GuardedAction, getActions(actionsModule), false)) {
String actionName = guardedAction.getName().getValue();
String functionUri = resource.getURI() + '#' + actionName;
actionsMap.put(guardedAction, functionUri);
}
}
List<IAction> actions = new ArrayList<IAction>();
List<GuardedAction> guardedActions = new ArrayList<GuardedAction>(actionsMap.keySet());
Collections.sort(guardedActions, new Comparator<GuardedAction>() {
public int compare(GuardedAction a1, GuardedAction a2) {
return a1.getName().getValue().compareTo(a2.getName().getValue());
}
});
for (GuardedAction guardedAction : guardedActions) {
String actionName = guardedAction.getName().getValue();
String functionUri = actionsMap.get(guardedAction);
IUpdatableAction action = contextProvider.getActionRegistry().getActionFactory().createActionCallAction(actionName, isAnalyze(), guardedAction.getEnablerPredicate(), functionUri);
action.update();
actions.add(action);
}
List<IContributionItem> items = new ArrayList<IContributionItem>();
HierarchicalFillMenuStrategy.instance().fillMenu(ActionListContainer.create(items), ActionSet.create(actions.toArray(new IAction[actions.size()])), 0, actions.size());
return items.toArray(new IContributionItem[items.size()]);
}
use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.
the class ActionsInterpreterVisitor method getActionsUri.
protected String getActionsUri(IEntity entity) {
if (actionsUri == null) {
LanguageActionFactory laf = Matcher.findAncestor(ActionsEntityDescriptorEnum.LanguageActionFactory, entity);
actionsUri = laf != null ? laf.getUri().getValue() : getBindings().wStringValue("actionsUri");
}
return actionsUri;
}
use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.
the class LanguageActionFactoryPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
LanguageActionFactory entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(7);
list.add(entity.getUri());
list.add(entity.getNamespace());
list.add(entity.getName());
list.add(entity.getVersion());
list.add(entity.getTargetLanguage());
list.add(entity.getToolbarActions());
list.add(entity.getContextMenuActions());
return list;
}
use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.
the class ActionsDynamicCompilerVisitor method getActionsUri.
protected String getActionsUri(IEntity entity) {
if (actionsUri == null) {
LanguageActionFactory laf = Matcher.findAncestor(ActionsEntityDescriptorEnum.LanguageActionFactory, entity);
actionsUri = laf != null ? laf.getUri().getValue() : getBindings().wStringValue("actionsUri");
}
return actionsUri;
}
use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.
the class ActionsDefaultEntityRegistryConfiguration method apply.
public void apply(IEntityRegistry er) {
super.apply(er);
ActionsEntityFactory ef = ActionsEntityFactory.instance(er);
er.put(ef.createContextMenuActions(ef.createMenuActions(0), ef.createMenuActions(0), ef.createMenuActions(0), ef.createMenuActions(0), ef.createMenuActions(0), CommonsEntityAdapterFactory.createResolver(ActionsEntityDescriptorEnum.SimpleAction)));
LanguageActionFactory factory = ef.createLanguageActionFactory();
factory.setContextMenuActions(ef.createContextMenuActions());
er.put(factory);
}
Aggregations