Search in sources :

Example 1 with BamMessageDefinition

use of com.centurylink.mdw.model.value.event.BamMessageDefinition in project mdw-designer by CenturyLinkCloud.

the class PropertyEditor method createBamEventComposer.

private BamEventComposer createBamEventComposer(Composite parent) {
    createLabel(parent, 5);
    final BamEventComposer composer = new BamEventComposer(parent, style, width, isReadOnly());
    composer.setElement(getElement());
    GridData gd = new GridData(SWT.LEFT);
    gd.horizontalSpan = COLUMNS - 1;
    gd.horizontalIndent = indent;
    composer.setLayoutData(gd);
    composer.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            BamMessageDefinition bamMsgDef = composer.getBamMessage();
            value = valueConverter.toPropertyValue(bamMsgDef);
            fireValueChanged(bamMsgDef);
        }
    });
    return composer;
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) BamMessageDefinition(com.centurylink.mdw.model.value.event.BamMessageDefinition)

Example 2 with BamMessageDefinition

use of com.centurylink.mdw.model.value.event.BamMessageDefinition in project mdw-designer by CenturyLinkCloud.

the class BamMonitoringSection method saveOverrideAttributes.

@Override
protected void saveOverrideAttributes() {
    // remove empty bam defs
    Map<String, BamMessageDefinition> defs = new HashMap<String, BamMessageDefinition>();
    for (String key : bamEventDefs.keySet()) {
        BamMessageDefinition def = bamEventDefs.get(key);
        def.setAttributes(removeEmpty(def.getAttributes()));
        if (!def.isEmpty())
            defs.put(key, def);
    }
    bamEventDefs = defs;
    // sync attributes
    for (String overrideAttr : getOverrideAttributes().keySet()) {
        if (!bamEventDefs.containsKey(overrideAttr))
            // to delete
            element.setAttribute(overrideAttr, null);
    }
    try {
        for (String key : bamEventDefs.keySet()) element.setAttribute(key, bamEventDefs.get(key).format());
        String msg = bamEvtVal.validateBamEventAttributes(bamEventDefs);
        if (msg.length() > 0) {
            msg += "\n Please correct the above errors before you continue.";
            MessageDialog.openError(getShell(), "Save Monitoring Attributes", msg);
        } else {
            super.saveOverrideAttributes();
        }
    } catch (MbengException ex) {
        PluginMessages.uiError(getShell(), ex, "Save Monitoring Attributes", element.getProject());
    }
}
Also used : MbengException(com.qwest.mbeng.MbengException) HashMap(java.util.HashMap) BamMessageDefinition(com.centurylink.mdw.model.value.event.BamMessageDefinition)

Example 3 with BamMessageDefinition

use of com.centurylink.mdw.model.value.event.BamMessageDefinition in project mdw-designer by CenturyLinkCloud.

the class BamMonitoringSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    element = (WorkflowElement) selection;
    // trigger dropdown
    triggerPropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_COMBO);
    triggerPropertyEditor.setLabel("BAM Trigger");
    triggerPropertyEditor.setWidth(100);
    triggerPropertyEditor.setReadOnly(true);
    ArrayList<String> triggerOpts = new ArrayList<String>();
    triggerOpts.add("Start");
    triggerOpts.add("Finish");
    triggerPropertyEditor.setValueOptions(triggerOpts);
    triggerPropertyEditor.setFireDirtyStateChange(false);
    triggerPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            if (newValue.equals("Start"))
                selectedTrigger = WorkAttributeConstant.BAM_START_MSGDEF;
            else if (newValue.equals("Finish"))
                selectedTrigger = WorkAttributeConstant.BAM_FINISH_MSGDEF;
            if (bamEventDefs.get(selectedTrigger) == null) {
                bamEventDefs.put(selectedTrigger, getValue(selectedTrigger));
            }
            bamMessagePropertyEditor.setValue(bamEventDefs.get(selectedTrigger));
            // otherwise
            bamMessagePropertyEditor.setEditable(isEditable());
        // reverts
        // Add/Delete
        // buttons
        // to
        // enabled
        }
    });
    triggerPropertyEditor.render(composite);
    separatorPropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_SEPARATOR);
    separatorPropertyEditor.setWidth(500);
    separatorPropertyEditor.render(composite);
    // bam message def
    bamMessagePropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_BAM_MESSAGE);
    bamMessagePropertyEditor.setLabel("BAM Message");
    bamMessagePropertyEditor.setWidth(500);
    bamMessagePropertyEditor.setFireDirtyStateChange(false);
    bamMessagePropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            BamMessageDefinition bamMessageDef = (BamMessageDefinition) newValue;
            bamEventDefs.put(selectedTrigger, bamMessageDef);
            element.setAttribute(selectedTrigger, valueConverter.toPropertyValue(bamMessageDef));
            setDirty(true);
        }
    });
    bamMessagePropertyEditor.render(composite);
    createSaveButton();
    // help link
    // spacer
    new Label(composite, SWT.NONE);
    helpPropertyEditor = new PropertyEditor(element, PropertyEditor.TYPE_LINK);
    helpPropertyEditor.setLabel("BAM Monitoring Help");
    helpPropertyEditor.render(composite);
    helpPropertyEditor.setValue("/MDWHub/doc/bam.html");
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) BamMessageDefinition(com.centurylink.mdw.model.value.event.BamMessageDefinition)

Aggregations

BamMessageDefinition (com.centurylink.mdw.model.value.event.BamMessageDefinition)3 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 MbengException (com.qwest.mbeng.MbengException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 Label (org.eclipse.swt.widgets.Label)1