Search in sources :

Example 1 with WritePVAction

use of org.csstudio.opibuilder.widgetActions.WritePVAction 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)

Aggregations

ActionsInput (org.csstudio.opibuilder.widgetActions.ActionsInput)1 WritePVAction (org.csstudio.opibuilder.widgetActions.WritePVAction)1 IPV (org.csstudio.simplepv.IPV)1 VEnum (org.diirt.vtype.VEnum)1 VType (org.diirt.vtype.VType)1