Java Code Examples for org.eclipse.swt.widgets.Button#getLayoutData()

The following examples show how to use org.eclipse.swt.widgets.Button#getLayoutData() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: xtext-eclipse   File: SWTUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets width and height hint for the button control.<br>
 * <b>Note:</b> This is a NOP if the button's layout data is not an instance of <code>GridData</code>.
 * 
 * @param button
 *            the button for which to set the dimension hint
 */
public static void setButtonDimensionHint(Button button) {
	Assert.isNotNull(button);
	Object gd = button.getLayoutData();
	if (gd instanceof GridData) {
		((GridData) gd).widthHint = getButtonWidthHint(button);
		((GridData) gd).horizontalAlignment = GridData.FILL;
	}
}
 
Example 2
private Control addSettingControl(Composite parent, FormatterProfile.IndentSetting bs, String label) {
    if (bs.isRange()) {
        Button cbox = null;
        if (bs.isRangeWithCheckbox()) {
            cbox = SWTFactory.createCheckbox(parent, label, 1);
        } else {
            SWTFactory.createLabel(parent, label, 1);
        }
        Combo cmb = SWTFactory.createCombo(parent, 1, SWT.DROP_DOWN | SWT.READ_ONLY, GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
        for (int i=bs.getMinVal(); i<=bs.getMaxVal(); ++i) {
            cmb.add(""+i); //$NON-NLS-1$
        }
        cmb.select(fp.getValueForDialog(bs) - bs.getMinVal());
        SettingSelectionListener ssl = new SettingSelectionListener(cmb, cbox, bs);
        cmb.addSelectionListener(ssl);
        if (cbox != null) {
            boolean unch = fp.getRangeCheckboxUncheckedState(bs);
            cbox.setSelection(!unch);
            cmb.setEnabled(!unch);
            cbox.addSelectionListener(ssl);
        }
        return cmb;
    } else {
        Button cb = SWTFactory.createCheckbox(parent, label, 2);
        cb.setSelection(fp.getAsBoolean(bs));
        cb.addSelectionListener(new SettingSelectionListener(cb, null, bs));
        
        GridData gd = (GridData)cb.getLayoutData();
        gd.heightHint = prefHeight;
        cb.setLayoutData(gd);
        
        return cb;
    }
}
 
Example 3
Source Project: xds-ide   File: SWTFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static void setButtonDimensionHint(Button button) {
	Assert.isNotNull(button);
	Object gd= button.getLayoutData();
	if (gd instanceof GridData) {
		((GridData)gd).widthHint= getButtonWidthHint(button);	
		((GridData)gd).horizontalAlignment = GridData.FILL;	 
	}
}
 
Example 4
protected void hideOpenExportedFileBooleanFieldEditor() {
	// hide the open exported file automatically boolean field editor
	Button checkBox = openExportedFileBooleanFieldEditor
			.getChangeControl(parent);
	checkBox.setVisible(false);
	((GridData) checkBox.getLayoutData()).exclude = true;
}
 
Example 5
protected void showOpenExportedFileBooleanFieldEditor() {
	// show the open exported file automatically boolean field editor
	Button checkBox = openExportedFileBooleanFieldEditor
			.getChangeControl(parent);
	checkBox.setVisible(true);
	((GridData) checkBox.getLayoutData()).exclude = false;
}
 
Example 6
Source Project: tlaplus   File: SWTFactory.java    License: MIT License 5 votes vote down vote up
/**
 * Sets width and height hint for the button control.
 * <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 * 
 * @param	the button for which to set the dimension hint
 */		
public static void setButtonDimensionHint(Button button) {
	Assert.isNotNull(button);
	Object gd = button.getLayoutData();
	if (gd instanceof GridData) {
		((GridData)gd).widthHint = getButtonWidthHint(button);
		((GridData)gd).horizontalAlignment = GridData.FILL;
	}
}
 
Example 7
/**
 * Sets width and height hint for the button control. <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 * 
 * @param the
 *            button for which to set the dimension hint
 */
public static void setButtonDimensionHint(Button button)
{
	Assert.isNotNull(button);
	Object gd = button.getLayoutData();
	if (gd instanceof GridData)
	{
		((GridData) gd).widthHint = getButtonWidthHint(button);
		((GridData) gd).horizontalAlignment = GridData.FILL;
	}
}
 
Example 8
/**
 * Sets width and height hint for the button control. <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 * 
 * @param the
 *            button for which to set the dimension hint
 */
public static void setButtonDimensionHint(Button button)
{
	Object gd = button.getLayoutData();
	if (gd instanceof GridData)
	{
		((GridData) gd).widthHint = getButtonWidthHint(button);
		((GridData) gd).horizontalAlignment = GridData.FILL;
	}
}
 
Example 9
/**
 * Sets width and height hint for the button control.
 * <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 *
 * @param button	the button for which to set the dimension hint
 */
public static void setButtonDimensionHint(Button button) {
	Assert.isNotNull(button);
	Object gd= button.getLayoutData();
	if (gd instanceof GridData) {
		((GridData)gd).widthHint= getButtonWidthHint(button);
		((GridData)gd).horizontalAlignment = GridData.FILL;
	}
}
 
Example 10
public static Button createCheckBox(Composite parent, String text, int span, boolean select, int indent) {
    Button btn = createCheckBox(parent, text,span, select);
    GridData gridData = (GridData) btn.getLayoutData();
    gridData.horizontalIndent = indent;    
    
    return btn;
}
 
Example 11
public static Button createRadio(Composite parent, String text, int span, SelectionListener listener, int indent) {
    Button btn = createRadio(parent, text, span, listener);
    GridData gridData = (GridData) btn.getLayoutData();
    gridData.horizontalIndent = indent;    

    return btn;
}
 
Example 12
Source Project: birt   File: ApplyButtonHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void setButton( Button button )
{
	this.button = button;
	( (GridData) button.getLayoutData( ) ).horizontalIndent = 10;

	// Default status is disabled
	button.setEnabled( false );
}
 
Example 13
Source Project: birt   File: CustomPreviewTable.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void moveTo(int index )
{
	int offset = 0;
	for ( int i = 0; i <= index; i++ )
	{
		offset += columnWidths.get( i ).intValue( ) ;
	}
	if ( offset > this.getVisibleTableWidth( ) )
	{
	offset -= this.getVisibleTableWidth( );
	iHiddenWidth = offset;
	// APPLY PIXEL SHIFT TO RELOCATE BUTTONS
	if ( btnHeaders.size( ) > 0 )
	{
		// MOVE ALL BUTTONS TO THE LEFT...AS MUCH AS THE
		// SCROLLING VALUE
		Button btn = btnHeaders.get( 0 );
		( (FormData) btn.getLayoutData( ) ).left = new FormAttachment( 0,
				-offset );
	}
	}
	
	getHorizontalBar( ).setSelection( offset );
	cmpHeaders.layout( );
	
	selectColumn( index );
	iLastProcessedHorizontalScrollPosition = getHorizontalBar( ).getSelection( );
	redraw( );
}
 
Example 14
Source Project: birt   File: ScriptSWTFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param button
 */
private static void setButtonDimensionHint( Button button )
{
	Assert.isNotNull( button );
	Object gd = button.getLayoutData( );
	if ( gd instanceof GridData )
	{
		( (GridData) gd ).widthHint = getButtonWidthHint( button );
		( (GridData) gd ).horizontalAlignment = GridData.FILL;
	}
}
 
Example 15
/**
 * @param button
 */
public static void setButtonDimensionHint( Button button )
{
	Assert.isNotNull( button );
	Object gd = button.getLayoutData( );
	if ( gd instanceof GridData )
	{
		( (GridData) gd ).widthHint = getButtonWidthHint( button );
		( (GridData) gd ).horizontalAlignment = GridData.FILL;
	}
}
 
Example 16
Source Project: Pydev   File: SWTUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets width and height hint for the button control.
 * <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 *
 * @param button    the button for which to set the dimension hint
 */
public static void setButtonDimensionHint(Button button) {
    Assert.isNotNull(button);
    Object gd = button.getLayoutData();
    if (gd instanceof GridData) {
        ((GridData) gd).widthHint = getButtonWidthHint(button);
        ((GridData) gd).horizontalAlignment = GridData.FILL;
    }
}
 
Example 17
Source Project: goclipse   File: SWTFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets width and height hint for the button control.
 * <b>Note:</b> This is a NOP if the button's layout data is not
 * an instance of <code>GridData</code>.
 * 
 * @param	the button for which to set the dimension hint
 */		
public static void setButtonDimensionHint(Button button) {
	Assert.isNotNull(button);
	Object gd= button.getLayoutData();
	if (gd instanceof GridData) {
		((GridData)gd).widthHint= getButtonWidthHint(button);	
		((GridData)gd).horizontalAlignment = GridData.FILL;	 
	}
}
 
Example 18
/**
 * {@inheritDoc}
 */
@Override
protected void finishedRun() {
	clearCursors();

	if (isConfirmCommit) {
		((RowData) buttonConfirmCommit.getLayoutData()).exclude = false;
		buttonConfirmCommit.setVisible(true);
	}

	if (commitButton.getListeners(SWT.Selection).length > 1) {
		commitButton.setVisible(true);
		((GridData) commitButton.getLayoutData()).exclude = false;
		if (isConfirmCommit) {
			commitButton.setEnabled(false);
		}
	}

	if (openButton.getListeners(SWT.Selection).length > 1) {
		openButton.setVisible(true);
		((GridData) openButton.getLayoutData()).exclude = false;
	}

	if (openWorkingCopyButton.getListeners(SWT.Selection).length > 1) {
		openWorkingCopyButton.setVisible(true);
		((GridData) openWorkingCopyButton.getLayoutData()).exclude = false;
	}

	if (openTortoiseSvnButton.getListeners(SWT.Selection).length > 1) {
		openTortoiseSvnButton.setVisible(true);
		((GridData) openTortoiseSvnButton.getLayoutData()).exclude = false;
	}

	closeButton.setVisible(true);
	((GridData) closeButton.getLayoutData()).exclude = false;

	final Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
	cancelButton.setVisible(false);
	((GridData) cancelButton.getLayoutData()).exclude = true;

	if (warningsTableViewer.getList().getItemCount() > 0) {
		((GridData) warningsTableViewer.getList().getParent().getLayoutData()).exclude = false;
		warningsTableViewer.getList().setVisible(true);
	}

	final Point size = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
	getShell().setSize(size);
	getShell().layout(true, true);
}
 
Example 19
Source Project: birt   File: CustomPreviewTable.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void widgetSelected( SelectionEvent e )
{
	if ( e.getSource( ) instanceof ScrollBar )
	{
		ScrollBar sb = (ScrollBar) e.getSource( );
		if ( ( sb.getStyle( ) | SWT.H_SCROLL ) == SWT.H_SCROLL )
		{
			if ( iLastProcessedHorizontalScrollPosition == 0 )
			{
				// Initialize the value
				iLastProcessedHorizontalScrollPosition = cnvCells.getVisibleTableWidth( );
			}
			if ( sb.getSelection( ) == iLastProcessedHorizontalScrollPosition )
			{
				return;
			}

			if ( ( sb.getStyle( ) | SWT.H_SCROLL ) == SWT.H_SCROLL )
			{
				// CALCULATE PIXEL SHIFT IN BUTTON POSITION
				int iShift = 0;
				if ( e.detail == SWT.ARROW_UP
						|| e.detail == SWT.PAGE_UP )
				{
					// SHIFT HEADERS ONE COLUMN TO THE RIGHT
					iShift = -SCROLL_HORIZONTAL_STEP;
				}
				else if ( e.detail == SWT.ARROW_DOWN
						|| e.detail == SWT.PAGE_DOWN )
				{
					// SHIFT HEADERS ONE COLUMN TO THE LEFT
					iShift = SCROLL_HORIZONTAL_STEP;
				}
				else
				{
					iShift = sb.getSelection( )
							- iLastProcessedHorizontalScrollPosition;
				}
				iHiddenWidth += iShift;
				// Correction for negative value or overflow
				if ( iHiddenWidth < 0 )
				{
					iShift -= iHiddenWidth;
					iHiddenWidth = 0;
				}
				else if ( iHiddenWidth + getVisibleTableWidth( ) > getMaxTableWidth( ) )
				{
					int diff = getMaxTableWidth( )
							- getVisibleTableWidth( )
							- iHiddenWidth;
					iShift += diff;
					iHiddenWidth += diff;
				}
				// APPLY PIXEL SHIFT TO RELOCATE BUTTONS
				if ( btnHeaders.size( ) > 0 )
				{
					// MOVE ALL BUTTONS TO THE LEFT...AS MUCH AS THE
					// SCROLLING VALUE
					Button btn = btnHeaders.get( 0 );
					( (FormData) btn.getLayoutData( ) ).left = new FormAttachment( 0,
							btn.getLocation( ).x - iShift );
				}
				cmpHeaders.layout( );
				// UPDATE LAST HORIZONTAL SCROLL POSITION
				iLastProcessedHorizontalScrollPosition = sb.getSelection( );
			}
		}
		else
		{
			if ( getVerticalBar( ).getSelection( ) == iLastProcessedVerticalScrollPosition )
			{
				return;
			}

			if ( e.detail == SWT.ARROW_UP || e.detail == SWT.PAGE_UP )
			{
				if ( iVScroll > 0 )
				{
					iVScroll--;
				}
			}
			else if ( e.detail == SWT.ARROW_DOWN
					|| e.detail == SWT.PAGE_DOWN )
			{
				iVScroll++;
			}
			else
			{
				iVScroll += ( sb.getSelection( ) - iLastProcessedVerticalScrollPosition );
			}
			iLastProcessedVerticalScrollPosition = sb.getSelection( );
		}
		redraw( );
	}
}
 
Example 20
/**
		 * Creates the widget for advanced options.
		 *  
		 * @param parent the parent composite
		 */
		protected void createAdvancedControls(Composite parent) {
			Preferences preferences = ResourcesPlugin.getPlugin()
					.getPluginPreferences();

			if (preferences.getBoolean(ResourcesPlugin.PREF_DISABLE_LINKING) == false
					&& isValidContainer()) {
				linkedResourceParent = new Composite(parent, SWT.NONE);
				linkedResourceParent.setFont(parent.getFont());
				linkedResourceParent.setLayoutData(new GridData(
						GridData.FILL_HORIZONTAL));
				GridLayout layout = new GridLayout();
				layout.marginHeight = 0;
				layout.marginWidth = 0;
				linkedResourceParent.setLayout(layout);

				advancedButton = new Button(linkedResourceParent, SWT.PUSH);
				advancedButton.setFont(linkedResourceParent.getFont());
				advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
				setButtonLayoutData(advancedButton);
				GridData data = (GridData) advancedButton.getLayoutData();
				data.horizontalAlignment = GridData.BEGINNING;
				advancedButton.setLayoutData(data);
				advancedButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						handleAdvancedButtonSelect();
					}
				});
			}
			linkedResourceGroup = new CreateLinkedResourceGroup(IResource.FOLDER,
					new Listener() {
						public void handleEvent(Event e) {
							validateLinkedResource();
							firstLinkCheck = false;
						}
					}, new CreateLinkedResourceGroup.IStringValue() {
						public void setValue(String string) {
							folderNameField.setText(string);
						}

						public String getValue() {
							return folderNameField.getText();
						}

						public IResource getResource() {
							return container;
						}
					});
		}