/** * Unregisters the event listener currently being invoked. * <p> * This method can only be called from within an event listener. Calling it * will remove the current event listener so no further events are passed to * it. */ public void unregisterListener() { if (unregisterListenerCommand == null) { throw new IllegalStateException( "unregisterListener can only be called inside the event listener"); } unregisterListenerCommand.execute(); }
@Override public void update(Command command) { lock(); try { command.execute(); } finally { unlock(); } }
private static void runOnAttach(StateNode node, Command command) { node.addAttachListener(command); if (node.isAttached()) { command.execute(); } }
event -> command.execute(), key).withModifiers(keyModifiers);
event -> command.execute(), key).withModifiers(keyModifiers);
private void runBeforeClientResponse(Command command) { getElement().getNode() .runWhenAttached(ui -> ui.getInternals().getStateTree() .beforeClientResponse(getElement().getNode(), context -> command.execute())); }
try { old = CurrentInstance.setCurrent(this); command.execute(); } finally { unlock();
private void accessSynchronously(Command command, SerializableRunnable detachHandler) { Map<Class<?>, CurrentInstance> old = null; VaadinSession session = getSession(); if (session == null) { handleAccessDetach(detachHandler); return; } VaadinService.verifyNoOtherSessionLocked(session); session.lock(); try { if (getSession() == null) { // UI was detached after fetching the session but before we // acquired the lock. handleAccessDetach(detachHandler); return; } old = CurrentInstance.setCurrent(this); command.execute(); } finally { session.unlock(); if (old != null) { CurrentInstance.restoreInstances(old); } } }
public void initView() { VerticalLayout content = getContent(); content.removeAll(); if (holder.getNotificationSize() > 0) { content.add(this.holder.getNotificationViews(showAll)); getElement().getClassList().add(Styles.APP_BAR_NOTIFICATION_LIST); if (! showAll && this.holder.getNotificationSize() > 4) { showAllButton = new Button(showAllText); showAllButton.setWidth("100%"); showAllButton.setHeight("28px"); showAllButton.addClickListener(clickEvent -> showAllCommand.execute()); content.add(showAllButton); } } else { noNotificationsLabel = new Label(noNotificationText); noNotificationsLabel.getStyle().set("color" , "var(--lumo-shade)") .set("font-size" , "var(--lumo-size-xxs)"); HorizontalLayout wrapper = new HorizontalLayout(noNotificationsLabel); wrapper.setWidth("100%"); wrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); PaperCard card = new PaperCard(wrapper); card.setWidth("100%"); card.getElement().getStyle().set("box-shadow" , "var(--app-layout-notification-shadow)"); content.add(card); } }