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

The following examples show how to use org.eclipse.swt.widgets.Spinner#setValues() . 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: ContributionCutoff.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private ContributionCutoff(Composite parent, FormToolkit toolkit) {
	Composite composite = UI.formComposite(parent, toolkit);
	UI.gridLayout(composite, 3, 10, 0);
	UI.gridData(composite, false, false).horizontalAlignment = SWT.RIGHT;
	UI.formLabel(composite, toolkit, M.DontShowSmallerThen);
	spinner = new Spinner(composite, SWT.BORDER);
	UI.formLabel(composite, toolkit, "%");
	spinner.setValues(1, 0, 100, 0, 1, 10);
}
 
Example 2
Source File: LocationPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createCombos(Composite body, FormToolkit tk) {

		Composite outer = tk.createComposite(body);
		UI.gridLayout(outer, 2, 5, 0);
		Composite comboComp = tk.createComposite(outer);
		UI.gridLayout(comboComp, 2);
		combos = Combo.on(result)
				.onSelected(this::onSelected)
				.withSelection(result.getFlows().iterator().next())
				.create(comboComp, tk);

		Composite cutoffComp = tk.createComposite(outer);
		UI.gridLayout(cutoffComp, 1, 0, 0);
		GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
		cutoffComp.setLayoutData(gd);

		Composite checkComp = tk.createComposite(cutoffComp);
		tk.createLabel(checkComp, M.DontShowSmallerThen);
		Spinner spinner = new Spinner(checkComp, SWT.BORDER);
		spinner.setValues(1, 0, 100, 0, 1, 10);
		tk.adapt(spinner);
		tk.createLabel(checkComp, "%");
		Controls.onSelect(spinner, e -> {
			cutoff = (spinner.getSelection()) / 100d;
			refreshSelection();
		});

		UI.gridLayout(checkComp, 5);
		Button zeroCheck = UI.formCheckBox(checkComp, tk, M.ExcludeZeroEntries);
		zeroCheck.setSelection(skipZeros);
		Controls.onSelect(zeroCheck, event -> {
			skipZeros = zeroCheck.getSelection();
			refreshSelection();
		});
	}
 
Example 3
Source File: ProcessResultPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createFlowSection(Composite parent) {
	Section section = UI.section(parent, toolkit,
			M.FlowContributionsToProcessResults);
	UI.gridData(section, true, true);
	Composite comp = toolkit.createComposite(section);
	section.setClient(comp);
	UI.gridLayout(comp, 1);

	Composite container = new Composite(comp, SWT.NONE);
	UI.gridData(container, true, false);
	UI.gridLayout(container, 5);
	UI.formLabel(container, toolkit, M.Process);
	flowProcessViewer = new ProcessViewer(container);
	flowProcessViewer.setInput(processes.values());
	flowProcessViewer.addSelectionChangedListener((selection) -> {
		flowResult.setProcess(selection);
		inputTable.refresh();
		outputTable.refresh();
	});

	UI.formLabel(container, toolkit, M.DontShowSmallerThen);
	flowSpinner = new Spinner(container, SWT.BORDER);
	flowSpinner.setValues(1, 0, 10000, 2, 1, 100);
	toolkit.adapt(flowSpinner);
	toolkit.createLabel(container, "%");
	Controls.onSelect(flowSpinner, (e) -> {
		flowCutOff = flowSpinner.getSelection();
		inputTable.refresh();
		outputTable.refresh();
	});

	Composite resultContainer = new Composite(comp, SWT.NONE);
	resultContainer.setLayout(new GridLayout(2, true));
	UI.gridData(resultContainer, true, true);
	UI.formLabel(resultContainer, M.Inputs);
	UI.formLabel(resultContainer, M.Outputs);
	inputTable = createFlowTable(resultContainer);
	outputTable = createFlowTable(resultContainer);
}
 
