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;
}
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);
}
}
}
Aggregations