Search in sources :

Example 1 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class GenOperationsDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    // from java (legacy)
    platform.addOperationFactory(JavaLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new JavaJavaModelGeneratorVisitor();
            else
                return new JavaJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
        }
    });
    // from artifacts (core)
    platform.addOperationFactory(ArtifactsLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new ArtifactsJavaModelGeneratorVisitor();
            else
                return new ArtifactsJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
        }
    });
    platform.addOperationFactory(ArtifactsLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            // if (stage == 0)
            IBindingManager args = operation.getOperationEnvironment();
            if (args.wIsSet("resourceKind") && ResourceKindEnum.FILE_SYSTEM.equals(((ResourceKind) args.wGet("resourceKind")).getValue()))
                return new ResourceArtifactsGeneratorVisitor();
            else
                return new WorkspaceArtifactsGeneratorVisitor();
        }
    });
    // from editors (core)
    // platform.addOperationFactory(EditorsLanguageKit.URI, JavaCompilerOperation.ID,
    // new IVisitorFactory() {
    // public IVisitor create(IOperation operation, int stage) {
    // if (stage == 0)
    // return new EditorsJavaModelGeneratorVisitor();
    // else
    // return new EditorsJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
    // }
    // });
    // misc (core)
    platform.addOperationFactory(MiscLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new MiscTraverseAllVisitor();
            else
                return new MiscJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
        }
    });
    // from models (core)
    platform.addOperationFactory(ModelsLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new ModelsJavaModelGeneratorVisitor();
            else
                return new ModelsJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
        }
    });
    platform.addOperationFactory(GrammarsLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return new GrammarsJavaModelGeneratorVisitor();
        }
    });
    // from pojo (core.op)
    platform.addOperationFactory(PojoLanguageKit.URI, JavaCompilerOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new PojoJavaModelGeneratorVisitor();
            else
                return new PojoJavaStoreGeneratorVisitor(((JavaCompilerOperation) operation).getGenerator().javaStoreBuilder(), true);
        }
    });
}
Also used : IOperation(org.whole.lang.operations.IOperation) ModelsJavaModelGeneratorVisitor(org.whole.lang.visitors.ModelsJavaModelGeneratorVisitor) PojoJavaModelGeneratorVisitor(org.whole.lang.visitors.PojoJavaModelGeneratorVisitor) IVisitor(org.whole.lang.visitors.IVisitor) ResourceArtifactsGeneratorVisitor(org.whole.lang.artifacts.visitors.ResourceArtifactsGeneratorVisitor) GrammarsJavaModelGeneratorVisitor(org.whole.lang.visitors.GrammarsJavaModelGeneratorVisitor) JavaCompilerOperation(org.whole.lang.operations.JavaCompilerOperation) MiscTraverseAllVisitor(org.whole.lang.misc.visitors.MiscTraverseAllVisitor) MiscJavaStoreGeneratorVisitor(org.whole.lang.visitors.MiscJavaStoreGeneratorVisitor) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) JavaJavaStoreGeneratorVisitor(org.whole.lang.visitors.JavaJavaStoreGeneratorVisitor) ArtifactsJavaModelGeneratorVisitor(org.whole.lang.visitors.ArtifactsJavaModelGeneratorVisitor) WorkspaceArtifactsGeneratorVisitor(org.whole.lang.visitors.WorkspaceArtifactsGeneratorVisitor) JavaJavaModelGeneratorVisitor(org.whole.lang.visitors.JavaJavaModelGeneratorVisitor) IBindingManager(org.whole.lang.bindings.IBindingManager) PojoJavaStoreGeneratorVisitor(org.whole.lang.visitors.PojoJavaStoreGeneratorVisitor) ModelsJavaStoreGeneratorVisitor(org.whole.lang.visitors.ModelsJavaStoreGeneratorVisitor) ArtifactsJavaStoreGeneratorVisitor(org.whole.lang.visitors.ArtifactsJavaStoreGeneratorVisitor)

Example 2 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class PNGImageFileTransferDragSourceListener method createFile.

protected File createFile(IEntityPart entityPart) throws Exception {
    Image image = WholeNonResizableEditPolicy.createFeedbackImage((IGraphicalEntityPart) entityPart, 255, false, FitToMemoryStrategy.instance());
    ImageData imageData = image.getImageData();
    String fileName = ClipboardUtils.DEFAULT_OUTPUT_FILENAME;
    if (getViewer() instanceof IEntityPartViewer) {
        IBindingManager bm = ((IEntityPartViewer) getViewer()).getContextBindings();
        if (bm.wIsSet("fileName"))
            fileName = bm.wStringValue("fileName");
    }
    File file = ClipboardUtils.createTempImageFile(fileName, imageData, ClipboardUtils.DEFAULT_OUTPUT_DPI);
    image.dispose();
    return file;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IBindingManager(org.whole.lang.bindings.IBindingManager) Image(org.eclipse.swt.graphics.Image) File(java.io.File) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 3 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class IEntityIterator method evaluateRemaining.

public default E evaluateRemaining() {
    E result = null;
    IBindingManager bm = getBindings();
    ITransactionScope resettableScope = BindingManagerFactory.instance.createTransactionScope();
    bm.wEnterScope(resettableScope);
    try {
        while (hasNext()) {
            bm.setResult(result = next());
            resettableScope.commit();
        }
    } finally {
        resettableScope.rollback();
        bm.wExitScope();
    }
    return result;
}
Also used : ITransactionScope(org.whole.lang.bindings.ITransactionScope) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 4 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class AbstractSingleValuedRunnableIterator method getResult.

@SuppressWarnings("unchecked")
protected E getResult() {
    if (!isExecuted) {
        isExecuted = true;
        IBindingManager bm = getBindings();
        bm.setResult(null);
        getBindings().wEnterScope(lookaheadScope(), true);
        run(selfEntity, bm);
        result = (E) bm.getResult();
        getBindings().wExitScope();
    }
    return result;
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 5 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class CompoundResourceRegistry method getFunctionCode.

@SuppressWarnings("unchecked")
public <B extends ICloneable> B getFunctionCode(String functionUri, boolean loadOnDemand, IBindingManager bm) {
    ICloneable functionCode = uriCodeMap.get(functionUri);
    if (functionCode == null) {
        IEntity functionModel = getFunctionModel(functionUri, loadOnDemand, bm);
        functionCode = uriCodeMap.get(functionUri);
        if (functionModel != null && functionCode == null) {
            IBindingManager args = BindingManagerFactory.instance.createArguments();
            DynamicCompilerOperation.compile(functionModel, args);
            functionCode = uriCodeMap.get(functionUri);
        }
    }
    if (functionCode == null)
        // TODO should be configurable
        functionCode = IteratorFactory.emptyIterator();
    return (B) functionCode.clone();
}
Also used : ICloneable(org.whole.lang.operations.ICloneable) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)223 IEntity (org.whole.lang.model.IEntity)141 Test (org.junit.Test)91 PathExpression (org.whole.lang.queries.model.PathExpression)49 ITemplateManager (org.whole.lang.templates.ITemplateManager)40 Grammar (org.whole.lang.grammars.model.Grammar)28 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)27 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)17 Model (org.whole.lang.models.model.Model)15 Production (org.whole.lang.grammars.model.Production)14 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)14 File (java.io.File)12 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)12 XmlModel (org.whole.lang.models.codebase.XmlModel)11 SimpleEntity (org.whole.lang.models.model.SimpleEntity)10 VisitException (org.whole.lang.visitors.VisitException)9 IBindingScope (org.whole.lang.bindings.IBindingScope)6 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)5