Search in sources :

Example 1 with ActionsUIEntityFactory

use of org.whole.lang.actions.ui.factories.ActionsUIEntityFactory 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;
}
Also used : EntityDescriptorEnum(org.whole.lang.reflect.EntityDescriptorEnum) QueriesEntityDescriptorEnum(org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum) Actions(org.whole.lang.actions.model.Actions) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ArrayList(java.util.ArrayList) ILanguageKit(org.whole.lang.reflect.ILanguageKit) GroupAction(org.whole.lang.actions.model.GroupAction) EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)

Example 2 with ActionsUIEntityFactory

use of org.whole.lang.actions.ui.factories.ActionsUIEntityFactory 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;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) Actions(org.whole.lang.actions.model.Actions) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ArrayList(java.util.ArrayList) ILanguageKit(org.whole.lang.reflect.ILanguageKit) GroupAction(org.whole.lang.actions.model.GroupAction) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)

Example 3 with ActionsUIEntityFactory

use of org.whole.lang.actions.ui.factories.ActionsUIEntityFactory 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);
}
Also used : GroupAction(org.whole.lang.actions.model.GroupAction) Actions(org.whole.lang.actions.model.Actions) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 4 with ActionsUIEntityFactory

use of org.whole.lang.actions.ui.factories.ActionsUIEntityFactory in project whole by wholeplatform.

the class QueriesContentAssistVisitor method allFeatureNames.

private boolean allFeatureNames(SortedSet<String> fNames, String actualFName) {
    ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    GroupAction featurenamesGroup = aef.createGroupAction();
    featurenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
    featurenamesGroup.getText().setValue("queries.featurenames");
    Actions actions = aef.createActions(0);
    for (String fName : fNames) {
        if (fName.equals(actualFName))
            continue;
        Name prototype = qef.createName(fName);
        actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, fName));
    }
    featurenamesGroup.setActions(actions);
    return mergeResult(featurenamesGroup);
}
Also used : GroupAction(org.whole.lang.actions.model.GroupAction) Actions(org.whole.lang.actions.model.Actions) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory) Name(org.whole.lang.queries.model.Name)

Example 5 with ActionsUIEntityFactory

use of org.whole.lang.actions.ui.factories.ActionsUIEntityFactory in project whole by wholeplatform.

the class WorkflowsUIContentAssistVisitor method allSignatures.

protected boolean allSignatures(IEntity entity) {
    if (!WorkflowsUtils.isSignatureInJavaActivity(entity))
        return false;
    IEntity parent = entity.wGetParent();
    boolean isMethod = !Matcher.match(CreateJavaClassInstance, parent);
    boolean isStatic = Matcher.match(InvokeJavaClassMethod, parent);
    IEntity classNameEntity = parent.wGet(className);
    if (!Matcher.matchImpl(StringLiteral, classNameEntity))
        return false;
    String className = classNameEntity.wStringValue();
    Class<?> declaringClass = null;
    try {
        declaringClass = JavaReflectUtils.forName(className, getClassLoader());
    } catch (IllegalArgumentException e) {
        return false;
    }
    ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
    GroupAction signaturesGroup = aef.createGroupAction();
    signaturesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(20)));
    signaturesGroup.getText().setValue("workflows.signatures");
    Actions actions = aef.createActions(0);
    WorkflowsEntityFactory wef = WorkflowsEntityFactory.instance;
    if (isMethod) {
        for (Method method : declaringClass.getMethods()) if (isStatic == Modifier.isStatic(method.getModifiers())) {
            JavaSignature signature = JavaReflectUtils.fromMethod(method);
            StringLiteral literal = wef.createStringLiteral(JavaReflectUtils.unparse(signature));
            actions.wAdd(aef.createReplaceDifferentTemplateAction(literal, WorkflowsUtils.unparseCompact(signature), calculateImageDescriptor(parent)));
        }
    } else {
        for (Constructor<?> constructor : declaringClass.getConstructors()) {
            JavaSignature signature = JavaReflectUtils.fromConstructor(constructor);
            StringLiteral literal = wef.createStringLiteral(JavaReflectUtils.unparse(signature));
            actions.wAdd(aef.createReplaceDifferentTemplateAction(literal, WorkflowsUtils.unparseCompact(signature), calculateImageDescriptor(parent)));
        }
    }
    signaturesGroup.setActions(actions);
    return EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, signaturesGroup) : mergeResult(signaturesGroup);
}
Also used : WorkflowsEntityFactory(org.whole.lang.workflows.factories.WorkflowsEntityFactory) IEntity(org.whole.lang.model.IEntity) Actions(org.whole.lang.actions.model.Actions) InvokeJavaClassMethod(org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum.InvokeJavaClassMethod) Method(java.lang.reflect.Method) JavaSignature(org.whole.lang.java.util.JavaReflectUtils.JavaSignature) GroupAction(org.whole.lang.actions.model.GroupAction) StringLiteral(org.whole.lang.workflows.model.StringLiteral) StringLiteral(org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum.StringLiteral) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)

Aggregations

Actions (org.whole.lang.actions.model.Actions)7 GroupAction (org.whole.lang.actions.model.GroupAction)7 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)7 ILanguageKit (org.whole.lang.reflect.ILanguageKit)5 ArrayList (java.util.ArrayList)4 IEntity (org.whole.lang.model.IEntity)4 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)4 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)3 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)3 WorkflowsEntityFactory (org.whole.lang.workflows.factories.WorkflowsEntityFactory)2 StringLiteral (org.whole.lang.workflows.model.StringLiteral)2 StringLiteral (org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum.StringLiteral)2 Method (java.lang.reflect.Method)1 FramesEntityFactory (org.whole.lang.frames.factories.FramesEntityFactory)1 JavaSignature (org.whole.lang.java.util.JavaReflectUtils.JavaSignature)1 Name (org.whole.lang.queries.model.Name)1 QueriesEntityDescriptorEnum (org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 WorkflowsEntityDescriptorEnum (org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum)1