Search in sources :

Example 6 with ActivityImpl

use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.

the class ProcessCanvasWrapper method handleSelection.

private void handleSelection(MouseEvent mouseEvent) {
    Graph lProcess = null;
    if (isInstance())
        lProcess = getProcessInstancePage().getProcess();
    else
        lProcess = getFlowchartPage().getProcess();
    int mouseX = mouseEvent.getX();
    int mouseY = mouseEvent.getY();
    if (lProcess.zoom != 100) {
        mouseX = mouseX * 100 / lProcess.zoom;
        mouseY = mouseY * 100 / lProcess.zoom;
    }
    Object obj = null;
    if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
        if (isInstance())
            obj = getProcessInstancePage().canvas.objectAt(lProcess, mouseX, mouseY, getProcessInstancePage().canvas.getGraphics());
        else
            obj = getFlowchartPage().canvas.objectAt(lProcess, mouseX, mouseY, getFlowchartPage().canvas.getGraphics());
    } else {
        obj = lProcess.objectAt(mouseX, mouseY, isInstance() ? getProcessInstancePage().canvas.getGraphics() : getFlowchartPage().canvas.getGraphics());
    }
    if (obj != null) {
        DesignerProxy designerProxy = getProcess().getProject().getDesignerProxy();
        // create the appropriate DesignerCanvasSelection
        if (obj instanceof Node) {
            ActivityImpl actImpl = getProcess().getProject().getActivityImpl(((Node) obj).nodet.getImplementorClassName());
            Activity activity = new Activity((Node) obj, getProcess(), actImpl);
            if (isInstance()) {
                activity.setProcessInstance(getProcess().getProcessInstance());
                List<ActivityInstanceVO> activityInstances = getProcess().getProcessInstance().getActivityInstances(activity.getId());
                if (activityInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
                    // try embedded subprocess instances
                    for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) activityInstances.addAll(embeddedSubProcessInstance.getActivityInstances(activity.getId()));
                }
                activity.setInstances(activityInstances);
                if (activity.isManualTask()) {
                    activity.setTaskInstances(getProcess().getMainTaskInstances(activity.getId()));
                    activity.setSubTaskInstances(getProcess().getSubTaskInstances(activity.getId()));
                }
                if (activity.isSubProcessInvoke()) {
                    // TODO: load subprocess instances when process instance
                    // id loaded (like manual task instances above)
                    List<ProcessInstanceVO> subProcessInstances = designerProxy.getSubProcessInstances(getProcess(), activity);
                    if (subProcessInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
                        for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) subProcessInstances.addAll(designerProxy.getSubProcessInstances(embeddedSubProcessInstance, activity));
                    }
                    activity.setSubProcessInstances(subProcessInstances);
                }
            } else {
                if (activity.getLogicalId() == null)
                    activity.setLogicalId(lProcess.generateLogicalId("A"));
                if (Node.ID_SEQUENCE.equals(getNodeIdType()) && activity.getSequenceId() == 0)
                    lProcess.assignSequenceIds();
            }
            designerCanvasSelection = activity;
        } else if (obj instanceof Link) {
            Transition transition = new Transition((Link) obj, getProcess());
            if (isInstance())
                transition.setInstances(getProcess().getProcessInstance().getTransitionInstances(transition.getId()));
            designerCanvasSelection = transition;
        } else if (obj instanceof SubGraph) {
            EmbeddedSubProcess embeddedSubProcess = new EmbeddedSubProcess((SubGraph) obj, getProcess());
            if (isInstance()) {
                embeddedSubProcess.setSubProcessInstances(((SubGraph) obj).getInstances());
            }
            designerCanvasSelection = embeddedSubProcess;
        } else if (obj instanceof TextNote) {
            TextNote textNote = (TextNote) obj;
            Note note = new Note(textNote, getProcess());
            designerCanvasSelection = note;
        } else {
            designerCanvasSelection = getProcess();
        }
    } else {
        designerCanvasSelection = getProcess();
    }
    designerCanvasSelection.addDirtyStateListener(this);
}
Also used : EmbeddedSubProcess(com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) Note(com.centurylink.mdw.plugin.designer.model.Note) TextNote(com.centurylink.mdw.designer.display.TextNote) Transition(com.centurylink.mdw.plugin.designer.model.Transition) JSONObject(org.json.JSONObject) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) Link(com.centurylink.mdw.designer.display.Link)

Example 7 with ActivityImpl

use of com.centurylink.mdw.plugin.designer.model.ActivityImpl 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 8 with ActivityImpl

use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method findActivityImplementors.

/**
 * Returns the activity implementors events belonging to a package version.
 */