Example 4
Source File: ProcessResultPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createImpactSection(Composite parent) {
	Section section = UI.section(parent, toolkit,
			M.ImpactAssessmentResults);
	UI.gridData(section, true, true);
	Composite composite = toolkit.createComposite(section);
	section.setClient(composite);
	UI.gridLayout(composite, 1);

	Composite container = new Composite(composite, SWT.NONE);
	UI.gridLayout(container, 5);
	UI.gridData(container, true, false);
	UI.formLabel(container, toolkit, M.Process);
	impactProcessCombo = new ProcessViewer(container);
	impactProcessCombo.setInput(processes.values());
	impactProcessCombo.addSelectionChangedListener((selection) -> {
		impactResult.setProcess(selection);
		impactTable.refresh();
	});
	UI.formLabel(container, toolkit, M.DontShowSmallerThen);
	impactSpinner = new Spinner(container, SWT.BORDER);
	impactSpinner.setValues(1, 0, 10000, 2, 1, 100);
	toolkit.adapt(impactSpinner);
	toolkit.createLabel(container, "%");
	Controls.onSelect(impactSpinner, (e) -> {
		impactCutOff = impactSpinner.getSelection();
		impactTable.refresh();
	});
	impactTable = createImpactTable(composite);
}
 
Example 5
Source File: CONAffinityView.java    From Universal-FE-Randomizer with MIT License 4 votes vote down vote up
public CONAffinityView(Composite parent, int style) {
	super(parent, style);
	
	FillLayout layout = new FillLayout();
	setLayout(layout);
	
	container = new Group(this, SWT.NONE);
	
	container.setText("Other Character Settings");
	
	FormLayout mainLayout = new FormLayout();
	mainLayout.marginLeft = 5;
	mainLayout.marginRight = 5;
	mainLayout.marginTop = 5;
	mainLayout.marginBottom = 5;
	container.setLayout(mainLayout);
	
	randomizeCONButton = new Button(container, SWT.CHECK);
	randomizeCONButton.setText("Randomize Constitution");
	randomizeCONButton.setToolTipText("Randomizes Constitution, which affects weight, and therefore, the ability to\nto shove/rescue and to be shoved/rescued.");
	
	FormData conData = new FormData();
	conData.left = new FormAttachment(0, 0);
	conData.top = new FormAttachment(0, 0);
	randomizeCONButton.setLayoutData(conData);
	
	conVarianceSpinner = new Spinner(container, SWT.NONE);
	conVarianceSpinner.setValues(3, 1, 8, 0, 1, 1);
	conVarianceSpinner.setToolTipText("Determines how far in each direction Constitution is allowed to adjust.");
	
	FormData spinnerData = new FormData();
	spinnerData.right = new FormAttachment(100, -12);
	spinnerData.top = new FormAttachment(randomizeCONButton, 5);
	conVarianceSpinner.setLayoutData(spinnerData);
	
	conVarianceLabel = new Label(container, SWT.NONE);
	conVarianceLabel.setText("Variance:");
	
	FormData labelData = new FormData();
	labelData.right = new FormAttachment(conVarianceSpinner, -5);
	labelData.top = new FormAttachment(conVarianceSpinner, 0, SWT.CENTER);
	conVarianceLabel.setLayoutData(labelData);
	
	conVarianceLabel.setEnabled(false);
	conVarianceSpinner.setEnabled(false);
	
	randomizeCONButton.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			conVarianceLabel.setEnabled(randomizeCONButton.getSelection());
			conVarianceSpinner.setEnabled(randomizeCONButton.getSelection());
		}
	});
	
	randomizeAffinityButton = new Button(container, SWT.CHECK);
	randomizeAffinityButton.setText("Randomize Affinity");
	randomizeAffinityButton.setToolTipText("Randomizes affinity, which affects support bonuses.");
	
	FormData affinityData = new FormData();
	affinityData.left = new FormAttachment(randomizeCONButton, 0, SWT.LEFT);
	affinityData.top = new FormAttachment(conVarianceSpinner, 5);
	randomizeAffinityButton.setLayoutData(affinityData);
}
 
Example 6
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 7
Source File: LegendLayoutSheet.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void setSpinnerValue( Spinner spn, double dValue )
{
	int spnValue = (int) ( dValue * 100 );
	spn.setValues( spnValue, 1, 100, 0, 1, 10 );
}