Java Code Examples for org.eclipse.swt.widgets.Spinner#setIncrement()

The following examples show how to use org.eclipse.swt.widgets.Spinner#setIncrement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GalleryExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createAnimationGroup(Composite parent) {
	Group animationGroup = createEmptyGroup(parent, "Animation");
	animationGroup.setLayout(new RowLayout());

	bAnimation = createButton(animationGroup, SWT.CHECK, "Animations", false, false);
	bAnimation.addListener(SWT.Selection, groupParamSelectionListener);

	cAnimationMovement = new Combo(animationGroup, SWT.READ_ONLY);
	cAnimationMovement.setItems(new String[] { "ExpoOut", "BounceOut", "ElasticOut", "LinearInOut" });
	cAnimationMovement.setText("ExpoOut");
	cAnimationMovement.addListener(SWT.Selection, groupParamSelectionListener);

	sAnimationDuration = new Spinner(animationGroup, SWT.NONE);
	sAnimationDuration.setMinimum(250);
	sAnimationDuration.setMaximum(5000);
	sAnimationDuration.setIncrement(100);
	sAnimationDuration.setSelection(500);
	sAnimationDuration.addListener(SWT.Selection, groupParamSelectionListener);
}
 
Example 2
Source File: GalleryExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createDecoratorsGroup(Composite parent) {
	Group dataGroup = createEmptyGroup(parent, "Decorators");
	dataGroup.setLayout(new RowLayout());

	sDecoratorNumber = new Spinner(dataGroup, SWT.NONE);
	sDecoratorNumber.setMinimum(1);
	sDecoratorNumber.setMaximum(5);
	sDecoratorNumber.setIncrement(1);
	sDecoratorNumber.setSelection(1);
	sDecoratorNumber.addListener(SWT.Selection, contentParamSelectionListener);

	bDecoratorLeft = createButton(dataGroup, SWT.CHECK, "Top Left", false, false);
	bDecoratorLeft.addListener(SWT.Selection, contentParamSelectionListener);
	bDecoratorUp = createButton(dataGroup, SWT.CHECK, "Top Right", false, false);
	bDecoratorUp.addListener(SWT.Selection, contentParamSelectionListener);
	bDecoratorRight = createButton(dataGroup, SWT.CHECK, "Bottom Right", false, false);
	bDecoratorRight.addListener(SWT.Selection, contentParamSelectionListener);
	bDecoratorDown = createButton(dataGroup, SWT.CHECK, "Bottom Left", false, false);
	bDecoratorDown.addListener(SWT.Selection, contentParamSelectionListener);
}
 
Example 3
Source File: GalleryExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createItemParametersGroup(Composite parent) {
	Group dataGroup = createEmptyGroup(parent, "Item parameters");
	dataGroup.setLayout(new RowLayout());

	cItemRenderer = new Combo(dataGroup, SWT.READ_ONLY);
	cItemRenderer.setItems(new String[] { "Icon", "List" });
	cItemRenderer.setText("Icon");
	cItemRenderer.addListener(SWT.Selection, itemRendererParamSelectionListener);

	bItemDropShadow = createButton(dataGroup, SWT.CHECK, "Drop shadow", false, true);

	sItemDropShadowSize = new Spinner(dataGroup, SWT.NONE);
	sItemDropShadowSize.setMinimum(0);
	sItemDropShadowSize.setMaximum(20);
	sItemDropShadowSize.setIncrement(1);
	sItemDropShadowSize.setSelection(5);
	sItemDropShadowSize.addListener(SWT.Selection, itemRendererParamSelectionListener);

	bItemLabel = createButton(dataGroup, SWT.CHECK, "Display labels", false, true);
}
 
Example 4
Source File: SankeySelectionDialog.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createCutoffSpinner(FormToolkit tk, Composite comp) {
	tk.createLabel(comp, M.DontShowSmallerThen);
	Composite inner = tk.createComposite(comp);
	UI.gridLayout(inner, 2, 10, 0);
	Spinner spinner = new Spinner(inner, SWT.BORDER);
	spinner.setIncrement(100);
	spinner.setMinimum(0);
	spinner.setMaximum(100000);
	spinner.setDigits(3);
	spinner.setSelection((int) (cutoff * 100000));
	spinner.addModifyListener(e -> {
		cutoff = spinner.getSelection() / 100000d;
	});
	tk.adapt(spinner);
	tk.createLabel(inner, "%");
}
 
Example 5
Source File: PageSettingDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void setMarginSpinner(final Spinner spinner) {
    spinner.setDigits(1);
    spinner.setIncrement(5);
    spinner.setMinimum(0);
    spinner.setMaximum(1000);
    spinner.setSelection(20);
}
 
