use of com.centurylink.mdw.plugin.designer.editors.ProcessEditor in project mdw-designer by CenturyLinkCloud.
the class ArtifactResourceListener method resourceChanged.
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta rootDelta = event.getDelta();
IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
byte[] newValue = PluginUtil.readFile(tempFile);
String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
WorkflowProcess processVersion = null;
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
activity.setAttribute(valueProvider.getAttributeName(), attrVal);
processVersion = activity.getProcess();
} else {
processVersion = (WorkflowProcess) getElement();
processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
}
processVersion.fireDirtyStateChanged(true);
ProcessEditor processEditor = findProcessEditor(processVersion);
if (processEditor == null) {
try {
processEditor = openProcessEditor(processVersion);
IEditorPart tempFileEditor = findTempFileEditor(tempFile);
if (tempFileEditor != null)
processEditor.addActiveScriptEditor(tempFileEditor);
} catch (PartInitException ex) {
PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
return;
}
}
processVersion = processEditor.getProcess();
if (processVersion.isReadOnly()) {
WorkflowProject workflowProject = getElement().getProject();
PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
return;
}
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
// previously-opened process version
for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
node.setAttribute(valueProvider.getAttributeName(), attrVal);
ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
element = new Activity(node, processVersion, actImpl);
}
}
activity.fireDirtyStateChanged(true);
}
processEditor.dirtyStateChanged(true);
valueProvider.afterTempFileSaved();
// process editor is open
String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
String toggleMessage = "Don't show me this message again.";
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
if (!prefsStore.getBoolean(prefsKey)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
prefsStore.setValue(prefsKey, dialog.getToggleState());
}
}
}
});
}
}
}
}
use of com.centurylink.mdw.plugin.designer.editors.ProcessEditor in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method syncOpenEditors.
public void syncOpenEditors(final WorkflowProject project) {
final WorkflowProjectManager projectMgr = WorkflowProjectManager.getInstance();
final List<ProcessEditor> processEditors = getOpenProcessEditors(project);
final List<IEditorPart> assetEditors = getOpenAssetEditors(project);
if (!processEditors.isEmpty() || !assetEditors.isEmpty()) {
// sync open editors
IRunnableWithProgress loader = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Loading " + project.getLabel(), 100);
monitor.worked(25);
// sync process editors
for (ProcessEditor ed : processEditors) {
WorkflowProcess pv = ed.getProcess();
pv.setProject(projectMgr.getWorkflowProject(pv.getProject().getName()));
if (pv.getPackage() != null && !pv.getPackage().isDefaultPackage()) {
WorkflowPackage pkg = pv.getProject().getPackage(pv.getPackage().getName());
WorkflowProcess oldPv = pkg.getProcess(pv.getName());
if (oldPv != null)
pkg.removeProcess(oldPv);
pkg.addProcess(pv);
pv.setPackage(pkg);
}
}
monitor.worked(50);
// sync asset editors
Map<IFile, AssetWorkbenchListener> assetListeners = WorkflowAssetFactory.getWorkbenchListeners();
for (IEditorPart assetEd : assetEditors) {
FileEditorInput fileInput = (FileEditorInput) assetEd.getEditorInput();
AssetWorkbenchListener wbListener = assetListeners.get(fileInput.getFile());
if (wbListener != null) {
WorkflowAsset asset = wbListener.getAsset();
WorkflowProject wfProj = projectMgr.getWorkflowProject(asset.getProject().getName());
WorkflowAsset oldAsset = wfProj.getAsset(asset.getName(), asset.getLanguage(), asset.getVersion());
if (asset.getPackage() != null && !asset.getPackage().isDefaultPackage()) {
WorkflowPackage pkg = wfProj.getPackage(asset.getPackage().getName());
if (pkg != null) {
pkg.removeAsset(oldAsset);
pkg.addAsset(asset);
asset.setPackage(pkg);
} else {
asset.setPackage(wfProj.getDefaultPackage());
}
} else {
asset.setPackage(wfProj.getDefaultPackage());
}
asset.addElementChangeListener(wfProj);
if (oldAsset != null)
WorkflowAssetFactory.deRegisterAsset(oldAsset);
WorkflowAssetFactory.registerAsset(asset);
assetEd.addPropertyListener(asset.new AssetEditorPropertyListener(assetEd));
WorkflowAssetFactory.registerWorkbenchListener(fileInput.getFile(), wbListener);
}
}
monitor.worked(25);
monitor.done();
}
};
ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(Display.getCurrent().getActiveShell());
try {
progMonDlg.run(true, false, loader);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Sync Open Editors", project);
}
}
}
use of com.centurylink.mdw.plugin.designer.editors.ProcessEditor in project mdw-designer by CenturyLinkCloud.
the class ProcessSearchQuery method handleOpen.
@Override
public void handleOpen(WorkflowElement workflowElement) {
WorkflowProcess processVersion = (WorkflowProcess) workflowElement;
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
ProcessEditor processEditor = (ProcessEditor) page.openEditor(processVersion, "mdw.editors.process");
processEditor.setFocus();
} catch (PartInitException ex) {
showError(ex, "Open Process", workflowElement.getProject());
}
}
use of com.centurylink.mdw.plugin.designer.editors.ProcessEditor in project mdw-designer by CenturyLinkCloud.
the class ProcessCanvasWrapper method toggleProcessLock.
public void toggleProcessLock(final boolean lock) {
boolean savePrompted = false;
IWorkbenchPage page = MdwPlugin.getActivePage();
if (page != null) {
ProcessEditor processEditor = (ProcessEditor) page.findEditor(getProcess());
if (processEditor != null && processEditor.isDirty()) {
int result = processEditor.promptToSaveOnClose();
savePrompted = true;
if (result == ISaveablePart2.CANCEL)
return;
}
}
final StringBuilder errorMessage = new StringBuilder();
BusyIndicator.showWhile(getDisplay(), new Runnable() {
public void run() {
try {
String lockMessage = getDesignerProxy().toggleProcessLock(getProcess(), lock);
if (lockMessage != null && lockMessage.length() > 0)
errorMessage.append(lockMessage);
} catch (Exception ex) {
PluginMessages.log(ex);
errorMessage.append(ex.getMessage());
}
}
});
if (savePrompted)
// avoid thread deadlock due to SWT/AWT contention
refreshNoPbi();
else
refresh();
if (errorMessage.toString().length() > 0)
PluginMessages.uiMessage(errorMessage.toString(), "Lock/Unlock Process", getProcess().getProject(), PluginMessages.INFO_MESSAGE);
}
use of com.centurylink.mdw.plugin.designer.editors.ProcessEditor in project mdw-designer by CenturyLinkCloud.
the class LogWatcher method openInstance.
private synchronized void openInstance(final ProcessInstanceVO processInstanceInfo) {
final WorkflowProcess newProcess = new WorkflowProcess(process);
if (!processInstanceInfo.getProcessId().equals(process.getId())) {
// must be a subprocess
ProcessVO subprocVO = new ProcessVO();
subprocVO.setProcessId(processInstanceInfo.getProcessId());
subprocVO.setProcessName(processInstanceInfo.getProcessName());
newProcess.setProcessVO(subprocVO);
}
final boolean isEmbedded = isEmbeddedProcess(processInstanceInfo);
final ProcessInstanceVO pageInfo = isEmbedded ? processInstances.get(processInstanceInfo.getOwnerId()) : processInstanceInfo;
newProcess.setProcessInstance(pageInfo);
display.syncExec(new Runnable() {
public void run() {
ProcessInstancePage procInstPage = null;
try {
IWorkbenchPage page = MdwPlugin.getActivePage();
ProcessEditor editor = null;
if (processInstancePages.get(pageInfo.getId()) == null) {
newProcess.setDesignerDataAccess(dataAccess);
editor = (ProcessEditor) page.openEditor(newProcess, "mdw.editors.process");
procInstPage = editor.getProcessCanvasWrapper().getProcessInstancePage();
if (procInstPage != null) {
processInstancePages.put(pageInfo.getId(), procInstPage);
}
} else if (isEmbedded && processInstancePages.get(processInstanceInfo.getId()) == null) {
newProcess.getProject().getDesignerProxy().loadProcessInstance(newProcess, processInstancePages.get(pageInfo.getId()));
processInstancePages.put(processInstanceInfo.getId(), processInstancePages.get(pageInfo.getId()));
} else {
editor = (ProcessEditor) page.findEditor(newProcess);
if (editor != null)
page.activate(editor);
}
} catch (Exception ex) {
PluginMessages.log(ex);
processInstancePages.remove(processInstanceInfo.getId());
}
}
});
}
Aggregations