use of org.whole.lang.actions.model.Actions in project whole by wholeplatform.
the class ActionsUIEntityFactory method createLanguagesGroupAction.
public GroupAction createLanguagesGroupAction(ActionKindEnum.Value kind, Set<String> excludeSet, EntityDescriptor<?> resultEd) {
GroupAction groupAction = createHierarchicalGroupAction(resultEd.getLanguageKit().getName() + ".languages");
Actions actions = createActions(0);
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
String uri = languageKit.getURI();
if (excludeSet.contains(uri))
continue;
actions.wAdd(createTemplateAction(kind, create(resultEd, uri), ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON, kind == ActionKindEnum.REPLACE));
}
groupAction.setActions(actions);
return groupAction;
}
use of org.whole.lang.actions.model.Actions in project whole by wholeplatform.
the class ActionsUIEntityFactory method createVariablesGroupAction.
public GroupAction createVariablesGroupAction(ActionKindEnum.Value kind, Set<String> excludeSet, EntityDescriptor<?> resultEd, IEntityIterator<IEntity> variableIterator) {
GroupAction groupAction = createHierarchicalGroupAction(resultEd.getLanguageKit().getName() + ".languages");
Actions actions = createActions(0);
SortedSet<String> names = new TreeSet<String>();
for (IEntity variable : variableIterator) {
String name = variable.wStringValue();
if (!excludeSet.contains(name))
names.add(name);
}
for (String name : names) actions.wAdd(createTemplateAction(kind, create(resultEd, name), name, kind == ActionKindEnum.REPLACE));
groupAction.setActions(actions);
return groupAction;
}
use of org.whole.lang.actions.model.Actions in project whole by wholeplatform.
the class QueriesContentAssistVisitor method allEntityTypes.
private boolean allEntityTypes(IEntity entity, EntityDescriptor<?> type) {
if (!EntityUtils.hasParent(entity))
return false;
EntityDescriptor<?> featureED = entity.wGetParent().wGetEntityDescriptor(entity);
if (!featureED.isPlatformSupertypeOf(EntityType) && !featureED.isPlatformSupertypeOf(TypeTest) && !featureED.isPlatformSupertypeOf(SubtypeTest) && !featureED.isPlatformSupertypeOf(SupertypeTest) && !featureED.isPlatformSupertypeOf(ExtendedSubtypeTest) && !featureED.isPlatformSupertypeOf(ExtendedSupertypeTest))
return false;
boolean alltypesTest = (type == SubtypeTest || type == SupertypeTest || type == ExtendedSubtypeTest || type == ExtendedSupertypeTest || type == AtTypeTest);
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("queries.languages");
Actions actions = aef.createActions(0);
QueriesEntityFactory qef = QueriesEntityFactory.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 (alltypesTest)
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 = qef.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(alltypesTest ? "queries.alltypenames" : "queries.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) || (!alltypesTest && ed.isAbstract()))
continue;
IEntity prototype = qef.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.Actions in project whole by wholeplatform.
the class QueriesContentAssistVisitor method allFeatureTypes.
private boolean allFeatureTypes(IEntity entity, EntityDescriptor<?> targetEd) {
if (!EntityUtils.hasParent(entity) || !entity.wGetParent().wGetEntityDescriptor(entity).isPlatformSupertypeOf(targetEd))
return false;
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("queries.languages");
Actions actions = aef.createActions(0);
QueriesEntityFactory qef = QueriesEntityFactory.instance;
String actualLanguageURI = "";
String actualFeatureName = "";
FeatureDescriptor actualFD = null;
try {
actualFD = CommonsDataTypePersistenceParser.parseFeatureDescriptor(entity.wStringValue());
actualLanguageURI = actualFD.getLanguageKit().getURI();
actualFeatureName = actualFD.getName();
} catch (Exception e) {
if (DataTypeUtils.getDataKind(entity).isString())
actualFeatureName = entity.wStringValue();
}
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
if (languageKit.getURI().equals(actualLanguageURI))
continue;
FeatureDescriptorEnum fdEnum = languageKit.getFeatureDescriptorEnum();
if (fdEnum.values().isEmpty())
continue;
FeatureDescriptor fd = null;
if (actualFeatureName.length() > 0)
fd = fdEnum.valueOf(actualFeatureName);
if (fd == null)
fd = fdEnum.valueOf(0);
IEntity prototype = qef.create(targetEd, CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
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 (actualFD != null) {
GroupAction featurenamesGroup = aef.createGroupAction();
featurenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
featurenamesGroup.getText().setValue("queries.featurenames");
actions = aef.createActions(0);
FeatureDescriptorEnum fdEnum = actualFD.getFeatureDescriptorEnum();
List<FeatureDescriptor> fds = new ArrayList<FeatureDescriptor>(fdEnum.values());
Collections.sort(fds, EnumValueImpl.getByNameComparator());
for (FeatureDescriptor fd : fds) {
if (fd.equals(actualFD))
continue;
IEntity prototype = qef.create(targetEd, CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, fd.getName()));
}
featurenamesGroup.setActions(actions);
addedLanguages |= EntityUtils.isResolver(entity) ? mergeResult(targetEd, languagesGroup) : mergeResult(featurenamesGroup);
}
return addedLanguages;
}
use of org.whole.lang.actions.model.Actions in project whole by wholeplatform.
the class QueriesContentAssistVisitor method visit.
@Override
public void visit(LanguageTest entity) {
String actualLanguageURI = entity.getValue();
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("queries.languages");
Actions actions = aef.createActions(0);
QueriesEntityFactory qef = QueriesEntityFactory.instance;
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
String languageURI = languageKit.getURI();
if (languageURI.equals(actualLanguageURI))
continue;
actions.wAdd(aef.createReplaceDifferentTemplateAction(qef.create(LanguageTest, languageURI), ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
}
languagesGroup.setActions(actions);
mergeResult(languagesGroup);
}
Aggregations