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

The following are Jave code examples for showing how to use getLayoutData() of the org.eclipse.swt.widgets.Button class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pgcodekeeper   File: DbStorePrefPage.java   View Source Code Vote up 5 votes
@Override
public void createControl(Composite parent) {
    super.createControl(parent);

    Button btnDef = getDefaultsButton();
    btnDef.setText(Messages.dbStorePrefPage_clear_db_store);
    GridData defGd = (GridData) btnDef.getLayoutData();
    defGd.widthHint = Math.max(defGd.widthHint,
            btnDef.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
    btnDef.getParent().layout();
}
 
Example 2
Project: Hydrograph   File: ExportXSDWidget.java   View Source Code Vote up 5 votes
@Override
public void attachToPropertySubGroup(AbstractELTContainerWidget container) {

	ELTDefaultSubgroupComposite exportFieldComposite = new ELTDefaultSubgroupComposite(
			container.getContainerControl());
	exportFieldComposite.createContainerWidget();

	// Create Label and into Composite.
	AbstractELTWidget exportXSDLableWidget = new ELTDefaultLable("Export XSD");
	exportFieldComposite.attachWidget(exportXSDLableWidget);
	setPropertyHelpWidget((Control) exportXSDLableWidget.getSWTWidgetControl());

	// Create export button and into Composite.
	AbstractELTWidget exportXSDButtonWidget = new ELTDefaultButton("Export").grabExcessHorizontalSpace(false);
	exportFieldComposite.attachWidget(exportXSDButtonWidget);
	exportButton = (Button) exportXSDButtonWidget.getSWTWidgetControl();
	GridData gridData = (GridData) exportButton.getLayoutData();
	gridData.widthHint = 90;

	// On export button click.
	exportButton.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {

			// Validation : Check whether schema is define or not before
			// exporting the file.
			Schema schema = (Schema) getComponent().getProperties().get(Constants.SCHEMA_PROPERTY_NAME);
			if ((null == schema || (schema != null && schema.getGridRow().size() == 0))) {
				// Show message dialog and return.
				MessageDialog.openError(exportButton.getShell(), "Error", "Schema not defined in Schema tab.");
				return;
			}
			exportSchemaFile();
		}

	});

}
 
Example 3
Project: Hydrograph   File: HydrographInstallationDialog.java   View Source Code Vote up 5 votes
public void update(String currentPageId) {
	if (composite == null || composite.isDisposed())
		return;
	GC metricsGC = new GC(composite);
	FontMetrics metrics = metricsGC.getFontMetrics();
	metricsGC.dispose();
	List buttons = (List) buttonMap.get(currentPageId);
	Control[] children = composite.getChildren();

	int visibleChildren = 0;
	Button closeButton = getButton(IDialogConstants.CLOSE_ID);

	for (int i = 0; i < children.length; i++) {
		Control control = children[i];
		if (closeButton == control)
			closeButton.dispose();
		else {
			control.setVisible(false);
			setButtonLayoutData(metrics, control, false);
		}
	}
	if (buttons != null) {
		for (int i = 0; i < buttons.size(); i++) {
			Button button = (Button) buttons.get(i);
			button.setVisible(true);
			setButtonLayoutData(metrics, button, true);
			GridData data = (GridData) button.getLayoutData();
			data.exclude = false;
			visibleChildren++;
		}
	}

	GridLayout compositeLayout = (GridLayout) composite.getLayout();
	compositeLayout.numColumns = visibleChildren;
	composite.layout(true);
}
 
Example 4
Project: Hydrograph   File: SelectionDatabaseWidget.java   View Source Code Vote up 4 votes
/**
 * Creates the stack layout composite for SQLQuery 
 * @param selectionComposite
 */
