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 };
}
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;
}
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;
}
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;
}
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;
}
Aggregations