/** * Triggers document view mode. */ public void onClick$btnView() { Events.postEvent("onViewOpen", root, true); }
/** Echos an event. * By echo we mean the event is fired after the client receives the AU * responses and then echoes back. * In other words, the event won't be processed in the current execution. * Rather, it executes after the client receives the AU responses * and then echoes back the event back. * * <p>It is usually if you want to prompt the user before doing a long * operation. A typical case is to open a highlighted window to * prevent the user from clicking any button before the operation gets done. * * <p>It is the same as <code>echoEvent(name, target, (Object)data)</code>. * * @since 3.0.2 * @see #sendEvent * @see #echoEvent(String, Component, Object) * @param name the event name, such as onSomething * @param target the component to receive the event (never null). * @param data the extra information, or null if not available. * It will become {@link Event#getData}. */ public static final void echoEvent(String name, Component target, String data) { echoEvent(name, target, (Object) data); }
public void onEvent(Event event) { Events.sendEvent(Tabbox.this, event); }
/*package*/ static void postOnCreateEvents(Component item) { for (final Iterator it = item.getChildren().iterator(); it.hasNext();) { final Component child = (Component) it.next(); postOnCreateEvents(child); //recursive } if (Events.isListened(item, Events.ON_CREATE, false)) { Events.postEvent(new CreateEvent(Events.ON_CREATE, item, null)); } } }
refs.add(dataTarget); bindings.add(binding); Events.sendEvent(new BindingSaveEvent("onBindingSave", dataTarget, target, binding, vals[0])); refs.add(dataTarget1); bindings.add(binding); Events.sendEvent( new BindingSaveEvent("onBindingSave", dataTarget1, target, binding, vals[0])); Events.sendEvent(new BindingValidateEvent("onBindingValidate", target, refs, bindings, values)); Events.postEvent(new Event("onLoadOnSave", loadOnSaveProxy, loadOnSaveInfos));
public boolean isDeferrable() { return !Events.isListened(Tabbox.this, Events.ON_SELECT, true); } }
public boolean addEventListener(int priority, String evtnm, EventListener<? extends Event> listener) { if (evtnm == null || listener == null) throw new IllegalArgumentException("null"); if (!Events.isValid(evtnm)) throw new IllegalArgumentException("Invalid event name: " + evtnm); final boolean oldasap = Events.isListened(this, evtnm, true); desktop.setAttribute("org.zkoss.desktop.visibilitychange.enabled", true); } else if (getClientEvents().containsKey(evtnm)) { final boolean asap = Events.isListened(this, evtnm, true); if (lis.size() == 1 || oldasap != asap) smartUpdate("$" + evtnm, asap);
public boolean activateServerPush(long timeout) throws InterruptedException { checkSeverPush("activate"); if (Events.inEventListener() && Executions.getCurrent().getDesktop() == this) throw new IllegalStateException("No need to invoke Executions.activate() in an event listener"); if (log.isDebugEnabled()) { log.debug("activateServerPush, timeout is [{}]", timeout); } return _spush.activate(timeout); }
if (Events.isListened(_comp, Events.ON_CREATE, false))//send onCreate event... Events.postEvent( new CreateEvent(Events.ON_CREATE, _comp, Executions.getCurrent().getArg()));
/** * First, posts any pending echo requests to the event queue. Then empties the event queue, * sending each queued event to its target. Finally, processes any events on the server push * event queue. * * @return True if events were flushed. */ public boolean flushEvents() { Event event; boolean result = false; for (AuEcho echo : execution.getEchoedEvents()) { Events.postEvent(toEvent(echo)); } execution.getEchoedEvents().clear(); while ((event = execution.getNextEvent()) != null) { Events.sendEvent(event); result = true; } result |= serverPush.flush(); return result; }
public boolean removeEventListener(String evtnm, EventListener<? extends Event> listener) { if (evtnm == null || listener == null) throw new IllegalArgumentException("null"); if (_auxinf != null && _auxinf.listeners != null) { final boolean oldasap = Events.isListened(this, evtnm, true); final List<EventListenerInfo> lis = _auxinf.listeners.get(evtnm); if (lis != null) { for (Iterator<EventListenerInfo> it = lis.iterator(); it.hasNext();) { final EventListenerInfo li = it.next(); if (li.listener.equals(listener)) { it.remove(); if (lis.isEmpty()) _auxinf.listeners.remove(evtnm); final Desktop desktop = getDesktop(); if (desktop != null) { onListenerChange(desktop, false); if (getClientEvents().containsKey(evtnm)) { if (lis.isEmpty() && !Events.isListened(this, evtnm, false)) smartUpdate("$" + evtnm, (Object) null); //no listener at all else if (oldasap != Events.isListened(this, evtnm, true)) smartUpdate("$" + evtnm, !oldasap); } } return true; } } } } return false; }
if (!Events.inEventListener()) throw new SuspendNotAllowedException("doModal must be called in an event listener");
/** * mark a draw flag to inform that this Chart needs update. */ protected void smartDrawChart() { if (_smartDrawChart) { //already mark smart draw return; } _smartDrawChart = true; Events.postEvent("onSmartDrawChart", this, null); }
public void onPiggyback() { //Note: we don't post ON_PIGGYBACK twice in an execution //(performance concern and back-compatibility). if (_piggybackListened && Executions.getCurrent().getAttribute(ATTR_PIGGYBACK_POSTED) == null) { for (Page page : _pages) { if (Executions.getCurrent().isAsyncUpdate(page)) { //ignore new created pages for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) { if (Events.isListened(root, Events.ON_PIGGYBACK, false)) { //asap+deferrable Events.postEvent(new Event(Events.ON_PIGGYBACK, root)); Executions.getCurrent().setAttribute(ATTR_PIGGYBACK_POSTED, Boolean.TRUE); } } } } } if (!_schedInfos.isEmpty()) Events.postEvent(ON_SCHEDULE, _dummyTarget, null); //we could not process them here (otherwise, event handling, thread //might not work) //Thus, we post an event and handle it in _dummyTarget if (_spush != null) _spush.onPiggyback(); }
/** Sends the event to the target specified in the event, and processes it immediately. * * <p>Note: {@link Event#getTarget} cannot be null. */ public static void sendEvent(Event event) { sendEvent(event.getTarget(), event); }
/** * Restarts the timer. */ private void resetTimer() { if (timer != null) { timer.stop(); Events.echoEvent("onResetTimer", timer, null); } }
private void onListenerChange(Desktop desktop, boolean listen) { if (listen) { if (Events.isListened(this, Events.ON_CLIENT_INFO, false)) { //asap+deferrable response(new AuClientInfo(desktop)); getDesktop().setAttribute("org.zkoss.desktop.clientinfo.enabled", true); //We always fire event not a root, since we don't like to //check when setParent or setPage is called } if (Events.isListened(this, Events.ON_PIGGYBACK, false)) ((DesktopCtrl) desktop).onPiggybackListened(this, true); if (Events.isListened(this, Events.ON_VISIBILITY_CHANGE, false)) getDesktop().setAttribute("org.zkoss.desktop.visibilitychange.enabled", true); } else { if (!Events.isListened(this, Events.ON_PIGGYBACK, false)) ((DesktopCtrl) desktop).onPiggybackListened(this, false); } }
/** * Force focus to the password text box. */ public void onBlur$txtPassword() { Events.postEvent(Events.ON_FOCUS, this, null); }
/** Sends the event to the target, and processes it immediately. * @param target the target of the event (never null) * @since 5.0.4 */ public static void sendEvent(String name, Component target, Object data) { sendEvent(new Event(name, target, data)); }
/** * Restarts the timer. */ private void resetTimer() { if (timer != null) { timer.stop(); Events.echoEvent("onResetTimer", timer, null); } }