use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT in project yamcs-studio by yamcs.
the class LabelEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setText((String) newValue);
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
}
});
return true;
});
setPropertyChangeHandler(PROP_ACTIONS, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
setPropertyChangeHandler(PROP_TOOLTIP, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
if ((Boolean) newValue) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
});
setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) 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;
});
getWidgetModel().getProperty(PROP_WRAP_WORDS).addPropertyChangeListener(evt -> updatePropertyVisibility());
setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, figure) -> {
if (figure instanceof WrappableTextFigure) {
((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
}
return false;
});
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT in project yamcs-studio by yamcs.
the class CheckBoxEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue == null) {
return false;
}
var figure = (CheckBoxFigure) 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;
}
figure.setValue(VTypeHelper.getDouble((VType) newValue));
return true;
});
setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
var figure = (CheckBoxFigure) refreshableFigure;
figure.setBit((Integer) newValue);
return true;
});
setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (CheckBoxFigure) refreshableFigure;
figure.setText((String) newValue);
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
performAutoSize(refreshableFigure);
}
});
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
if ((Boolean) newValue) {
performAutoSize(figure);
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_SELECTED_COLOR, (oldValue, newValue, figure) -> {
((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
performAutoSize(figure);
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT 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_FONT 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