Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Component


  public static final
  void outPageContent(Execution exec, Page page, Writer out, boolean au)
  throws IOException {
    final Desktop desktop = page.getDesktop();
    final PageCtrl pageCtrl = (PageCtrl)page;
    final Component owner = pageCtrl.getOwner();
    boolean contained = owner == null && exec.isIncluded();
      //a standalong page (i.e., no owner), and being included by
      //non-ZK page (e.g., JSP).
      //
      //Revisit Bug 2001707: OK to use exec.isIncluded() since
      //we use PageRenderer now (rather than Servlet's include)
      //TODO: test again

    //prepare style
    String style = page.getStyle();
    if (style == null || style.length() == 0) {
      style = null;
      String wd = null, hgh = null;
      if (owner instanceof HtmlBasedComponent) {
        final HtmlBasedComponent hbc = (HtmlBasedComponent)owner;
        wd = hbc.getWidth(); //null if not set
        hgh = hbc.getHeight(); //null if not set
      }

      if (wd != null || hgh != null || contained) {
        final StringBuffer sb = new StringBuffer(32);
        HTMLs.appendStyle(sb, "width", wd != null ? wd: "100%");
        HTMLs.appendStyle(sb, "height",
          hgh != null ? hgh: contained ? null: "100%");
        style = sb.toString();
      }
    }

    RenderContext rc = null, old = null;
    final boolean divRequired = !au || owner != null;
    final boolean standalone = !au && owner == null;
    if (standalone) {
      rc = new RenderContext(
        out, desktop.getWebApp().getConfiguration().isCrawlable());
      setRenderContext(exec, rc);
    } else if (owner != null) {
      old = getRenderContext(exec); //store
      setRenderContext(exec, null);
    }

    //generate div first
    if (divRequired) {
      outDivTemplateBegin(out, page.getUuid());
    }
    if (standalone) { //switch out
      //don't call outDivTemplateEnd yet since rc.temp will be generated before it
      out = new StringWriter();
    } else if (divRequired) {
      outDivTemplateEnd(out); //close it now since no rc.temp
    }

    //generate JS second
    final boolean aupg = exec.isAsyncUpdate(page); //AU this page
    if (divRequired) {
      out.write("\n<script type=\"text/javascript\">");
      if (!aupg && owner != null) {
        out.write("zkq('");
        out.write(owner.getUuid());
        out.write("',function(){");
      }
      out.write(outZkIconJS());
    }

    exec.setAttribute(ATTR_DESKTOP_JS_GENED, Boolean.TRUE);
    final int order = ComponentRedraws.beforeRedraw(false);
    final String extra;
    try {
      if (order < 0)
        out.write(aupg ? "[": divRequired ? "zkmx(": "zkx(");
      else if (order > 0) //not first child
        out.write(',');
      out.write("\n[0,'"); //0: page
      out.write(page.getUuid());
      out.write("',{");

      final StringBuffer props = new StringBuffer(128);
      final String pgid = page.getId();
      if (pgid.length() > 0)
        appendProp(props, "id", pgid);
      if (owner != null) {
        appendProp(props, "ow", owner.getUuid());
      } else {
        appendProp(props, "dt", desktop.getId());
        appendProp(props, "cu", getContextURI(exec));
        appendProp(props, "uu", desktop.getUpdateURI(null));
        appendProp(props, "ru", desktop.getRequestPath());
View Full Code Here


   *
   * @since 2.4.1
   * @see Treerow#getLinkedTreechildren
   */
  public Treerow getLinkedTreerow() {
    final Component parent = getParent();
    return parent instanceof Treeitem ?
      ((Treeitem)parent).getTreerow(): null;
  }
View Full Code Here

   */
  public boolean isVisible() {
    if (!super.isVisible())
      return false;

    Component comp = getParent();
    if (!(comp instanceof Treeitem))
      return true;
    if (!((Treeitem)comp).isOpen())
      return false;
    comp = comp.getParent();
    return !(comp instanceof Treechildren)
      || ((Treechildren)comp).isVisible(); //recursive
  }
View Full Code Here

    super.onChildRemoved(child);
    addVisibleItemCount(-((Treeitem)child).getVisibleItemCount());
  }
  void addVisibleItemCount(int count) {
    if (count == 0) return;
    Component parent = getParent();
    if (parent instanceof Treeitem) {
      if (((Treeitem)parent).isOpen())
        ((Treeitem)parent).addVisibleItemCount(count, false);
    } else if (parent instanceof Tree)
      ((Tree)parent).addVisibleItemCount(count);
View Full Code Here

    && !(parent instanceof Treeitem))
      throw new UiException("Wrong parent: "+parent);
    super.beforeParentChanged(parent);
  }
  public void setParent(Component parent) {
    final Component oldp = getParent();
    if (oldp == parent)
      return; //nothing changed

    final Tree oldtree = oldp != null ? getTree(): null;
View Full Code Here

  //-- Component --//
  public String getZclass() {
    return _zclass == null ? "z-treechildren" : _zclass;
  }
  protected void smartUpdate(String name, Object value) {
    Component comp = getParent();
    if (comp instanceof Treeitem)
      ((Treeitem)comp).getTreerow().smartUpdate(name, value);
    else
      ((Tree)comp).smartUpdate(name, value);
  }
View Full Code Here

    for (Iterator it = coll.iterator(); it.hasNext();) {
      final Object o = it.next();
      if (!(o instanceof Component))
        continue;

      final Component comp = (Component)o;
      final Page page = comp.getPage();
      if (page == null || !_exec.isAsyncUpdate(page)) {
        if (!bResponse) it.remove(); //just in case
        continue;
      }
View Full Code Here

    //1. scan once
    final Desktop desktop = _exec.getDesktop();
    Set pages = null;
    for (Iterator it = desktop.getPages().iterator(); it.hasNext();) {
      final Page page = (Page)it.next();
      final Component owner = ((PageCtrl)page).getOwner();
      if (owner != null) { //included
        final Page ownerPage = owner.getPage();
        if (ownerPage == null //detached
        || (_pgInvalid != null && _pgInvalid.contains(ownerPage))
        || isAncestor(_invalidated, owner, true)
        || isAncestor(_attached, owner, true)
        || isAncestor(removed, owner, true)) {
          addPageRemoved(page);
        } else {
          if (pages == null) pages = new LinkedHashSet();
          pages.add(page);
        }
      }
    }
    if (_pgRemoved == null || pages == null) return;
      //done if no page is removed or no more included page

    //2. if a page is ever removed, it might cause chain effect
    //so we have to loop until nothing changed
    boolean pgRemovedFound;
    do {
      pgRemovedFound = false;
      for (Iterator it = pages.iterator(); it.hasNext();) {
        final Page page = (Page)it.next();
        final Component owner = ((PageCtrl)page).getOwner();
        if (_pgRemoved.contains(owner.getPage())) {
          it.remove();
          addPageRemoved(page);
          pgRemovedFound = true;
        }
      }
View Full Code Here

//    if (D.ON && log.debugable()) log.debug("Page removed: "+page);
  }
  /** Clears components if it belongs to invalidated or removed page. */
  private void clearInInvalidPage(Collection coll) {
    for (Iterator it = coll.iterator(); it.hasNext();) {
      final Component comp = (Component)it.next();
      final Page page = comp.getPage();
      if (page != null
      && ((_pgRemoved != null && _pgRemoved.contains(page))
      ||  (_pgInvalid != null && _pgInvalid.contains(page))))
        it.remove();
    }
View Full Code Here

    }
    public Set getAvailableAtClient() {
      if (!isCropper()) return null;

      final Tree tree = getTree();
      final Component parent = getParent();
      final Execution exe = Executions.getCurrent();
      final String attrnm = VISIBLE_ITEM + tree.getUuid();
      Map map = (Map)exe.getAttribute(attrnm);
      if (map == null) {
        //Test very simple case first since getVisibleItems costly
        if (parent instanceof Treeitem) {
          for (Treeitem ti = (Treeitem)parent;;) {
            if (!ti.isOpen())
              return Collections.EMPTY_SET;
            Component gp = ti.getParent().getParent();
            if (!(gp instanceof Treeitem))
              break;
            ti = (Treeitem)gp;
          }
        }
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.