Search in sources :

Example 1 with PropertyEditorList

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList in project mdw-designer by CenturyLinkCloud.

the class PageletSection method setSelection.

public void setSelection(WorkflowElement selection) {
    element = (WorkflowElement) selection;
    if (propertyEditors != null) {
        for (PropertyEditor propertyEditor : propertyEditors) {
            propertyEditor.dispose();
        }
    }
    if (savePropertyEditor != null)
        savePropertyEditor.dispose();
    if (offlinePropertyEditor != null)
        offlinePropertyEditor.dispose();
    if (helpPropertyEditor != null)
        helpPropertyEditor.dispose();
    final PageletTab tab = element.getProject().getPageletTab(tabId);
    if (tab != null) {
        if (element.overrideAttributesApplied()) {
            attributeNames = new ArrayList<String>();
            propertyEditors = new PropertyEditorList(element, tab.getXml());
            for (PropertyEditor propertyEditor : propertyEditors) {
                attributeNames.add(propertyEditor.getName());
                propertyEditor.setFireDirtyStateChange(false);
                propertyEditor.render(composite);
                propertyEditor.setValue(element.getAttribute(propertyEditor.getName()));
                if (!propertyEditor.getType().equals(PropertyEditor.TYPE_LINK)) {
                    // pagelet-driven attributes are always considered
                    // override attributes
                    boolean editable = element.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION) && !propertyEditor.isReadOnly();
                    propertyEditor.setEditable(editable);
                    propertyEditor.setFireDirtyStateChange(false);
                }
                if (!propertyEditor.isReadOnly()) {
                    propertyEditor.addValueChangeListener(new ValueChangeListener() {

                        public void propertyValueChanged(Object newValue) {
                            setDirty(true);
                        }
                    });
                }
            }
            // help link
            helpPropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_LINK);
            helpPropertyEditor.setLabel("Override Attributes Help");
            helpPropertyEditor.render(composite);
            helpPropertyEditor.setValue("/MDWHub/doc/override-attributes.html");
            // save button
            savePropertyEditor = createSaveButton();
        } else {
            // offline message
            offlinePropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_INFO);
            offlinePropertyEditor.render(composite);
            offlinePropertyEditor.setValue("Attributes unavailable. Reload process with server online.");
            // help link
            helpPropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_LINK);
            helpPropertyEditor.setLabel("Override Attributes Help");
            helpPropertyEditor.render(composite);
            helpPropertyEditor.setValue("/MDWHub/doc/todo.html");
        }
    }
    composite.layout(true);
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 2 with PropertyEditorList

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList in project mdw-designer by CenturyLinkCloud.

the class AssetDrivenActivityCustomSection method determineCustomAttr.

private CustomAttributeVO determineCustomAttr(Activity activity) {
    PropertyEditorList propEditorList = new PropertyEditorList(activity);
    for (PropertyEditor propertyEditor : propEditorList) {
        if (propertyEditor instanceof WorkflowAssetEditor) {
            WorkflowAssetEditor assetEditor = (WorkflowAssetEditor) propertyEditor;
            propertyEditor.setValue(activity);
            AssetLocator locator = new AssetLocator(assetEditor.getElement(), assetEditor.getLocatorType());
            WorkflowAsset asset = (WorkflowAsset) locator.assetFromAttr(activity.getAttribute(assetEditor.getAttributeName()));
            if (asset != null) {
                // language definitively determined by selected asset
                return activity.getProject().getDataAccess().getAssetCustomAttribute(asset.getLanguage());
            } else {
                // guess language based on presence of custom attributes
                for (String language : assetEditor.getAssetTypes()) {
                    CustomAttributeVO customAttr = activity.getProject().getDataAccess().getAssetCustomAttribute(language);
                    if (customAttr != null && !StringHelper.isEmpty(customAttr.getDefinition()))
                        return customAttr;
                }
            }
        }
    }
    return null;
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) WorkflowAssetEditor(com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor) AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 3 with PropertyEditorList

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList in project mdw-designer by CenturyLinkCloud.

