Java Code Examples for org.eclipse.swt.widgets.Text#addVerifyListener()
The following examples show how to use
org.eclipse.swt.widgets.Text#addVerifyListener() .
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: ServerPortExtension.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override public void createControl(UI_POSITION position, Composite parent) { // We add controls only to the BOTTOM position. if (position == UI_POSITION.BOTTOM) { portLabel = new Label(parent, SWT.NONE); portLabel.setVisible(false); portLabel.setText(Messages.getString("NEW_SERVER_DIALOG_PORT")); portText = new Text(parent, SWT.SINGLE | SWT.BORDER); portText.setVisible(false); portText.setText(String.valueOf(LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT)); portText.addVerifyListener(new PortChangeMonitor()); portText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); Image errorImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); portDecoration = new ControlDecoration(portText, SWT.LEFT | SWT.TOP); portDecoration.setDescriptionText(Messages.getString("NEW_SERVER_DIALOG_INVALID_PORT_VALUE")); portDecoration.setImage(errorImage); portDecoration.hide(); } }
Example 2
Source File: AppEngineWizardPage.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private void createPackageField(Composite parent) { Label packageNameLabel = new Label(parent, SWT.LEAD); packageNameLabel.setText(Messages.getString("java.package")); //$NON-NLS-1$ javaPackageField = new Text(parent, SWT.BORDER); javaPackageField.addModifyListener(event -> revalidate()); javaPackageField.addVerifyListener(event -> { // if the user ever changes the package name field, then we never auto-generate again. if (!javaPackageProgrammaticUpdate) { autoGeneratePackageName = false; } }); }
Example 3
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates the controls for the type name field. Expects a <code>GridLayout</code> with at * least 2 columns. * * @param composite the parent composite * @param nColumns number of columns to span */ protected void createTypeNameControls(Composite composite, int nColumns) { fTypeNameDialogField.doFillIntoGrid(composite, nColumns - 1); DialogField.createEmptySpace(composite); Text text= fTypeNameDialogField.getTextControl(null); LayoutUtil.setWidthHint(text, getMaxFieldWidth()); TextFieldNavigationHandler.install(text); text.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { if (fCanModifyPackage && ! fEnclosingTypeSelection.isSelected() && e.start == 0 && e.end == ((Text) e.widget).getCharCount()) { String typeNameWithoutParameters= getTypeNameWithoutParameters(e.text); int lastDot= typeNameWithoutParameters.lastIndexOf('.'); if (lastDot == -1 || lastDot == typeNameWithoutParameters.length() - 1) return; String pack= typeNameWithoutParameters.substring(0, lastDot); if (validatePackageName(pack, null).getSeverity() == IStatus.ERROR) return; fPackageDialogField.setText(pack); e.text= e.text.substring(lastDot + 1); } } }); }
Example 4
Source File: DimensionBuilderDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @param composite */ private void createMeasureField(Composite composite) { new Label(composite, SWT.NONE).setText(LABEL_MEASURE); measure = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 2; measure.setLayoutData(gridData); measure.setFont(composite.getFont()); if ( measureData != null && !measureData.equals( "" ) ) //$NON-NLS-1$ { measure.setText( NumberUtil.double2LocaleNum( ( (Double) measureData ).doubleValue( ) ) ); } measure.addVerifyListener(new VerifyListener(){ public void verifyText(VerifyEvent e) { // TODO Auto-generated method stub boolean doit = false; char eChar = e.character;System.out.print(eChar + 0); String validChars = "0123456789,.\b"; //$NON-NLS-1$ if(e.keyCode == SWT.DEL || validChars.indexOf(eChar) >= 0) { doit = true; } e.doit = doit; }}); }
Example 5
Source File: FolderSelectionGroup.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Create group * * @param parent */ public void create( Composite parent ) { // get font Font font = parent.getFont( ); // label control Label label = new Label( parent, SWT.LEFT ); label.setFont( font ); label.setText( this.labelText ); Composite composite = new Composite( parent, SWT.NULL ); GridLayout layout = new GridLayout( ); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 2; composite.setLayout( layout ); GridData data = new GridData( GridData.FILL_HORIZONTAL ); composite.setLayoutData( data ); // text control text = new Text( composite, SWT.BORDER ); text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); text.setFont( font ); text.setText( this.textValue ); text.addVerifyListener( new VerifyListener( ) { public void verifyText( VerifyEvent e ) { e.doit = e.text.indexOf( DELIMITER ) < 0; } } ); // directory selection button button = new Button( composite, SWT.PUSH ); button.setFont( font ); button.setText( this.buttonText ); button.addSelectionListener( new SelectionAdapter( ) { public void widgetSelected( SelectionEvent event ) { dialog = new DirectoryDialog( PlatformUI.getWorkbench( ) .getDisplay( ).getActiveShell( ) ); dialog.setText( dialogTitle ); dialog.setMessage( dialogMessage ); dialog.setFilterPath( dialogFilterPath ); String folderName = dialog.open( ); if ( folderName == null ) { return; } text.setText( folderName ); } } ); }
Example 6
Source File: FolderSelectionGroup.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Create group * * @param parent */ public void create( Composite parent ) { // get font Font font = parent.getFont( ); // label control Label label = new Label( parent, SWT.LEFT ); label.setFont( font ); label.setText( this.labelText ); Composite composite = new Composite( parent, SWT.NULL ); GridLayout layout = new GridLayout( ); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 2; composite.setLayout( layout ); GridData data = new GridData( GridData.FILL_HORIZONTAL ); composite.setLayoutData( data ); // text control text = new Text( composite, SWT.BORDER ); text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); text.setFont( font ); text.setText( this.textValue ); text.addVerifyListener( new VerifyListener( ) { public void verifyText( VerifyEvent e ) { e.doit = e.text.indexOf( DELIMITER ) < 0; } } ); // directory selection button button = new Button( composite, SWT.PUSH ); button.setFont( font ); button.setText( this.buttonText ); button.addSelectionListener( new SelectionAdapter( ) { public void widgetSelected( SelectionEvent event ) { dialog = new DirectoryDialog( PlatformUI.getWorkbench( ) .getDisplay( ).getActiveShell( ) ); dialog.setText( dialogTitle ); dialog.setMessage( dialogMessage ); dialog.setFilterPath( dialogFilterPath ); String folderName = dialog.open( ); if ( folderName == null ) { return; } text.setText( folderName ); } } ); }
Example 7
Source File: ExportImportablePartDialog.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); AbstractSection.spacer(composite); createWideLabel(composite, "Base file name (without path or following \".xml\":"); baseFileNameUI = new Text(composite, SWT.BORDER); baseFileNameUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); baseFileNameUI.addModifyListener(m_dialogModifyListener); baseFileNameUI.addVerifyListener(new DialogVerifyListener()); baseFileName = ""; newErrorMessage(composite); createWideLabel(composite, "Where the generated part descriptor file will be stored:"); genFilePathUI = new Text(composite, SWT.BORDER | SWT.H_SCROLL); genFilePathUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); genFilePathUI.setText(rootPath + ".xml"); new Label(composite, SWT.NONE).setText(""); importByNameUI = new Button(composite, SWT.RADIO); importByNameUI.setText("Import by Name"); importByNameUI .setToolTipText("Importing by name looks up the name on the classpath and datapath."); importByLocationUI = new Button(composite, SWT.RADIO); importByLocationUI.setText("Import By Location"); importByLocationUI.setToolTipText("Importing by location requires a relative or absolute URL"); String defaultBy = CDEpropertyPage.getImportByDefault(editor.getProject()); if (defaultBy.equals("location")) { importByNameUI.setSelection(false); importByLocationUI.setSelection(true); } else { importByNameUI.setSelection(true); importByLocationUI.setSelection(false); } baseFileNameUI.setFocus(); return composite; }
Example 8
Source File: SWTUtil.java From eclipse-cs with GNU Lesser General Public License v2.1 | 2 votes |
/** * Adds a verifier to the given text control which allows only digits to be entered. * * @param text * the text control */ public static void addOnlyDigitInputSupport(Text text) { text.addVerifyListener(new OnlyDigitsVerifyListener()); }