use of org.csstudio.swt.widgets.figures.AbstractChoiceFigure in project yamcs-studio by yamcs.
the class AbstractChoiceEditPart method doCreateFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure doCreateFigure() {
final AbstractChoiceModel model = getWidgetModel();
updatePropSheet(model.isItemsFromPV());
AbstractChoiceFigure choiceFigure = createChoiceFigure();
choiceFigure.setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
choiceFigure.setFont(CustomMediaFactory.getInstance().getFont(model.getFont().getFontData()));
choiceFigure.setHorizontal((Boolean) (model.getPropertyValue(AbstractChoiceModel.PROP_HORIZONTAL)));
if (!model.isItemsFromPV() || getExecutionMode() == ExecutionMode.EDIT_MODE) {
List<String> items = getWidgetModel().getItems();
if (items != null)
choiceFigure.setStates(items);
}
choiceFigure.addChoiceButtonListener(new IChoiceButtonListener() {
@Override
public void buttonPressed(int index, String value) {
setPVValue(AbstractChoiceModel.PROP_PVNAME, value);
}
});
markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
return choiceFigure;
}
use of org.csstudio.swt.widgets.figures.AbstractChoiceFigure 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()));
}
Aggregations