the class AssetDrivenActivityCustomSection method setSelection.

@Override
public void setSelection(WorkflowElement selection) {
    activity = (Activity) selection;
    CustomAttributeVO customAttrVO = determineCustomAttr(activity);
    if (propertyEditors != null) {
        for (PropertyEditor propertyEditor : propertyEditors) propertyEditor.dispose();
    }
    if (warningLabel != null)
        warningLabel.dispose();
    if (commentLabel != null)
        commentLabel.dispose();
    if (clearBtnPropertyEditor != null)
        clearBtnPropertyEditor.dispose();
    if (customAttrVO == null || StringHelper.isEmpty(customAttrVO.getDefinition())) {
        warningLabel = new Label(composite, SWT.NONE);
        warningLabel.setText("No custom attributes defined for workflow asset type" + (customAttrVO == null ? "." : ": " + customAttrVO.getCategorizer()));
    } else {
        commentLabel = new Label(composite, SWT.NONE);
        GridData gd = new GridData(SWT.LEFT);
        gd.horizontalSpan = PropertyEditor.COLUMNS;
        commentLabel.setLayoutData(gd);
        commentLabel.setText("Enter the custom attribute values that must be matched at runtime for the asset to be in effect.");
        valueMap = new HashMap<>();
        String attr = activity.getAttribute("CustomAttributes");
        if (attr != null)
            valueMap = StringHelper.parseMap(attr);
        // TODO: update is broken
        // setAttribute() must be called on property update (must not update
        // activity directly)
        propertyEditors = new PropertyEditorList(activity, customAttrVO.getDefinition());
        for (PropertyEditor propertyEditor : propertyEditors) {
            propertyEditor.setReadOnly(true);
            propertyEditor.render(composite);
            propertyEditor.setValue(valueMap.get(propertyEditor.getName()));
        }
        // clear button
        clearBtnPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_BUTTON);
        clearBtnPropertyEditor.setLabel("Clear");
        clearBtnPropertyEditor.setComment("Remove Criteria:");
        clearBtnPropertyEditor.setWidth(65);
        clearBtnPropertyEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                clear();
            }
        });
        clearBtnPropertyEditor.render(composite);
    }
    composite.layout(true);
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 4 with PropertyEditorList

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList in project mdw-designer by CenturyLinkCloud.

the class EventsSection method select.

@Override
public boolean select(Object toTest) {
    if (toTest == null || !(toTest instanceof Activity))
        return false;
    Activity activity = (Activity) toTest;
    if (activity.isForProcessInstance())
        return false;
    PropertyEditorList propEditorList = new PropertyEditorList(activity);
    for (PropertyEditor propertyEditor : propEditorList) {
        // return true if any widgets specify EVENTS section
        if (PropertyEditor.SECTION_EVENTS.equals(propertyEditor.getSection()))
            return true;
    }
    return false;
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) Activity(com.centurylink.mdw.plugin.designer.model.Activity) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 5 with PropertyEditorList

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList in project mdw-designer by CenturyLinkCloud.

the class SubProcessMappingSection method select.

public boolean select(Object toTest) {
    if (toTest == null || !(toTest instanceof Activity))
        return false;
    activity = (Activity) toTest;
    if (!activity.isSubProcessInvoke())
        return false;
    if (activity.isForProcessInstance())
        return false;
    PropertyEditorList propEditorList = new PropertyEditorList(activity);
    for (PropertyEditor propertyEditor : propEditorList) {
        if (propertyEditor.getType().equals(MappingEditor.TYPE_MAPPING))
            return true;
    }
    return false;
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) Activity(com.centurylink.mdw.plugin.designer.model.Activity) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Aggregations

PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)12 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)11 Activity (com.centurylink.mdw.plugin.designer.model.Activity)6 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)3 Label (org.eclipse.swt.widgets.Label)3 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)2 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)2 WorkflowAssetEditor (com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor)2 AssetLocator (com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator)1 GridData (org.eclipse.swt.layout.GridData)1 PartInitException (org.eclipse.ui.PartInitException)1