Search in sources :

Example 11 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory 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 12 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory 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 13 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class QueriesUtils method createRootPath.

public static Path createRootPath(IEntity entity) {
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    Path path = qef.createPath(0);
    IEntity parent = null;
    IEntityIterator<IEntity> iterator = IteratorFactory.ancestorOrSelfReverseIterator();
    iterator.reset(entity);
    if (CommonsEntityDescriptorEnum.RootFragment.equals(iterator.lookahead().wGetEntityDescriptor()))
        iterator.next();
    for (IEntity child : iterator) {
        if (parent != null)
            path.wAdd(EntityUtils.isSimple(parent) ? qef.createFeatureStep(CommonsDataTypePersistenceParser.unparseFeatureDescriptor(parent.wGetFeatureDescriptor(child))) : qef.createFilter(qef.createChildStep(), qef.createIndexTest(qef.createIntLiteral(parent.wIndexOf(child)))));
        parent = child;
    }
    return path;
}
Also used : Path(org.whole.lang.queries.model.Path) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory)

Example 14 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testPathOfChildSteps.

@Test
public void testPathOfChildSteps() {
    Model model = new XmlModel().create();
    IEntity decl3 = model.getDeclarations().wGet(3);
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    PathExpression pe = ef.createPath(ef.createFeatureStep("declarations"), ef.createFilter(ef.createChildStep(), ef.createIndexTest(ef.createIntLiteral(3))));
    IEntity result = BehaviorUtils.evaluateFirstResult(pe, model);
    Assert.assertSame(decl3, result);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Example 15 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testChildStepByName.

@Test
public void testChildStepByName() {
    Model model = new XmlModel().create();
    SimpleName name = model.getName();
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    IEntity result = BehaviorUtils.evaluateFirstResult(ef.createFeatureStep("name"), model);
    Assert.assertSame(name, result);
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) SimpleName(org.whole.lang.models.model.SimpleName) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Aggregations

QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)21 IEntity (org.whole.lang.model.IEntity)17 Test (org.junit.Test)11 PathExpression (org.whole.lang.queries.model.PathExpression)6 ITemplateManager (org.whole.lang.templates.ITemplateManager)6 Actions (org.whole.lang.actions.model.Actions)4 GroupAction (org.whole.lang.actions.model.GroupAction)4 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)4 ILanguageKit (org.whole.lang.reflect.ILanguageKit)4 XmlModel (org.whole.lang.models.codebase.XmlModel)3 Model (org.whole.lang.models.model.Model)3 ArrayList (java.util.ArrayList)2 IBindingManager (org.whole.lang.bindings.IBindingManager)2 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)2 Path (org.whole.lang.queries.model.Path)2 HashSet (java.util.HashSet)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 ActionsEntityFactory (org.whole.lang.actions.factories.ActionsEntityFactory)1 ActionCall (org.whole.lang.actions.model.ActionCall)1 ActionFactory (org.whole.lang.e4.ui.actions.ActionFactory)1