Search in sources :

Example 66 with IBindingManager

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

the class ActivateToolAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    boolean clearCaret = Tools.TEXTUAL != tool && Tools.TEXTUAL.isActive(viewer);
    if (tool.ensureActive(viewer) && clearCaret) {
        IEntity focusEntity = bm.wGet("focusEntity");
        IEntityPart focusPart = viewer.getEditPartRegistry().get(focusEntity);
        if (focusPart instanceof ITextualEntityPart) {
            ITextualEntityPart textualPart = (ITextualEntityPart) focusPart;
            textualPart.setCaretVisible(false);
            viewer.setSelection(new StructuredSelection(textualPart));
        }
    }
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 67 with IBindingManager

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

the class WholePluginProjectWizard method performFinish.

public boolean performFinish() {
    // outside WorkspaceModifyOperation.execute() due to a concurrency bug of OSGI
    final IBindingManager params = BindingManagerFactory.instance.createArguments();
    params.wDefValue("projectName", newProjectCreationPage.getProjectName());
    params.wDefValue("pluginId", newProjectCreationPage.getPluginId());
    params.wDefValue("pluginVersion", newProjectCreationPage.getPluginVersion());
    params.wDefValue("pluginName", newProjectCreationPage.getPluginName());
    params.wDefValue("pluginProvider", newProjectCreationPage.getPluginProvider());
    if (!newProjectCreationPage.useDefaults())
        params.wDefValue("locationURI", newProjectCreationPage.getLocationURI());
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor progressMonitor) {
            try {
                progressMonitor.beginTask("Generating...", IOperationProgressMonitor.TOTAL_WORK);
                params.wDefValue("progressMonitor", new OperationProgressMonitorAdapter(progressMonitor));
                IEntity projectTemplate = ProjectsArtifactsTemplateManager.instance().create("WholePluginProject");
                projectTemplate = BehaviorUtils.evaluate(projectTemplate, 1, params);
                Matcher.removeVars(projectTemplate, false);
                ArtifactsGeneratorOperation.generate(projectTemplate, params);
            } catch (Exception exception) {
                E4CompatibilityPlugin.log(exception);
            } finally {
                progressMonitor.done();
            }
        }
    };
    try {
        getContainer().run(false, false, operation);
    } catch (Exception exception) {
        E4CompatibilityPlugin.log(exception);
        return false;
    }
    if (project != null) {
        IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(project);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
    }
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEntity(org.whole.lang.model.IEntity) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) IBindingManager(org.whole.lang.bindings.IBindingManager) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) OperationProgressMonitorAdapter(org.whole.lang.operations.OperationProgressMonitorAdapter)

Example 68 with IBindingManager

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

the class WholeProjectWizard method performFinish.

public boolean performFinish() {
    // outside WorkspaceModifyOperation.execute() due to a concurrency bug of OSGI
    final IBindingManager params = BindingManagerFactory.instance.createArguments();
    params.wDefValue("projectName", projectName);
    if (!newProjectCreationPage.useDefaults())
        params.wDefValue("locationURI", newProjectCreationPage.getLocationURI());
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor progressMonitor) {
            try {
                progressMonitor.beginTask("Generating...", IOperationProgressMonitor.TOTAL_WORK);
                params.wDefValue("progressMonitor", new OperationProgressMonitorAdapter(progressMonitor));
                IEntity projectTemplate = ProjectsArtifactsTemplateManager.instance().create("WholeProject");
                projectTemplate = BehaviorUtils.evaluate(projectTemplate, 1, params);
                Matcher.removeVars(projectTemplate, false);
                ArtifactsGeneratorOperation.generate(projectTemplate, params);
            } catch (Exception exception) {
                E4CompatibilityPlugin.log(exception);
            } finally {
                progressMonitor.done();
            }
        }
    };
    try {
        getContainer().run(false, false, operation);
    } catch (Exception exception) {
        E4CompatibilityPlugin.log(exception);
        return false;
    }
    if (project != null) {
        IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(project);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
    }
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEntity(org.whole.lang.model.IEntity) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) IBindingManager(org.whole.lang.bindings.IBindingManager) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) OperationProgressMonitorAdapter(org.whole.lang.operations.OperationProgressMonitorAdapter)

Example 69 with IBindingManager

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

the class WorkflowsIDEInterpreterVisitor method createArtifactsBindings.

@Override
protected IBindingManager createArtifactsBindings(String resource, ResourceKind resourceKind) {
    if (!ResourceKindEnum.WORKSPACE.equals(resourceKind.getValue()))
        return super.createArtifactsBindings(resource, resourceKind);
    try {
        IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
        IResource rootResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resource);
        if (rootResource == null)
            throw new IllegalArgumentException("root resource does not exist");
        bindings.wDefValue("artifactsOperations", new WorkspaceResourceOperations());
        bindings.wDefValue("rootResource", rootResource);
        IContainer container = rootResource.getParent();
        if (container != null) {
            int type = container.getType();
            switch(type) {
                case IResource.PROJECT:
                    bindings.wDefValue("project", container);
                    break;
                case IResource.FOLDER:
                    bindings.wDefValue("folder", container);
                    break;
                default:
                    break;
            }
        }
        return bindings;
    } catch (Exception e) {
        throw new IllegalArgumentException("Cannot find the specified resource", e);
    }
}
Also used : WorkspaceResourceOperations(org.whole.lang.artifacts.util.WorkspaceResourceOperations) IBindingManager(org.whole.lang.bindings.IBindingManager) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) Breakpoint(org.whole.lang.workflows.model.Breakpoint) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) VisitException(org.whole.lang.visitors.VisitException)

Example 70 with IBindingManager

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

the class WorkflowsInterpreterVisitor method getPersistenceProvider.

protected IPersistenceProvider getPersistenceProvider(PersistenceActivity entity) {
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    getBindings().wEnterScope(bm, true);
    entity.getBindings().accept(this);
    getBindings().wExitScope();
    String resource = getResourceString(entity);
    ResourceKind resourceKind = getResourceKind(entity);
    switch(resourceKind.getValue().getOrdinal()) {
        case ResourceKindEnum.FILE_SYSTEM_ord:
            return getFileSystemProvider(bm, resource);
        case ResourceKindEnum.WORKSPACE_ord:
            return getWorkspaceProvider(bm, resource);
        case ResourceKindEnum.CLASSPATH_ord:
            ReflectionFactory.setClassLoader(bm, ReflectionFactory.getClassLoader(getBindings()));
            return getClasspathProvider(bm, resource);
        case ResourceKindEnum.URL_ord:
            return getURLProvider(bm, resource);
        case ResourceKindEnum.VARIABLE_ord:
            return getStringProvider(bm, resource);
        default:
            throw new IllegalArgumentException("Unsupported resource kind");
    }
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ResourceKind(org.whole.lang.workflows.model.ResourceKind) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

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