Search in sources :

Example 6 with ActionsInput

use of org.csstudio.opibuilder.widgetActions.ActionsInput in project yamcs-studio by yamcs.

the class MenuButtonEditPart method registerLoadActionsListener.

private void registerLoadActionsListener() {
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        if (getWidgetModel().isActionsFromPV()) {
            IPV pv = getPV(AbstractPVWidgetModel.PROP_PVNAME);
            if (pv != null) {
                if (loadActionsFromPVListener == null)
                    loadActionsFromPVListener = new IPVListener.Stub() {

                        @Override
                        public void valueChanged(IPV pv) {
                            VType value = pv.getValue();
                            if (value != null && value instanceof VEnum) {
                                List<String> new_meta = ((VEnum) value).getLabels();
                                if (meta == null || !meta.equals(new_meta)) {
                                    meta = new_meta;
                                    ActionsInput actionsInput = new ActionsInput();
                                    for (String writeValue : meta) {
                                        WritePVAction action = new WritePVAction();
                                        action.setPropertyValue(WritePVAction.PROP_PVNAME, getWidgetModel().getPVName());
                                        action.setPropertyValue(WritePVAction.PROP_VALUE, writeValue);
                                        action.setPropertyValue(WritePVAction.PROP_DESCRIPTION, writeValue);
                                        actionsInput.getActionsList().add(action);
                                    }
                                    getWidgetModel().setPropertyValue(AbstractWidgetModel.PROP_ACTIONS, actionsInput);
                                }
                            }
                        }
                    };
                pv.addListener(loadActionsFromPVListener);
            }
        }
    }
}
Also used : VType(org.diirt.vtype.VType) ActionsInput(org.csstudio.opibuilder.widgetActions.ActionsInput) WritePVAction(org.csstudio.opibuilder.widgetActions.WritePVAction) VEnum(org.diirt.vtype.VEnum) IPV(org.csstudio.simplepv.IPV)

Example 7 with ActionsInput

use of org.csstudio.opibuilder.widgetActions.ActionsInput in project yamcs-studio by yamcs.

the class ActionsProperty method writeToXML.

@Override
public void writeToXML(Element propElement) {
    ActionsInput actionsInput = (ActionsInput) getPropertyValue();
    // //$NON-NLS-1$
    propElement.setAttribute(XML_ATTRIBUTE_HOOK_FIRST, "" + actionsInput.isFirstActionHookedUpToWidget());
    // //$NON-NLS-1$
    propElement.setAttribute(XML_ATTRIBUTE_HOOK_ALL, "" + actionsInput.isHookUpAllActionsToWidget());
    for (AbstractWidgetAction action : actionsInput.getActionsList()) {
        Element actionElement = new Element(XML_ELEMENT_ACTION);
        actionElement.setAttribute(XML_ATTRIBUTE_ACTION_TYPE, action.getActionType().toString());
        for (AbstractWidgetProperty property : action.getAllProperties()) {
            Element propEle = new Element(property.getPropertyID());
            property.writeToXML(propEle);
            actionElement.addContent(propEle);
        }
        propElement.addContent(actionElement);
    }
}
Also used : ActionsInput(org.csstudio.opibuilder.widgetActions.ActionsInput) Element(org.jdom.Element) AbstractWidgetAction(org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)

Example 8 with ActionsInput

use of org.csstudio.opibuilder.widgetActions.ActionsInput in project yamcs-studio by yamcs.

the class ActionsProperty method checkValue.

@Override
public Object checkValue(Object value) {
    if (value == null)
        return null;
    ActionsInput acceptableValue = null;
    if (value instanceof ActionsInput) {
        ((ActionsInput) value).setWidgetModel(widgetModel);
        acceptableValue = (ActionsInput) value;
    }
    return acceptableValue;
}
Also used : ActionsInput(org.csstudio.opibuilder.widgetActions.ActionsInput)

Aggregations

ActionsInput (org.csstudio.opibuilder.widgetActions.ActionsInput)8 AbstractWidgetAction (org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)4 IPV (org.csstudio.simplepv.IPV)2 Element (org.jdom.Element)2 OpenRelatedDisplayAction (org.csstudio.opibuilder.actions.OpenRelatedDisplayAction)1 WidgetActionMenuAction (org.csstudio.opibuilder.actions.WidgetActionMenuAction)1 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 ScriptData (org.csstudio.opibuilder.script.ScriptData)1 OpenDisplayAction (org.csstudio.opibuilder.widgetActions.OpenDisplayAction)1 WritePVAction (org.csstudio.opibuilder.widgetActions.WritePVAction)1 VEnum (org.diirt.vtype.VEnum)1 VType (org.diirt.vtype.VType)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1