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:org.eclipse.koneki.ldt.ui.SWTUtil.java
License:Open Source License
public static int getButtonWidthHint(Button button) { /* button.setFont(JFaceResources.getDialogFont()); */ 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:org.eclipse.linuxtools.dataviewers.dialogs.STDataViewersSortDialog.java
License:Open Source License
/** * Set the layout data of the button to a GridData with * appropriate heights and widths./* w w w .j a v a 2 s .c o m*/ * @param button */ private void setButtonSize(Button button, GridData buttonData) { button.setFont(button.getParent().getFont()); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); buttonData.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(buttonData); }
From source file:org.eclipse.linuxtools.internal.cdt.libhover.devhelp.preferences.LibHoverPreferencePage.java
License:Open Source License
protected void contributeButtons(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; generateButton = new Button(parent, SWT.NONE); generateButton.setFont(parent.getFont()); generateButton.setText(LibHoverMessages.getString(GENERATE)); generateButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { regenerate();//from w w w . j av a 2s . co m } }); generateButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { generateButton = null; } }); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, generateButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); generateButton.setLayoutData(gd); }
From source file:org.eclipse.linuxtools.internal.docker.ui.launch.LaunchConfigurationUtils.java
License:Open Source License
/** * Computes the size of the given {@link Button} and returns the width. * //from ww w. ja v a 2 s . c om * @param button * the button for which the size must be computed. * @return the width hint for the given button */ public static int getButtonWidthHint(final Button button) { /* button.setFont(JFaceResources.getDialogFont()); */ final PixelConverter converter = new PixelConverter(button); final int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java
License:Open Source License
private Composite createPreviousAndNextButtons(Composite parent) { // Copied from Wizard Dialog. // increment the number of columns in the button bar GridLayout barLayout = (GridLayout) parent.getLayout(); barLayout.numColumns += 2; // parent is assumed to have a GridLayout (see javadoc of Dialog#createButton(..)) Composite composite = new Composite(parent, SWT.NONE); // create a layout with spacing and margins appropriate for the font // size./*from www .ja v a2s. c o m*/ GridLayout layout = new GridLayout(); layout.numColumns = 0; // will be incremented by createButton layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = 0; layout.verticalSpacing = 0; composite.setLayout(layout); composite.setFont(parent.getFont()); Button backButton = createButton(composite, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false); backButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { backPressed(); } }); Button nextButton = createButton(composite, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false); nextButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { nextOrPreviewPressed(); } }); GridData data = new GridData(); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize1 = backButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point minSize2 = nextButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); int minSize = Math.max(minSize1.x, minSize2.x); ((GridData) backButton.getLayoutData()).widthHint = minSize; ((GridData) nextButton.getLayoutData()).widthHint = minSize; data.widthHint = 2 * Math.max(widthHint, minSize) + barLayout.horizontalSpacing; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; data.horizontalSpan = 2; composite.setLayoutData(data); return composite; }
From source file:org.eclipse.ltk.internal.ui.refactoring.util.SWTUtil.java
License:Open Source License
public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); return Math.max(new PixelConverter(button).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.m2e.ui.internal.launch.MavenLaunchMainTab.java
License:Open Source License
private MavenPropertyDialog getMavenPropertyDialog(String title, String initName, String initValue) { return new MavenPropertyDialog(getShell(), title, initName, initValue, null) { protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); Button variablesButton = new Button(comp, SWT.PUSH); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END); gd.horizontalSpan = 2;// w w w . java 2s . c o m gd.widthHint = Math.max(convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), // variablesButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); variablesButton.setLayoutData(gd); variablesButton.setFont(comp.getFont()); variablesButton.setText(Messages.launchPropertyDialogBrowseVariables); //$NON-NLS-1$; variablesButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent se) { StringVariableSelectionDialog variablesDialog = new StringVariableSelectionDialog( getShell()); if (variablesDialog.open() == IDialogConstants.OK_ID) { String variable = variablesDialog.getVariableExpression(); if (variable != null) { valueText.insert(variable.trim()); } } } }); return comp; } }; }
From source file:org.eclipse.mylyn.internal.tasks.ui.wizards.AttachmentSourcePage.java
License:Open Source License
private void createAttachmentFileGroup(Composite parent) { final Composite composite = new Composite(parent, SWT.NULL); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;/*from w ww.java2s .co m*/ composite.setLayout(gridLayout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // new row GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); useFileButton = new Button(composite, SWT.RADIO); useFileButton.setText(Messages.AttachmentSourcePage_File); fileNameField = new Combo(composite, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = SIZING_TEXT_FIELD_WIDTH; fileNameField.setLayoutData(gd); fileNameField.setText(""); //$NON-NLS-1$ fileBrowseButton = new Button(composite, SWT.PUSH); fileBrowseButton.setText(Messages.AttachmentSourcePage_Browse_); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = fileBrowseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); fileBrowseButton.setLayoutData(data); // new row gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalSpan = 3; useClipboardButton = new Button(composite, SWT.RADIO); useClipboardButton.setText(Messages.AttachmentSourcePage_Clipboard); useClipboardButton.setLayoutData(gd); useClipboardButton.setSelection(initUseClipboard); // new row useWorkspaceButton = new Button(composite, SWT.RADIO); useWorkspaceButton.setText(Messages.AttachmentSourcePage_Workspace); gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); useWorkspaceButton.setLayoutData(gd); addWorkspaceControls(parent); // Add listeners useClipboardButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!useClipboardButton.getSelection()) { return; } clearErrorMessage(); showError = true; storeClipboardContents(); updateWidgetEnablements(); } }); useFileButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!useFileButton.getSelection()) { return; } // If there is anything typed in at all clearErrorMessage(); showError = (fileNameField.getText() != ""); //$NON-NLS-1$ updateWidgetEnablements(); } }); fileNameField.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setSourceName(fileNameField.getText()); updateWidgetEnablements(); } }); fileNameField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { clearErrorMessage(); showError = true; updateWidgetEnablements(); } }); fileBrowseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { clearErrorMessage(); showError = true; FileDialog fileChooser = new FileDialog(composite.getShell(), SWT.OPEN); fileChooser.setText(Messages.AttachmentSourcePage_Select_File_Dialog_Title); if (fileNameField.getText().trim().length() > 0) { lastFilename = fileNameField.getText().trim(); } fileChooser.setFileName(lastFilename); String file = fileChooser.open(); if (file == null) { return; } // remember the last selected directory lastFilename = file; fileNameField.setText(file); updateWidgetEnablements(); } }); useWorkspaceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!useWorkspaceButton.getSelection()) { return; } clearErrorMessage(); // If there is anything typed in at all showError = (!treeViewer.getSelection().isEmpty()); updateWidgetEnablements(); } }); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { clearErrorMessage(); updateWidgetEnablements(); } }); treeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof TreeSelection) { TreeSelection treeSel = (TreeSelection) selection; Object res = treeSel.getFirstElement(); if (res != null) { if (res instanceof IProject || res instanceof IFolder) { if (treeViewer.getExpandedState(res)) { treeViewer.collapseToLevel(res, 1); } else { treeViewer.expandToLevel(res, 1); } } else if (res instanceof IFile) { getContainer().showPage(getNextPage()); } } } } }); useFileButton.setSelection(!initUseClipboard); setEnableWorkspaceAttachment(false); }
From source file:org.eclipse.ocl.examples.modelregistry.ui.properties.PropertyPage.java
License:Open Source License
@Override protected void contributeButtons(Composite parent) { createAccessorCombo(parent);/*from ww w.j a v a 2 s. c o m*/ createFiller(parent); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); configurationBlock.createAddButton(parent, widthHint); configurationBlock.createEditButton(parent, widthHint); configurationBlock.createRemoveButton(parent, widthHint); createFiller(parent); parent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); Layout layout = parent.getLayout(); if (layout instanceof GridLayout) ((GridLayout) layout).numColumns += 7; super.contributeButtons(parent); }
From source file:org.eclipse.oomph.preferences.presentation.AllPreferencesPreferencePage.java
License:Open Source License
@Override protected void contributeButtons(Composite parent) { super.contributeButtons(parent); GridLayout gridLayout = (GridLayout) parent.getLayout(); gridLayout.numColumns += 1;/*from ww w . j a va 2 s. c o m*/ Button editButton = new Button(parent, SWT.PUSH); editButton.setText("Edit..."); Dialog.applyDialogFont(editButton); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minButtonSize = editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = Math.max(widthHint, minButtonSize.x); editButton.setLayoutData(data); editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Invoke the close method on the preference dialog, but avoid using internal API, so do it reflectively. IPreferencePageContainer container = getContainer(); try { Method method = container.getClass().getMethod("close"); method.invoke(container); } catch (Throwable ex) { PreferencesEditorPlugin.INSTANCE.log(ex); } openWorkingSetsEditor(); } }); }