X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fplugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Feditors%2FProcessEditor.java;h=f4cd3f29eb0f8be57823e06d3f816ead5ebfd9d6;hb=f48476cba243066d5797b8073c15d6ab6842eb6a;hp=b00b41298f3b545f290307beb4488ad7fcb8f06f;hpb=0e2ff188c2e8ffac85739cccc3925e8bd82d7be9;p=gpl%2Fargeo-slc.git diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessEditor.java b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessEditor.java index b00b41298..f4cd3f29e 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessEditor.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessEditor.java @@ -6,10 +6,11 @@ import java.util.Map; import java.util.UUID; import javax.jcr.Node; +import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.argeo.eclipse.ui.Error; +import org.argeo.eclipse.ui.ErrorFeedback; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; import org.argeo.slc.client.ui.ClientUiPlugin; @@ -24,9 +25,12 @@ import org.argeo.slc.jcr.SlcTypes; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.editor.FormEditor; +/** Editor for an execution process. */ public class ProcessEditor extends FormEditor implements ExecutionProcessNotifier, SlcTypes, SlcNames { public final static String ID = ClientUiPlugin.ID + ".processEditor"; @@ -40,6 +44,8 @@ public class ProcessEditor extends FormEditor implements private ExecutionModulesManager modulesManager; + private Boolean switchToLog = false; + @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { @@ -96,7 +102,7 @@ public class ProcessEditor extends FormEditor implements } /** Actually runs the process. */ - public void process() { + void process() { // the modifications have to be saved before execution try { processNode.setProperty(SLC_STATUS, ExecutionProcess.SCHEDULED); @@ -105,13 +111,67 @@ public class ProcessEditor extends FormEditor implements } doSave(null); try { + // show log + if (switchToLog) + setActivePage(logPage.getId()); + ExecutionProcess process = processController.process(processNode); Map properties = new HashMap(); properties.put(ExecutionModulesManager.SLC_PROCESS_ID, process.getUuid()); modulesManager.registerProcessNotifier(this, properties); } catch (Exception e) { - Error.show("Execution of " + processNode + " failed", e); + ErrorFeedback.show("Execution of " + processNode + " failed", e); + } + } + + void kill() { + processController.kill(processNode); + } + + /** Opens a new editor with a copy of this process */ + void relaunch() { + try { + Node duplicatedNode = duplicateProcess(); + IWorkbenchPage activePage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + activePage.openEditor( + new ProcessEditorInput(duplicatedNode.getPath()), + ProcessEditor.ID); + close(false); + } catch (Exception e1) { + throw new SlcException("Cannot relaunch " + processNode, e1); + } + } + + /** Duplicates the process */ + protected Node duplicateProcess() { + try { + Session session = processNode.getSession(); + String uuid = UUID.randomUUID().toString(); + String destPath = SlcJcrUtils.createExecutionProcessPath(uuid); + Node newNode = JcrUtils.mkdirs(session, destPath, + SlcTypes.SLC_PROCESS); + + Node rootRealizedFlowNode = newNode.addNode(SLC_FLOW); + // copy node + JcrUtils.copy(processNode.getNode(SLC_FLOW), rootRealizedFlowNode); + + newNode.setProperty(SLC_UUID, uuid); + newNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED); + + // reset realized flow status + // we just manage one level for the time being + NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW); + while (nit.hasNext()) { + nit.nextNode().setProperty(SLC_STATUS, + ExecutionProcess.INITIALIZED); + } + + session.save(); + return newNode; + } catch (RepositoryException e) { + throw new SlcException("Cannot duplicate process", e); } } @@ -121,7 +181,7 @@ public class ProcessEditor extends FormEditor implements builderPage = new ProcessBuilderPage(this, processNode); addPage(builderPage); firePropertyChange(PROP_DIRTY); - logPage = new ProcessLogPage(this); + logPage = new ProcessLogPage(this, processNode); addPage(logPage); } catch (PartInitException e) { throw new SlcException("Cannot add pages", e); @@ -160,7 +220,7 @@ public class ProcessEditor extends FormEditor implements } public void addSteps(ExecutionProcess process, List steps) { - logPage.addSteps(steps); + // logPage.addSteps(steps); } /** Expects one session per editor. */