@Override public Registration addOpenListener(EditorOpenListener<T> listener) { return eventRouter.addListener(EditorOpenEvent.class, listener, ReflectTools.getMethod(EditorOpenListener.class)); }
/** * Sends the event to all listeners. * * @param event * the Event to be sent to all listeners. */ protected void fireEvent(EventObject event) { if (eventRouter != null) { eventRouter.fireEvent(event); } }
/** * Registers a new listener with the specified activation method to listen * events generated by this component. If the activation method does not * have any arguments the event object will not be passed to it when it's * called. * * @param eventType * the type of the listened event. Events of this type or its * subclasses activate the listener. * @param listener * the object instance who owns the activation method. * @param method * the activation method. * @return a registration for the listener */ protected Registration addListener(Class<?> eventType, DataProviderListener<T> listener, Method method) { if (eventRouter == null) { eventRouter = new EventRouter(); } return eventRouter.addListener(eventType, listener, method); }
/** * Adds a listener that will be invoked when the bootstrap HTML is about to * be generated. This can be used to modify the contents of the HTML that * loads the Vaadin application in the browser and the HTTP headers that are * included in the response serving the HTML. * * @see BootstrapListener#modifyBootstrapFragment(BootstrapFragmentResponse) * @see BootstrapListener#modifyBootstrapPage(BootstrapPageResponse) * * @param listener * the bootstrap listener to add * @return a registration object for removing the listener * @since 8.0 */ public Registration addBootstrapListener(BootstrapListener listener) { assert hasLock(); eventRouter.addListener(BootstrapFragmentResponse.class, listener, BOOTSTRAP_FRAGMENT_METHOD); eventRouter.addListener(BootstrapPageResponse.class, listener, BOOTSTRAP_PAGE_METHOD); return () -> { eventRouter.removeListener(BootstrapFragmentResponse.class, listener, BOOTSTRAP_FRAGMENT_METHOD); eventRouter.removeListener(BootstrapPageResponse.class, listener, BOOTSTRAP_PAGE_METHOD); }; }
Object target) { if (eventRouter != null) { eventRouter.removeListener(eventType, target); if (!eventRouter.hasListeners(eventType)) { ComponentStateUtil.removeRegisteredEventListener(getState(), eventIdentifier);
/** * Removes all registered listeners matching the given parameters. Since * this method receives the event type and the listener object as * parameters, it will unregister all <code>object</code>'s methods that are * registered to listen to events of type <code>eventType</code> generated * by this component. * * <p> * For more information on the inheritable event mechanism see the * {@link com.vaadin.event com.vaadin.event package documentation}. * </p> * * @param eventType * the exact event type the <code>object</code> listens to. * @param target * the target object that has registered to listen to events of * type <code>eventType</code> with one or more methods. * @deprecated use a {@link Registration} from {@link #addListener} to * remove a listener */ @Deprecated @Override public void removeListener(Class<?> eventType, Object target) { if (eventRouter != null) { eventRouter.removeListener(eventType, target); } }
/** * Returns the event router for this binder. * * @return the event router, not null */ protected EventRouter getEventRouter() { if (eventRouter == null) { eventRouter = new EventRouter(); } return eventRouter; }
/** * Checks if the given {@link Event} type is listened for this component. * * @param eventType * the event type to be checked * @return true if a listener is registered for the given event type */ protected boolean hasListeners(Class<?> eventType) { return eventRouter != null && eventRouter.hasListeners(eventType); }
/** * Returns all listeners that are registered for the given event type or one * of its subclasses. * * @param eventType * The type of event to return listeners for. * @return A collection with all registered listeners. Empty if no listeners * are found. */ public Collection<?> getListeners(Class<?> eventType) { if (eventRouter == null) { return Collections.emptyList(); } return eventRouter.getListeners(eventType); }
/** * Removes one registered listener method. The given method owned by the * given object will no longer be called when the specified events are * generated by this component. * * <p> * For more information on the inheritable event mechanism see the * {@link com.vaadin.event com.vaadin.event package documentation}. * </p> * * @param eventType * the exact event type the <code>object</code> listens to. * @param target * target object that has registered to listen to events of type * <code>eventType</code> with one or more methods. * @param method * the method owned by <code>target</code> that's registered to * listen to events of type <code>eventType</code>. * @deprecated use a {@link Registration} from * {@link #addListener(Class, Object, Method)} to remove a * listener */ @Override @Deprecated public void removeListener(Class<?> eventType, Object target, Method method) { if (eventRouter != null) { eventRouter.removeListener(eventType, target, method); } }
protected EventRouter getEventRouter() { if (eventRouter == null) { eventRouter = new EventRouter(); } return eventRouter; } }
/** * Removes a {@link BrowserWindowResizeListener} from this UI. The listener * will no longer be notified when the browser window is resized. * * @param resizeListener * the listener to remove * * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the * registration object returned from * {@link #addBrowserWindowResizeListener(BrowserWindowResizeListener)} * . */ @Deprecated public void removeBrowserWindowResizeListener( BrowserWindowResizeListener resizeListener) { removeListener(BrowserWindowResizeEvent.class, resizeListener, BROWSER_RESIZE_METHOD); getState(true).hasResizeListeners = hasEventRouter() && eventRouter.hasListeners(BrowserWindowResizeEvent.class); }
/** * Sends an event to all registered listeners. The listeners will decide if * the activation method should be called or not. * * @param event * the Event to be sent to all listeners. */ public void fireEvent(EventObject event) { fireEvent(event, null); }
@Override public Registration addCancelListener(EditorCancelListener<T> listener) { return eventRouter.addListener(EditorCancelEvent.class, listener, ReflectTools.getMethod(EditorCancelListener.class)); }
/** * Registers a new listener with the specified activation method to listen * events generated by this component. If the activation method does not * have any arguments the event object will not be passed to it when it's * called. * * <p> * For more information on the inheritable event mechanism see the * {@link com.vaadin.event com.vaadin.event package documentation}. * </p> * * @param eventType * the type of the listened event. Events of this type or its * subclasses activate the listener. * @param target * the object instance who owns the activation method. * @param method * the activation method. * @return a registration object for removing the listener */ @Override public Registration addListener(Class<?> eventType, Object target, Method method) { if (eventRouter == null) { eventRouter = new EventRouter(); } return eventRouter.addListener(eventType, target, method); }
/** * Remove a bootstrap listener that was previously added. * * @see #addBootstrapListener(BootstrapListener) * * @param listener * the bootstrap listener to remove * @deprecated Use a {@link Registration} object returned by * {@link #addBootstrapListener(BootstrapListener)} to remove a * listener */ @Deprecated public void removeBootstrapListener(BootstrapListener listener) { assert hasLock(); eventRouter.removeListener(BootstrapFragmentResponse.class, listener, BOOTSTRAP_FRAGMENT_METHOD); eventRouter.removeListener(BootstrapPageResponse.class, listener, BOOTSTRAP_PAGE_METHOD); }
private EventRouter getEventRouter() { if (eventRouter == null) { eventRouter = new EventRouter(); } return eventRouter; }
if (!hasListeners(eventType)) { registration.remove();
/** * Sends the event to all listeners. * * @param event * the Event to be sent to all listeners. */ protected void fireEvent(EventObject event) { if (eventRouter != null) { eventRouter.fireEvent(event); } } }
@Override public Registration addSaveListener(EditorSaveListener<T> listener) { return eventRouter.addListener(EditorSaveEvent.class, listener, ReflectTools.getMethod(EditorSaveListener.class)); }