com.vaadin.event.FieldEvents.FocusEvent Java Examples

The following examples show how to use com.vaadin.event.FieldEvents.FocusEvent. 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: AceEditor.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addFocusListener(FocusListener listener) {
       Registration registration = addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
               FocusListener.focusMethod);
       getState().listenToFocusChanges = true;
       return registration;
   }
 
Example #2
Source File: AbstractNumberFieldTest.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Test
public void addAndRemoveFocusListener() {
  // Try both add remove a FocusListener, and ,ake sure they get delegated to the textfield
  assertTrue(field.tf.getListeners(FocusEvent.class).isEmpty());
  field.addFocusListener(FOCUS_LISTENER);
  Collection<?> listeners = field.tf.getListeners(FocusEvent.class);
  assertEquals(1, listeners.size());
  assertEquals(FOCUS_LISTENER, listeners.iterator().next());

  field.removeFocusListener(FOCUS_LISTENER);
  assertTrue(field.tf.getListeners(FocusEvent.class).isEmpty());
}
 
Example #3
Source File: AbstractNumberFieldTest.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Test
public void addAndRemoveFocusListenerWithMethodOverload() {
  // Try both add remove a FocusListener, and ,ake sure they get delegated to the textfield
  assertTrue(field.tf.getListeners(FocusEvent.class).isEmpty());
  field.addFocusListener(FOCUS_LISTENER);
  Collection<?> listeners = field.tf.getListeners(FocusEvent.class);
  assertEquals(1, listeners.size());
  assertEquals(FOCUS_LISTENER, listeners.iterator().next());

  field.removeFocusListener(FOCUS_LISTENER);
  assertTrue(field.tf.getListeners(FocusEvent.class).isEmpty());
}
 
Example #4
Source File: AbstractNumberFieldTest.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Test
public void withFocusListener() {

  assertTrue(field.tf.getListeners(FocusEvent.class).isEmpty());

  AbstractNumberField<Integer> fluid = field.withFocusListener(FOCUS_LISTENER);
  Collection<?> listeners = field.tf.getListeners(FocusEvent.class);
  assertEquals(1, listeners.size());
  assertEquals(FOCUS_LISTENER, listeners.iterator().next());
  assertSame(field, fluid);
}
 
Example #5
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addFocusListener(final FocusListener listener) {
    return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod);
}
 
Example #6
Source File: AceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void removeFocusListener(FocusListener listener) {
	removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
	getState().listenToFocusChanges = !getListeners(FocusEvent.class)
			.isEmpty() || !getListeners(BlurEvent.class).isEmpty();
}
 
Example #7
Source File: AceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void removeBlurListener(BlurListener listener) {
	removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
	getState().listenToFocusChanges = !getListeners(FocusEvent.class)
			.isEmpty() || !getListeners(BlurEvent.class).isEmpty();
}
 
Example #8
Source File: AceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
private void fireFocus() {
	fireEvent(new FocusEvent(this));
}
 
Example #9
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addFocusListener(final FocusListener listener) {
    return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod);
}