Search in sources :

Example 1 with VNumber

use of org.diirt.vtype.next.VNumber in project org.csstudio.display.builder by kasemir.

the class RadioRepresentation method selectionChanged.

private void selectionChanged(final ObservableValue<? extends Toggle> obs, final Toggle oldval, final Toggle newval) {
    if (!active && newval != null) {
        active = true;
        try {
            // For now reset to old value.
            // New value will be shown if the PV accepts it and sends a value update.
            toggle.selectToggle(oldval);
            final Object value;
            final VType pv_value = model_widget.runtimePropValue().getValue();
            if (pv_value instanceof VEnum || pv_value instanceof VNumber)
                // PV uses enumerated or numeric type, so write the index
                value = toggle.getToggles().indexOf(newval);
            else
                // PV uses text
                value = FormatOptionHandler.parse(pv_value, ((RadioButton) newval).getText(), FormatOption.DEFAULT);
            logger.log(Level.FINE, "Writing " + value);
            toolkit.fireWrite(model_widget, value);
        } finally {
            active = false;
        }
    }
}
Also used : VType(org.diirt.vtype.VType) VNumber(org.diirt.vtype.next.VNumber) VEnum(org.diirt.vtype.VEnum)

Aggregations

VEnum (org.diirt.vtype.VEnum)1 VType (org.diirt.vtype.VType)1 VNumber (org.diirt.vtype.next.VNumber)1