@Override protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); composite.setFont(parent.getFont()); GridData data = new GridData(GridData.FILL, GridData.FILL, true, true); configurationBlockControl = super.createContents(composite); configurationBlockControl.setLayoutData(data); if (isProjectPreferencePage()) { boolean useProjectSpecificSettings = hasProjectSpecificOptions(); enableProjectSpecificSettings(useProjectSpecificSettings); } Dialog.applyDialogFont(composite); return composite; }
@Override public String getReplacementText() { SelectEcoreIFileDialog dialog = new SelectEcoreIFileDialog(); if (dialog.open() == Dialog.OK) { Object[] selections = dialog.getResult(); if(selections != null && selections.length != 0 && selections[0] instanceof IResource ){ IResource ecoreFile = (IResource) selections[0]; ecoreProject = ecoreFile.getProject(); String path = "/"+ecoreFile.getProject().getName() +"/"+ecoreFile.getProjectRelativePath(); URI uri = URI.createPlatformResourceURI(path,true); String replacementText = "\""+uri.toString()+"\""; return replacementText; } } return ""; }
@Override public String getReplacementText() { SelectAnyIProjectDialog dialog = new SelectAnyIProjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); if (dialog.open() == Dialog.OK) { Object[] selections = dialog.getResult(); if(selections != null && selections.length != 0 && selections[0] instanceof IProject ){ dsaProject = (IProject) selections[0]; Set<String> aspects = SequentialSingleLanguageTemplate.getAspectClassesList(dsaProject); final StringBuilder insertion = new StringBuilder(); for (String asp : aspects) { insertion.append("\twith " + asp + "\n"); } insertion.replace(0, 1, "");//remove the first \t return insertion.toString(); } } return ""; }
protected void chooseWorkspace () { final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () ); dialog.setTitle ( "Select driver exporter configuration file" ); dialog.setMessage ( "Choose a driver exporter file for the configuration" ); dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () ); dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) ); dialog.setAllowMultiple ( true ); dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE ); if ( dialog.open () == IDialogConstants.OK_ID ) { final IResource resource = (IResource)dialog.getFirstResult (); if ( resource != null ) { final String arg = resource.getFullPath ().toString (); final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$ this.fileText.setText ( fileLoc ); makeDirty (); } } }
private static final IStashing chooseFile(PersistType type) throws IOException { FileSelectionDialog dialog = new FileSelectionDialog(Display.getCurrent().getActiveShell(), previousFile); dialog.setExtensions(extensions); dialog.setFiles(files); dialog.setNewFile(type==PersistType.SAVE); dialog.setFolderSelector(false); dialog.create(); if (dialog.open() != Dialog.OK) return null; String path = dialog.getPath(); if (!path.endsWith(extensions[0])) { //should always be saved to .json path = path.concat("." + extensions[0]); } final File file = new File(path); previousFile = file.getCanonicalPath(); IStashing stash = ServiceHolder.getStashingService().createStash(file); return stash; }
/** * @wbp.parser.entryPoint */ @Override public void createControl(Composite p) { parent_1 = new Composite(p, SWT.NONE); setControl(parent_1); GridLayout gl_parent_1 = new GridLayout(); gl_parent_1.numColumns = 3; parent_1.setLayout(gl_parent_1); createAllSections(parent_1); Dialog.applyDialogFont(parent_1); new Label(parent_1, SWT.NONE); validatePage(); updateLaunchConfigurationDialog(); updateConfigState(); }
/** * Creates the page control by creating individual options in the order * subject to their position in the list.' * * @param composite */ public void createControl(Composite composite) { Composite container = new Composite(composite, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.verticalSpacing = 9; container.setLayout(layout); for (int i = 0; i < options.size(); i++) { TemplateOption option = (TemplateOption) options.get(i); option.createControl(container, 3); } if (helpContextId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(container, helpContextId); setControl(container); Dialog.applyDialogFont(container); container.forceFocus(); }
@Override protected Control createContents(Composite parent) { Control control = super.createContents(parent); boolean selected = false; if (folder.getItemCount() > 0) { if (lastSelectedTabId != null) { CTabItem[] items = folder.getItems(); for (int i = 0; i < items.length; i++) if (items[i].getData(ID).equals("30.PluginPage")) { folder.setSelection(i); tabSelected(items[i]); selected = true; break; } } if (!selected) tabSelected(folder.getItem(0)); } // need to reapply the dialog font now that we've created new // tab items Dialog.applyDialogFont(folder); return control; }
/** * Get a progress monitor that forwards to an event loop monitor. * Override #setBlocked() so that we always open the blocked dialog. * * @return the monitor on the event loop */ private IProgressMonitor getEventLoopMonitor() { if (PlatformUI.isWorkbenchStarting()) return new NullProgressMonitor(); return new EventLoopProgressMonitor(new NullProgressMonitor()) { @Override public void setBlocked(IStatus reason) { // Set a shell to open with as we want to create // this // even if there is a modal shell. Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } }; }
@Override protected Control createDialogArea(Composite parent) { Composite top = (Composite) super.createDialogArea(parent); Composite editArea = new Composite(top, SWT.NONE); editArea.setLayout(new GridLayout()); editArea.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); runInBackground = new BooleanFieldEditor(IProgressConstants.RUN_IN_BACKGROUND, ProgressMessages.JobsViewPreferenceDialog_RunInBackground, editArea); runInBackground.setPreferenceName(IProgressConstants.RUN_IN_BACKGROUND); runInBackground.setPreferenceStore(preferenceStore); runInBackground.load(); showSystemJob = new BooleanFieldEditor(IProgressConstants.SHOW_SYSTEM_JOBS, ProgressMessages.JobsViewPreferenceDialog_ShowSystemJobs, editArea); showSystemJob.setPreferenceName(IProgressConstants.SHOW_SYSTEM_JOBS); showSystemJob.setPreferenceStore(preferenceStore); showSystemJob.load(); Dialog.applyDialogFont(top); return top; }
@Execute public void execute( @Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Optional TerminologyService terminologyService, @Optional ETerminology terminology, @Optional IndexedCorpus indexedCorpus ) throws IOException { FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); fileDialog.setText("Exporting terminology "+ TerminologyPart.toPartLabel(terminology) +" to " + formatName); String path = fileDialog.open(); if(path != null) { if(withOptionDialog) { Dialog dialog = getDialog(shell); if(dialog.open() == Dialog.OK) export(shell, terminology, getExporter(dialog), indexedCorpus, path); } else // no option dialog export(shell, terminology, getExporter(), indexedCorpus, path); } }
@Execute public void execute( @Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Optional TerminologyService terminologyService, @Optional ETerminoViewerConfig viewerConfig, @Optional MPart terminologyPart ) { EList<String> viewerList = viewerConfig.getSelectedPropertyNames(); List<Property<?>> selectedProperties = viewerList .stream() .map(s -> PropertyUtil.forName(s)).collect(Collectors.toList()); SelectPropertyDialog dialog = new SelectPropertyDialog(shell, selectedProperties, p-> true, false); if(dialog.open() == Dialog.OK) { List<String> propertyNames = dialog.getSelectedPropertyNames(); viewerList.retainAll(propertyNames); propertyNames.removeAll(viewerList); viewerList.addAll(propertyNames); } }
@Override protected Control createContents(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; parent.setLayout(layout); Composite innerParent = new Composite(parent, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 2; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; innerParent.setLayout(innerLayout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; innerParent.setLayoutData(gd); Dialog.applyDialogFont(parent); innerParent.layout(); return parent; }
@Override public void createControl(Composite parent) { composite = SWTFactory.createComposite(parent, 1, SWT.FILL, SWT.FILL); initializeDialogUnits(parent); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); initCommonParts(composite); initMultiProjectParts(composite); initJavaParts(composite); // Show description on opening setErrorMessage(null); setMessage(null); setControl(composite); Dialog.applyDialogFont(composite); updateUI(); }
@Override protected Control createDialogArea(Composite parent) { setTitle("Path placeholder"); getShell().setText("Path placeholder usage"); setMessage("Path placeholder usage"); Composite parentComposite = (Composite) super.createDialogArea(parent); Composite container = new Composite(parentComposite, SWT.NONE); GridData gd = new GridData(GridData.FILL_BOTH); container.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.makeColumnsEqualWidth = false; layout.horizontalSpacing = 5; layout.verticalSpacing = 10; container.setLayout(layout); createCollapsableBookmarksList(container).setLayoutData(new GridData(GridData.FILL_BOTH)); createButtonArea(container); createCollapsedBookmarksList(container).setLayoutData(new GridData(GridData.FILL_BOTH)); updateButtonEnablement(); Dialog.applyDialogFont(parentComposite); return container; }
private void process(IFile file) { Shell activeShell = Display.getCurrent().getActiveShell(); UIConfiguration uiConfig = prepareUIConfiguration(file); ConfigurationDialog dialog = new ConfigurationDialog(activeShell, uiConfig); if(dialog.open() != Dialog.OK ){ return ; } if(!uiConfig.isValid()){ return; } Configuration configuration = prepareConfiguraton(uiConfig); try { File ramlOSFile = uiConfig.getRamlFile().getLocation().toFile(); InputStreamReader ramlReader = new InputStreamReader( new FileInputStream(ramlOSFile) ); new GeneratorProxy().run(ramlReader, configuration,ramlOSFile.getAbsolutePath()); uiConfig.getDstFolder().refreshLocal( IResource.DEPTH_ONE, new NullProgressMonitor() ); } catch (Exception e) { e.printStackTrace(); } }
private void computeMetrics() { Control control = getControl(); if (control == null && Display.getCurrent() != null) { control = Display.getCurrent().getActiveShell(); } if (control == null) { return; } /* Compute metrics in pixels */ final GC gc = new GC(control); final FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); spacing = Math.max(horizontalSpacing, verticalSpacing); horizontalMargin = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); verticalMargin = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN); }
@Override public void setBlocked(final IStatus reason) { if (isDisposed()) { return; } statusLabel.setText(Dialog.shortenText(reason.getMessage(), statusLabel)); try { final Method showPausedMethod = progressIndicator.getClass().getMethod("showPaused", new Class[0]); //$NON-NLS-1$ if (showPausedMethod != null) { showPausedMethod.invoke(progressIndicator, new Object[0]); } } catch (final Exception e) { log.debug("Could not show progress monitor control as paused", e); //$NON-NLS-1$ } }
public BaseControl(final Composite parent, final int style) { super(parent, style); /* Compute metrics in pixels */ final GC gc = new GC(this); final FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); spacing = Math.max(horizontalSpacing, verticalSpacing); horizontalMargin = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); verticalMargin = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN); minimumMessageAreaWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); }
private final void computeMetrics() { Control control = getControl(); if (control == null && Display.getCurrent() != null) { control = Display.getCurrent().getActiveShell(); } if (control == null) { return; } /* Compute metrics in pixels */ final GC gc = new GC(control); final FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); spacing = Math.max(horizontalSpacing, verticalSpacing); horizontalMargin = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); verticalMargin = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN); initializedMetrics = true; }
protected Point getTooltipSize(final Shell tooltipShell) { if (maxTooltipSize == null) { final GC gc = new GC(tooltipShell); final int max = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(), IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); maxTooltipSize = new Point(max, max); gc.dispose(); } Point tooltipSize = tooltipShell.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (tooltipSize.x > maxTooltipSize.x) { tooltipSize = tooltipShell.computeSize(maxTooltipSize.x, SWT.DEFAULT); } if (tooltipSize.y > maxTooltipSize.y) { tooltipSize = tooltipShell.computeSize(maxTooltipSize.x, maxTooltipSize.y); } return tooltipSize; }
private ICoverageLaunch openDialog(ExecutionEvent event, List<ICoverageLaunch> launches) { final ListDialog dialog = new ListDialog(HandlerUtil.getActiveShell(event)) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); ContextHelp.setHelp(shell, ContextHelp.DUMP_EXECUTION_DATA); } }; dialog.setTitle(UIMessages.DumpExecutionDataDialog_title); dialog.setMessage(UIMessages.DumpExecutionDataDialog_message); dialog.setContentProvider(ArrayContentProvider.getInstance()); dialog.setLabelProvider(new LaunchLabelProvider()); dialog.setInput(launches); if (dialog.open() == Dialog.OK && dialog.getResult().length == 1) { return (ICoverageLaunch) dialog.getResult()[0]; } return null; }
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); composite.setLayout(layout); GridData data = new GridData(GridData.FILL); composite.setLayoutData(data); getStatus(); addFirstSection(composite); if (status != null) { addSeparator(composite); addSecondSection(composite); setValues(); } Dialog.applyDialogFont(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SVN_RESOURCE_PROPERTIES_PAGE); return composite; }
@Override protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); Composite composite = new Composite(dialogArea, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); setTitle("Import Bookmarks file"); getShell().setText("Import Bookmarks file"); setMessage("Import a bookmarks file"); GridLayout gridLayout = new GridLayout(2, false); composite.setLayout(gridLayout); createFileTableViewer(composite); createAddLinkButton(composite); Dialog.applyDialogFont(composite); return dialogArea; }
@Override public void addPages() { super.addPages(); mainPage = new WizardNewProjectCreationPage("basicNewProjectPage") { //$NON-NLS-1$ @Override public void createControl(Composite parent) { super.createControl(parent); createWorkingSetGroup((Composite) getControl(), getSelection(), new String[] { "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$ Dialog.applyDialogFont(getControl()); } }; mainPage.setTitle("Android Application"); mainPage.setDescription("Create Android Application Project"); this.addPage(mainPage); // only add page if there are already projects in the workspace if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length > 0) { referencePage = new WizardNewProjectReferencePage("basicReferenceProjectPage");//$NON-NLS-1$ referencePage.setTitle("Project References"); referencePage.setDescription("Project References"); this.addPage(referencePage); } }
/** * @see org.eclipse.jface.wizard.Wizard#addPages() */ @Override public void addPages() { this.projectCreationPage = new WizardNewProjectCreationPage("basicNewProjectPage") { //$NON-NLS-1$ @Override public void createControl(Composite parent) { super.createControl(parent); createWorkingSetGroup((Composite) getControl(), getSelection(), new String[] { "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$ Dialog.applyDialogFont(getControl()); } }; this.projectCreationPage.setTitle(Messages.NewArduinoSCTProjectWizard_title); this.projectCreationPage.setDescription(Messages.NewArduinoSCTProjectWizard_description); this.arduinoSCTWizardPage = new ArduinoSCTWizardPage(); this.arduinoSCTWizardPage.setTitle(Messages.NewArduinoSCTProjectWizard_title); addPage(this.projectCreationPage); addPage(this.arduinoSCTWizardPage); }
public HtrModelChooserButton(Composite parent) { super(parent, 0); this.setLayout(SWTUtil.createGridLayout(1, false, 0, 0)); baseModelBtn = new Button(this, 0); baseModelBtn.setLayoutData(new GridData(GridData.FILL_BOTH)); updateModelText(); SWTUtil.onSelectionEvent(baseModelBtn, (e) -> { HtrModelsDialog diag = new HtrModelsDialog(getShell()); if (diag.open() == Dialog.OK) { setModel(diag.getSelectedHtr()); } }); }
@Override protected Control createDialogArea ( final Composite parent ) { final Composite wrapper = (Composite)super.createDialogArea ( parent ); initializeDialogUnits ( wrapper ); final Composite contents = createComposite ( wrapper ); contents.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) ); Dialog.applyDialogFont ( wrapper ); setTitle ( Messages.LoginDialog_Dlg_Title ); return wrapper; }
@Override protected Control createDialogArea ( final Composite parent ) { final Composite wrapper = (Composite)super.createDialogArea ( parent ); initializeDialogUnits ( wrapper ); final Composite contents = createComposite ( wrapper ); contents.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) ); Dialog.applyDialogFont ( wrapper ); return wrapper; }
@Override public void createControl ( final Composite parent ) { super.createControl ( parent ); final Composite control = (Composite)getControl (); createWorkingSetGroup ( control, this.selection, new String[] { "org.eclipse.ui.resourceWorkingSetPage" } ); //$NON-NLS-1$ Dialog.applyDialogFont ( control ); }
protected void chooseVariable () { final StringVariableSelectionDialog dlg = new StringVariableSelectionDialog ( getShell () ); dlg.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.VARIABLE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE ); if ( dlg.open () == Window.OK ) { this.fileText.insert ( dlg.getVariableExpression () ); makeDirty (); } }
protected void renderResult ( final ViewerCell cell, final Entry element ) { if ( element.getException () != null ) { cell.setText ( ExceptionHelper.getMessage ( element.getException () ) ); cell.setImage ( JFaceResources.getImage ( Dialog.DLG_IMG_MESSAGE_ERROR ) ); } else { cell.setText ( element.getNewName () ); cell.setImage ( null ); } }
@Override protected void setParentDialog(Dialog parentDialog) { super.setParentDialog(parentDialog); if (isUpdateMode()) { addToCombo(((RemoteFileReference)getDbo()).getUrlpath()); combo.setEnabled(false); Composite fileSelectionArea = wsRefAuthenticated.getFileSelectionArea(); editor.setEnabled(false, fileSelectionArea); useAuthentication.setEnabled(false); } else { fillReference(); } }
public static int setHeight(FormData fd, Control control, int rowcount) { int height = 0; if (control != null && !control.isDisposed()) { GC gc = new GC(control); try { gc.setFont(JFaceResources.getDialogFont()); fd.height = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), rowcount); } finally { gc.dispose(); } } return height; }
public void addDependency() { if (isDBLoaded){ ManualDepciesDialog dialog = new ManualDepciesDialog(parent.getShell(), manualDepciesSource, manualDepciesTarget, PgDatabase.listPgObjects(dbRemote.getDbObject()), PgDatabase.listPgObjects(dbProject.getDbObject()), Messages.database, Messages.ProjectEditorDiffer_project); if (dialog.open() == Dialog.OK) { manualDepciesSource = dialog.getDepciesSourceList(); manualDepciesTarget = dialog.getDepciesTargetList(); } } }
public void addPreference() { String parent = ""; ISelection selection = viewer.getSelection(); Object element = null; if (!selection.isEmpty()) { element = ((StructuredSelection) selection).getFirstElement(); } if (element == null) { Object[] elements = contentProvider.getElements(""); if (elements.length > 0) { element = elements[0]; } } if (element != null) { if (element instanceof KeyValue) { parent = ((KeyValue) element).getParentNode(); } else { parent = String.valueOf(element); } } Object input = viewer.getInput(); if (input instanceof IPreferenceProvider) { NewPreferenceDialog dialog = input instanceof PlatformPreferenceProvider? new NewPlatformPreferenceDialog(preferenceView.getSite().getShell(), parent, ((IPreferenceProvider) input).getNodeNames()) : new NewPreferenceDialog(preferenceView.getSite().getShell(), parent, ((IPreferenceProvider) input).getNodeNames()); if (dialog.open() == Dialog.OK) { parent = dialog.getParent(); String name = dialog.getName(); String value = dialog.getValue(); KeyValue newElement = new KeyValue(parent, name, value); ((IPreferenceProvider) input).add(newElement); refreshTree(); } } }
protected void setButtonLayoutData(FontMetrics metrics, Control button, boolean visible) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); data.exclude = !visible; button.setLayoutData(data); }
/** * Set the layout data of the button to a GridData with appropriate heights and widths. * * @param button The button to set the layoutdata * @param data The GridData to use */ protected static void setButtonLayoutData(Button button, GridData data) { /* GC to retrieve fontmetrics object */ GC gc = new GC(button); FontMetrics fontMetrics = gc.getFontMetrics(); /* Apply appropiate gridata */ int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); /* Dispose GC */ gc.dispose(); }