Search in sources :

Example 16 with Activity

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

the class AssetDrivenActivityCustomSection method select.

@Override
public boolean select(Object toTest) {
    if (toTest == null || !(toTest instanceof Activity))
        return false;
    Activity testActivity = (Activity) toTest;
    if (// manual tasks have asset-driven widgets
    testActivity.isManualTask())
        // but no custom section
        return false;
    if (// so do subprocess launch activities
    testActivity.isSubProcessInvoke())
        return false;
    if (testActivity.isForProcessInstance())
        return false;
    PropertyEditorList propEditorList = new PropertyEditorList((Activity) toTest);
    for (PropertyEditor propertyEditor : propEditorList) {
        // return true if any widgets are considered asset-driven
        if (propertyEditor instanceof WorkflowAssetEditor)
            return true;
    }
    return false;
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) WorkflowAssetEditor(com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor) Activity(com.centurylink.mdw.plugin.designer.model.Activity) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 17 with Activity

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

Activity (com.centurylink.mdw.plugin.designer.model.Activity)17 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)7 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)6 PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)6 IEditorPart (org.eclipse.ui.IEditorPart)4 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 PartInitException (org.eclipse.ui.PartInitException)3 Node (com.centurylink.mdw.designer.display.Node)2 TextNote (com.centurylink.mdw.designer.display.TextNote)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)2 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)2 AdapterActivity (com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity)2 EvaluatorActivity (com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity)2 StartActivity (com.centurylink.mdw.plugin.designer.model.Activity.StartActivity)2 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)2 EmbeddedSubProcess (com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess)2 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)2 Note (com.centurylink.mdw.plugin.designer.model.Note)2 ActivityLaunchShortcut (com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut)2