Search in sources :

Example 1 with WorkspaceResourceOperations

use of org.whole.lang.artifacts.util.WorkspaceResourceOperations 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)

Aggregations

IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1 WorkspaceResourceOperations (org.whole.lang.artifacts.util.WorkspaceResourceOperations)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 OperationCanceledException (org.whole.lang.operations.OperationCanceledException)1 VisitException (org.whole.lang.visitors.VisitException)1 Breakpoint (org.whole.lang.workflows.model.Breakpoint)1