+ /** Opens a new editor with a copy of this process */
+ protected void relaunch() {
+ try {
+ Node duplicatedNode = duplicateProcess();
+ IWorkbenchPage activePage = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ activePage.openEditor(
+ new ProcessEditorInput(duplicatedNode.getPath()),
+ ProcessEditor.ID);
+ getEditor().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);
+ JcrUtils.copy(processNode, newNode);
+ // session.getWorkspace().copy(processNode.getPath(), destPath);
+ // Node newNode = session.getNode(destPath);
+ // make sure that we kept the mixins
+ // newNode.addMixin(NodeType.MIX_CREATED);
+ // newNode.addMixin(NodeType.MIX_LAST_MODIFIED);
+ newNode.setProperty(SLC_UUID, uuid);
+ newNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
+ session.save();
+ return newNode;
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot duplicate process", e);
+ }
+ }
+
+ /** Reflects a status change */
+ protected void statusChanged() {
+ String status = getProcessStatus();
+ statusLabel.setText(status);
+ Boolean isEditable = isEditable(status);
+ run.setEnabled(isEditable);
+ remove.setEnabled(isEditable);
+ clear.setEnabled(isEditable);
+ // flowsViewer.getTree().setEnabled(isEditable);
+ if (status.equals(ExecutionProcess.COMPLETED)
+ || status.equals(ExecutionProcess.ERROR)) {
+ run.setEnabled(true);
+ run.setImage(SlcImages.RELAUNCH);
+ run.setToolTipText("Relaunch");
+ }
+ }
+
+ /** Adds initial flows from the editor input if any */
+ protected void addInitialFlows() {
+ for (String path : ((ProcessEditorInput) getEditorInput())
+ .getInitialFlowPaths()) {
+ addFlow(path);
+ }
+ }
+
+ /**
+ * Adds a new flow.
+ *
+ * @param path
+ * the path of the flow
+ */