Java Code Examples for org.eclipse.swt.widgets.Spinner#setSelection()
The following examples show how to use
org.eclipse.swt.widgets.Spinner#setSelection() .
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 |
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 |
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 |
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: PWSpinner.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.nebula.widgets.opal.preferencewindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite) */ @Override public Control build(final Composite parent) { buildLabel(parent, GridData.CENTER); final Spinner spinner = new Spinner(parent, SWT.HORIZONTAL | SWT.BORDER); addControl(spinner); spinner.setMinimum(min); spinner.setMaximum(max); final Integer originalValue = (Integer) PreferenceWindow.getInstance().getValueFor(getPropertyKey()); spinner.setSelection(originalValue.intValue()); spinner.addListener(SWT.Modify, event -> { PreferenceWindow.getInstance().setValue(getPropertyKey(), Integer.valueOf(spinner.getSelection())); }); return spinner; }
Example 5
Source File: SeriesSheetImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void initZOrderUI( Composite parent ) { spnZOrder = new Spinner( parent, SWT.BORDER ); { GridData gd = new GridData( ); gd.horizontalAlignment = SWT.CENTER; spnZOrder.setLayoutData( gd ); spnZOrder.setMinimum( 0 ); spnZOrder.setMaximum( 10 ); if ( getChart( ) instanceof ChartWithAxes && !( getContext( ).getChartType( ) instanceof BubbleChart ) && getChart( ).getDimension( ) == ChartDimension.TWO_DIMENSIONAL_LITERAL ) { // Bubble chart has special z order spnZOrder.setSelection( seriesDefn.getZOrder( ) ); spnZOrder.addSelectionListener( this ); } else { spnZOrder.setEnabled( false ); } ChartUIUtil.addSpinnerScreenReaderAccessbility( spnZOrder, Messages.getString( "SeriesSheetImpl.Label.ZOrder" ) ); //$NON-NLS-1$ } }
Example 6
Source File: SankeySelectionDialog.java From olca-app with Mozilla Public License 2.0 | 6 votes |
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 7
Source File: PageSettingDialog.java From ermasterr with Apache License 2.0 | 5 votes |
private void setMarginSpinner(final Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 8
Source File: ControlBindingManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void initSpinners() { Iterator<Spinner> it = spinnerControls.keySet().iterator(); while (it.hasNext()) { final Spinner spinner = it.next(); final Object key = spinnerControls.get(spinner); String value = preferenceDelegate.getString(key); if (!StringUtil.isEmpty(value)) { spinner.setSelection(Integer.parseInt(value)); } } }
Example 9
Source File: PageSettingDialog.java From erflute with Apache License 2.0 | 5 votes |
private void setMarginSpinner(Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 10
Source File: PageSettingDialog.java From ermaster-b with Apache License 2.0 | 5 votes |
private void setMarginSpinner(Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 11
Source File: HorizontalSpinnerSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
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 12
Source File: CompositeTableRow.java From dawnsci with Eclipse Public License 1.0 | 4 votes |
public CompositeTableRow(CompositeEntry entry, Table container, CompositingControl control, boolean disableOp) { this.name = entry.getName(); TableItem newItem = new TableItem(container,SWT.DOUBLE_BUFFERED); TableEditor editor0 = new TableEditor(container); editor0.horizontalAlignment = SWT.CENTER; editor0.grabHorizontal = true; chkActive = new Button(container,SWT.CHECK); chkActive.setSelection(true); chkActive.addSelectionListener(control); editor0.setEditor(chkActive,newItem,0); TableEditor editor = new TableEditor(container); editor.horizontalAlignment = SWT.CENTER; editor.grabHorizontal = true; panel = new Composite(container, SWT.NONE); panel.setLayout(new GridLayout(2,true)); slider = new Slider(panel,SWT.HORIZONTAL|SWT.NO_TRIM); slider.setValues((int)(entry.getWeight()*100), 0, 104, 5, 1, 5); slider.addSelectionListener(this); slider.addSelectionListener(control); spinner = new Spinner(panel,SWT.DOUBLE_BUFFERED); spinner.setMinimum(0); spinner.setMaximum(100); spinner.setSelection((int)(entry.getWeight()*100)); spinner.addSelectionListener(control); spinner.addSelectionListener(this); panel.pack(); editor.setEditor(panel,newItem,2); newItem.setText(1,name); TableEditor editor2 = new TableEditor(container); editor2.horizontalAlignment = SWT.CENTER; editor2.grabHorizontal = true; editor2.grabVertical = true; op = new Combo(container,SWT.NONE); op.add("ADD"); op.add("SUBTRACT"); op.add("MULTIPLY"); op.add("DIVIDE"); op.add("MINIMUM"); op.add("MAXIMUM"); op.select(convertOperationToInt(entry.getOperation())); op.pack(); op.addSelectionListener(control); op.setEnabled(!disableOp); editor2.setEditor(op,newItem,3); TableEditor editor3 = new TableEditor(container); editor3.horizontalAlignment = SWT.CENTER; editor3.grabHorizontal = true; editor3.grabVertical = true; chkRed = new Button(container,SWT.CHECK); chkRed.setSelection(true); chkRed.pack(); chkRed.addSelectionListener(control); editor3.setEditor(chkRed,newItem,4); TableEditor editor4 = new TableEditor(container); editor4.horizontalAlignment = SWT.CENTER; editor4.grabHorizontal = true; editor4.grabVertical = true; chkGreen = new Button(container,SWT.CHECK); chkGreen.pack(); chkGreen.setSelection(true); chkGreen.addSelectionListener(control); editor4.setEditor(chkGreen,newItem,5); TableEditor editor5 = new TableEditor(container); editor5.horizontalAlignment = SWT.CENTER; editor5.grabHorizontal = true; editor5.grabVertical = true; chkBlue = new Button(container,SWT.CHECK); chkBlue.pack(); chkBlue.setSelection(true); chkBlue.addSelectionListener(control); editor5.setEditor(chkBlue,newItem,6); }
Example 13
Source File: FormatSpecifierComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
private void placeComponents( ) { GridLayout glNumberStandard = new GridLayout( ); glNumberStandard.verticalSpacing = 5; glNumberStandard.numColumns = 4; glNumberStandard.marginHeight = 2; glNumberStandard.marginWidth = 2; GridData gdGRPNumberStandard = new GridData( GridData.FILL_BOTH ); this.setLayoutData( gdGRPNumberStandard ); this.setLayout( glNumberStandard ); lblPrefix = new Label( this, SWT.NONE ); GridData gdLBLPrefix = new GridData( ); lblPrefix.setLayoutData( gdLBLPrefix ); lblPrefix.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Prefix" ) ); //$NON-NLS-1$ txtPrefix = new Text( this, SWT.BORDER | SWT.SINGLE ); GridData gdTXTPrefix = new GridData( GridData.FILL_HORIZONTAL ); gdTXTPrefix.widthHint = 60; txtPrefix.setLayoutData( gdTXTPrefix ); txtPrefix.addModifyListener( this ); lblSuffix = new Label( this, SWT.NONE ); GridData gdLBLSuffix = new GridData( ); lblSuffix.setLayoutData( gdLBLSuffix ); lblSuffix.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Suffix" ) ); //$NON-NLS-1$ txtSuffix = new Text( this, SWT.BORDER | SWT.SINGLE ); GridData gdTXTSuffix = new GridData( GridData.FILL_HORIZONTAL ); gdTXTSuffix.widthHint = 60; txtSuffix.setLayoutData( gdTXTSuffix ); txtSuffix.addModifyListener( this ); lblMultiplier = new Label( this, SWT.NONE ); GridData gdLBLMultiplier = new GridData( ); lblMultiplier.setLayoutData( gdLBLMultiplier ); lblMultiplier.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Multiplier" ) ); //$NON-NLS-1$ txtMultiplier = new LocalizedNumberEditorComposite( this, SWT.BORDER | SWT.SINGLE ); new TextNumberEditorAssistField( txtMultiplier.getTextControl( ), null ); GridData gdTXTMultiplier = new GridData( GridData.FILL_HORIZONTAL ); gdTXTMultiplier.widthHint = 60; txtMultiplier.setLayoutData( gdTXTMultiplier ); txtMultiplier.addModifyListener( this ); lblFractionDigit = new Label( this, SWT.NONE ); GridData gdLBLFractionDigit = new GridData( ); lblFractionDigit.setLayoutData( gdLBLFractionDigit ); lblFractionDigit.setText( Messages.getString( "FormatSpecifierComposite.Lbl.FractionDigits" ) ); //$NON-NLS-1$ iscFractionDigits = new Spinner( this, SWT.BORDER ); GridData gdISCFractionDigits = new GridData( GridData.FILL_HORIZONTAL ); gdISCFractionDigits.widthHint = 60; iscFractionDigits.setLayoutData( gdISCFractionDigits ); iscFractionDigits.setSelection( 2 ); iscFractionDigits.addListener( SWT.Selection, this ); }
Example 14
Source File: DateUtil.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public static void setWidgetDisplayDuration(Spinner year,Spinner month,Spinner daySpinner, Spinner hourSpinner,Spinner minutesSpinner,Spinner secondsSpinner,long parseLong) { long rest ; if(year != null){ int years = (int) (parseLong/(long)(3600000*(long)24*(long)30*(long)12)) ; year.setSelection(years); rest = parseLong - (long)(years*(long)(3600000*(long)24*(long)30*(long)12)) ; parseLong = rest ; } if(month != null){ int months = (int) (parseLong/(long)((long)3600000*(long)24*(long)30)) ; month.setSelection(months); rest = parseLong - (long)(months*(long)((long)3600000*(long)24*(long)30)) ; parseLong = rest ; } if(daySpinner != null){ int days = (int) (parseLong/(long)((long)3600000*(long)24)) ; daySpinner.setSelection(days); rest = parseLong - (long)(days*(long)((long)3600000*(long)24)) ; parseLong = rest ; } if(hourSpinner != null){ int hours = (int) ((long)parseLong/(long)3600000) ; hourSpinner.setSelection(hours); rest = parseLong - (hours*3600000L) ; parseLong = rest ; } if(minutesSpinner != null){ int minutes = (int) (parseLong/60000) ; minutesSpinner.setSelection(minutes); rest = parseLong - minutes*60000L ; parseLong = rest ; } if(secondsSpinner != null){ int seconds = (int) (parseLong/1000); secondsSpinner.setSelection(seconds); } }