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

The following examples show how to use org.eclipse.swt.widgets.Spinner#setLayoutData() . 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: AttachMainTab.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
@Override public void createControl(Composite parent) {
	Composite res = new Composite(parent, SWT.NONE);
	res.setLayout(new GridLayout(3, false));
	Label pidLabel = new Label(res, SWT.NONE);
	pidLabel.setText(Messages.AttachMainTab_processId);
	// As pid is volatile, additionally to PID, we should store the
	// CLI param of selected PID to easily discover other PID started
	// with same params.
	pidText = new Spinner(res, SWT.BORDER);
	pidText.setMinimum(0);
	pidText.setMaximum(Integer.MAX_VALUE);
	pidText.setLayoutData(new GridData(120, SWT.DEFAULT));
	pidText.addModifyListener(e -> {
		setDirty(true);
		updateLaunchConfigurationDialog();
	});
	// with Java 9, add a Search button showing a "ProcessSelectionDialog"
	// filtering process using dotnet as command.
	setControl(res);
}
 
Example 2
Source File: SWTFactory.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param parent
 * @param min
 * @param max
 * @param hspan
 * @param style
 * @return
 */
public static Spinner createSpinner(Composite parent, int min, int max, int hspan, int style)
{
	Spinner spinner = new Spinner(parent, SWT.BORDER | style);
	spinner.setMinimum(min);
	spinner.setMaximum(max);

	GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, hspan, 1);
	PixelConverter pc = new PixelConverter(spinner);
	// See http://jira.appcelerator.org/browse/APSTUD-3215
	// We need to add some extra spacing to the MacOSX spinner in order to adjust the size to the way Mac draws
	// spinners.
	int extraWidth = Platform.OS_MACOSX.equals(Platform.getOS()) ? 25 : 0;
	gd.widthHint = pc.convertWidthInCharsToPixels(2) + extraWidth;
	spinner.setLayoutData(gd);
	return spinner;
}
 
Example 3
Source File: SeriesSheetImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 4
Source File: ChartSpinner.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void placeComponents( int styles, boolean enabled, String label, String endLabel ) 
{
	int colNum = 1;
	if ( label != null )
		colNum++;
	if ( endLabel != null )
		colNum++;
	GridLayout gl = new GridLayout( );
	gl.numColumns = colNum;
	gl.makeColumnsEqualWidth = false;
	gl.marginBottom = 0;
	gl.marginHeight = 0;
	gl.marginLeft = 0;
	gl.marginRight = 0;
	gl.marginTop = 0;
	gl.marginWidth = 0;
	this.setLayout( gl );
	if ( label != null )
	{
		lblLabel = new Label( this, SWT.NONE );
		lblLabel.setText( label );
	}
	spinner = new Spinner( this, styles );
	GridData gd = new GridData( GridData.FILL_BOTH );
	spinner.setLayoutData( gd );
	setEnabled( enabled );
	if ( endLabel != null )
	{
		lblEndLabel = new Label( this, SWT.NONE );
		lblEndLabel.setText( endLabel );
	}
}
 
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: FormatSpecifierComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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 );
}