@Override public <H extends EventHandler> void fireEvent(Event<H> event) { wrapped.fireEvent(event); }
protected void goToWithoutChecks(Location newLocation) { this.where = newLocation; eventBus.fireEvent(new LocationChangedEvent(newLocation)); } }
/** * Send an event to the system event bus. */ private void sendEvent(AppRegistryEventType eventType, Collection<DefinitionMetadata> appDescriptors) { for (DefinitionMetadata appMetadata : appDescriptors) { systemEventBus.fireEvent(new AppRegistryEvent(appMetadata, eventType)); } } }
@Override protected void onPostExecute() throws Exception { // Propagate event eventBus.fireEvent(new ContentChangedEvent(itemIdOfChangedItem)); }
@Override public void setLayout(AppLauncherLayoutDefinition layout) { this.layoutDefinitionReference.set(i18nizerProvider.get().decorate(layout)); log.debug("Sending AppLauncherLayoutChangedEvent on the system bus"); appPermissionsCache.invalidateAll(); systemEventBus.fireEvent(new AppLauncherLayoutChangedEvent()); }
@Override public void removeDecorator(DefinitionDecorator<EndpointDefinition> decorator) { Optional<DefinitionProvider<EndpointDefinition>> targetProvider = getAllProviders().stream() .filter(decorator::appliesTo) .findFirst(); super.removeDecorator(decorator); targetProvider.ifPresent(provider -> systemEventBus.fireEvent(new EndpointDefinitionRegistryEvent(REREGISTERED, provider))); }
/** * Sends an event on the system event bus. */ private void logAndSendChangedEvent(AppRegistryEvent event) { String name = event.getAppDescriptorMetadata().getName(); log.debug("Got AppRegistryEvent." + event.getEventType() + " for app: " + name); appPermissionsCache.invalidateAll(); systemEventBus.fireEvent(new AppLauncherLayoutChangedEvent()); log.debug("Sending AppLauncherLayoutChangedEvent on the system bus"); } });
@Override public void messageCleared(final Message message) { if (ui.isAttached()) { ui.access(() -> eventBus.fireEvent(new MessageEvent(message, true))); } }
public BeanStore createBeanStore(UiContextReference key, Map<Key, Object> initialInstances) { final BeanStore beanStore = new BeanStore(); vaadinSession.setAttribute(key.asString(), beanStore); initialInstances.forEach(beanStore::put); eventBus.fireEvent(new BeanStoreLifecycleEvent.Create(key, beanStore)); return beanStore; }
@Override public void messageSent(final Message message) { if (ui.isAttached()) { ui.access(() -> eventBus.fireEvent(new MessageEvent(message, false))); } }
@Override public void messageRemoved(final String id) { if (ui.isAttached()) { ui.access(() -> eventBus.fireEvent(new MessageEvent(id, true))); } } }
private void sendSubAppLifecycleEvent(SubAppContext ctx, SubAppLifecycleEvent.Type type) { getSubAppEventBus(ctx).fireEvent(new SubAppLifecycleEvent(ctx.getSubAppDescriptor(), type)); }
@Override public void execute() throws ActionExecutionException { super.execute(); // Workaround because standard SaveDialogAction doesn't forward newly created JcrItemId to the editor callback, so we have to: // * fetch newly created node's itemId (no longer a JcrNewNodeItemId) // * use it to fire the ContentChangeEvent for the choose-dialog if (item instanceof JcrNewNodeAdapter) { try { Object itemId = JcrItemUtil.getItemId(((JcrNodeAdapter) item).getJcrItem()); admincentralEventBus.fireEvent(new ContentChangedEvent(itemId)); } catch (RepositoryException e) { log.info("Could not fetch the JCR item for the newly created asset.", e); } } }
@Override public void register(DefinitionProvider<EndpointDefinition> provider) { DefinitionMetadata registeredMetadata = getRegistryMap().put(onRegister(provider)); if (registeredMetadata != null) { DefinitionProvider<EndpointDefinition> decoratedProvider = getDecoratedDefinitionProvider(provider); systemEventBus.fireEvent(new EndpointDefinitionRegistryEvent(REGISTERED, decoratedProvider)); } }
@Test public void appLauncherLayoutChangedEventHandler() { DefinitionMetadata appMetadata1 = getDefinitionMetadata(appDescriptor1); DefinitionMetadata appMetadata2 = getDefinitionMetadata(appDescriptor2); DefinitionMetadata appMetadata3 = getDefinitionMetadata(appDescriptor3); final ArrayList<AppLauncherLayoutChangedEvent> events = new ArrayList<AppLauncherLayoutChangedEvent>(); systemEventBus.addHandler(AppLauncherLayoutChangedEvent.class, event -> events.add(event)); // WHEN systemEventBus.fireEvent(new AppRegistryEvent(appMetadata1, AppRegistryEventType.REGISTERED)); systemEventBus.fireEvent(new AppRegistryEvent(appMetadata2, AppRegistryEventType.REREGISTERED)); systemEventBus.fireEvent(new AppRegistryEvent(appMetadata3, AppRegistryEventType.UNREGISTERED)); // THEN assertThat(events, hasSize(3)); }
@Test public void isEnabledForValidSelection() { // GIVEN when(availabilityChecker.isAvailable(any(ConfiguredAvailabilityDefinition.class), anyList())).thenReturn(true); View view = renderer.start(actionDefinition, actionListener); // WHEN // applicable item change event is sent, should pass availability check chooseDialogEventBus.fireEvent(event); // THEN assertTrue(view.asVaadinComponent().isEnabled()); }
@Test public void isDisabledForInvalidSelection() { // GIVEN when(availabilityChecker.isAvailable(any(ConfiguredAvailabilityDefinition.class), anyList())).thenReturn(false); View view = renderer.start(actionDefinition, actionListener); // WHEN // non-applicable item change event is sent, shouldn't pass availability check chooseDialogEventBus.fireEvent(event); // THEN assertFalse(view.asVaadinComponent().isEnabled()); } }
@Test public void movePropertyIntoNode() throws Exception { //GIVEN action = new MoveNodeAction(definition, Arrays.asList(property1), node1, adminCentralEventBusMock, mock(UiContext.class), callback, new TreeViewDropHandler(null, null)); definition.setMoveLocation(MoveLocation.INSIDE); when(provider.newInstance(any(Class.class), anyVararg())).thenReturn(action); //WHEN executor.execute(MOVE_ACTION_NAME); //THEN assertThat(node1.getJcrItem(), hasProperty(PROPERTY_NAME_1)); assertThat(node2.getJcrItem(), not(hasProperty(PROPERTY_NAME_1))); verify(adminCentralEventBusMock, times(1)).fireEvent(any(ContentChangedEvent.class)); }
@Test public void moveNodeIntoNode() throws Exception { //GIVEN definition.setMoveLocation(MoveLocation.INSIDE); when(provider.newInstance(any(Class.class), anyVararg())).thenReturn(action); //WHEN executor.execute(MOVE_ACTION_NAME); //THEN assertThat(node3.getJcrItem(), hasNode(NODE_NAME_1)); assertThat(node3.getJcrItem(), hasNode(NODE_NAME_2)); verify(adminCentralEventBusMock, times(1)).fireEvent(any(ContentChangedEvent.class)); }
@Test public void contentChangedEventCheckIfItemCanBeHandledByContentConnector() throws Exception { // GIVEN given(contentConnector.canHandleItem(node.getIdentifier())).willReturn(true); given(contentConnector.getItem(anyObject())).willReturn(null); given(presenter.getSelectedItemIds()).willReturn(Lists.<Object>newArrayList(node.getIdentifier())); // Save the deletion request. node.remove(); session.save(); // WHEN admincentralEventBus.fireEvent(new ContentChangedEvent(node.getIdentifier())); // THEN verify(workbenchPresenter).select(eq(Collections.emptyList())); } }