use of org.csstudio.swt.widgets.figures.CheckBoxFigure in project yamcs-studio by yamcs.
the class CheckBoxEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// value
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
CheckBoxFigure 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(AbstractPVWidgetModel.PROP_PVVALUE, handler);
// bit
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setBit((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_BIT, handler);
// label
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setText((String) newValue);
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize())
performAutoSize(refreshableFigure);
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_LABEL, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if ((Boolean) newValue) {
performAutoSize(figure);
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_SELECTED_COLOR, handler);
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);
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
}
use of org.csstudio.swt.widgets.figures.CheckBoxFigure in project yamcs-studio by yamcs.
the class CheckBoxEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
CheckBoxFigure figure = new CheckBoxFigure(getExecutionMode().equals(ExecutionMode.RUN_MODE));
figure.setBit(getWidgetModel().getBit());
figure.setText(getWidgetModel().getLabel());
figure.setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
figure.addManualValueChangeListener(new IManualValueChangeListener() {
@Override
public void manualValueChanged(double newValue) {
if (getExecutionMode() == ExecutionMode.RUN_MODE)
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, newValue);
}
});
markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
return figure;
}
Aggregations