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.objectstyle.wolips.launching.ui.AbstractWOArgumentsTab.java
License:Open Source License
/** * Returns a width hint for a button control. *//*from ww w . j ava 2s . com*/ private static int getButtonWidthHint(Button button) { GC gc = new GC(button); gc.setFont(button.getFont()); FontMetrics fFontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.objectstyle.wolips.ui.preferences.LaunchPreferencesPage.java
License:Open Source License
protected Control createContents(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NULL); GridLayout layout = new GridLayout(); layout.marginWidth = 0;//w w w. j a v a2 s . co m layout.marginHeight = 0; layout.numColumns = 2; parent.setLayout(layout); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; parent.setLayoutData(data); // set F1 help // WorkbenchHelp.setHelp(parent, // IHelpContextIds.IGNORE_PREFERENCE_PAGE); Label l1 = new Label(parent, SWT.NULL); l1.setText(PreferencesMessages.getString("LaunchPreferencesPage.label")); //$NON-NLS-1$ data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); data.horizontalSpan = 3; l1.setLayoutData(data); // includeTable = new Table(parent, SWT.CHECK | SWT.BORDER); this.includeTable = new Table(parent, SWT.CHECK | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); // gd.widthHint = convertWidthInCharsToPixels(30); gd.heightHint = 300; this.includeTable.setLayoutData(gd); this.includeTable.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { handleSelection(); } }); Composite buttons = new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); this.addButton = new Button(buttons, SWT.PUSH); this.addButton.setText(PreferencesMessages.getString("LaunchPreferencesPage.add")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; data.heightHint = Math.max(data.heightHint, this.addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, this.addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); this.addButton.setLayoutData(data); this.addButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { addIgnore(); } }); this.removeButton = new Button(buttons, SWT.PUSH); this.removeButton.setText(PreferencesMessages.getString("LaunchPreferencesPage.remove")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; data.heightHint = Math.max(data.heightHint, this.removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, this.removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); this.removeButton.setLayoutData(data); this.removeButton.setEnabled(false); this.removeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { removeIgnore(); } }); this.changeButton = new Button(buttons, SWT.PUSH); this.changeButton.setText(PreferencesMessages.getString("LaunchPreferencesPage.change")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; data.heightHint = Math.max(data.heightHint, this.changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, this.removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); this.changeButton.setLayoutData(data); this.changeButton.setEnabled(false); this.changeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { changeArgument(); } }); fillTable(Preferences.getLaunchInfoForKey(this.preferencesKey)); Dialog.applyDialogFont(ancestor); return parent; }
From source file:org.org.eclipse.core.utils.platform.dialogs.Dialog.java
License:Open Source License
/** * Set the layout data of the button to a GridData with appropriate heights and widths. * //from w w w. j av a2 s .c o m * @param button */ protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
From source file:org.org.eclipse.core.utils.platform.dialogs.Dialog.java
License:Open Source License
/** * Set the layout data of the button to a FormData with appropriate heights and widths. * /*from w ww .j a va 2 s . c om*/ * @param button */ protected void setButtonLayoutFormData(Button button) { FormData data = new FormData(); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.width = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
From source file:org.python.pydev.ui.dialogs.AbstractKeyValueDialog.java
License:Open Source License
/** * Creates the three widgets that represent the password entry area. * @param parent the parent of the widgets, which has two columns *//*ww w . j a v a 2 s . c o m*/ protected void createFields(Composite parent) { changesValidator = createChangesValidator(); new Label(parent, SWT.NONE).setText(getKeyLabelText()); keyField = new Text(parent, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 3; data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); keyField.setLayoutData(data); keyField.addListener(SWT.SELECTED, changesValidator); keyField.addListener(SWT.KeyDown, changesValidator); keyField.addListener(SWT.KeyUp, changesValidator); new Label(parent, SWT.NONE).setText(getValueLabelText()); valueField = new Text(parent, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); valueField.setLayoutData(data); valueField.addListener(SWT.SELECTED, changesValidator); valueField.addListener(SWT.KeyDown, changesValidator); valueField.addListener(SWT.KeyUp, changesValidator); browserButton = createButton(parent, BROWSER_ID, BROWSER_LABEL, true); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); browserButton.setLayoutData(data); browserButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { String file = handleBrowseButton(); if (file != null) { file = file.trim(); setValueField(file); } changesValidator.handleEvent(null); //Make it update the error message } }); }
From source file:org.python.pydev.ui.dialogs.SelectExistingOrCreateNewDialog.java
License:Open Source License
private Button createPushButton(Composite parent, String text) { Button button = new Button(parent, SWT.PUSH); button.setText(text);/* w w w . j a v a 2 s . c om*/ 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(this); return button; }
From source file:org.python.pydev.ui.pythonpathconf.AbstractInterpreterEditor.java
License:Open Source License
/** * Helper method to create a push button. * * @param parent the parent control//from w ww . j a v a 2 s . c o m * @param key the resource name used to supply the button's label text * @param listenerToAdd * @return Button */ /*default*/Button createBt(Composite parent, String key, SelectionListener listenerToAdd) { Button button = new Button(parent, SWT.PUSH); button.setText(JFaceResources.getString(key)); button.setFont(parent.getFont()); GridData data = new GridData(GridData.FILL_HORIZONTAL); // data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT); 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(listenerToAdd); return button; }
From source file:org.rdkit.knime.util.PreferenceButton.java
License:Open Source License
protected void doFillIntoGrid(Composite parent, int numColumns) { m_button = getButtonControl(parent); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(m_button, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, m_button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); m_button.setLayoutData(gd);//from ww w.j av a2 s. com }
From source file:org.rssowl.ui.internal.util.NewsColumnSelectionControl.java
License:Open Source License
private GridData setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data);/*from www .j a v a2s . co m*/ return data; }
From source file:org.seasar.s2junit4plugin.preference.QuickJUnitPreferencePage.java
License:Apache License
protected Control createContents(Composite parent) { IPreferenceStore store = getPreferenceStore(); NamingRules namingRules = new NamingRules(store); TabFolder tabFolder = new TabFolder(parent, SWT.NULL); tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); TabItem item1 = new TabItem(tabFolder, SWT.NULL); item1.setText(Messages.getString("Preference.tabItem.defaultFolder")); //$NON-NLS-1$ defaultFolderPreference = new DefaultFolderPreference(store, tabFolder); item1.setControl(defaultFolderPreference); TabItem item2 = new TabItem(tabFolder, SWT.NULL); item2.setText(Messages.getString("Preference.tabItem.namingRule")); //$NON-NLS-1$ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); namingRulesPreference = new NamingRulesPreference(store, tabFolder, widthHint); Dialog.applyDialogFont(namingRulesPreference); item2.setControl(namingRulesPreference); return parent; }