Search in sources :

Example 6 with GroupAction

use of org.whole.lang.actions.model.GroupAction 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 7 with GroupAction

use of org.whole.lang.actions.model.GroupAction 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 8 with GroupAction

use of org.whole.lang.actions.model.GroupAction 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)

Example 9 with GroupAction

use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.

the class WorkflowsUIContentAssistVisitor method allEntityTypes.

protected boolean allEntityTypes(IEntity entity) {
    if (!WorkflowsUtils.isEntityTypeInCreateEntity(entity))
        return false;
    ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
    GroupAction languagesGroup = aef.createGroupAction();
    languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
    languagesGroup.getText().setValue("workflows.languages");
    Actions actions = aef.createActions(0);
    WorkflowsEntityFactory wef = WorkflowsEntityFactory.instance;
    String actualLanguageURI = "";
    String actualEntityName = "";
    EntityDescriptor<?> actualED = null;
    try {
        if (Matcher.matchImpl(StringLiteral, entity)) {
            StringLiteral literal = (StringLiteral) entity;
            actualED = CommonsDataTypePersistenceParser.parseEntityDescriptor(literal.getValue());
            actualLanguageURI = actualED.getLanguageKit().getURI();
            actualEntityName = actualED.getName();
        }
    } catch (Exception e) {
    }
    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)
            ed = edEnum.valueOf(0);
        StringLiteral prototype = wef.createStringLiteral(CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
        actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
    }
    languagesGroup.setActions(actions);
    boolean adeddLanguages = EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, languagesGroup) : mergeResult(languagesGroup);
    if (actualED != null) {
        GroupAction typenamesGroup = aef.createGroupAction();
        typenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
        typenamesGroup.getText().setValue("workflows.typenames");
        actions = aef.createActions(0);
        EntityDescriptorEnum edEnum = actualED.getEntityDescriptorEnum();
        List<EntityDescriptor<?>> eds = new ArrayList<EntityDescriptor<?>>(edEnum.values());
        Collections.sort(eds, new Comparator<EntityDescriptor<?>>() {

            public int compare(EntityDescriptor<?> ed1, EntityDescriptor<?> ed2) {
                return ed1.getName().compareTo(ed2.getName());
            }
        });
        for (EntityDescriptor<?> ed : eds) {
            if (ed.equals(actualED))
                continue;
            StringLiteral prototype = wef.createStringLiteral(CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
            actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ed.getName()));
        }
        typenamesGroup.setActions(actions);
        adeddLanguages |= EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, typenamesGroup) : mergeResult(typenamesGroup);
    }
    return adeddLanguages;
}
Also used : WorkflowsEntityFactory(org.whole.lang.workflows.factories.WorkflowsEntityFactory) WorkflowsEntityDescriptorEnum(org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum) EntityDescriptorEnum(org.whole.lang.reflect.EntityDescriptorEnum) Actions(org.whole.lang.actions.model.Actions) ArrayList(java.util.ArrayList) ILanguageKit(org.whole.lang.reflect.ILanguageKit) GroupAction(org.whole.lang.actions.model.GroupAction) EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) StringLiteral(org.whole.lang.workflows.model.StringLiteral) StringLiteral(org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum.StringLiteral) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)

Example 10 with GroupAction

use of org.whole.lang.actions.model.GroupAction in project whole by wholeplatform.

the class ActionsUIEntityFactory method createPersistencesGroupAction.

public GroupAction createPersistencesGroupAction(ActionKindEnum.Value kind, Set<String> excludeSet, EntityDescriptor<?> resultEd) {
    GroupAction groupAction = createHierarchicalGroupAction(resultEd.getLanguageKit().getName() + ".persistences");
    Actions actions = createActions(0);
    for (IPersistenceKit persistenceKit : ReflectionFactory.getPersistenceKits()) actions.wAdd(createTemplateAction(kind, create(resultEd, persistenceKit.getId()), persistenceKit.getDescription(), IActionConstants.SELECT_PERSISTENCE_ICON, kind == ActionKindEnum.REPLACE));
    groupAction.setActions(actions);
    return groupAction;
}
Also used : GroupAction(org.whole.lang.actions.model.GroupAction) Actions(org.whole.lang.actions.model.Actions) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit)

Aggregations

GroupAction (org.whole.lang.actions.model.GroupAction)15 Actions (org.whole.lang.actions.model.Actions)11 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)7 IEntity (org.whole.lang.model.IEntity)7 ILanguageKit (org.whole.lang.reflect.ILanguageKit)7 ArrayList (java.util.ArrayList)5 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)4 ActionsEntityFactory (org.whole.lang.actions.factories.ActionsEntityFactory)3 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)3 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)3 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)2 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 TreeSet (java.util.TreeSet)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 IAction (org.eclipse.jface.action.IAction)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Action (org.whole.lang.actions.model.Action)1