Search in sources :

Example 1 with IntegerSpinner

use of com.sldeditor.ui.widgets.IntegerSpinner in project sldeditor by robward-scisys.

the class FieldConfigInteger method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (spinner == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        spinner = new IntegerSpinner(minValue, maxValue, stepSize);
        spinner.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(spinner);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
        }
        spinner.registerObserver(new SpinnerNotifyInterface() {

            @Override
            public void notify(double oldValue, double newValue) {
                Integer oldValueObj = Double.valueOf(oldValue).intValue();
                Integer newValueObj = Double.valueOf(newValue).intValue();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) IntegerSpinner(com.sldeditor.ui.widgets.IntegerSpinner) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Aggregations

UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 SpinnerNotifyInterface (com.sldeditor.ui.iface.SpinnerNotifyInterface)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 IntegerSpinner (com.sldeditor.ui.widgets.IntegerSpinner)1