private String getUuid(AuRequest request) { final Component comp = request.getComponent(); if (comp != null) return comp.getUuid(); final Page page = request.getPage(); if (page != null) return page.getUuid(); return null; }
/** * Processes an AU request. * * <p>Default: in addition to what are handled by {@link XulElement#service}, it also handles * onTimeZoneChange, onChange, onChanging and onError. * * @since 5.0.0 */ public void service(org.zkoss.zk.au.AuRequest request, boolean everError) { final String cmd = request.getCommand(); if (cmd.equals("onTimeZoneChange")) { final Map<String, Object> data = request.getData(); String timezone = (String) data.get("timezone"); setTimeZone(timezone); } else super.service(request, everError); }
/** * Converts an AU request to a selection event. * * @since 5.0.0 */ public static final SelectionEvent getSelectionEvent(AuRequest request) { final Map data = request.getData(); return new SelectionEvent( request.getCommand(), request.getComponent(), AuRequests.getInt(data, "start", 0), AuRequests.getInt(data, "end", 0), (String) data.get("selected")); }
private static boolean isObsolete(AuRequest request) { final Component comp = request.getComponent(); if (comp != null) { final Desktop dt = comp.getDesktop(); return dt != null && dt != request.getDesktop(); // Since 3.5.0, we allow a component to process events even // if it is detached (due to implementation of EventQueue) } return false; }
public void addRequests(Collection requests) { for (Iterator it = requests.iterator(); it.hasNext(); ) { final AuRequest request = (AuRequest) it.next(); try { request.activate(); if (!isObsolete(request)) addRequest(request); } catch (ComponentNotFoundException ex) { // ignore it // ignore it since a long request might remove a timer // while clients already queues onTimer generated by the timer if (log.debugable()) log.debug("Ignore request: " + ex.getMessage()); } } }
public static final ResizeEvent getResizeEvent(AuRequest request) { final Component comp = request.getComponent(); if (comp == null) throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, request); final Map data = request.getData(); if (data == null) throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] {data, request}); return new ResizeEvent( request.getCommand(), comp, AuRequests.getInt(data, "width", 0), AuRequests.getInt(data, "height", 0)); }
/** * Processes an AU request. * * <p>Default: in addition to what are handled by {@link HtmlBasedComponent#service}, it also * handles onOpen. * * @since 5.0.0 */ public void service(org.zkoss.zk.au.AuRequest request, boolean everError) { final String cmd = request.getCommand(); if (cmd.equals(Events.ON_TIMER)) { if (!_repeats) _running = false; // Bug 1829397 } super.service(request, everError); }
/** * Processes an AU request. * * <p>Default: in addition to what are handled by {@link XulElement#service}, it also handles * onOpen. * * @since 5.0.0 */ public void service(org.zkoss.zk.au.AuRequest request, boolean everError) { final String cmd = request.getCommand(); if (cmd.equals(Events.ON_OPEN)) { OpenEvent evt = OpenEvent.getOpenEvent(request); setVisible(evt.isOpen()); Events.postEvent(evt); } else if (cmd.equals(Events.ON_MAXIMIZE)) { MaximizeEvent evt = MaximizeEvent.getMaximizeEvent(request); setLeftDirectly(evt.getLeft()); setTopDirectly(evt.getTop()); setWidthDirectly(evt.getWidth()); setHeightDirectly(evt.getHeight()); _maximized = evt.isMaximized(); if (_maximized) setVisibleDirectly(true); Events.postEvent(evt); } else if (cmd.equals(Events.ON_MINIMIZE)) { MinimizeEvent evt = MinimizeEvent.getMinimizeEvent(request); setLeftDirectly(evt.getLeft()); setTopDirectly(evt.getTop()); setWidthDirectly(evt.getWidth()); setHeightDirectly(evt.getHeight()); _minimized = evt.isMinimized(); if (_minimized) { setVisibleDirectly(false); if (_mode == MODAL) leaveModal(OVERLAPPED); } Events.postEvent(evt); } else super.service(request, everError); }
/** * Processes an AU request. * * <p>Default: in addition to what are handled by {@link LabelImageElement#service}, it also * handles onCheck. * * @since 5.0.0 */ public void service(org.zkoss.zk.au.AuRequest request, boolean everError) { final String cmd = request.getCommand(); if (cmd.equals(Events.ON_CHECK)) { CheckEvent evt = CheckEvent.getCheckEvent(request); _checked = evt.isChecked(); Events.postEvent(evt); } else super.service(request, everError); }
public boolean shallBlock(AuRequest request) { // B50-3316103: special case of readonly component: do not block onChange and onSelect final String cmd = request.getCommand(); if (Events.ON_OPEN.equals(cmd)) return false; return !Components.isRealVisible(Datebox.this) || isDisabled() || (isReadonly() && Events.ON_CHANGING.equals(cmd)); }
/** * Processes an AU request. * * <p>Default: in addition to what are handled by its superclass, it also handles onSort. * * @since 6.5.0 */ public void service(org.zkoss.zk.au.AuRequest request, boolean everError) { final String cmd = request.getCommand(); if (cmd.equals(Events.ON_SORT)) { SortEvent evt = SortEvent.getSortEvent(request); Events.postEvent(evt); } else if (cmd.equals(Events.ON_GROUP)) { final Map<String, Object> data = request.getData(); final boolean ascending = AuRequests.getBoolean(data, ""); Events.postEvent(new SortEvent(cmd, this, ascending)); // internal use, and it should be invoked after onGroup event. Events.postEvent(-1000, new SortEvent("onGroupLater", this, ascending)); } else if (cmd.equals(Events.ON_UNGROUP)) { final Map<String, Object> data = request.getData(); final boolean ascending = AuRequests.getBoolean(data, ""); ungroup(ascending); Events.postEvent(new SortEvent(cmd, request.getComponent(), ascending)); } else super.service(request, everError); }
private void addRequest(AuRequest request) { // case 1, BUSY_IGNORE: Drop any existent ignorable requests // We don't need to iterate all because requests is added one-by-one // In other words, if any temporty request, it must be the last { int last = _requests.size() - 1; if (last < 0) { // optimize the most common case _requests.add(request); return; } final AuRequest req2 = (AuRequest) _requests.get(last); if ((req2.getOptions() & AuRequest.BUSY_IGNORE) != 0) { _requests.remove(last); // drop it if (last == 0) { _requests.add(request); return; } } } final String name = request.getCommand(); final int opts = request.getOptions(); // Since 3.0.2, redundant CTRL_GROUP is removed at the client // case 2, DUPLICATE_IGNORE: drop existent request if they are the same // as the arrival. if ((opts & AuRequest.DUPLICATE_IGNORE) != 0) { final String uuid = getUuid(request); for (Iterator it = _requests.iterator(); it.hasNext(); ) { final AuRequest req2 = (AuRequest) it.next(); if (req2.getCommand().equals(name) && Objects.equals(getUuid(req2), uuid)) { it.remove(); // drop req2 (the old one) break; // no need to iterate because impossible to have more } } // Case 3, REPEAT_IGNORE: drop existent if the immediate // following is the same } else if ((opts & AuRequest.REPEAT_IGNORE) != 0) { final int last = _requests.size() - 1; final AuRequest req2 = (AuRequest) _requests.get(last); if (req2.getCommand().equals(name) && Objects.equals(getUuid(req2), getUuid(request))) { _requests.remove(last); } } _requests.add(request); }