use of org.yamcs.studio.data.vtype.VType in project yamcs-studio by yamcs.
the class AbstractBoolEditPart method registerCommonPropertyChangeHandlers.
/**
* Registers property change handlers for the properties defined in {@link AbstractBoolWidgetModel}. This method is
* provided for the convenience of subclasses, which can call this method in their implementation of
* {@link #registerPropertyChangeHandlers()}.
*/
protected void registerCommonPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue == null || !(newValue instanceof VType)) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
switch(VTypeHelper.getBasicDataType((VType) newValue)) {
case SHORT:
figure.setTotalBits(TotalBits.BITS_16);
break;
case INT:
case ENUM:
figure.setTotalBits(TotalBits.BITS_32);
break;
default:
break;
}
updateFromValue((VType) newValue, figure);
return true;
});
setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
if (getWidgetModel().getDataType() != 0) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBit((Integer) newValue);
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
IWidgetPropertyChangeHandler dataTypeHandler = (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
if ((Integer) newValue == 0) {
figure.setBit(getWidgetModel().getBit());
} else {
figure.setBit(-1);
}
updateFromValue(getPVValue(PROP_PVNAME), figure);
updatePropSheet((Integer) newValue);
return true;
};
getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> dataTypeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
setPropertyChangeHandler(PROP_ON_STATE, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
setPropertyChangeHandler(PROP_SHOW_BOOL_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setShowBooleanLabel((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_BOOL_LABEL_POS, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBoolLabelPosition(BoolLabelPosition.values()[(Integer) newValue]);
return false;
});
setPropertyChangeHandler(PROP_ON_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_OFF_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_ON_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnColor(((OPIColor) newValue).getSWTColor());
return true;
});
setPropertyChangeHandler(PROP_OFF_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffColor(((OPIColor) newValue).getSWTColor());
return true;
});
}
use of org.yamcs.studio.data.vtype.VType 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()));
}
use of org.yamcs.studio.data.vtype.VType in project yamcs-studio by yamcs.
the class ComboEditPart method registerPropertyChangeHandlers.
@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadItemsListener();
return false;
});
autoSizeWidget((ComboFigure) getFigure());
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null) {
var stringValue = VTypeHelper.getString((VType) newValue);
if (Arrays.asList(combo.getItems()).contains(stringValue)) {
combo.setText(stringValue);
} else {
combo.deselectAll();
//
// if(getWidgetModel().isBorderAlarmSensitve())
// autoSizeWidget((ComboFigure) refreshableFigure);
}
}
return true;
});
setPropertyChangeHandler(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof List) {
updateCombo((List<String>) newValue);
if (getWidgetModel().isItemsFromPV()) {
combo.setText(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
}
}
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
// size change handlers--always apply the default height
IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
autoSizeWidget((ComboFigure) figure);
return true;
};
setPropertyChangeHandler(PROP_WIDTH, handle);
setPropertyChangeHandler(PROP_HEIGHT, handle);
setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(PROP_FONT, handle);
}
Aggregations