Search in sources :

Example 1 with PROP_ITEMS_FROM_PV

use of org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_ITEMS_FROM_PV in project yamcs-studio by yamcs.

the class AbstractChoiceEditPart method registerPropertyChangeHandlers.

@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
        registerLoadItemsListener();
        return false;
    });
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
        if (newValue != null && newValue instanceof VType) {
            var stringValue = VTypeHelper.getString((VType) newValue);
            ((AbstractChoiceFigure) refreshableFigure).setState(stringValue);
        }
        return false;
    });
    setPropertyChangeHandler(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
        if (newValue != null && newValue instanceof List) {
            ((AbstractChoiceFigure) refreshableFigure).setStates(((List<String>) newValue));
            if (getWidgetModel().isItemsFromPV()) {
                ((AbstractChoiceFigure) refreshableFigure).setState(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
            }
        }
        return true;
    });
    IWidgetPropertyChangeHandler selectedColorHandler = (oldValue, newValue, figure) -> {
        ((AbstractChoiceFigure) figure).setSelectedColor(((OPIColor) newValue).getSWTColor());
        return false;
    };
    setPropertyChangeHandler(PROP_SELECTED_COLOR, selectedColorHandler);
    setPropertyChangeHandler(PROP_HORIZONTAL, (oldValue, newValue, figure) -> {
        ((AbstractChoiceFigure) figure).setHorizontal((Boolean) newValue);
        return true;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
        if (!(Boolean) newValue) {
            ((AbstractChoiceFigure) refreshableFigure).setStates((getWidgetModel().getItems()));
        }
        updatePropSheet((Boolean) newValue);
        return false;
    };
    getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) VTypeHelper(org.yamcs.studio.data.VTypeHelper) VEnum(org.yamcs.studio.data.vtype.VEnum) PROP_HORIZONTAL(org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_HORIZONTAL) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) IPV(org.yamcs.studio.data.IPV) PROP_ITEMS_FROM_PV(org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_ITEMS_FROM_PV) List(java.util.List) AbstractChoiceFigure(org.csstudio.swt.widgets.figures.AbstractChoiceFigure) VType(org.yamcs.studio.data.vtype.VType) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) IPVListener(org.yamcs.studio.data.IPVListener) PROP_SELECTED_COLOR(org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_SELECTED_COLOR) OPIColor(org.csstudio.opibuilder.util.OPIColor) PROP_ITEMS(org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_ITEMS) AbstractChoiceModel(org.csstudio.opibuilder.widgets.model.AbstractChoiceModel) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VType(org.yamcs.studio.data.vtype.VType) AbstractChoiceFigure(org.csstudio.swt.widgets.figures.AbstractChoiceFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) List(java.util.List) OPIColor(org.csstudio.opibuilder.util.OPIColor)

Aggregations

List (java.util.List)1 AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)1 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 AbstractChoiceModel (org.csstudio.opibuilder.widgets.model.AbstractChoiceModel)1 PROP_HORIZONTAL (org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_HORIZONTAL)1 PROP_ITEMS (org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_ITEMS)1 PROP_ITEMS_FROM_PV (org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_ITEMS_FROM_PV)1 PROP_SELECTED_COLOR (org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_SELECTED_COLOR)1 AbstractChoiceFigure (org.csstudio.swt.widgets.figures.AbstractChoiceFigure)1 CustomMediaFactory (org.csstudio.ui.util.CustomMediaFactory)1 IFigure (org.eclipse.draw2d.IFigure)1 IPV (org.yamcs.studio.data.IPV)1 IPVListener (org.yamcs.studio.data.IPVListener)1 VTypeHelper (org.yamcs.studio.data.VTypeHelper)1 VEnum (org.yamcs.studio.data.vtype.VEnum)1 VType (org.yamcs.studio.data.vtype.VType)1