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.talend.designer.neo4j.ui.footer.FooterComposite.java
License:Open Source License
private void createComponents() { final UIManager uiManager = neo4jManager.getUiManager(); GridData footerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL); setLayoutData(footerCompositeGridData); FormLayout formLayout = new FormLayout(); setLayout(formLayout);// www .j a v a 2 s .c om Button okButton = new Button(this, SWT.NONE); okButton.setText("Ok"); // Internationalize this FormData okFormData = new FormData(); Point minSize = okButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); okFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x); okButton.setLayoutData(okFormData); okButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { } @Override public void widgetDefaultSelected(SelectionEvent arg0) { uiManager.closeNeo4j(SWT.OK, false); } }); Button cancelButton = new Button(this, SWT.NONE); cancelButton.setText("Cancel"); // Internationalize this FormData cancelFormData = new FormData(); cancelFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x); cancelButton.setLayoutData(cancelFormData); cancelButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { } @Override public void widgetDefaultSelected(SelectionEvent arg0) { uiManager.closeNeo4j(SWT.CANCEL, false); } }); cancelFormData.right = new FormAttachment(100, -5); okFormData.right = new FormAttachment(cancelButton, -5); }
From source file:org.talend.designer.rowgenerator.ui.footer.FooterComposite.java
License:Open Source License
/** * amaumont Comment method "createComponents". *//* www.j av a2s . c o m*/ private void createComponents() { final UIManager uiManager = generatorManager.getUiManager(); GridData footerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL); this.setLayoutData(footerCompositeGridData); FormLayout formLayout = new FormLayout(); this.setLayout(formLayout); Button okButton = new Button(this, SWT.NONE); okButton.setText(Messages.getString("FooterComposite.OkButton.Text")); //$NON-NLS-1$ FormData okFormData = new FormData(); Point minSize = okButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); okFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x); okButton.setLayoutData(okFormData); okButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { FunParaTableView2 editor = uiManager.getGeneratorUI().getTabFolderEditors().getParameterEditor(); editor.notifyOkPressed(); uiManager.closeRowGenerator(SWT.OK, false); } }); Button cancelButton = new Button(this, SWT.NONE); cancelButton.setText(Messages.getString("FooterComposite.CancelButton.Text")); //$NON-NLS-1$ cancelButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { uiManager.closeRowGenerator(SWT.CANCEL, false); } }); FormData cancelFormData = new FormData(); minSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); cancelFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x); cancelButton.setLayoutData(cancelFormData); cancelFormData.right = new FormAttachment(100, -5); okFormData.right = new FormAttachment(cancelButton, -5); }
From source file:org.talend.repository.ui.wizards.ConfigExternalLib.TableField.java
License:Open Source License
/** * Helper method to create a push button. * /* w ww . ja v a 2 s . c o m*/ * @param parent 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 | GridData.VERTICAL_ALIGN_BEGINNING); int widthHint = 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:org.talend.repository.ui.wizards.metadata.connection.ldap.BaseWidgetUtils.java
License:Open Source License
/** * Creates a button under the given parent. The button width is set to the default width. * //w ww . j a va2 s . c o m * @param parent the parent * @param text the label of the button * @param span the horizontal span * @return the created button */ public static Button createButton(Composite parent, String text, int span) { GC gc = new GC(parent); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); Button button = new Button(parent, SWT.PUSH); GridData gd = new GridData(); gd.widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); button.setLayoutData(gd); button.setText(text); return button; }
From source file:org.talend.sqlbuilder.ui.SQLBuilderDialog.java
License:Open Source License
@Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button button = new Button(parent, SWT.PUSH); button.setText(label);/*w w w . ja va 2 s. c om*/ button.setFont(JFaceResources.getDialogFont()); 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); } } GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); 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); return button; }
From source file:org.tigris.subversion.subclipse.ui.comments.CommentTemplatesPreferencePage.java
License:Open Source License
private void createButtons(Composite parent) { Composite buttons = new Composite(parent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); GridLayout layout = new GridLayout(); layout.marginHeight = 0;//w w w. ja v a2 s. co m layout.marginWidth = 0; buttons.setLayout(layout); Button newButton = new Button(buttons, SWT.PUSH); newButton.setText(Policy.bind("CommentTemplatesPreferencePage.New")); //$NON-NLS-1$ GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); newButton.setLayoutData(data); newButton.setEnabled(true); newButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { newTemplate(); } }); editButton = new Button(buttons, SWT.PUSH); editButton.setText(Policy.bind("CommentTemplatesPreferencePage.Edit")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); editButton.setLayoutData(data); editButton.setEnabled(false); editButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { editTemplate(); } }); removeButton = new Button(buttons, SWT.PUSH); removeButton.setText(Policy.bind("CommentTemplatesPreferencePage.Remove")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); removeButton.setLayoutData(data); removeButton.setEnabled(false); removeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); }
From source file:org.tigris.subversion.subclipse.ui.dialogs.DialogArea.java
License:Open Source License
protected Button createButton(Composite parent, String label, int style) { Button button = new Button(parent, SWT.PUSH); button.setText(label);/* www. j a v a 2 s. c o m*/ // we need to explicitly set the font to the parent's font for dialogs button.setFont(parent.getFont()); GridData data = new GridData(style); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); return button; }
From source file:org.tigris.subversion.subclipse.ui.preferences.SVNDecoratorPreferencesPage.java
License:Open Source License
/** * creates the following controls (sample) * File Format : [{added_flag}{dirty_flag}{name} {revision} {date} {author}] [Add Variables] * Example : [ ] * supportedBindings is a map of {key : description} (ex : {"name","name of the resource being decorated"}) * @returns the text control for the format and the text control for the example *//*from w ww.j ava 2s. c o m*/ protected TextPair createFormatEditorControl(Composite composite, String title, String buttonText, final Map supportedBindings) { createLabel(composite, title, 1); Text format = new Text(composite, SWT.BORDER); format.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); format.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateExamples(); } }); Button b = new Button(composite, SWT.NONE); b.setText(buttonText); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); b.setLayoutData(data); final Text formatToInsert = format; b.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { addVariables(formatToInsert, supportedBindings); } }); return new TextPair(format, null); }
From source file:org.tigris.subversion.subclipse.ui.wizards.generatediff.PatchFileSelectionPage.java
License:Open Source License
/** * Allow the user to chose to save the patch to the workspace or outside * of the workspace.// ww w .ja va 2 s. c om */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); composite.setLayout(layout); composite.setLayoutData(new GridData()); setControl(composite); initializeDialogUnits(composite); // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_SELECTION_PAGE); // Clipboard saveToClipboard = new Button(composite, SWT.RADIO); saveToClipboard.setText(Policy.bind("GenerateSVNDiff.SaveToClipboard")); //$NON-NLS-1$ saveToClipboard.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { validatePage(); updateEnablements(); } }); // File System saveInFilesystem = new Button(composite, SWT.RADIO); saveInFilesystem.setText(Policy.bind("GenerateSVNDiff.SaveInFileSystem")); //$NON-NLS-1$ saveInFilesystem.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { validatePage(); updateEnablements(); } }); Composite nameGroup = new Composite(composite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; nameGroup.setLayout(layout); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); nameGroup.setLayoutData(data); filenameCombo = new Text(nameGroup, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); filenameCombo.setLayoutData(gd); filenameCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { setPageComplete(validatePage()); } }); FocusListener focusListener = new FocusAdapter() { public void focusGained(FocusEvent e) { ((Text) e.getSource()).selectAll(); } public void focusLost(FocusEvent e) { ((Text) e.getSource()).setText(((Text) e.getSource()).getText()); } }; filenameCombo.addFocusListener(focusListener); browseButton = new Button(nameGroup, SWT.NULL); browseButton.setText(Policy.bind("GenerateSVNDiff.Browse")); //$NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); browseButton.setLayoutData(data); browseButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FileDialog d = new FileDialog(getShell(), SWT.PRIMARY_MODAL | SWT.SAVE); d.setText(Policy.bind("GenerateSVNDiff.SavePatchAs")); //$NON-NLS-1$ d.setFileName(Policy.bind("GenerateSVNDiff.patchTxt")); //$NON-NLS-1$ String file = d.open(); if (file != null) { IPath path = new Path(file); setFilesystemFilename(path.toOSString()); } } }); // Workspace saveInWorkspace = new Button(composite, SWT.RADIO); saveInWorkspace.setText(Policy.bind("GenerateSVNDiff.SaveInWorkspace")); //$NON-NLS-1$ saveInWorkspace.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { validatePage(); updateEnablements(); } }); final Composite pathGroup = new Composite(composite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; pathGroup.setLayout(layout); data = new GridData(SWT.FILL, SWT.FILL, true, false); pathGroup.setLayoutData(data); wsPathText = new Text(pathGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.verticalAlignment = GridData.CENTER; gd.grabExcessVerticalSpace = false; gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; wsPathText.setLayoutData(gd); wsPathText.setEditable(false); wsBrowseButton = new Button(pathGroup, SWT.NULL); gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, wsBrowseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); wsBrowseButton.setLayoutData(gd); wsBrowseButton.setText(Policy.bind("GenerateSVNDiff.Browse")); //$NON-NLS-1$ wsBrowseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { final WorkspaceDialog dialog = new WorkspaceDialog(getShell(), Policy.bind("GenerateSVNDiff.workspaceDialogTitle"), //$NON-NLS-1$ Policy.bind("GenerateSVNDiff.workspaceDialogMessage"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_WIZBAN_DIFF), wsPathText); wsBrowsed = true; dialog.open(); validatePage(); } }); resourceSelectionTree = new ResourceSelectionTree(composite, SWT.NONE, Policy.bind("GenerateSVNDiff.Changes"), ResourceSelectionTree.dedupeResources(resources), statusMap, //$NON-NLS-1$ null, true, null, null); ((CheckboxTreeViewer) resourceSelectionTree.getTreeViewer()).setAllChecked(true); resourceSelectionTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { validatePage(); } }); saveToClipboard.setSelection(true); validatePage(); updateEnablements(); }
From source file:org.tuleap.mylyn.task.ui.internal.preferences.TuleapPreferencePage.java
License:Open Source License
/** * Returns the grid data for the given button. * * @param button/*from w ww . j a v a 2 s . com*/ * The button * @return The grid data for the given button */ private GridData getButtonGridData(Button button) { GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return gd; }