use of org.csstudio.opibuilder.util.OPIFont in project yamcs-studio by yamcs.
the class TextUpdateEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
setFigureText((String) newValue);
if (isAutoSize) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
performAutoSize();
}
});
}
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_TEXT, handler);
IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_FONT, fontHandler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize()) {
performAutoSize();
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
isAutoSize = (Boolean) newValue;
if ((Boolean) newValue) {
performAutoSize();
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
if (newValue == null)
return false;
formatValue(newValue, AbstractPVWidgetModel.PROP_PVVALUE);
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
format = FormatEnum.values()[(Integer) newValue];
formatValue(newValue, TextUpdateModel.PROP_FORMAT_TYPE);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_FORMAT_TYPE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
precision = (Integer) newValue;
formatValue(newValue, TextUpdateModel.PROP_PRECISION);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
isPrecisionFromDB = (Boolean) newValue;
formatValue(newValue, TextUpdateModel.PROP_PRECISION_FROM_DB);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION_FROM_DB, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
isShowUnits = (Boolean) newValue;
formatValue(newValue, TextUpdateModel.PROP_SHOW_UNITS);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_SHOW_UNITS, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setRotate((Double) newValue);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_ROTATION, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
AbstractWidgetModel model = getWidgetModel();
AbstractContainerModel parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_WRAP_WORDS, handler);
}
Aggregations