List of usage examples for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH
int BUTTON_WIDTH
To view the source code for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH.
Click Source Link
From source file:com.google.dart.tools.ui.internal.util.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. */// ww w . ja va 2 s.co m public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); @SuppressWarnings("deprecation") PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:com.google.dart.tools.ui.web.pubspec.DependenciesMasterBlock.java
License:Open Source License
@Override protected void createMasterPart(final IManagedForm managedForm, Composite parent) { FormToolkit toolkit = managedForm.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Dependencies"); //$NON-NLS-1$ section.setDescription("Specify all the packages required by this package"); //$NON-NLS-1$ section.marginHeight = 5;//from ww w . ja v a 2s . c om Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); Table t = toolkit.createTable(client, SWT.NULL); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 20; gd.widthHint = 100; t.setLayoutData(gd); toolkit.paintBordersFor(client); Composite buttonGroup = toolkit.createComposite(client); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); buttonGroup.setLayoutData(gd); buttonGroup.setLayout(new GridLayout()); Button addButton = toolkit.createButton(buttonGroup, "Add...", SWT.PUSH); addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAddDependency(); } }); PixelConverter converter = new PixelConverter(addButton); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); GridDataFactory.swtDefaults().hint(widthHint, -1).applyTo(addButton); Button b = toolkit.createButton(buttonGroup, "Remove", SWT.PUSH); b.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemoveDependency(); } }); GridDataFactory.swtDefaults().hint(widthHint, -1).applyTo(b); section.setClient(client); sectionPart = new SectionPart(section); managedForm.addPart(sectionPart); viewer = new TableViewer(t); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { managedForm.fireSelectionChanged(sectionPart, event.getSelection()); } }); viewer.setContentProvider(new MasterContentProvider()); viewer.setLabelProvider(new MasterLabelProvider()); viewer.setComparator(new ViewerComparator()); viewer.setInput(page.getEditor().getEditorInput()); model.addModelListener(this); }
From source file:com.google.gdt.eclipse.gph.egit.wizard.CloneRepositoryWizardPage.java
License:Open Source License
@Override protected Control createPageContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().margins(10, 10).applyTo(composite); Group selectRepoGroup = new Group(composite, SWT.NONE); selectRepoGroup.setText("Repository to import from"); GridDataFactory.fillDefaults().grab(true, false).applyTo(selectRepoGroup); GridLayoutFactory.swtDefaults().applyTo(selectRepoGroup); repoList = new TableViewer(selectRepoGroup, SWT.SINGLE | SWT.BORDER); repoList.setLabelProvider(new RepositoryLabelProvider()); repoList.setContentProvider(new ArrayContentProvider()); repoList.setComparator(new ViewerComparator()); repoList.setInput(wizard.getGPHProject().getRepoUrls()); Object firstElement = repoList.getElementAt(0); if (firstElement != null) { repoList.setSelection(new StructuredSelection(firstElement)); }/*from ww w . ja v a 2 s.co m*/ repoList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { handleRepoSelectionChanged(); } }); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 80) .applyTo(repoList.getTable()); Group selectLocalDirGroup = new Group(composite, SWT.NONE); selectLocalDirGroup.setText("Select local destination directory"); GridDataFactory.fillDefaults().grab(true, true).applyTo(selectLocalDirGroup); GridLayoutFactory.swtDefaults().numColumns(3).applyTo(selectLocalDirGroup); Label label = new Label(selectLocalDirGroup, SWT.NONE); label.setText("Destination:"); destinationText = new Text(selectLocalDirGroup, SWT.BORDER | SWT.SINGLE); destinationText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateButtons(); } }); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(destinationText); Button button = new Button(selectLocalDirGroup, SWT.PUSH); button.setText("Browse..."); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); GridDataFactory.swtDefaults().hint(widthHint, -1).applyTo(button); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { performSelectLocalDirectory(); } }); Group cloneRepoGroup = new Group(composite, SWT.NONE); cloneRepoGroup.setText("Clone repository"); GridDataFactory.fillDefaults().grab(true, true).applyTo(cloneRepoGroup); GridLayoutFactory.swtDefaults().numColumns(3).applyTo(cloneRepoGroup); cloneFeedbackLabel = new CLabel(cloneRepoGroup, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cloneFeedbackLabel); cloneButton = new Button(cloneRepoGroup, SWT.PUSH); cloneButton.setText("Clone"); GridDataFactory.swtDefaults().hint(widthHint, -1).applyTo(cloneButton); cloneButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { performCloneRepo(); } }); handleRepoSelectionChanged(); return composite; }
From source file:com.iw.plugins.spindle.ui.CheckboxTreeAndList.java
License:Mozilla Public License
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont());/* w w w. j a v a 2 s. c o m*/ button.setText(label); PixelConverter converter = new PixelConverter(button); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); data.heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); button.setData(new Integer(id)); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonPressed(((Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } return button; }
From source file:com.iw.plugins.spindle.ui.dialogfields.StringButtonDefaultField.java
License:Mozilla Public License
public void fillIntoGrid(Composite parent, int numcols) { Assert.isLegal(defaultLabelControl == null, "can't use GridLayout, already used FormLayout!"); Assert.isTrue(numcols >= 5);/*w w w.j ava2 s .com*/ GridData data; PixelConverter converter = new PixelConverter(parent); Label labelControl = getLabelControl(parent); data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); data.horizontalSpan = 1; labelControl.setLayoutData(data); Text textControl = getTextControl(parent); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = numcols - 3; textControl.setLayoutData(data); Label defaultLabel = getDefaultLabelControl(parent); defaultLabel.setText("(default)"); defaultLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); data = new GridData(GridData.HORIZONTAL_ALIGN_END); data.horizontalSpan = 1; data.widthHint = Math.max(converter.convertHorizontalDLUsToPixels("(default)".length()), defaultLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); defaultLabel.setLayoutData(data); int heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Button buttonControl = getButtonControl(parent); data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); data.horizontalSpan = 1; data.heightHint = heightHint; data.widthHint = Math.max(widthHint, buttonControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); buttonControl.setLayoutData(data); }
From source file:com.iw.plugins.spindle.ui.dialogfields.StringButtonField.java
License:Mozilla Public License
public void fillIntoGrid(Composite parent, int numcols) { Assert.isTrue(numcols >= 3);/*from w ww. ja va 2s .c o m*/ super.fillIntoGrid(parent, numcols - 1); PixelConverter converter = new PixelConverter(parent); int heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Button buttonControl = getButtonControl(parent); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); data.horizontalSpan = 1; data.heightHint = heightHint; data.widthHint = Math.max(widthHint, buttonControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); buttonControl.setLayoutData(data); }
From source file:com.iw.plugins.spindle.ui.preferences.WizardTemplatesPreferencePage.java
License:Mozilla Public License
protected void contributeButtons(Composite parent) { Font font = parent.getFont(); GridLayout layout = (GridLayout) parent.getLayout(); layout.numColumns += 2;/*from w ww . j av a 2 s . co m*/ int heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); fImport = new Button(parent, SWT.PUSH); fImport.setText("Import"); Dialog.applyDialogFont(fImport); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = heightHint; data.widthHint = Math.max(widthHint, fImport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fImport.setLayoutData(data); fImport.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performImport(); } }); fExport = new Button(parent, SWT.PUSH); fExport.setText("Export"); Dialog.applyDialogFont(fImport); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = heightHint; data.widthHint = Math.max(widthHint, fExport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fExport.setLayoutData(data); fExport.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performExport(); } }); }
From source file:com.iw.plugins.spindle.ui.properties.ProjectTemplatesPropertyPage.java
License:Mozilla Public License
protected void contributeButtons(Composite parent) { Font font = parent.getFont(); GridLayout layout = (GridLayout) parent.getLayout(); layout.numColumns += 3;/* w w w .j a va2s .c om*/ int heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); fImport = new Button(parent, SWT.PUSH); fImport.setText("Import"); Dialog.applyDialogFont(fImport); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = heightHint; data.widthHint = Math.max(widthHint, fImport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fImport.setLayoutData(data); fImport.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performImport(); } }); fExport = new Button(parent, SWT.PUSH); fExport.setText("Export"); Dialog.applyDialogFont(fImport); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = heightHint; data.widthHint = Math.max(widthHint, fExport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fExport.setLayoutData(data); fExport.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performExport(); } }); fExportProject = new Button(parent, SWT.PUSH); fExportProject.setText("Export to Project"); Dialog.applyDialogFont(fImport); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = heightHint; data.widthHint = Math.max(widthHint, fExportProject.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fExportProject.setLayoutData(data); fExportProject.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performProjectExport(); } }); }
From source file:com.ixenit.membersort.preferences.editor.ListEditor.java
License:Apache License
/** * Helper method to create a push button. * * @param parent// ww w . j av a 2s. c o m * the parent control * @param key * the resource name used to supply the button's label text * @return Button */ private Button _createPushButton(Composite parent, String key) { Button button = new Button(parent, SWT.PUSH); button.setText(JFaceResources.getString(key)); button.setFont(parent.getFont()); GridData data = new GridData(GridData.FILL_HORIZONTAL); int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); button.addSelectionListener(_getSelectionListener()); return button; }
From source file:com.liferay.ide.ui.util.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. *//*ww w .j av a 2 s. co m*/ protected static int getButtonWidthHint(Button button) { int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }