Beispiel #1
0
 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;
 }
Beispiel #2
0
 /**
  * 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"));
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
  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));
  }
Beispiel #5
0
  /**
   * 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);
  }