Search in sources :

Example 1 with WorkflowDefinitionEditorInput

use of com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput 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)

Example 2 with WorkflowDefinitionEditorInput

use of com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput in project liferay-ide by liferay.

the class EditWorkflowDefinitionAction method perform.

@Override
public void perform(Object entry) {
    if (entry instanceof WorkflowDefinitionEntry) {
        WorkflowDefinitionEntry workflowEntry = (WorkflowDefinitionEntry) entry;
        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchWindow wbWindow = workBench.getActiveWorkbenchWindow();
        IWorkbenchPage page = wbWindow.getActivePage();
        IEditorPart[] dirtyEditors = page.getDirtyEditors();
        for (IEditorPart dirtyEditor : dirtyEditors) {
            IEditorInput editorInput = dirtyEditor.getEditorInput();
            if (editorInput instanceof WorkflowDefinitionEditorInput) {
                WorkflowDefinitionEditorInput dirtyWorkflowEditorInput = (WorkflowDefinitionEditorInput) editorInput;
                boolean opened = dirtyWorkflowEditorInput.getName().contains(workflowEntry.getName());
                if (opened) {
                    IEditorSite editorSite = dirtyEditor.getEditorSite();
                    boolean saveOld = MessageDialog.openQuestion(editorSite.getShell(), "Save " + dirtyWorkflowEditorInput.getName(), "Do you want to save contents of this editor?");
                    page.closeEditor(dirtyEditor, saveOld);
                }
            }
        }
        try {
            WorkflowDefinitionEditorInput editorInput = new WorkflowDefinitionEditorInput(workflowEntry);
            IEditorPart editor = page.openEditor(editorInput, WorkflowDefinitionEditor.EDITOR_ID, true, IWorkbenchPage.MATCH_INPUT);
            editor.addPropertyListener(new IPropertyListener() {

                public void propertyChanged(Object source, int propId) {
                    if (source.equals(editor) && (propId == WorkflowDefinitionEditor.propUpdateVersion)) {
                        workflowEntry.getParent().clearCache();
                        ((CommonViewer) EditWorkflowDefinitionAction.this.getSelectionProvider()).refresh(true);
                    }
                }
            });
        } catch (PartInitException pie) {
            KaleoUI.logError("Error opening kaleo workflow editor.", pie);
        }
    }
}
Also used : WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorPart(org.eclipse.ui.IEditorPart) IPropertyListener(org.eclipse.ui.IPropertyListener) IWorkbench(org.eclipse.ui.IWorkbench) WorkflowDefinitionEditorInput(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) IEditorSite(org.eclipse.ui.IEditorSite)

Aggregations

WorkflowDefinitionEditorInput (com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput)2 WorkflowDefinitionEntry (com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry)2 IEditorInput (org.eclipse.ui.IEditorInput)2 WorkflowSupportManager (com.liferay.ide.kaleo.core.WorkflowSupportManager)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 IFile (org.eclipse.core.resources.IFile)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 ISapphirePart (org.eclipse.sapphire.ui.ISapphirePart)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IEditorSite (org.eclipse.ui.IEditorSite)1 IPropertyListener (org.eclipse.ui.IPropertyListener)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 IServer (org.eclipse.wst.server.core.IServer)1