Java Code Examples for org.eclipse.swt.widgets.Button#setFocus()
The following examples show how to use
org.eclipse.swt.widgets.Button#setFocus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutDialog.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Add buttons to the dialog's button bar. * * Subclasses should override. * * @param parent * the button bar composite */ protected void createButtonsForButtonBar(Composite parent) { parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createButton(parent, DETAILS_ID, WorkbenchMessages.AboutDialog_DetailsButton, false); Label l = new Label(parent, SWT.NONE); l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = (GridLayout) parent.getLayout(); layout.numColumns++; layout.makeColumnsEqualWidth = false; Button b = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); b.setFocus(); }
Example 2
Source File: WizardExportResourcesPage2.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Creates a new button with the given id. * <p> * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers for * selection events including button presses and registers default buttons with its shell. The button id is stored * as the buttons client data. Note that the parent's layout is assumed to be a GridLayout and the number of columns * in this layout is incremented. Subclasses may override. * </p> * @param parent * the parent composite * @param id * the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids) * @param label * the label from the button * @param defaultButton * <code>true</code> if the button is to be the default button, and <code>false</code> otherwise */ protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(buttonData); button.setData(new Integer(id)); button.setText(label); button.setFont(parent.getFont()); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); setButtonLayoutData(button); return button; }
Example 3
Source File: WizardExportResourcesPage2.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Creates a new button with the given id. * <p> * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers for * selection events including button presses and registers default buttons with its shell. The button id is stored * as the buttons client data. Note that the parent's layout is assumed to be a GridLayout and the number of columns * in this layout is incremented. Subclasses may override. * </p> * @param parent * the parent composite * @param id * the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids) * @param label * the label from the button * @param defaultButton * <code>true</code> if the button is to be the default button, and <code>false</code> otherwise */ protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(buttonData); button.setData(new Integer(id)); button.setText(label); button.setFont(parent.getFont()); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); setButtonLayoutData(button); return button; }
Example 4
Source File: VButtonImageBak.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void createImage(VButton button) { String key = getKey(button); if(requests.containsKey(key)) { requests.get(key).add(button); } else { requests.put(key, new ArrayList<VButton>()); requests.get(key).add(button); int style = button.getStyle() & (SWT.CHECK | SWT.RADIO); if(style == 0) { style = SWT.TOGGLE; // defaults to, and converts PUSH buttons to, TOGGLE } Button b = new Button(button.composite, style); b.setBackground(button.getBackground()); b.setBounds(button.getBounds()); if(button.hasState(VControl.STATE_SELECTED)) { b.setSelection(true); } if(button == VTracker.getFocusControl()) { b.setFocus(); } b.addListener(SWT.Paint, new ImageListener(key, b)); b.redraw(); b.update(); } }
Example 5
Source File: INSDComponentPage.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Creates a new button * <p> * The <code>Dialog</code> implementation of this framework method creates a standard push * button, registers for selection events including button presses and registers default buttons * with its shell. The button id is stored as the buttons client data. Note that the parent's * layout is assumed to be a GridLayout and the number of columns in this layout is incremented. * Subclasses may override. * </p> * * @param parent the parent composite * @param label the label from the button * @param defaultButton <code>true</code> if the button is to be the default button, and <code>false</code> * otherwise * @param text the text * @return the button */ protected Button addButton(Composite parent, String label, boolean defaultButton, final Text text) { Button button = new Button(parent, SWT.PUSH); button.setText(label); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ResourceSelectionDialog dialog = new ResourceSelectionDialog(getShell(), currentContainer, "Selection Dialog"); dialog.setTitle("Selection Dialog"); dialog.setMessage("Please select a file:"); dialog.open(); Object[] result = dialog.getResult(); if (result[0] != null) { IResource res = (IResource) result[0]; text.setText(res.getProjectRelativePath().toOSString()); } } }; button.addSelectionListener(listener); return button; }
Example 6
Source File: AddProjectToSessionWizard.java From saros with GNU General Public License v2.0 | 5 votes |
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button ok = getButton(IDialogConstants.OK_ID); ok.setText(Messages.JoinSessionWizard_yes); Button no = createButton(parent, IDialogConstants.CANCEL_ID, Messages.JoinSessionWizard_no, true); no.moveBelow(ok); no.setFocus(); }
Example 7
Source File: DeleteWarningDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
protected boolean initDialog( ) { getButton( IDialogConstants.OK_ID ).setText( IDialogConstants.YES_LABEL ); Button no = getButton( IDialogConstants.CANCEL_ID ); no.setText( IDialogConstants.NO_LABEL ); /** * Set cancel button on focus when initial. */ no.setFocus(); getShell( ).setDefaultButton( no ); return true; }
Example 8
Source File: GetActiveKeyDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button nextBtn = getButton(IDialogConstants.OK_ID); nextBtn.setText(Messages.getString("license.LicenseAgreementDialog.nextBtn")); Button exitBtn = getButton(IDialogConstants.CANCEL_ID); exitBtn.setText(Messages.getString("license.LicenseAgreementDialog.exitBtn")); exitBtn.setFocus(); }
Example 9
Source File: GetActiveKeyDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button nextBtn = getButton(IDialogConstants.OK_ID); nextBtn.setText(Messages.getString("license.LicenseAgreementDialog.nextBtn")); Button exitBtn = getButton(IDialogConstants.CANCEL_ID); exitBtn.setText(Messages.getString("license.LicenseAgreementDialog.exitBtn")); exitBtn.setFocus(); }
Example 10
Source File: ChangeExceptionHandler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button ok= getButton(IDialogConstants.OK_ID); ok.setText( RefactoringMessages.ChangeExceptionHandler_undo_button); Button abort= createButton(parent, IDialogConstants.CANCEL_ID, RefactoringMessages.ChangeExceptionHandler_abort_button, true); abort.moveBelow(ok); abort.setFocus(); }
Example 11
Source File: DeleteWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Adds the "delete subpackages" checkbox to the composite. Note that * this code assumes that the control of the parent is a Composite with * GridLayout and a horizontal span of 2. * * @see MessageWizardPage#createControl(Composite) */ private void addDeleteSubPackagesCheckBox() { Composite c= new Composite((Composite) getControl(), SWT.NONE); GridLayout gd= new GridLayout(); gd.horizontalSpacing= 10; c.setLayout(gd); GridData data= new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan= 2; c.setLayoutData(data); final boolean selection= getRefactoringSettings().getBoolean(DIALOG_SETTINGS_DELETE_SUB_PACKAGES); fDeleteSubPackagesCheckBox= new Button(c, SWT.CHECK); fDeleteSubPackagesCheckBox.setText(RefactoringMessages.DeleteWizard_also_delete_sub_packages); fDeleteSubPackagesCheckBox.setSelection(selection); fDeleteSubPackagesCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection()); } }); fDeleteSubPackagesCheckBox.setFocus(); getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection()); }
Example 12
Source File: ChangeExceptionHandler.java From typescript.java with MIT License | 5 votes |
protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button ok= getButton(IDialogConstants.OK_ID); ok.setText( RefactoringMessages.ChangeExceptionHandler_undo_button); Button abort= createButton(parent, IDialogConstants.CANCEL_ID, RefactoringMessages.ChangeExceptionHandler_abort_button, true); abort.moveBelow(ok); abort.setFocus(); }
Example 13
Source File: DialogWithUrls.java From WebpifyYourAndroidApp with Apache License 2.0 | 5 votes |
@Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button button = super.createButton(parent, id, label, defaultButton); // Be sure to set the focus if the custom area cannot so as not // to lose the defaultButton. if (defaultButton && !customShouldTakeFocus()) { button.setFocus(); } return button; }
Example 14
Source File: CustomFiltersDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Overrides method in Dialog * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) */ @Override protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); // create a composite with standard margins and spacing Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); Composite group= composite; // Checkbox fEnableUserDefinedPatterns= new Button(group, SWT.CHECK); fEnableUserDefinedPatterns.setFocus(); fEnableUserDefinedPatterns.setText(FilterMessages.CustomFiltersDialog_enableUserDefinedPattern); // Pattern field fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); data.widthHint= convertWidthInCharsToPixels(59); fUserDefinedPatterns.setLayoutData(data); String patterns= convertToString(fPatterns, SEPARATOR); fUserDefinedPatterns.setText(patterns); SWTUtil.setAccessibilityText(fUserDefinedPatterns, FilterMessages.CustomFiltersDialog_name_filter_pattern_description); // Info text final Label info= new Label(group, SWT.LEFT); info.setText(FilterMessages.CustomFiltersDialog_patternInfo); // Enabling / disabling of pattern group fEnableUserDefinedPatterns.setSelection(fEnablePatterns); fUserDefinedPatterns.setEnabled(fEnablePatterns); info.setEnabled(fEnablePatterns); fEnableUserDefinedPatterns.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean state= fEnableUserDefinedPatterns.getSelection(); fUserDefinedPatterns.setEnabled(state); info.setEnabled(fEnableUserDefinedPatterns.getSelection()); if (state) fUserDefinedPatterns.setFocus(); } }); // Filters provided by extension point if (fBuiltInFilters.length > 0) createCheckBoxList(group); applyDialogFont(parent); return parent; }
Example 15
Source File: AboutDialog.java From developer-studio with Apache License 2.0 | 4 votes |
protected void createButtonsForButtonBar(Composite parent) { parent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); button.setFocus(); }
Example 16
Source File: DeviceNotFoundDialog.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
protected void createButtonsForButtonBar(Composite parent) { Button btn = createButton(parent, DNF_KEY_CANCEL, Messages.DeviceNotFoundDialog_CANCEL, true); btn.setFocus(); }
Example 17
Source File: CustomPreviewTable.java From birt with Eclipse Public License 1.0 | 4 votes |
public void mouseUp( MouseEvent e ) { // DO NOT PROCESS IF DRAGGING IN PROGRESS! if ( bDragging ) { updateScrollbars( ); return; } this.bColumnSelection = false; if ( e.button != 3 ) { // TODO: These values will change based on scrolling or // resizing! this.iSelectedRow = e.y / ROW_HEIGHT + iVScroll; for ( int i = 0, iTmp = 0; i < columnWidths.size( ); i++ ) { iTmp = getAdjustedLeftEdgeForColumn( i ); if ( iTmp > e.x ) { iColumnIndex = i - 1; break; } iColumnIndex = i; } if ( iColumnIndex >= 0 ) { btnHeaders.elementAt( iColumnIndex ).setFocus( ); } redraw( ); } else { iColumnIndex = -1; for ( int i = 0, iTmp = 0; i < columnWidths.size( ); i++ ) { iTmp = getAdjustedLeftEdgeForColumn( i ); if ( iTmp > e.x ) { iColumnIndex = i - 1; break; } iColumnIndex = i; } Button currentButton = btnHeaders.elementAt( iColumnIndex ); currentButton.setFocus( ); fireMenuEvent( currentButton, true ); } }
Example 18
Source File: AboutDialog.java From devstudio-tooling-ei with Apache License 2.0 | 4 votes |
protected void createButtonsForButtonBar(Composite parent) { parent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); button.setFocus(); }
Example 19
Source File: TableView.java From hop with Apache License 2.0 | 4 votes |
private void editButton( TableItem row, int rownr, int colnr ) { beforeEdit = getItemText( row ); fieldChanged = false; ColumnInfo colinfo = columns[ colnr - 1 ]; if ( colinfo.isReadOnly() ) { return; } if ( colinfo.getDisabledListener() != null ) { boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr ); if ( disabled ) { return; } } button = new Button( table, SWT.PUSH ); props.setLook( button, Props.WIDGET_STYLE_TABLE ); String buttonText = columns[ colnr - 1 ].getButtonText(); if ( buttonText != null ) { button.setText( buttonText ); } button.setImage( GuiResource.getInstance().getImage( "ui/images/edittext.svg" ) ); SelectionListener selAdpt = colinfo.getSelectionAdapter(); if ( selAdpt != null ) { button.addSelectionListener( selAdpt ); } buttonRownr = rownr; buttonColnr = colnr; // button.addTraverseListener(lsTraverse); buttonContent = row.getText( colnr ); String tooltip = columns[ colnr - 1 ].getToolTip(); if ( tooltip != null ) { button.setToolTipText( tooltip ); } else { button.setToolTipText( "" ); } button.addTraverseListener( lsTraverse ); // hop to next field button.addTraverseListener( new TraverseListener() { @Override public void keyTraversed( TraverseEvent arg0 ) { closeActiveButton(); } } ); editor.horizontalAlignment = SWT.LEFT; editor.verticalAlignment = SWT.TOP; editor.grabHorizontal = false; editor.grabVertical = false; Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ); editor.minimumWidth = size.x; editor.minimumHeight = size.y - 2; // setRowNums(); editor.layout(); // Open the text editor in the correct column of the selected row. editor.setEditor( button ); button.setFocus(); // if the button loses focus, destroy it... /* * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } ); */ }
Example 20
Source File: TableView.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void editButton( TableItem row, int rownr, int colnr ) { beforeEdit = getItemText( row ); fieldChanged = false; ColumnInfo colinfo = columns[colnr - 1]; if ( colinfo.isReadOnly() ) { return; } if ( colinfo.getDisabledListener() != null ) { boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr ); if ( disabled ) { return; } } button = new Button( table, SWT.PUSH ); props.setLook( button, Props.WIDGET_STYLE_TABLE ); String buttonText = columns[colnr - 1].getButtonText(); if ( buttonText != null ) { button.setText( buttonText ); } button.setImage( GUIResource.getInstance().getImage( "ui/images/edittext.svg" ) ); SelectionListener selAdpt = colinfo.getSelectionAdapter(); if ( selAdpt != null ) { button.addSelectionListener( selAdpt ); } buttonRownr = rownr; buttonColnr = colnr; // button.addTraverseListener(lsTraverse); buttonContent = row.getText( colnr ); String tooltip = columns[colnr - 1].getToolTip(); if ( tooltip != null ) { button.setToolTipText( tooltip ); } else { button.setToolTipText( "" ); } button.addTraverseListener( lsTraverse ); // hop to next field button.addTraverseListener( new TraverseListener() { @Override public void keyTraversed( TraverseEvent arg0 ) { closeActiveButton(); } } ); editor.horizontalAlignment = SWT.LEFT; editor.verticalAlignment = SWT.TOP; editor.grabHorizontal = false; editor.grabVertical = false; Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ); editor.minimumWidth = size.x; editor.minimumHeight = size.y - 2; // setRowNums(); editor.layout(); // Open the text editor in the correct column of the selected row. editor.setEditor( button ); button.setFocus(); // if the button loses focus, destroy it... /* * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } ); */ }