com.vaadin.shared.Registration Java Examples

The following examples show how to use com.vaadin.shared.Registration. 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: VertxVaadin.java    From vertx-vaadin with MIT License 7 votes vote down vote up
private void configureSessionStore() {
    final Registration sessionInitListenerReg = this.service.addSessionInitListener(event -> {
        MessageConsumer<String> consumer = sessionExpiredHandler(vertx, msg ->
            Optional.of(event.getSession().getSession())
                .filter(session -> msg.body().equals(session.getId()))
                .ifPresent(WrappedSession::invalidate));
        AtomicReference<Registration> sessionDestroyListenerUnregister = new AtomicReference<>();
        sessionDestroyListenerUnregister.set(
            event.getService().addSessionDestroyListener(ev2 -> {
                consumer.unregister();
                sessionDestroyListenerUnregister.get().remove();
            })
        );

    });
    this.service.addServiceDestroyListener(event -> sessionInitListenerReg.remove());
}
 
Example #2
Source File: CubaPickerField.java    From cuba with Apache License 2.0 6 votes vote down vote up
public Registration addFieldListener(FieldValueChangeListener<T> listener) {
    if (fieldValueChangeListener == null) {
        fieldValueChangeListener = ((CubaTextField) field).addValueChangeListener(event -> {
            String text = event.getValue();

            if (!suppressTextChangeListener &&
                    !Objects.equals(getStringRepresentation(), text)) {
                suppressTextChangeListener = true;

                FieldValueChangeEvent<T> e = new FieldValueChangeEvent<>(CubaPickerField.this, text, getValue());
                fireEvent(e);

                suppressTextChangeListener = false;

                // update text representation manually
                if (field instanceof TextField) {
                    updateTextRepresentation();
                }
            }
        });
    }

    addListener(FieldValueChangeEvent.class, listener, FIELD_VALUE_CHANGE_METHOD);

    return fieldValueChangeListener;
}
 
Example #3
Source File: DemoUI.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void setResolution(org.tltv.gantt.client.shared.Resolution resolution) {
    resolutionValueChangeRegistration.ifPresent(Registration::remove);
    try {
        reso.setValue(resolution);
    } finally {
        resolutionValueChangeRegistration = Optional.of(reso.addValueChangeListener(resolutionValueChangeListener));
    }
}
 
Example #4
Source File: CubaTreeTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager == null) {
        shortcutActionManager = new ShortcutActionManager(this);
    }

    shortcutActionManager.addAction(shortcut);
    return () -> getActionManager().removeAction(shortcut);
}
 
Example #5
Source File: CubaTable.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener shortcut) {
    if (shortcutActionManager == null) {
        shortcutActionManager = new ShortcutActionManager(this);
    }

    shortcutActionManager.addAction(shortcut);
    return () -> getActionManager().removeAction(shortcut);
}
 
Example #6
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 #7
Source File: AceEditor.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Registration addBlurListener(BlurListener listener) {
       Registration registration = addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
               BlurListener.blurMethod);
       getState().listenToFocusChanges = true;
       return registration;
   }
 
Example #8
Source File: Calendar.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
@Override
public Registration setHandler(CalendarComponentEvents.ForwardHandler listener) {
    return setHandler(CalendarComponentEvents.ForwardEvent.EVENT_ID, CalendarComponentEvents.ForwardEvent.class, listener,
            CalendarComponentEvents.ForwardHandler.forwardMethod);
}
 
Example #9
Source File: DemoUI.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void syncLocale() {
    startDateValueChangeRegistration.ifPresent(Registration::remove);
    endDateValueChangeRegistration.ifPresent(Registration::remove);
    try {
        start.setLocale(gantt.getLocale());
        start.setValue(gantt.getStartLocalDateTime());
        end.setLocale(gantt.getLocale());
        end.setValue(gantt.getEndLocalDateTime());
    } finally {
        startDateValueChangeRegistration = Optional.of(start.addValueChangeListener(startDateValueChangeListener));
        endDateValueChangeRegistration = Optional.of(end.addValueChangeListener(endDateValueChangeListener));
    }
    dateFormat = new SimpleDateFormat("MMM dd HH:mm:ss zzz yyyy", gantt.getLocale());
}
 
Example #10
Source File: PopupButton.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addComponentAttachListener(ComponentAttachListener listener) {
    return addListener(ComponentAttachEvent.class, listener,
            ComponentAttachListener.attachMethod);
}
 
Example #11
Source File: CubaSearchSelectPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addValueChangeListener(ValueChangeListener<T> listener) {
    return getFieldInternal().addValueChangeListener(listener);
}
 