Example 6
Source File: CameraDirectionGroup.java    From depan with Apache License 2.0 5 votes vote down vote up
private Spinner setupDirection(Composite parent) {
  Spinner result = new Spinner(parent, SWT.NONE);
  result.setMinimum(-180);
  result.setMaximum(180);
  result.setIncrement(1);
  result.setPageIncrement(10);
  return result;
}
 
Example 7
Source File: PageSettingDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void setMarginSpinner(Spinner spinner) {
    spinner.setDigits(1);
    spinner.setIncrement(5);
    spinner.setMinimum(0);
    spinner.setMaximum(1000);
    spinner.setSelection(20);
}
 
Example 8
Source File: NumberInput.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create an empty number input with a default increment of 5, a minimum of 5 and a maximum of
 * 1440 (which happens to be the number of minutes in a day)
 * 
 * @param parent
 * @param label
 *            the label to display on top of the input field
 */
public NumberInput(Composite parent, String label){
	super(parent, SWT.NONE);
	setLayout(new GridLayout());
	new Label(this, SWT.NONE).setText(label);
	inp = new Spinner(this, SWT.NONE);
	inp.setMinimum(5);
	inp.setMaximum(1440);
	inp.setIncrement(5);
}
 
Example 9
Source File: PageSettingDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private void setMarginSpinner(Spinner spinner) {
	spinner.setDigits(1);
	spinner.setIncrement(5);
	spinner.setMinimum(0);
	spinner.setMaximum(1000);
	spinner.setSelection(20);
}
 
Example 10
Source File: HorizontalSpinnerSnippet.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static void createSpinnerGroup(final Shell shell) {
	final Group group = new Group(shell, SWT.NONE);
	group.setLayout(new GridLayout(1, false));

	final Label lbl1 = new Label(group, SWT.NONE);
	lbl1.setText("Simple vertical spinner :");
	final Spinner spinner1 = new Spinner(group, SWT.BORDER);
	spinner1.setMinimum(0);
	spinner1.setMaximum(1000);
	spinner1.setSelection(500);
	spinner1.setIncrement(1);
	spinner1.setPageIncrement(100);

	final Label lbl2 = new Label(group, SWT.NONE);
	lbl2.setText("Floating point values in Spinner :");
	final Spinner spinner2 = new Spinner(group, SWT.NONE);
	// allow 3 decimal places
	spinner2.setDigits(3);
	// set the minimum value to 0.001
	spinner2.setMinimum(1);
	// set the maximum value to 20
	spinner2.setMaximum(20000);
	// set the increment value to 0.010
	spinner2.setIncrement(10);
	// set the seletion to 3.456
	spinner2.setSelection(3456);
	spinner2.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(final SelectionEvent e) {
			final int selection = spinner2.getSelection();
			final int digits = spinner2.getDigits();
			System.out.println("Selection is " + selection / Math.pow(10, digits));
		}
	});

	final Label lbl3 = new Label(group, SWT.NONE);
	lbl3.setText("Validate input in a spinner widget :");
	final Spinner spinner3 = new Spinner(group, SWT.BORDER);
	spinner3.setValues(0, -100, 100, 0, 1, 10);
	spinner3.setLayoutData(new GridData(200, SWT.DEFAULT));
	final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_WARNING);
	spinner3.addModifyListener(e -> {
		final String string = spinner3.getText();
		String message = null;
		try {
			final int value = Integer.parseInt(string);
			final int maximum = spinner3.getMaximum();
			final int minimum = spinner3.getMinimum();
			if (value > maximum) {
				message = "Current input is greater than the maximum limit (" + maximum + ")";
			} else if (value < minimum) {
				message = "Current input is less than the minimum limit (" + minimum + ")";
			}
		} catch (final Exception ex) {
			message = "Current input is not numeric";
		}
		if (message != null) {
			spinner3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_RED));
			final Rectangle rect = spinner3.getBounds();
			final GC gc = new GC(spinner3);
			final Point pt = gc.textExtent(string);
			gc.dispose();
			toolTip.setLocation(shell.getDisplay().map(shell, null, rect.x + pt.x, rect.y + rect.height));
			toolTip.setMessage(message);
			toolTip.setVisible(true);
		} else {
			toolTip.setVisible(false);
			spinner3.setForeground(null);
		}
	});

}
 
Example 11
Source File: CameraPositionGroup.java    From depan with Apache License 2.0 4 votes vote down vote up
private Spinner setupPosition(Composite parent) {
  Spinner result = new Spinner(parent, SWT.NONE);
  result.setIncrement(1);
  result.setPageIncrement(10);
  return result;
}