com.vaadin.event.FieldEvents.TextChangeListener Java Examples

The following examples show how to use com.vaadin.event.FieldEvents.TextChangeListener. 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: GitPushWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeText() {
	this.textAreaComments.setImmediate(true);
	this.textAreaComments.addTextChangeListener(new TextChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void textChange(TextChangeEvent event) {
			if (event.getText().isEmpty()) {
				self.buttonPush.setEnabled(false);
			} else {
				if (self.container.getConflictCount() == 0) {
					self.buttonPush.setEnabled(true);
				} else {
					self.buttonPush.setEnabled(false);
				}
			}
		}			
	});
}
 
Example #2
Source File: ColumnSelectionWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeText() {
	//
	// Add a validator
	//
	this.textFieldColumn.addValidator(new IntegerRangeValidator("Please enter an integer greater than or equal to 0.", 0, null));
	//
	// Respond to text changing to setup the button
	//
	this.textFieldColumn.addTextChangeListener(new TextChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void textChange(TextChangeEvent event) {
			if (event.getText() != null && event.getText().isEmpty() == false) {
				self.buttonSave.setEnabled(true);
			} else {
				self.buttonSave.setEnabled(false);
			}
		}
	});
}
 
Example #3
Source File: TextFieldBuilder.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a search text field.
 * 
 * @param textChangeListener
 *            listener when text is changed.
 * @return the textfield
 */
public TextField createSearchField(final TextChangeListener textChangeListener) {
    final TextField textField = style("filter-box").styleName("text-style filter-box-hide").buildTextComponent();
    textField.setWidth(100.0F, Unit.PERCENTAGE);
    textField.addTextChangeListener(textChangeListener);
    textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    // 1 seconds timeout.
    textField.setTextChangeTimeout(1000);
    return textField;
}
 
Example #4
Source File: FunctionSelectionWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeTextField() {
	//
	// Initialize GUI settings
	//
	this.textFieldFilter.setImmediate(true);
	//
	// Respond to the text change events
	//
	this.textFieldFilter.addTextChangeListener(new TextChangeListener() {
		private static final long serialVersionUID = 1L;
		SimpleStringFilter currentFilter = null;

		@Override
		public void textChange(TextChangeEvent event) {
			//
			// Remove current filter
			//
			if (this.currentFilter != null) {
				FunctionSelectionWindow.highOrderFunctions.removeContainerFilter(this.currentFilter);
				this.currentFilter = null;
			}
			//
			// Get the text
			//
			String value = event.getText();
			if (value != null && value.length() > 0) {
				//
				// Add the new filter
				//
				this.currentFilter = new SimpleStringFilter(PROPERTY_SHORTNAME, value, true, false);
				FunctionSelectionWindow.highOrderFunctions.addContainerFilter(this.currentFilter);
			}
		}
	});
}
 
Example #5
Source File: SubDomainEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeTextField() {
	this.textFieldSubdomain.setRequired(true);
	this.textFieldSubdomain.setRequiredError("Please enter a valid sub domain");
	//
	// Validate the name entered
	//
	this.textFieldSubdomain.addValidator(new RegexpValidator(SUBDOMAIN_NAME_PATTERN, true, ERROR_MESSAGE) {
		private static final long serialVersionUID = 1L;
		
	});
	//
	// Respond to events
	//
	this.textFieldSubdomain.setImmediate(true);
	this.textFieldSubdomain.addTextChangeListener(new TextChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void textChange(TextChangeEvent event) {
			if (event.getText() != null && event.getText().length() > 0) {
				self.buttonSave.setEnabled(true);
			} else {
				self.buttonSave.setEnabled(false);
			}
		}
		
	});
}
 
Example #6
Source File: EditPDPGroupWindow.java    From XACML with MIT License 4 votes vote down vote up
protected void initializeText() {
	this.textName.setNullRepresentation("");
	this.textDescription.setNullRepresentation("");
	if (this.group != null) {
		this.textName.setValue(this.group.getName());
		this.textDescription.setValue(this.group.getDescription());
	}
	//
	// Validation
	//
	this.textName.addValidator(new Validator() {
		private static final long serialVersionUID = 1L;

		@Override
		public void validate(Object value) throws InvalidValueException {
			assert(value instanceof String);
			if (value == null) {
				throw new InvalidValueException("The name cannot be blank.");
			}
			// Group names must be unique so that user can distinguish between them (and we can create unique IDs from them)
			for (PDPGroup g : self.groups) {
				if (group != null && g.getId().equals(group.getId())) {
					// ignore this group - we may or may not be changing the name
					continue;
				}
				if (g.getName().equals(value.toString())) {
					throw new InvalidValueException("Name must be unique");
				}
			}
		}
	});
	this.textName.addTextChangeListener(new TextChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void textChange(TextChangeEvent event) {
			if (event.getText() == null || event.getText().isEmpty()) {
				self.buttonSave.setEnabled(false);
			} else {
				self.buttonSave.setEnabled(true);
			}
		}
	});
}