Search in sources :

Example 1 with WheelListener

use of org.csstudio.swt.widgets.figures.ThumbWheelFigure.WheelListener 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;
}
Also used : ThumbWheelFigure(org.csstudio.swt.widgets.figures.ThumbWheelFigure) WheelListener(org.csstudio.swt.widgets.figures.ThumbWheelFigure.WheelListener) FontData(org.eclipse.swt.graphics.FontData)

Aggregations

ThumbWheelFigure (org.csstudio.swt.widgets.figures.ThumbWheelFigure)1 WheelListener (org.csstudio.swt.widgets.figures.ThumbWheelFigure.WheelListener)1 FontData (org.eclipse.swt.graphics.FontData)1