Esempio n. 1
0
 /**
  *
  * <li>功能描述:将树节点展开。
  *
  * @param chi void
  * @author DaLei
  */
 @SuppressWarnings("unchecked")
 private void openTree(Treechildren chi) {
   if (chi == null) return;
   List<Treeitem> tlist = chi.getChildren();
   for (int i = 0; i < tlist.size(); i++) {
     Treeitem item = (Treeitem) tlist.get(i);
     item.setOpen(true);
     openTree(item.getTreechildren());
   }
 }
Esempio n. 2
0
 /**
  *
  * <li>功能描述:将树节点展开并默认打开某个部门用户。
  *
  * @param chi
  * @param dept void
  * @author DaLei
  */
 @SuppressWarnings("unchecked")
 private void openTree(Treechildren chi, WkTDept dept) {
   if (chi == null) return;
   List<Treeitem> tlist = chi.getChildren();
   for (int i = 0; i < tlist.size(); i++) {
     Treeitem item = (Treeitem) tlist.get(i);
     WkTDept d = (WkTDept) item.getValue();
     if (d.getKdId().intValue() == dept.getKdId().intValue()) {
       tree.setSelectedItem(item);
       if (uWindow == null) {
         openListWindow(d);
       } else {
         uWindow.initWindow(d);
       }
     }
     if (d.getKdLevel() == WkTDept.GRADE_SCH.intValue()) item.setOpen(true);
     else item.setOpen(false);
     openTree(item.getTreechildren(), dept);
   }
 }
