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:au.com.cybersearch2.controls.DialogPixels.java
License:Open Source License
public DialogPixels(FontMetrics fontMetrics) { marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN); marginHeight = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN); horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); buttonWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); }
From source file:au.gov.ga.earthsci.discovery.ui.preferences.DiscoveryServicesPreferencePage.java
License:Apache License
private GridData setVerticalButtonLayoutData(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);/* w ww.jav a2 s . c o m*/ return data; }
From source file:ca.usask.cs.srlab.simclipse.ui.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * @param button The button to calculate the width for * @return The width of the button/*from w w w .j ava 2 s .c om*/ */ 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:ch.netcetera.eclipse.common.fieldeditor.AbstractEditableStringListFieldEditor.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 om * @param key the key used to look-up the button text * @param selectionListener the selection listener to attach to the new button * @return the new button */ private Button createPushButton(Composite parent, String key, SelectionListener selectionListener) { Button button = new Button(parent, SWT.PUSH); button.setText(this.textAccessor.getText(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(selectionListener); return button; }
From source file:ch.powerunit.poweruniteclipse.helper.SWTHelper.java
License:Open Source License
public static int getButtonWidthHint(Button button) { 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.android.ide.eclipse.adt.installer.InstallSdkDialog.java
License:Open Source License
private Field createField(Composite composite, String textValue, String textLabel, String buttonLabel) { GridData gd;// w ww . j av a 2 s.com Label label = new Label(composite, SWT.NONE); gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); label.setLayoutData(gd); label.setText(textLabel); Text text = new Text(composite, SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, true, false); text.setLayoutData(gd); text.setText(textValue); Button button = new Button(composite, SWT.PUSH); button.setFont(composite.getFont()); gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(gd); button.setText(buttonLabel); return new Field(button, text); }
From source file:com.aptana.editor.common.preferences.TasksPreferencePage.java
License:Open Source License
private void createTaskButtons(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().create()); composite.setLayout(GridLayoutFactory.fillDefaults().create()); // Now create the buttons fAddButton = new Button(composite, SWT.PUSH); fAddButton.setText(StringUtil.ellipsify(CoreStrings.NEW)); fAddButton//from w w w. jav a 2 s. com .setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .hint(Math.max(fAddButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)), SWT.DEFAULT) .create()); fAddButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TaskTag tag = new TaskTag("", IMarker.PRIORITY_NORMAL); //$NON-NLS-1$ List<TaskTag> tags = new ArrayList<TaskTag>(); TableItem[] items = fTasksTableViewer.getTable().getItems(); for (TableItem anItem : items) { tags.add((TaskTag) anItem.getData()); } // Open a dialog for user to enter the tag name and select priority! TaskTagInputDialog dialog = new TaskTagInputDialog(tag, tags, getShell()); dialog.setTitle(Messages.TasksPreferencePage_NewTagTitle); if (dialog.open() == Window.OK) { // Insert task in our model and set the new input on the table! tags.add(dialog.getTaskTag()); fTasksTableViewer.setInput(tags); } } }); fEditButton = new Button(composite, SWT.PUSH); fEditButton.setText(StringUtil.ellipsify(CoreStrings.EDIT)); fEditButton .setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .hint(Math.max(fEditButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)), SWT.DEFAULT) .create()); fEditButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { List<TaskTag> tags = new ArrayList<TaskTag>(); TableItem[] items = fTasksTableViewer.getTable().getItems(); for (TableItem anItem : items) { tags.add((TaskTag) anItem.getData()); } int index = fTasksTableViewer.getTable().getSelectionIndex(); TableItem item = fTasksTableViewer.getTable().getItem(index); TaskTag tag = (TaskTag) item.getData(); // Open a dialog for user to edit the tag name and priority! List<TaskTag> copy = new ArrayList<TaskTag>(tags); copy.remove(index); TaskTagInputDialog dialog = new TaskTagInputDialog(tag, copy, getShell()); dialog.setTitle(Messages.TasksPreferencePage_EditTagTitle); if (dialog.open() == Window.OK) { tags.set(index, dialog.getTaskTag()); fTasksTableViewer.setInput(tags); } } }); fRemoveButton = new Button(composite, SWT.PUSH); fRemoveButton.setText(CoreStrings.REMOVE); fRemoveButton .setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .hint(Math.max(fRemoveButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)), SWT.DEFAULT) .create()); fRemoveButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Remove first selected tag from table! int index = fTasksTableViewer.getTable().getSelectionIndex(); fTasksTableViewer.getTable().remove(index); } }); }
From source file:com.aptana.editor.js.preferences.NodePreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { // Node Executable location FileFieldEditor fileEditor = new FileFieldEditor(IPreferenceConstants.NODEJS_EXECUTABLE_PATH, StringUtil.makeFormLabel(Messages.NodePreferencePage_LocationLabel), true, FileFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent()) { @Override//w w w . j a v a 2 s . c o m protected boolean doCheckState() { // Now check that the executable is ok String text = getTextControl().getText(); if (!StringUtil.isEmpty(text)) { IStatus status = getNodeService().acceptBinary(Path.fromOSString(text)); if (!status.isOK()) { setErrorMessage(status.getMessage()); return false; } } return true; } }; addField(fileEditor); sfe = new StringFieldEditor("some_non_existent_pref_key", //$NON-NLS-1$ StringUtil.makeFormLabel(Messages.NodePreferencePage_DetectedPathLabel), fep = getFieldEditorParent()); addField(sfe); // Node Source location sourceEditor = new DirectoryFieldEditor(IPreferenceConstants.NODEJS_SOURCE_PATH, StringUtil.makeFormLabel(Messages.NodePreferencePage_SourceLocationLabel), getFieldEditorParent()) { @Override public int getNumberOfControls() { return super.getNumberOfControls() + 1; } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns - 1); createDownloadButton(parent); Text textControl = getTextControl(); ((GridData) textControl.getLayoutData()).widthHint = convertHorizontalDLUsToPixels(textControl, 180); } @Override protected void adjustForNumColumns(int numColumns) { super.adjustForNumColumns(numColumns - 1); } @Override protected boolean doCheckState() { // Now check that the dir is ok String text = getTextControl().getText(); if (!StringUtil.isEmpty(text)) { IPath path = Path.fromOSString(text); IStatus status = getNodeService().validateSourcePath(path); if (!status.isOK()) { setErrorMessage(status.getMessage()); return false; } } return true; } // Create the NodeJS download button private Button createDownloadButton(Composite parent) { Button downloadBt = new Button(parent, SWT.PUSH); downloadBt.setText(Messages.NodePreferencePage_downloadButtonText); downloadBt.setFont(parent.getFont()); GridData gd = GridDataFactory.fillDefaults().create(); int widthHint = convertHorizontalDLUsToPixels(downloadBt, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, downloadBt.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); downloadBt.setLayoutData(gd); downloadBt.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { downloadNodeJS(); } }); return downloadBt; } }; addField(sourceEditor); }
From source file:com.aptana.formatter.ui.preferences.AddRemoveList.java
License:Open Source License
/** * Sets the <code>GridData</code> on the specified button to be one that is spaced for the current dialog page * units. The method <code>initializeDialogUnits</code> must be called once before calling this method for the first * time./*from w w w . ja va 2s .c o m*/ * * @param button * the button to set the <code>GridData</code> * @return the <code>GridData</code> set on the specified button */ protected GridData setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); return data; }
From source file:com.aptana.git.ui.internal.preferences.GithubAccountPageProvider.java
License:Open Source License
private static int getButtonWidthHint(Button button) { PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }