use of org.csstudio.opibuilder.widgets.model.ActionButtonModel.PROP_TEXT in project yamcs-studio by yamcs.
the class Draw2DButtonEditPartDelegate method registerPropertyChangeHandlers.
@Override
public void registerPropertyChangeHandlers() {
editpart.setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
figure.setText(newValue.toString());
figure.calculateTextPosition();
return true;
});
editpart.setPropertyChangeHandler(PROP_IMAGE, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var absolutePath = (String) newValue;
if (absolutePath != null && !absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(editpart.getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
figure.setImagePath(absolutePath);
return true;
});
editpart.setPropertyChangeHandler(PROP_WIDTH, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var height = (Integer) editpart.getPropertyValue(PROP_HEIGHT);
figure.calculateTextPosition((Integer) newValue, height);
return true;
});
editpart.setPropertyChangeHandler(PROP_HEIGHT, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var width = (Integer) editpart.getPropertyValue(PROP_WIDTH);
figure.calculateTextPosition(width, (Integer) newValue);
return true;
});
IWidgetPropertyChangeHandler buttonStyleHandler = (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
figure.setToggleStyle((Boolean) newValue);
editpart.updatePropSheet();
return true;
};
editpart.getWidgetModel().getProperty(PROP_TOGGLE_BUTTON).addPropertyChangeListener(evt -> buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), editpart.getFigure()));
}
Aggregations