Esempio n. 3
0
  private void open(int level) {
    Treechildren treechildren = this.getTreechildren();

    for (int mylevel = 0; mylevel < level; mylevel++) {
      for (Object object : treechildren.getItems()) {
        if (object instanceof Treeitem) {
          Treeitem item = (Treeitem) object;
          item.setOpen(true);
          Events.sendEvent(item, new Event(Events.ON_OPEN, item));
          treechildren = item.getTreechildren();
          if (treechildren == null || treechildren.getChildren().size() == 0) {
            continue;
          }
          break;
        }
      }
    }
  }
  public Treeitem cargarHijosTreePorDemanda(
      Treechildren padre, String[] sec, String ids, boolean treeItemRenderMovimiento)
      throws Exception {
    log.info("Ejecutando el metodo [Treeitem cargarHijosTreePorDemanda...]");

    Component itemSelected = null;
    List<Component> listItem = padre.getChildren();
    Map<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("GRUPO", padre.getAttribute("grupo").toString());
    if (sec != null) {
      List<Component> arbol =
          ((Treechildren) ((Treeitem) listItem.get(0)).getChildren().get(1)).getChildren();
      for (int i = (sec.length - 1); i > 0; i--) {
        for (Component itemTree : arbol) {
          if (itemTree.getId().trim().equals(ids + sec[i])) {
            if (i == 1) {
              ((Treeitem) itemTree).setSelected(true);
              itemSelected = itemTree;
              break;
            } else {
              parameter.put("PADRE", sec[i]);
              List<MyItemTree> listaHijos =
                  (List<MyItemTree>)
                      ParametrizacionFac.getFacade()
                          .obtenerListado(itemTree.getAttribute("Consulta").toString(), parameter);
              Treechildren tchil = (Treechildren) itemTree.getChildren().get(1);
              tchil.getChildren().clear();
              for (MyItemTree myItemTree : listaHijos) {
                Treeitem tiHijo = new Treeitem();
                Treerow trow = new Treerow();
                Treecell tcEti = new Treecell(myItemTree.getEtiqueta());

                if (!treeItemRenderMovimiento) { // valida si se debe habilitar o no el componente
                                                 // dragdroptree
                  trow.setDroppable("true");
                  trow.setDraggable("true");
                }
                if (myItemTree.getParametros() != null) {
                  if (myItemTree.getParametros().equals("I")) {
                    trow.setStyle("background-color:#E3F6CE");

                  } else if (myItemTree.getParametros().equals("E")) {
                    trow.setStyle("background-color:#F6CECE");
                  }
                }
                if (myItemTree.getOtherValue() != null
                    && myItemTree.getOtherValue().toString().equals("N")) {
                  tcEti.setStyle("color:#BDBDBD;font-weight: bold");
                }

                tcEti.setTooltiptext(myItemTree.getEtiqueta());
                trow.appendChild(tcEti);
                trow.appendChild(
                    new Treecell(
                        myItemTree.getValor() != null ? myItemTree.getValor().trim() : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getPadre() != null ? myItemTree.getPadre().trim() : null));
                trow.appendChild(new Treecell(myItemTree.getNivel().toString()));
                trow.appendChild(
                    new Treecell(myItemTree.getId() != null ? myItemTree.getId().trim() : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getOtherValue() != null
                            ? myItemTree.getOtherValue().toString().trim()
                            : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getParametros() != null
                            ? myItemTree.getParametros().trim()
                            : null));

                trow.setAttribute("valor", myItemTree.getValor());
                trow.setAttribute("padre", myItemTree.getPadre());
                trow.setAttribute("nivel", myItemTree.getNivel());
                trow.setAttribute("llave", myItemTree.getId());
                trow.setAttribute("movimiento", myItemTree.getOtherValue());
                trow.setAttribute("parametros", myItemTree.getParametros());

                tiHijo.appendChild(trow);
                tiHijo.setId(ids + myItemTree.getId());
                tiHijo.setAttribute("Consulta", itemTree.getAttribute("Consulta"));
                tiHijo.setAttribute("grupo", itemTree.getAttribute("grupo"));
                if (padre.hasFellow(ids + myItemTree.getId()))
                  padre.getFellow(ids + myItemTree.getId());
                tchil.appendChild(tiHijo);
                if (myItemTree.getNumeroDescendientes() > 0) {
                  cargarHijosTreePorDemanda(
                      tiHijo, myItemTree.getId(), ids, treeItemRenderMovimiento);
                }
              }
              ((Treeitem) itemTree).setOpen(true);
              arbol = ((Treechildren) itemTree.getChildren().get(1)).getChildren();
              break;
            }
          }
        }
      }
    } else {
      itemSelected = (Treeitem) listItem.get(0);
      ((Treeitem) listItem.get(0)).setSelected(true);
    }
    return ((Treeitem) itemSelected);
  }
  public void cargarHijosTreePorDemanda(
      Treeitem ti, final String sec, final String ids, final boolean treeItemRenderMovimiento) {
    log.info("Ejecutando el metodo [void cargarHijosTreePorDemanda...]");

    final String consulta = ti.getAttribute("Consulta").toString();
    final Treechildren hijo = new Treechildren();
    final String grupo = ti.getAttribute("grupo").toString();
    final Map<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("GRUPO", grupo);
    parameter.put("PADRE", sec);
    ti.appendChild(hijo);
    ti.setOpen(false);
    ti.addEventListener(
        "onOpen",
        new EventListener<Event>() {
          public void onEvent(Event arg0) throws Exception {
            OpenEvent oe = (OpenEvent) arg0;
            if (oe.isOpen()) {
              List<MyItemTree> listaHijos =
                  (List<MyItemTree>)
                      ParametrizacionFac.getFacade().obtenerListado(consulta, parameter);
              hijo.getChildren().clear();
              for (MyItemTree myItemTree : listaHijos) {
                Treeitem tiHijo = new Treeitem();
                Treerow trow = new Treerow();
                Treecell tcEti = new Treecell(myItemTree.getEtiqueta());

                if (!treeItemRenderMovimiento) { // valida si se debe habilitar o no el componente
                                                 // dragdroptree
                  trow.setDroppable("true");
                  trow.setDraggable("true");
                }

                if (myItemTree.getParametros() != null) {
                  if (myItemTree.getParametros().equals("I")) {
                    trow.setStyle("background-color:#E3F6CE");

                  } else if (myItemTree.getParametros().equals("E")) {
                    trow.setStyle("background-color:#F6CECE");
                  }
                }
                if (myItemTree.getOtherValue() != null
                    && myItemTree.getOtherValue().toString().equals("N")) {
                  tcEti.setStyle("color:#BDBDBD;font-weight: bold");
                }

                tcEti.setTooltiptext(myItemTree.getEtiqueta());

                trow.appendChild(tcEti);
                trow.appendChild(
                    new Treecell(
                        myItemTree.getValor() != null ? myItemTree.getValor().trim() : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getPadre() != null ? myItemTree.getPadre().trim() : null));
                trow.appendChild(new Treecell(myItemTree.getNivel().toString()));
                trow.appendChild(
                    new Treecell(myItemTree.getId() != null ? myItemTree.getId().trim() : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getOtherValue() != null
                            ? myItemTree.getOtherValue().toString().trim()
                            : null));
                trow.appendChild(
                    new Treecell(
                        myItemTree.getParametros() != null
                            ? myItemTree.getParametros().trim()
                            : null));

                trow.setAttribute("valor", myItemTree.getValor());
                trow.setAttribute("padre", myItemTree.getPadre());
                trow.setAttribute("nivel", myItemTree.getNivel());
                trow.setAttribute("llave", myItemTree.getId());
                trow.setAttribute("movimiento", myItemTree.getOtherValue());
                trow.setAttribute("parametros", myItemTree.getParametros());

                tiHijo.appendChild(trow);
                tiHijo.setId(ids + myItemTree.getId());
                tiHijo.setAttribute("Consulta", consulta);
                tiHijo.setAttribute("grupo", grupo);
                hijo.appendChild(tiHijo);
                if (myItemTree.getNumeroDescendientes() > 0) {
                  cargarHijosTreePorDemanda(
                      tiHijo, myItemTree.getId(), ids, treeItemRenderMovimiento);
                }
              }
            }
          }
        });
  }