Search in sources :

Example 76 with Spinner

use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.

the class AbstractNumericEditorFactory method createOtherControlsOn.

public Control[] createOtherControlsOn(Composite parent, PropertyDescriptor<T> desc, Rule rule, ValueChangeListener listener, SizeChangeListener sizeListener) {
    Label defaultLabel = newLabel(parent, SWTUtil.stringFor(StringKeys.RULEEDIT_LABEL_DEFAULT));
    Control valueControl = newEditorOn(parent, desc, rule, listener, sizeListener);
    Label minLabel = newLabel(parent, SWTUtil.stringFor(StringKeys.RULEEDIT_LABEL_MIN));
    Spinner minWidget = newSpinnerFor(parent, digitPrecision());
    Label maxLabel = newLabel(parent, SWTUtil.stringFor(StringKeys.RULEEDIT_LABEL_MAX));
    Spinner maxWidget = newSpinnerFor(parent, digitPrecision());
    linkup(minWidget, (Spinner) valueControl, maxWidget);
    return new Control[] { defaultLabel, valueControl, minLabel, minWidget, maxLabel, maxWidget };
}
Also used : Control(org.eclipse.swt.widgets.Control) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label)

Example 77 with Spinner

use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.

the class AbstractNumericEditorFactory method newSpinnerFor.

protected static Spinner newSpinnerFor(Composite parent, int digits) {
    Spinner spinner = new Spinner(parent, SWT.BORDER);
    spinner.setDigits(digits);
    return spinner;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner)

Example 78 with Spinner

use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.

the class AbstractRealNumberEditor method newSpinnerFor.

protected final Spinner newSpinnerFor(Composite parent, PropertySource source, NumericPropertyDescriptor<T> numDesc) {
    Spinner spinner = newSpinnerFor(parent, DIGITS);
    int min = (int) (numDesc.lowerLimit().doubleValue() * SCALE);
    int max = (int) (numDesc.upperLimit().doubleValue() * SCALE);
    spinner.setMinimum(min);
    spinner.setMaximum(max);
    Number value = valueFor(source, numDesc);
    if (value != null) {
        int intVal = (int) (value.doubleValue() * SCALE);
        spinner.setSelection(intVal);
    }
    return spinner;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner)

Example 79 with Spinner

use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.

the class FloatEditorFactory method newEditorOn.

public Control newEditorOn(Composite parent, final PropertyDescriptor<Float> desc, final PropertySource source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
    final Spinner spinner = newSpinnerFor(parent, source, (NumericPropertyDescriptor<Float>) desc);
    spinner.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            Float newValue = (float) (spinner.getSelection() / SCALE);
            if (newValue.equals(valueFor(source, desc))) {
                return;
            }
            source.setProperty(desc, newValue);
            listener.changed(source, desc, newValue);
            adjustRendering(source, desc, spinner);
        }
    });
    return spinner;
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner)

Example 80 with Spinner

use of org.eclipse.swt.widgets.Spinner in project pmd-eclipse-plugin by pmd.

the class IntegerEditorFactory method newSpinner.

public static Spinner newSpinner(Composite parent, NumericPropertyDescriptor<?> desc, Object valueIn) {
    Spinner spinner = newSpinnerFor(parent, 0);
    spinner.setMinimum(desc.lowerLimit().intValue());
    spinner.setMaximum(desc.upperLimit().intValue());
    int value = valueIn == null ? spinner.getMinimum() : ((Number) valueIn).intValue();
    spinner.setSelection(value);
    return spinner;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)159 Composite (org.eclipse.swt.widgets.Composite)108 GridData (org.eclipse.swt.layout.GridData)105 GridLayout (org.eclipse.swt.layout.GridLayout)103 Label (org.eclipse.swt.widgets.Label)102 Button (org.eclipse.swt.widgets.Button)86 SelectionEvent (org.eclipse.swt.events.SelectionEvent)59 Group (org.eclipse.swt.widgets.Group)58 Text (org.eclipse.swt.widgets.Text)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 ModifyListener (org.eclipse.swt.events.ModifyListener)33 SelectionListener (org.eclipse.swt.events.SelectionListener)31 ModifyEvent (org.eclipse.swt.events.ModifyEvent)30 Combo (org.eclipse.swt.widgets.Combo)27 SWT (org.eclipse.swt.SWT)18 Point (org.eclipse.swt.graphics.Point)12 FormLayout (org.eclipse.swt.layout.FormLayout)11 RowLayout (org.eclipse.swt.layout.RowLayout)11 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)11 FormAttachment (org.eclipse.swt.layout.FormAttachment)9