Search in sources :

Example 1 with WorkflowSupportManager

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

the class WorkflowProjectAdapterService method convert.

@Override
public <A> A convert(Object object, Class<A> adapterType) {
    A retval = null;
    if (IProject.class.equals(adapterType)) {
        ISapphirePart sapphirePart = context().find(ISapphirePart.class);
        WorkflowDefinition workflowDefinition = sapphirePart.getLocalModelElement().nearest(WorkflowDefinition.class);
        IFile file = workflowDefinition.adapt(IFile.class);
        if (file != null) {
            retval = adapterType.cast(file.getProject());
        } else {
            // create support project
            WorkflowSupportManager workflowSupportManager = KaleoCore.getDefault().getWorkflowSupportManager();
            IEditorInput editorInput = workflowDefinition.adapt(IEditorInput.class);
            if (editorInput instanceof WorkflowDefinitionEditorInput) {
                WorkflowDefinitionEditorInput workflowInput = (WorkflowDefinitionEditorInput) editorInput;
                WorkflowDefinitionEntry workflowEntry = workflowInput.getWorkflowDefinitionEntry();
                IServer server = workflowEntry.getParent().getParent();
                workflowSupportManager.setCurrentServer(server);
            }
            IJavaProject supportProject = workflowSupportManager.getSupportProject();
            retval = adapterType.cast(supportProject.getProject());
        }
    }
    return retval;
}
Also used : WorkflowDefinitionEditorInput(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput) WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) IServer(org.eclipse.wst.server.core.IServer) IFile(org.eclipse.core.resources.IFile) IJavaProject(org.eclipse.jdt.core.IJavaProject) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) WorkflowSupportManager(com.liferay.ide.kaleo.core.WorkflowSupportManager) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

WorkflowSupportManager (com.liferay.ide.kaleo.core.WorkflowSupportManager)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 WorkflowDefinitionEditorInput (com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput)1 WorkflowDefinitionEntry (com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry)1 IFile (org.eclipse.core.resources.IFile)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 ISapphirePart (org.eclipse.sapphire.ui.ISapphirePart)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IServer (org.eclipse.wst.server.core.IServer)1