Exemplo n.º 1
0
  @Override
  protected void doFillIntoGrid(Composite parent, int numColumns) {
    Control control = getLabelControl(parent);
    GridData gd = new GridData();
    control.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalAlignment = GridData.FILL;
    gd.horizontalSpan = numColumns - 1;
    gd.grabExcessHorizontalSpace = true;
    spinner.setLayoutData(gd);
    spinner.layout();
  }
Exemplo n.º 2
0
  public SpinnerFieldEditor(
      String name,
      String labelText,
      Composite parent,
      int min,
      int max,
      int increment,
      int pageIncrement) {
    init(name, labelText);

    GridLayout layout = new GridLayout();
    layout.numColumns = getNumberOfControls();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = HORIZONTAL_GAP;
    parent.setLayout(layout);

    // create label control
    getLabelControl(parent);

    spinner = new BigDecimalSpinner(parent, SWT.NONE, 0, min, max, increment, pageIncrement);

    spinner.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            valueChanged();
          }
        });

    doFillIntoGrid(parent, layout.numColumns);
  }
Exemplo n.º 3
0
  /**
   * Informs this field editor's listener, if it has one, about a change to the value (<code>VALUE
   * </code> property) provided that the old and new values are different.
   *
   * <p>This hook is <em>not</em> called when the scale is initialized (or reset to the default
   * value) from the preference store.
   */
  protected void valueChanged() {
    setPresentsDefaultValue(false);

    int newValue = spinner.getSelection().intValue();
    if (newValue != oldValue) {
      fireStateChanged(IS_VALID, false, true);
      fireValueChanged(VALUE, new Integer(oldValue), new Integer(newValue));
      oldValue = newValue;
    }
  }
Exemplo n.º 4
0
 @Override
 protected void doStore() {
   getPreferenceStore().setValue(getPreferenceName(), spinner.getSelection().intValue());
 }
Exemplo n.º 5
0
 @Override
 protected void doLoadDefault() {
   int value = getPreferenceStore().getDefaultInt(getPreferenceName());
   spinner.setSelection(new BigDecimal(value));
   valueChanged();
 }
Exemplo n.º 6
0
 @Override
 protected void doLoad() {
   int value = getPreferenceStore().getInt(getPreferenceName());
   spinner.setSelection(new BigDecimal(value));
   oldValue = value;
 }
Exemplo n.º 7
0
 @Override
 protected void adjustForNumColumns(int numColumns) {
   ((GridData) spinner.getLayoutData()).horizontalSpan = numColumns - 1;
 }
Exemplo n.º 8
0
 @Override
 public void setFocus() {
   spinner.setFocus();
 }