use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.
the class ActionsUIContentAssistVisitor method allLanguages.
protected boolean allLanguages(IEntity entity) {
if (!Matcher.match(ActionsEntityDescriptorEnum.URI, entity))
return false;
ActionsEntityFactory aef = ActionsEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
Actions actions = aef.createActions(0);
String actualLanguageURI = DataTypeUtils.getAsPersistenceString(entity);
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
String uri = languageKit.getURI();
if (uri.equals(actualLanguageURI))
continue;
URI prototype = aef.createURI(uri);
actions.wAdd(createReplaceTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
}
languagesGroup.setActions(actions);
return mergeResult(languagesGroup);
}
use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.
the class FramesContentAssistVisitor method allEntityTypes.
private boolean allEntityTypes(IEntity entity, EntityDescriptor<?> type) {
if (!EntityUtils.hasParent(entity))
return false;
boolean subtypeTest = false;
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("frames.languages");
Actions actions = aef.createActions(0);
FramesEntityFactory fef = FramesEntityFactory.instance;
String actualLanguageURI = "";
String actualEntityName = "";
EntityDescriptor<?> actualED = null;
EntityDescriptor<?> targetED = type;
try {
actualED = CommonsDataTypePersistenceParser.parseEntityDescriptor(entity.wStringValue());
actualLanguageURI = actualED.getLanguageKit().getURI();
actualEntityName = actualED.getName();
} catch (Exception e) {
if (DataTypeUtils.getDataKind(entity).isString())
actualEntityName = entity.wStringValue();
}
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
if (languageKit.getURI().equals(actualLanguageURI))
continue;
EntityDescriptorEnum edEnum = languageKit.getEntityDescriptorEnum();
EntityDescriptor<?> ed = null;
if (actualEntityName.length() > 0)
ed = edEnum.valueOf(actualEntityName);
if (ed == null) {
if (subtypeTest)
ed = edEnum.valueOf(0);
else {
Iterator<EntityDescriptor<?>> iterator = edEnum.values().iterator();
EntityDescriptor<?> nextED;
while (ed == null && iterator.hasNext()) if (!(nextED = iterator.next()).isAbstract())
ed = nextED;
if (ed == null)
continue;
}
}
IEntity prototype = fef.create(targetED, CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
}
languagesGroup.setActions(actions);
boolean addedLanguages = EntityUtils.isResolver(entity) ? mergeResult(targetED, languagesGroup) : mergeResult(languagesGroup);
if (actualED != null) {
GroupAction typenamesGroup = aef.createGroupAction();
typenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
typenamesGroup.getText().setValue(subtypeTest ? "frames.subtypenames" : "frames.typenames");
actions = aef.createActions(0);
EntityDescriptorEnum edEnum = actualED.getEntityDescriptorEnum();
List<EntityDescriptor<?>> eds = new ArrayList<EntityDescriptor<?>>(edEnum.values());
Collections.sort(eds, EnumValueImpl.getByNameComparator());
for (EntityDescriptor<?> ed : eds) {
if (ed.equals(actualED) || (!subtypeTest && ed.isAbstract()))
continue;
IEntity prototype = fef.create(targetED, CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ed.getName()));
}
typenamesGroup.setActions(actions);
addedLanguages |= EntityUtils.isResolver(entity) ? mergeResult(targetED, typenamesGroup) : mergeResult(typenamesGroup);
}
return addedLanguages;
}
use of org.whole.lang.actions.model.GroupAction 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);
}
use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.
the class WorkflowsIDEContentAssistVisitor method chooseClass.
protected boolean chooseClass(IEntity entity) {
if (!WorkflowsUtils.isClassNameInJavaActivity(entity))
return false;
ReplaceWithClassNameAction action = new ReplaceWithClassNameAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), "Select class...");
ActionsEntityFactory aef = ActionsEntityFactory.instance;
GroupAction customGroup = aef.createGroupAction();
customGroup.setFillStrategy(aef.createFlat());
customGroup.getText().setValue("workflows.custom");
customGroup.setActions(aef.createActions(aef.createCustomAction(action)));
return EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, customGroup) : mergeResult(customGroup);
}
use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.
the class WorkflowsIDEContentAssistVisitor method chooseResource.
protected boolean chooseResource(IEntity entity) {
Object customAction = null;
if (WorkflowsUtils.isResourceInPersistenceActivity(entity)) {
PersistenceActivity parent = (PersistenceActivity) entity.wGetParent();
Expression expression = parent.getPersistence();
IPersistenceKit persistenceKit = Matcher.match(WorkflowsEntityDescriptorEnum.StringLiteral, expression) ? (ReflectionFactory.hasPersistenceKit(expression.wStringValue()) ? ReflectionFactory.getPersistenceKit(expression.wStringValue()) : null) : ReflectionFactory.getDefaultPersistenceKit();
customAction = new ReplaceWithResourceAndPersistenceAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), persistenceKit, "Select resource...") {
protected boolean isLoading(IEntity entity) {
return Matcher.match(WorkflowsEntityDescriptorEnum.LoadModel, entity.wGetParent());
}
protected ResourceKind getResourceKind(IEntity selectedEntity) {
switch(selectedEntity.wGetParent().wGet(WorkflowsFeatureDescriptorEnum.resourceKind).wEnumValue().getOrdinal()) {
default:
case ResourceKindEnum.WORKSPACE_ord:
return ResourceKind.WORKSPACE;
case ResourceKindEnum.FILE_SYSTEM_ord:
return ResourceKind.FILE_SYSTEM;
case ResourceKindEnum.CLASSPATH_ord:
return ResourceKind.CLASSPATH;
case ResourceKindEnum.URL_ord:
return ResourceKind.URL;
}
}
protected void performReplacePersistence(IEntity parent) {
((PersistenceActivity) parent).setPersistence(WorkflowsEntityFactory.instance.createStringLiteral(persistenceKit.getId()));
}
};
} else if (WorkflowsUtils.isResourceInArtifactsActivity(entity)) {
customAction = new ReplaceWithResourceAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), "Select resource...") {
protected boolean isLoading(IEntity entity) {
return Matcher.match(WorkflowsEntityDescriptorEnum.LoadArtifacts, entity.wGetParent());
}
protected ResourceKind getResourceKind(IEntity selectedEntity) {
switch(selectedEntity.wGetParent().wGet(WorkflowsFeatureDescriptorEnum.rootResourceKind).wEnumValue().getOrdinal()) {
default:
case ResourceKindEnum.WORKSPACE_ord:
return ResourceKind.WORKSPACE;
case ResourceKindEnum.FILE_SYSTEM_ord:
return ResourceKind.FILE_SYSTEM;
case ResourceKindEnum.CLASSPATH_ord:
return ResourceKind.CLASSPATH;
case ResourceKindEnum.URL_ord:
return ResourceKind.URL;
}
}
};
} else
return false;
ActionsEntityFactory aef = ActionsEntityFactory.instance;
GroupAction customGroup = aef.createGroupAction();
customGroup.setFillStrategy(aef.createFlat());
customGroup.getText().setValue("workflows.custom");
customGroup.setActions(aef.createActions(aef.createCustomAction(customAction)));
return EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, customGroup) : mergeResult(customGroup);
}
Aggregations