Example #12
Source File: CubaEditorImpl.java    From cuba with Apache License 2.0 4 votes vote down vote up
public Registration addBeforeSaveListener(CubaEditorBeforeSaveListener<T> listener) {
    return eventRouter.addListener(CubaEditorBeforeSaveEvent.class, listener,
            ReflectTools.getMethod(CubaEditorBeforeSaveListener.class));
}
 
Example #13
Source File: CubaGridLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #14
Source File: AbstractNumberField.java    From viritin with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addFocusListener(FocusListener listener) {
    return tf.addFocusListener(listener);
}
 
Example #15
Source File: CubaComboBox.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #16
Source File: CubaComboBoxPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addValueChangeListener(ValueChangeListener<T> listener) {
    return getFieldInternal().addValueChangeListener(listener);
}
 
Example #17
Source File: ClearableTextField.java    From viritin with Apache License 2.0 4 votes vote down vote up
public Registration addFocusListener(FocusListener listener) {
    return textfield.addFocusListener(listener);
}
 
Example #18
Source File: PopupButton.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addComponentDetachListener(ComponentDetachListener listener) {
    return addListener(ComponentDetachEvent.class, listener,
            ComponentDetachListener.detachMethod);
}
 
Example #19
Source File: AbstractNumberField.java    From viritin with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addBlurListener(BlurListener listener) {
    return tf.addBlurListener(listener);
}
 
Example #20
Source File: ClearableTextField.java    From viritin with Apache License 2.0 4 votes vote down vote up
public Registration addBlurListener(BlurListener listener) {
    return textfield.addBlurListener(listener);
}
 
Example #21
Source File: CubaTextField.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #22
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addBlurListener(final BlurListener listener) {
    return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod);
}
 
Example #23
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 #24
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addValueChangeListener(final HasValue.ValueChangeListener<Set<T>> listener) {
    return addSelectionListener(event -> listener
                                .valueChange(new ValueChangeEvent<>(event.getComponent(), this, event.getOldValue(), event.isUserOriginated())));
}
 
Example #25
Source File: SliderPanel.java    From vaadin-sliderpanel with MIT License 4 votes vote down vote up
public Registration addToggleListener(SliderPanelToggleListener listener) {
    return this.addListener(SliderPanelToggleEvent.class, listener, SliderPanelToggleListener.ELEMENT_TOGGLED_METHOD);
}
 
Example #26
Source File: CubaCssActionsLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Registration addShortcutListener(ShortcutListener listener) {
    getActionManager().addAction(listener);
    return () -> getActionManager().removeAction(listener);
}
 
Example #27
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
/**
 * Set the handler for the given type information. Mirrors
 * {@link #addListener(String, Class, Object, Method) addListener} from
 * AbstractComponent
 *
 * @param eventId
 *            A unique id for the event. Usually one of
 *            {@link CalendarEventId}
 * @param eventType
 *            The class of the event, most likely a subclass of
 *            {@link CalendarComponentEvent}
 * @param listener
 *            A listener that listens to the given event
 * @param listenerMethod
 *            The method on the lister to call when the event is triggered
 * @return handler registration
 */
protected Registration setHandler(String eventId, Class<?> eventType, EventListener listener, Method listenerMethod) {

    if (handlers.get(eventId) != null) {
        handlers.get(eventId).remove();
        handlers.remove(eventId);
    }

    if (listener != null) {
        Registration registration = addListener(eventId, eventType, listener, listenerMethod);
        handlers.put(eventId, registration);
        return registration;
    }

    return null;
}
 
Example #28
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
@Override
public Registration setHandler(CalendarComponentEvents.BackwardHandler listener) {
    return setHandler(CalendarComponentEvents.BackwardEvent.EVENT_ID,
            CalendarComponentEvents.BackwardEvent.class, listener,
            CalendarComponentEvents.BackwardHandler.backwardMethod);
}
 
Example #29
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
@Override
public Registration setHandler(CalendarComponentEvents.DateClickHandler listener) {
    return setHandler(CalendarComponentEvents.DateClickEvent.EVENT_ID,
            CalendarComponentEvents.DateClickEvent.class, listener,
            CalendarComponentEvents.DateClickHandler.dateClickMethod);
}
 
Example #30
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
@Override
public Registration setHandler(CalendarComponentEvents.ItemClickHandler listener) {
    return setHandler(CalendarComponentEvents.ItemClickEvent.EVENT_ID,
            CalendarComponentEvents.ItemClickEvent.class, listener,
            CalendarComponentEvents.ItemClickHandler.itemClickMethod);
}