/** * Checks if there is at least one listener registered for the given event * type for this component. * * @param eventType * the component event type * @return <code>true</code> if at least one listener is registered, * <code>false</code> otherwise */ @SuppressWarnings("rawtypes") protected boolean hasListener(Class<? extends ComponentEvent> eventType) { return eventBus != null && eventBus.hasListener(eventType); }
@Override public boolean listenProgress() { return upload.getEventBus().hasListener(ProgressUpdateEvent.class); }
/** * Dispatches the event to all listeners registered for the event type. * * @param event * the event to fire */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void fireEvent(ComponentEvent event) { Class<? extends ComponentEvent> eventType = event.getClass(); if (!hasListener(eventType)) { return; } // Copy the list to avoid ConcurrentModificationException for (ListenerWrapper wrapper : new ArrayList<>( componentEventData.get(event.getClass()))) { fireEventForListener(event, wrapper); } }