use of org.csstudio.swt.widgets.figures.ThumbWheelFigure in project yamcs-studio by yamcs.
the class ThumbWheelEditPart method doCreateFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure doCreateFigure() {
model = (ThumbWheelModel) getWidgetModel();
logic = new ThumbWheelLogic(0, model.getWholePartDigits(), model.getDecimalPartDigits());
logic.setMax(model.getMaximum());
logic.setMin(model.getMinimum());
figure = new ThumbWheelFigure(logic.getIntegerWheels(), logic.getDecimalWheels(), this.getExecutionMode() == ExecutionMode.RUN_MODE);
model.setWholePartDigits(logic.getIntegerWheels());
model.setDecimalPartDigits(logic.getDecimalWheels());
FontData fontData = model.getFont().getFontData();
figure.setWheelFont(CustomMediaFactory.getInstance().getFont(fontData.getName(), fontData.getHeight(), fontData.getStyle()));
figure.setInternalBorderColor(model.getInternalBorderColor());
figure.setInternalFocusedBorderColor(model.getInternalFocusedBorderColor());
figure.setInternalBorderThickness(model.getInternalBorderWidth());
figure.setButtonVisibility(model.isButtonVisible());
markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
figure.addWheelListener(new WheelListener() {
@Override
public void decrementDecimalPart(int index) {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
logic.decrementDecimalDigitAt(index);
updateWheelValues();
// write value to pv if pv name is not empty
if (getWidgetModel().getPVName().trim().length() > 0) {
double doubleValue = logic.getValue();
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, doubleValue);
}
}
}
@Override
public void incrementDecimalPart(int index) {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
logic.incrementDecimalDigitAt(index);
updateWheelValues();
// write value to pv if pv name is not empty
if (getWidgetModel().getPVName().trim().length() > 0) {
double doubleValue = logic.getValue();
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, doubleValue);
}
}
}
@Override
public void decrementIntegerPart(int index) {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
logic.decrementIntigerDigitAt(index);
updateWheelValues();
// write value to pv if pv name is not empty
if (getWidgetModel().getPVName().trim().length() > 0) {
double doubleValue = logic.getValue();
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, doubleValue);
}
}
}
@Override
public void incrementIntegerPart(int index) {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
logic.incrementIntigerWheel(index);
updateWheelValues();
// write value to pv if pv name is not empty
if (getWidgetModel().getPVName().trim().length() > 0) {
double doubleValue = logic.getValue();
setPVValue(AbstractPVWidgetModel.PROP_PVNAME, doubleValue);
}
}
}
});
updateWheelValues();
return figure;
}
use of org.csstudio.swt.widgets.figures.ThumbWheelFigure in project yamcs-studio by yamcs.
the class ThumbWheelEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// PV value
IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue != null) {
double doubleValue = VTypeHelper.getDouble((VType) newValue);
logic.setValue(doubleValue);
updateWheelValues();
}
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_PVVALUE, pvhandler);
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
// decimal wheels
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
logic.setDecimalWheels((Integer) newValue);
figure.setDecimalDigits(logic.getDecimalWheels());
model.setDecimalPartDigits(logic.getDecimalWheels());
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_DECIMAL_DIGITS_PART, handler);
// integer wheels
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
logic.setIntegerWheels((Integer) newValue);
figure.setIntegerDigits(logic.getIntegerWheels());
model.setWholePartDigits(logic.getIntegerWheels());
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTEGER_DIGITS_PART, handler);
// min
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
logic.setMin((Double) newValue);
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_MIN, handler);
// max
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
logic.setMax((Double) newValue);
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_MAX, handler);
// value
// handler = new IWidgetPropertyChangeHandler() {
// public boolean handleChange(final Object oldValue,
// final Object newValue, final IFigure refreshableFigure) {
// logic.setValue((Double) newValue);
// updateWheelValues();
// return true;
// }
// };
// setPropertyChangeHandler(ThumbWheelModel.PROP_VALUE, handler);
// font
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
FontData fontData = ((OPIFont) newValue).getFontData();
figure.setWheelFont(CustomMediaFactory.getInstance().getFont(fontData.getName(), fontData.getHeight(), fontData.getStyle()));
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_FONT, handler);
// border color
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalBorderColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_COLOR, handler);
// focused border color
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalFocusedBorderColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FOCUSED_FRAME_COLOR, handler);
// border width
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalBorderThickness((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_THICKNESS, handler);
// show button
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setButtonVisibility((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_SHOW_BUTTONS, handler);
}
Aggregations