Search in sources :

Example 6 with ProcessEditor

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());
                            }
                        }
                    }
                });
            }
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PartInitException(org.eclipse.ui.PartInitException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) IResourceDelta(org.eclipse.core.resources.IResourceDelta) Display(org.eclipse.swt.widgets.Display)

Example 7 with ProcessEditor

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);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) AssetWorkbenchListener(com.centurylink.mdw.plugin.designer.model.WorkflowAsset.AssetWorkbenchListener) IFile(org.eclipse.core.resources.IFile) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor)

Example 8 with ProcessEditor

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());
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor)

Example 9 with ProcessEditor

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);
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) JSONException(org.json.JSONException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 10 with ProcessEditor

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());
            }
        }
    });
}
Also used : ProcessInstancePage(com.centurylink.mdw.designer.runtime.ProcessInstancePage) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) IOException(java.io.IOException)

Aggregations

ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)10 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)6 PartInitException (org.eclipse.ui.PartInitException)6 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)2 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)2 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IFile (org.eclipse.core.resources.IFile)2 IEditorPart (org.eclipse.ui.IEditorPart)2 Node (com.centurylink.mdw.designer.display.Node)1 ProcessInstancePage (com.centurylink.mdw.designer.runtime.ProcessInstancePage)1 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 ExportAsDialog (com.centurylink.mdw.plugin.designer.dialogs.ExportAsDialog)1 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 ProcessSaveAsDialog (com.centurylink.mdw.plugin.designer.dialogs.ProcessSaveAsDialog)1 Activity (com.centurylink.mdw.plugin.designer.model.Activity)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1