use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ProgressBarEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
IWidgetPropertyChangeHandler originHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOrigin((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN, originHandler);
IWidgetPropertyChangeHandler originIgnoredHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOriginIgnored((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN_IGNORED, originIgnoredHandler);
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_EFFECT3D, effect3DHandler);
// effect 3D
IWidgetPropertyChangeHandler showLabelHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setShowLabel((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_SHOW_LABEL, showLabelHandler);
IWidgetPropertyChangeHandler indicatorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setIndicatorMode((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_INDICATOR_MODE, indicatorHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setHorizontal((Boolean) newValue);
ProgressBarModel model = (ProgressBarModel) getModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_HORIZONTAL, horizontalHandler);
// enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
// which is not the case for the scaled slider
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ENABLED, enableHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ProgressBarFigure figure = (ProgressBarFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
ProgressBarFigure progress = (ProgressBarFigure) figure;
progress.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class SashContainerEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getSashFigure().setSashPosition((Double) newValue);
return false;
}
};
setPropertyChangeHandler(SashContainerModel.PROP_SASH_POSITION, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getSashFigure().setSashStyle(getWidgetModel().getSashStyle());
return false;
}
};
setPropertyChangeHandler(SashContainerModel.PROP_SASH_STYLE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getSashFigure().setSashWidth((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(SashContainerModel.PROP_SASH_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getSashFigure().setHorizontal((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(SashContainerModel.PROP_HORIZONTAL, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getSashFigure().setOpaque(!(Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(SashContainerModel.PROP_TRANSPARENT, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ScrollbarEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
((ScrollbarFigure) getFigure()).setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
// enable
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (getExecutionMode() == ExecutionMode.RUN_MODE)
figure.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, enableHandler);
// value
IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
((ScrollbarFigure) refreshableFigure).setValue(VTypeHelper.getDouble((VType) newValue));
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
// minimum
IWidgetPropertyChangeHandler minimumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setMinimum((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_MIN, minimumHandler);
// maximum
IWidgetPropertyChangeHandler maximumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setMaximum((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_MAX, maximumHandler);
// page increment
IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setPageIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
// step increment
IWidgetPropertyChangeHandler stepIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setStepIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_STEP_INCREMENT, stepIncrementHandler);
// bar length
IWidgetPropertyChangeHandler barLengthHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setExtent((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_BAR_LENGTH, barLengthHandler);
// value tip
IWidgetPropertyChangeHandler valueTipHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setShowValueTip((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_SHOW_VALUE_TIP, valueTipHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setHorizontal((Boolean) newValue);
ScrollBarModel model = getWidgetModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_HORIZONTAL, horizontalHandler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class SpinnerEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// text
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
String text = (String) newValue;
try {
// $NON-NLS-1$ //$NON-NLS-2$
text = text.replace("e", "E");
double value = new DecimalFormat().parse(text).doubleValue();
// coerce value in range
value = Math.max(((SpinnerFigure) figure).getMin(), Math.min(((SpinnerFigure) figure).getMax(), value));
((SpinnerFigure) figure).setValue(value);
if (getExecutionMode() == ExecutionMode.RUN_MODE)
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, value);
getWidgetModel().setText(((SpinnerFigure) figure).getLabelFigure().getText(), false);
return false;
} catch (Exception e) {
return false;
}
}
};
setPropertyChangeHandler(SpinnerModel.PROP_TEXT, handler);
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
// pv value
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (newValue == null)
return false;
double value = VTypeHelper.getDouble((VType) newValue);
((SpinnerFigure) figure).setDisplayValue(value);
getWidgetModel().setText(((SpinnerFigure) figure).getLabelFigure().getText(), false);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_PVVALUE, handler);
// min
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setMin((Double) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_MIN, handler);
// max
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setMax((Double) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_MAX, handler);
// step increment
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setStepIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_STEP_INCREMENT, handler);
// page increment
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setPageIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_PAGE_INCREMENT, handler);
// font
IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).getLabelFigure().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, IFigure figure) {
((SpinnerFigure) figure).getLabelFigure().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) {
((SpinnerFigure) figure).getLabelFigure().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, IFigure figure) {
((SpinnerFigure) figure).getLabelFigure().setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setFormatType(NumericFormatType.values()[(Integer) newValue]);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_FORMAT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setPrecision((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_PRECISION, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setArrowButtonsOnLeft((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_BUTTONS_ON_LEFT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).setArrowButtonsHorizontal((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_HORIZONTAL_BUTTONS_LAYOUT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((SpinnerFigure) figure).showText((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(SpinnerModel.PROP_SHOW_TEXT, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TabEditPart method registerTabPropertyChangeHandlers.
private void registerTabPropertyChangeHandlers() {
// set prop handlers and init all the potential tabs
for (int i = 0; i < TabModel.MAX_TABS_AMOUNT; i++) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i);
IWidgetPropertyChangeHandler handler = new TabPropertyChangeHandler(i, tabProperty);
setPropertyChangeHandler(propID, handler);
}
}
for (int i = TabModel.MAX_TABS_AMOUNT - 1; i >= getWidgetModel().getTabsAmount(); i--) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i);
getWidgetModel().setPropertyVisible(propID, false);
}
}
}
Aggregations