use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class TextUpdateEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
setFigureText((String) newValue);
if (isAutoSize) {
Display.getCurrent().timerExec(10, this::performAutoSize);
}
return true;
});
setPropertyChangeHandler(PROP_FONT, (oldValue, newValue, figure) -> {
figure.setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
performAutoSize();
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
figure.setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
isAutoSize = (Boolean) newValue;
if ((Boolean) newValue) {
performAutoSize();
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
if (figure instanceof TextFigure) {
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
}
return true;
});
setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
if (figure instanceof TextFigure) {
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
}
return true;
});
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, figure) -> {
if (newValue == null) {
return false;
}
formatValue(newValue, PROP_PVVALUE);
return false;
});
setPropertyChangeHandler(PROP_FORMAT_TYPE, (oldValue, newValue, figure) -> {
format = FormatEnum.values()[(Integer) newValue];
formatValue(newValue, PROP_FORMAT_TYPE);
return true;
});
setPropertyChangeHandler(PROP_PRECISION, (oldValue, newValue, figure) -> {
precision = (Integer) newValue;
formatValue(newValue, PROP_PRECISION);
return true;
});
setPropertyChangeHandler(PROP_PRECISION_FROM_DB, (oldValue, newValue, figure) -> {
isPrecisionFromDB = (Boolean) newValue;
formatValue(newValue, PROP_PRECISION_FROM_DB);
return true;
});
setPropertyChangeHandler(PROP_SHOW_UNITS, (oldValue, newValue, figure) -> {
isShowUnits = (Boolean) newValue;
formatValue(newValue, PROP_SHOW_UNITS);
return true;
});
setPropertyChangeHandler(PROP_ROTATION, (oldValue, newValue, figure) -> {
if (figure instanceof TextFigure) {
((TextFigure) figure).setRotate((Double) newValue);
}
return true;
});
setPropertyChangeHandler(PROP_WRAP_WORDS, (oldValue, newValue, figure) -> {
AbstractWidgetModel model = getWidgetModel();
var parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
});
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class ImageBoolButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// Save CPU usage
// removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
// value
// IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
// public boolean handleChange(Object oldValue,
// final Object newValue,
// final IFigure refreshableFigure) {
// if(newValue == null)
// return false;
// ImageBoolButtonFigure figure = (ImageBoolButtonFigure) refreshableFigure;
// //figure.setValue(ValueUtil.getDouble((IValue)newValue));
// autoSizeWidget(figure);
// return true;
// }
// };
// setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
setPropertyChangeHandler(PROP_ON_IMAGE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
var absolutePath = (String) newValue;
if (!absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
imageFigure.setOnImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_OFF_IMAGE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
var absolutePath = (String) newValue;
if (!absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
imageFigure.setOffImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setStretch((Boolean) newValue);
autoSizeWidget(imageFigure);
return true;
});
FigureTransparencyHelper.addHandler(this, figure);
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAnimationDisabled((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAlignedToNearestSecond((Boolean) newValue);
return false;
});
// changes to the border width property
IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
};
setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
// size change handlers - so we can stretch accordingly
handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
};
setPropertyChangeHandler(PROP_HEIGHT, handle);
setPropertyChangeHandler(PROP_WIDTH, handle);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE 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