com.vaadin.event.FieldEvents.TextChangeEvent Java Examples

The following examples show how to use com.vaadin.event.FieldEvents.TextChangeEvent. 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: CSCTextChangeListener.java    From chipster with MIT License 6 votes vote down vote up
@Override
public void textChange(TextChangeEvent event) {
	String text = "";
	if(model instanceof Tool) {
		if(isId) {
			text = ((Tool) model).getTitleId(event.getText());
		} else {
			text = ((Tool) model).getTitleDisplayName(event.getText());
		}
		model.getToolEditor().getToolEditorUI().getTreeToolEditor().updateToolTitle(text);
	} else {
		if(!isId && (model.getId() != null && !model.getId().isEmpty())) {
			return;
		}
		if(event.getText().isEmpty() && isId) {
			text = getValue(model.getNameValue()) + " " + getValue(model.getTypeValue());
		} else {
			text = getValue(event.getText()) + " " + getValue(model.getTypeValue());
		}
		model.getToolEditor().getToolEditorUI().getTreeToolEditor().setItemCaption(model, text);
	}
	model.setTitleDescriptionValue(text);
}
 
Example #2
Source File: NumericQuestion.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void textChange(TextChangeEvent event) {
    String newValue = event.getText();
    logger.debug("Text Change Event fired in {} with text = {}", NumericQuestion.class.getSimpleName(), newValue);
    if (isValid(answerField, newValue)) {
        String questionCode = questionDTO.getCode();
        Answer answer = null;
        if (StringUtils.isEmpty(newValue)) {
            answer = NoAnswer.create();
        } else {
            answer = NumericAnswer.fromValue(Integer.parseInt(newValue));
        }
        answerSavedEvent.fire(AnswerSavedEvent.with().questionCode(questionCode).answer(answer).build());
        answerField.setComponentError(null);
    }
}
 
Example #3
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 #4
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 #5
Source File: SpColorPickerPreview.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void textChange(final TextChangeEvent event) {
    super.valueChange(new ValueChangeEvent() {
        private static final long serialVersionUID = 1L;

        @Override
        public Property<String> getProperty() {
            return new EventHolder(event);
        }

    });

}
 
Example #6
Source File: ShortFreeTextQuestion.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void textChange(TextChangeEvent event) {
    String text = event.getText();
    logger.debug("Text Change Event fired in ShortFreeTextQuestion with text = {}", text);
    String questionCode = questionDTO.getCode();
    Answer answer = null;
    if (StringUtils.isBlank(text)) {
        answer = NoAnswer.create();
    } else {
        answer = TextAnswer.fromValue(text);
    }
    answerSavedEvent.fire(AnswerSavedEvent.with().questionCode(questionCode).answer(answer).build());
}
 
Example #7
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 #8
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 #9
Source File: AbstractMetadataPopupLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void onValueChange(final TextChangeEvent event) {
    if (hasCreatePermission() || hasUpdatePermission()) {
        if (!keyTextField.getValue().isEmpty() && !event.getText().isEmpty()) {
            metadataWindow.setSaveButtonEnabled(true);
        } else {
            metadataWindow.setSaveButtonEnabled(false);
        }
    }
}
 
Example #10
Source File: AbstractMetadataPopupLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void onKeyChange(final TextChangeEvent event) {
    if (hasCreatePermission() || hasUpdatePermission()) {
        if (!valueTextArea.getValue().isEmpty() && !event.getText().isEmpty()) {
            metadataWindow.setSaveButtonEnabled(true);
        } else {
            metadataWindow.setSaveButtonEnabled(false);
        }
    }
}
 
Example #11
Source File: CommonDialogWindow.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void removeTextListener(final AbstractField<?> field) {
    if (!(field instanceof TextChangeNotifier)) {
        return;
    }
    for (final Object listener : field.getListeners(TextChangeEvent.class)) {
        if (listener instanceof ChangeListener) {
            ((TextChangeNotifier) field).removeTextChangeListener((ChangeListener) listener);
        }
    }
}
 
Example #12
Source File: CreateOrUpdateFilterHeader.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void onFilterNameChange(final TextChangeEvent event) {
    if (isNameAndQueryEmpty(event.getText(), queryTextField.getValue())
            || (event.getText().equals(oldFilterName) && queryTextField.getValue().equals(oldFilterQuery))) {
        saveButton.setEnabled(false);
    } else {
        if (hasSavePermission()) {
            saveButton.setEnabled(true);
        }
    }
}
 
Example #13
Source File: ContractApplicationChangeViewImplEx.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Override
public void textChange(TextChangeEvent event) {
	System.out.println(event);
	
}
 
Example #14
Source File: ContractApplicationAddViewImplEx.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Override
public void textChange(TextChangeEvent event) {
	updateValidation();
	
}
 
Example #15
Source File: CommonDialogWindow.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void textChange(final TextChangeEvent event) {
    saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(field, event.getText()));
}
 
Example #16
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);
			}
		}
	});
}
 
Example #17
Source File: MaintenanceWindowLayout.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void textChange(final TextChangeEvent event) {
    scheduleTranslator.setValue(translateCron(event.getText()));
}
 
Example #18
Source File: SpColorPickerPreview.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
private EventHolder(final TextChangeEvent event) {
    this.event = event;
}
 
Example #19
Source File: MaintenanceWindowLayout.java    From hawkbit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Method, used for validity check, when duration text is changed.
 *
 * @param event
 *            (@link TextChangeEvent} the event object after duration text
 *            change.
 * @return validity of maintenance window controls.
 */
public boolean onDurationChange(final TextChangeEvent event) {
    duration.setValue(event.getText());
    return isScheduleAndDurationValid();
}
 
Example #20
Source File: MaintenanceWindowLayout.java    From hawkbit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Method, used for validity check, when schedule text is changed.
 *
 * @param event
 *            (@link TextChangeEvent} the event object after schedule text
 *            change.
 * @return validity of maintenance window controls.
 */
public boolean onScheduleChange(final TextChangeEvent event) {
    schedule.setValue(event.getText());
    return isScheduleAndDurationValid();
}