public List<ActivityImpl> findActivityImplementors(WorkflowPackage aPackage) {
    List<ActivityImpl> impls = new ArrayList<>();
    List<ActivityImplementorVO> implVOs = getDataAccess().getActivityImplementors(false);
    for (ActivityImplementorVO implVO : implVOs) {
        if ((aPackage.isDefaultPackage() && !isPackaged(implVO)) || (!aPackage.isDefaultPackage() && aPackage.getPackageVO().containsActivityImpl(implVO.getImplementorClassName()))) {
            ActivityImpl activityImpl = activityImpls.get(implVO.getImplementorClassName());
            if (activityImpl == null) {
                activityImpl = new ActivityImpl(implVO, aPackage);
                activityImpl.addElementChangeListener(this);
                activityImpls.put(implVO.getImplementorClassName(), activityImpl);
            }
            if (!impls.contains(activityImpl))
                impls.add(activityImpl);
        }
    }
    Collections.sort(impls);
    return impls;
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) ArrayList(java.util.ArrayList)

Example 9 with ActivityImpl

use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.

the class ToolboxViewActionGroup method enableToolbarActions.

public void enableToolbarActions(boolean enabled) {
    sortAction.setEnabled(enabled);
    refreshAction.setEnabled(enabled);
    ActivityImpl impl = view.getSelection();
    saveAction.setEnabled(enabled && view.isDirty() && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
    deleteAction.setEnabled(enabled && view.isSelection() && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
    newAction.setEnabled(enabled && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
    filterAction.setEnabled(enabled);
    discoverAction.setEnabled(enabled && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
}
Also used : ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl)

Example 10 with ActivityImpl

use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerContentProvider method handleElementChange.

private void handleElementChange(ElementChangeEvent ece) {
    if (ece.getChangeType().equals(ChangeType.ELEMENT_CREATE)) {
        Object parent = getParent(ece.getElement());
        if (parent == null) {
            treeViewer.refresh(true);
            ece.getElement().addElementChangeListener(this);
        } else {
            if (parent instanceof WorkflowPackage) {
                try {
                    ((WorkflowPackage) parent).getFolder().refreshLocal(IResource.DEPTH_ONE, null);
                } catch (Exception ex) {
                    PluginMessages.log(ex);
                }
            }
            treeViewer.refresh(parent, true);
        }
        treeViewer.expandToLevel(ece.getElement(), 0);
        treeViewer.setSelection(ece.getElement());
    } else if (ece.getChangeType().equals(ChangeType.ELEMENT_DELETE)) {
        Object parent = getParent(ece.getElement());
        if (parent != null) {
            if (ece.getElement() instanceof ActivityImpl)
                // impl can be associated with
                treeViewer.refresh();
            else
                // multiple packages
                treeViewer.refresh(parent, true);
        } else {
            // must be a workflowProject
            ece.getElement().removeElementChangeListener(this);
            treeViewer.refresh();
        }
    } else if (ece.getChangeType().equals(ChangeType.RENAME)) {
        treeViewer.refresh(ece.getElement(), true);
        treeViewer.getControl().forceFocus();
    } else if (ece.getChangeType().equals(ChangeType.VERSION_CHANGE)) {
        treeViewer.refresh(ece.getElement(), true);
        if (ece.getElement() instanceof WorkflowPackage)
            treeViewer.refresh(ece.getElement().getProject().getArchivedUserVisiblePackagesFolder(), true);
    } else if (ece.getChangeType().equals(ChangeType.LABEL_CHANGE)) {
        treeViewer.update(ece.getElement(), null);
    } else if (ece.getChangeType().equals(ChangeType.SETTINGS_CHANGE)) {
        // only applies for workflow projects
        if (ece.getElement() instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) ece.getElement();
            if (ece.getNewValue() instanceof JdbcDataSource) {
                treeViewer.collapseToLevel(workflowProject, TreeViewer.ALL_LEVELS);
                treeViewer.refresh(workflowProject, true);
            } else if (ece.getNewValue() == null) {
                // general refresh
                treeViewer.refresh(workflowProject, true);
            }
        } else {
            treeViewer.refresh(ece.getElement(), true);
        }
    } else if (ece.getChangeType().equals(ChangeType.STATUS_CHANGE)) {
        treeViewer.update(ece.getElement(), null);
        if (ece.getElement() instanceof AutomatedTestCase) {
            AutomatedTestCase testCase = (AutomatedTestCase) ece.getElement();
            Object testResults;
            if (testCase.isLegacy())
                testResults = testCase.getLegacyExpectedResults();
            else
                testResults = testCase.getExpectedResults();
            if (testResults != null)
                treeViewer.refresh(testResults, true);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException)

Aggregations

ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)19 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)6 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)5 ArrayList (java.util.ArrayList)5 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)4 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)4 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)4 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)4 Node (com.centurylink.mdw.designer.display.Node)2 Activity (com.centurylink.mdw.plugin.designer.model.Activity)2 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)2 TaskTemplate (com.centurylink.mdw.plugin.designer.model.TaskTemplate)2 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 GridData (org.eclipse.swt.layout.GridData)2 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)1 ProcessPersister (com.centurylink.mdw.dataaccess.ProcessPersister)1 DataUnavailableException (com.centurylink.mdw.designer.DataUnavailableException)1