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);
}
}
}
}
Aggregations