Search in sources :

Example 1 with NewWorkflowDefinitionOp

use of com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp in project liferay-ide by liferay.

the class NewWorkflowDefinitionHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    NewWorkflowDefinitionOp op = NewWorkflowDefinitionOp.TYPE.instantiate();
    NewWorkflowDefinitionWizard wizard = new NewWorkflowDefinitionWizard(op);
    WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
    dialog.open();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with NewWorkflowDefinitionOp

use of com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp in project liferay-ide by liferay.

the class NewWorkflowDefinitionAdapter method convert.

@Override
public <A> A convert(Object object, Class<A> adapterType) {
    if (adapterType.equals(IProject.class)) {
        NewWorkflowDefinitionOp op = context().find(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> referProject = op.getProject();
        if (referProject != null) {
            IProject project = referProject.target();
            if (project != null) {
                return adapterType.cast(project);
            }
        }
    }
    return null;
}
Also used : NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) IProject(org.eclipse.core.resources.IProject)

Example 3 with NewWorkflowDefinitionOp

use of com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp in project liferay-ide by liferay.

the class NewWorkflowDefinitionWizard method init.

public void init(IWorkbench workbench, IStructuredSelection selection) {
    if (selection instanceof IStructuredSelection) {
        IProject selectedProject = null;
        IContainer selectedFolder = null;
        IStructuredSelection sel = (IStructuredSelection) selection;
        Object selectedObject = sel.getFirstElement();
        if (selectedObject instanceof IProject) {
            selectedProject = (IProject) selectedObject;
        } else if (selectedObject instanceof IJavaProject) {
            selectedProject = ((IJavaProject) selectedObject).getProject();
        } else if (selectedObject instanceof IContainer) {
            selectedFolder = (IContainer) selectedObject;
            selectedProject = selectedFolder.getProject();
        } else if (selectedObject instanceof IFile) {
            selectedFolder = ((IFile) selectedObject).getParent();
            selectedProject = selectedFolder.getProject();
        }
        if (selectedProject != null) {
            NewWorkflowDefinitionOp op = element().nearest(NewWorkflowDefinitionOp.class);
            op.setProject(selectedProject.getName());
            if (selectedFolder != null) {
                op.setFolder(selectedFolder.getProjectRelativePath().toPortableString());
            }
        }
    }
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IContainer(org.eclipse.core.resources.IContainer) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) IProject(org.eclipse.core.resources.IProject)

Example 4 with NewWorkflowDefinitionOp

use of com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp in project liferay-ide by liferay.

the class EmailAddressValidationService method _getSchemaVersion.

private Version _getSchemaVersion() {
    Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
    if (context(WorkflowDefinition.class) != null) {
        WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewNodeOp.class) != null) {
        NewNodeOp newNodeOp = context(NewNodeOp.class);
        ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
        WorkflowDefinition workflowDefinition = workflowDef.content();
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewWorkflowDefinitionOp.class) != null) {
        NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
        IProject project = opProject.target();
        ILiferayProject liferayProj = LiferayCore.create(project);
        ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
        if (portal != null) {
            schemaVersion = new Version(portal.getVersion());
        }
    }
    return schemaVersion;
}
Also used : Version(org.eclipse.sapphire.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) ReferenceValue(org.eclipse.sapphire.ReferenceValue) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementHandle(org.eclipse.sapphire.ElementHandle) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Aggregations

NewWorkflowDefinitionOp (com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp)4 IProject (org.eclipse.core.resources.IProject)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ElementHandle (org.eclipse.sapphire.ElementHandle)1 ReferenceValue (org.eclipse.sapphire.ReferenceValue)1 Value (org.eclipse.sapphire.Value)1 Version (org.eclipse.sapphire.Version)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1