Search in sources :

Example 1 with EmbeddedSubProcess

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

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

the class SubProcessInstancesSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    this.element = selection;
    tableEditor = new TableEditor(element, TableEditor.TYPE_TABLE);
    tableEditor.setReadOnly(true);
    if (columnSpecs == null)
        columnSpecs = createColumnSpecs();
    tableEditor.setColumnSpecs(columnSpecs);
    if (contentProvider == null)
        contentProvider = new SubProcessInstanceContentProvider();
    tableEditor.setContentProvider(contentProvider);
    if (labelProvider == null)
        labelProvider = new SubProcessInstanceLabelProvider();
    tableEditor.setLabelProvider(labelProvider);
    tableEditor.render(composite);
    // double-click
    tableEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            if (!(element instanceof EmbeddedSubProcess))
                openSubProcessInstance((ProcessInstanceVO) newValue);
        }
    });
    // right-click menu
    tableEditor.getTable().addListener(SWT.MenuDetect, new Listener() {

        public void handleEvent(Event event) {
            tableEditor.getTable().setMenu(element instanceof EmbeddedSubProcess ? null : createContextMenu(getShell()));
        }
    });
}
Also used : EmbeddedSubProcess(com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) Listener(org.eclipse.swt.widgets.Listener) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)

Example 3 with EmbeddedSubProcess

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

the class DocumentationSection method setSelection.

public void setSelection(WorkflowElement selection) {
    element = selection;
    String attrVal = element.getAttribute(ATTR);
    if (attrVal != null && !attrVal.isEmpty()) {
        if (attrVal.length() >= 8) {
            byte[] first4 = RuleSetVO.decode(attrVal.substring(0, 8));
            if (first4[0] == 68 && first4[1] == 35 && first4[2] == 17 && first4[3] == 0)
                language = DocumentationEditorValueProvider.MS_WORD;
        }
    }
    if (artifactEditor != null) {
        artifactEditor.dispose();
        artifactEditor = null;
    }
    if (referenceIdEditor != null) {
        referenceIdEditor.dispose();
        referenceIdEditor = null;
    }
    if (sequenceIdEditor != null) {
        sequenceIdEditor.dispose();
        sequenceIdEditor = null;
    }
    if (webEditor != null) {
        webEditor.dispose();
        webEditor = null;
    }
    // artifact editor
    ArtifactEditorValueProvider valueProvider = new DocumentationEditorValueProvider(selection) {

        @Override
        public void languageChanged(String newLanguage) {
            super.languageChanged(newLanguage);
            boolean proceed = true;
            String attrVal = element.getAttribute(ATTR);
            if (attrVal != null && !attrVal.isEmpty() && !language.equals(newLanguage))
                proceed = MessageDialog.openConfirm(getShell(), "Confirm Format", "Proceed with switch to " + newLanguage + " format? (" + language + " formatted content will be lost.)");
            if (proceed) {
                language = newLanguage;
                element.setAttribute(getAttributeName(), " ");
                setSelection(element);
            } else {
                artifactEditor.setLanguage(language);
            }
        }

        @Override
        public String getLanguage() {
            return language;
        }
    };
    artifactEditor = new ArtifactEditor(selection, valueProvider, "Format");
    artifactEditor.render(composite);
    artifactEditor.setElement(selection);
    artifactEditor.setEditable(!selection.isReadOnly());
    artifactEditor.setLanguage(language);
    if (element instanceof Activity || element instanceof EmbeddedSubProcess) {
        // reference ID text field
        sequenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT);
        sequenceIdEditor.setLabel("Sequence Number");
        sequenceIdEditor.setWidth(100);
        sequenceIdEditor.setVerticalIndent(5);
        sequenceIdEditor.render(composite);
        sequenceIdEditor.setElement(selection);
        sequenceIdEditor.setValue(element instanceof EmbeddedSubProcess ? ((EmbeddedSubProcess) element).getSequenceId() : ((Activity) element).getSequenceId());
        sequenceIdEditor.setEditable(false);
        // reference ID text field
        referenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT);
        referenceIdEditor.setLabel("Reference ID");
        referenceIdEditor.setWidth(100);
        referenceIdEditor.setComment("Optional (select Reference ID element order when exporting)");
        referenceIdEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                element.setAttribute(WorkAttributeConstant.REFERENCE_ID, (String) newValue);
            }
        });
        referenceIdEditor.render(composite);
        referenceIdEditor.setElement(selection);
        referenceIdEditor.setEditable(!selection.isReadOnly());
        referenceIdEditor.setValue(element.getAttribute(WorkAttributeConstant.REFERENCE_ID));
    }
    if (DocumentationEditorValueProvider.MARKDOWN.equals(language) && element.getProject().checkRequiredVersion(6, 0)) {
        webEditor = new PropertyEditor(element, PropertyEditor.TYPE_WEB);
        webEditor.render(composite);
        webEditor.setElement(element);
        MarkdownRenderer renderer = new MarkdownRenderer(attrVal);
        webEditor.setValue(renderer.renderHtml());
        webEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                MarkdownRenderer renderer = new MarkdownRenderer(newValue == null ? null : newValue.toString());
                String html = renderer.renderHtml();
                webEditor.setValue(html);
            }
        });
    }
    composite.layout(true);
}
Also used : EmbeddedSubProcess(com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess) ArtifactEditor(com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) DocumentationEditorValueProvider(com.centurylink.mdw.plugin.designer.properties.value.DocumentationEditorValueProvider) Activity(com.centurylink.mdw.plugin.designer.model.Activity) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ArtifactEditorValueProvider(com.centurylink.mdw.plugin.designer.properties.value.ArtifactEditorValueProvider) MarkdownRenderer(com.centurylink.mdw.designer.utils.MarkdownRenderer)

Aggregations

EmbeddedSubProcess (com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess)3 Activity (com.centurylink.mdw.plugin.designer.model.Activity)2 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)2 Graph (com.centurylink.mdw.designer.display.Graph)1 Link (com.centurylink.mdw.designer.display.Link)1 Node (com.centurylink.mdw.designer.display.Node)1 SubGraph (com.centurylink.mdw.designer.display.SubGraph)1 TextNote (com.centurylink.mdw.designer.display.TextNote)1 MarkdownRenderer (com.centurylink.mdw.designer.utils.MarkdownRenderer)1 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1 Note (com.centurylink.mdw.plugin.designer.model.Note)1 Transition (com.centurylink.mdw.plugin.designer.model.Transition)1 ArtifactEditor (com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor)1 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)1 ArtifactEditorValueProvider (com.centurylink.mdw.plugin.designer.properties.value.ArtifactEditorValueProvider)1 DocumentationEditorValueProvider (com.centurylink.mdw.plugin.designer.properties.value.DocumentationEditorValueProvider)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1