private void createSQLQueryComposite(ELTSubGroupCompositeWithStack selectionComposite) {

	Utils.INSTANCE.loadProperties();
	cursor = selectionComposite.getContainerControl().getDisplay().getSystemCursor(SWT.CURSOR_HAND);
	sqlQueryComposite = new ELTSubGroupCompositeWithStack(selectionComposite.getContainerControl());
	sqlQueryComposite.createContainerWidget();

	sqlQueryComposite.numberOfBasicWidgets(3);

	AbstractELTWidget createWidgetlabel = createWidgetlabel(Messages.SQL_QUERY, sqlQueryComposite);
	selectLable.getSWTWidgetControl().setData(String.valueOf(key_value++), createWidgetlabel.getSWTWidgetControl());

	AbstractELTWidget sqlQueryWgt = createWidgetTextbox(Messages.SQL_QUERY, sqlQueryComposite);
	sqlQueryDecorator = attachDecoratorToTextbox(Messages.SQL_QUERY, sqlQueryWgt, sqlQueryDecorator);
	sqlQueryTextBox = (Text) sqlQueryWgt.getSWTWidgetControl();
	attachListeners(sqlQueryWgt);

	ELTDefaultButton sqlQueryButtonWgt = new ELTDefaultButton("...");
	sqlQueryButtonWgt.buttonWidth(25);
	sqlQueryButtonWgt.buttonHeight(20);
	sqlQueryButtonWgt.grabExcessHorizontalSpace(false);
	sqlQueryComposite.attachWidget(sqlQueryButtonWgt);
	Button buttonAlignment = ((Button) sqlQueryButtonWgt.getSWTWidgetControl());
	GridData data = (GridData) buttonAlignment.getLayoutData();
	data.verticalIndent = 5;
	buttonAlignment.addSelectionListener(buttonWidgetSelectionListener(sqlQueryTextBox));
	buttonWidgetSelectionListener(sqlQueryTextBox);

	AbstractELTWidget createWidgetlabel2 = createWidgetlabel(Messages.EXTRACT_FROM_METASTORE, sqlQueryComposite);
	selectLable.getSWTWidgetControl().setData(String.valueOf(key_value++), createWidgetlabel2.getSWTWidgetControl());

	ELTDefaultButton editButton = new ELTDefaultButton(Messages.EXTRACT);
	sqlQueryComposite.attachWidget(editButton);

	Button button = (Button) editButton.getSWTWidgetControl();
	GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 0, 0);
	gridData.widthHint = 92;
	gridData.horizontalIndent = 15;
	button.setLayoutData(gridData);

	button.addSelectionListener(attachExtractButtonSelectionListner());
	//TODO Below code commented for future use
	/*
	 * Currently, we are not showing SQL_QUERY_COUNTER widget. So, below code will be comment out.
	 */
	/*createWidgetlabel(Messages.SQL_QUERY_COUNTER, sqlQueryComposite);
	AbstractELTWidget sqlQueryCounterWgt = createWidgetTextbox(Messages.SQL_QUERY_COUNTER, sqlQueryComposite);
	sqlQueryCountertextbox = (Text) sqlQueryCounterWgt.getSWTWidgetControl();
	attachListeners(sqlQueryCounterWgt);

	ELTDefaultButton sqlQueryCounterButtonWgt = new ELTDefaultButton("...");
	sqlQueryCounterButtonWgt.buttonWidth(25);
	sqlQueryCounterButtonWgt.buttonHeight(20);
	sqlQueryCounterButtonWgt.grabExcessHorizontalSpace(false);
	sqlQueryComposite.attachWidget(sqlQueryCounterButtonWgt);
	Button sqlQueryCounterButton = ((Button) sqlQueryCounterButtonWgt.getSWTWidgetControl());
	GridData sqlQueryCounterData = (GridData) sqlQueryCounterButton.getLayoutData();
	sqlQueryCounterData.verticalIndent = 5;
	sqlQueryCounterButton.addSelectionListener(buttonWidgetSelectionListener(sqlQueryCountertextbox));*/

}
 
Example 5
Project: Hydrograph   File: HydrographInstallationDialog.java   View Source Code Vote up 4 votes
private void tabSelected(CTabItem item) {
	if (item.getData() instanceof IConfigurationElement) {
		final IConfigurationElement element = (IConfigurationElement) item
				.getData();

		Composite pageComposite = (Composite) item.getControl();
		try {
			final InstallationPage page = (InstallationPage) element
					.createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS);
			page.createControl(pageComposite);
			// new controls created since the dialog font was applied, so
			// apply again.
			Dialog.applyDialogFont(pageComposite);
			page.setPageContainer(this);
			// Must be done before creating the buttons because the control
			// button creation methods
			// use this map.
			pageToId.put(page, element
					.getAttribute(IWorkbenchRegistryConstants.ATT_ID));
			createButtons(page);
			item.setData(page);
			item.addDisposeListener(new DisposeListener() {

				@Override
				public void widgetDisposed(DisposeEvent e) {
					page.dispose();
				}
			});
			pageComposite.layout(true, true);

		} catch (CoreException e1) {
			Label label = new Label(pageComposite, SWT.NONE);
			label.setText(e1.getMessage());
			item.setData(null);
		}

	}
	String id = (String) item.getData(ID);
	rememberSelectedTab(id);
	buttonManager.update(id);
	Button button = createButton(buttonManager.getParent(),
			IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
	GridData gd = (GridData) button.getLayoutData();
	gd.horizontalAlignment = SWT.BEGINNING;
	gd.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH) / 2;
	// Layout the button bar's parent and all of its children.  We must
	// cascade through all children because the buttons have changed and
	// because tray dialog inserts an extra composite in the button bar
	// hierarchy.
	getButtonBar().getParent().layout(true, true);

}