Java Code Examples for org.eclipse.swt.widgets.Text.addVerifyListener()

The following are Jave code examples for showing how to use addVerifyListener() of the org.eclipse.swt.widgets.Text class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Hydrograph   File: ParameterGridDialog.java   View Source Code Vote up 6 votes
private void attachKeyValidator(final Text text) {
	text.addVerifyListener(new VerifyListener() {
		@Override
		public void verifyText(VerifyEvent e) {
			txtDecorator.hide();
			String currentText = ((Text) e.widget).getText();
			String newName = (currentText.substring(0, e.start) + e.text + currentText.substring(e.end));
			Matcher matchName = Pattern.compile("[\\@]{1}[\\{]{1}[\\w]*[\\}]{1}||[\\w]*").matcher(newName);
			if(!matchName.matches()){
				text.setToolTipText(Messages.CHARACTERSET);
				txtDecorator=WidgetUtility.addDecorator(text,Messages.CHARACTERSET);
				txtDecorator.setDescriptionText(Messages.CHARACTERSET);
				txtDecorator.show();
				e.doit=false;
			}
			else
			{
				text.setToolTipText("");
				text.setMessage("");
				txtDecorator.hide();
			}
		}
	});
}
 
Example 2
Project: Hydrograph   File: DebugDataViewer.java   View Source Code Vote up 6 votes
private void createJumpPageTextBox(Composite composite_3) {
	Text jumpPageTextBox = new Text(composite_3, SWT.BORDER);
	jumpPageTextBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	jumpPageTextBox.addVerifyListener(new VerifyListener() {
		@Override
		public void verifyText(VerifyEvent e) {
			String currentText = ((Text) e.widget).getText();
			String pageNumberText = currentText.substring(0, e.start) + e.text + currentText.substring(e.end);
			try {
				long pageNumber = Long.valueOf(pageNumberText);
				if (pageNumber < 1) {
					e.doit = false;
				}
			} catch (NumberFormatException ex) {
				if (!pageNumberText.equals(""))
					e.doit = false;
			}
		}
	});

	dataViewerListeners.attachJumpPageListener(jumpPageTextBox);
	windowControls.put(ControlConstants.JUMP_TEXT, jumpPageTextBox);

}
 
Example 3
Project: Hydrograph   File: CustomPaletteViewer.java   View Source Code Vote up 6 votes
private void refreshThePaletteBasedOnSearchString(final PaletteRoot paletteRoot,
		final ELTGraphicalEditor editor, final Map<String, PaletteDrawer> categoryPaletteContainer,
		final Text text, final List<Component> componentsConfig, final Composite container) {
	text.addVerifyListener(new VerifyListener() {
		@Override
		public void verifyText(VerifyEvent e) {
			boolean matchFound = false;
			final List<Component> matchingComponents = new ArrayList<>();
			paletteRoot.getChildren().clear();
			String currentText = ((Text) e.widget).getText();
			createPaletteContainers(paletteRoot, categoryPaletteContainer, editor);
			String searchedString = (currentText.substring(0, e.start) + e.text + currentText.substring(e.end))
					.toUpperCase();
				if (StringUtils.isEmpty(searchedString)) {
					showAllContainers(paletteRoot, editor, categoryPaletteContainer, componentsConfig);
				} else {
					showOpenPaletteContainers(paletteRoot.getChildren());
					matchFound = checkSearchedComponentFoundInPalette(editor, categoryPaletteContainer, componentsConfig,
							 matchingComponents, searchedString);
					showMessageWhenComponentNotFound(container, matchFound);
					showMatchingContainers(paletteRoot, categoryPaletteContainer, matchingComponents);
				}
		}
	});
}