private void addValue_(CfgValue newValue) {
   cfgValue.addValue(newValue);
   if (!embed) {
     mainPanel.removeChild(saveBtn);
   }
   Component elePane = createPane(newValue);
   mainPanel.appendChild(elePane);
   if (!embed) {
     mainPanel.appendChild(saveBtn);
   }
 }
    protected void renderEditors(final Component parent) {
      final DefaultLiveEditBrowserModel model = (DefaultLiveEditBrowserModel) getModel();
      final PreviewDataModel previewData = model.getPreviewData();

      if (previewData != null) {
        final TypedObject previewDataTO = getTypeService().wrapItem(previewData);

        final Collection<EditorRowConfiguration> rowConfigs =
            getRowConfigs(previewDataTO.getType());
        final Collection<PropertyDescriptor> props = new ArrayList<PropertyDescriptor>();
        for (final EditorRowConfiguration row : rowConfigs) {
          props.add(row.getPropertyDescriptor());
        }
        final ObjectValueContainer valueContainer =
            TypeTools.createValueContainer(
                previewDataTO,
                new HashSet<PropertyDescriptor>(props),
                UISessionUtils.getCurrentSession().getSystemService().getAvailableLanguageIsos());

        int index = 0;
        Hbox singleRow = null;
        for (final EditorRowConfiguration row : rowConfigs) {
          if (index % EDITORS_PER_ROW == 0) {
            singleRow = new Hbox();
            parent.appendChild(singleRow);
          }
          singleRow.appendChild(createEditor(previewDataTO, row, valueContainer));
          index++;
        }
      }
    }
 protected void injectSites(final Component parent) {
   boolean first = true;
   for (final CMSSiteModel site : getCmsCockpitService().getSites()) {
     if (first) {
       first = false;
     } else {
       final Space space = new Space();
       space.setOrient("vertical");
       space.setWidth("3px");
       space.setHeight("154px");
       space.setStyle("float: left; margin-right: 3px;");
       space.setBar(true);
       parent.appendChild(space);
     }
     parent.appendChild(new SiteBox(site));
   }
 }
 protected void restoreHeader() {
   layout.getNorth().setVisible(true);
   max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
   showHeader.setVisible(false);
   pnlHead.detach();
   headerContainer.appendChild(pnlHead);
   Clients.resize(pnlHead);
   updateHeaderCollapsedPreference(false);
 }
 private Component createBody_listOrMap() {
   mainPanel = new Vlayout();
   for (CfgValue cCfgValue : cfgValue.getValues()) {
     Component elePane = createPane(cCfgValue);
     mainPanel.appendChild(elePane);
   }
   createSaveBtn();
   return mainPanel;
 }
 protected CfgValueViewer(CfgValue cfgValue, Component viewParent, boolean embed) {
   this.cfgValue = cfgValue;
   this.embed = embed;
   this.viewParent = viewParent;
   //
   createView();
   if (!embed && viewParent != null) { // in dialog,viewParent is null
     viewParent.appendChild(view);
   }
 }
 private void deleteValue(Component btn) {
   CfgValue deleteCfgValue = (CfgValue) btn.getAttribute("cfgValue");
   CfgValue parent = deleteCfgValue.getParent();
   if (parent.getCfgInfo().getType().isStruct()) {
     buttonPanel.appendChild(createAddPartBtn(deleteCfgValue.getCfgInfo()));
     addBtn.setVisible(true);
   }
   parent.removeValue(deleteCfgValue);
   ((Component) btn.getAttribute("partPane")).setParent(null);
 }
  @Override
  protected MenuFactoryDto createMenuComponent(Component parent) {
    DefaultDropDownMenu menu = new DefaultDropDownMenu();
    parent.appendChild(menu);

    Menupopup menupopup = new Menupopup();
    menu.appendChild(menupopup);

    return new MenuFactoryDto(menupopup, menu);
  }
 private Component createBody_struct() {
   buttonPanel = new Vlayout();
   //
   mainPanel = new Vlayout();
   ((Vlayout) mainPanel).setSpacing("0.5em");
   //
   CfgInfo cfgInfo = cfgValue.getCfgInfo();
   for (CfgInfo cCfgInfo : cfgInfo.getPartsInfo()) {
     CfgValue cCfgValue = cfgValue.getValue(cCfgInfo.getId());
     if (cCfgValue == null) {
       Button btn = createAddPartBtn(cCfgInfo);
       buttonPanel.appendChild(btn);
     } else {
       Component partPane = createPane(cCfgValue);
       mainPanel.appendChild(partPane);
     }
   }
   createSaveBtn();
   addBtn.setVisible(!buttonPanel.getChildren().isEmpty());
   return mainPanel;
 }
  /// Showd Data on grid table
  public void showgrid() {
    for (Component c : find(this.getPage(), "#showsell > rows > row")) {
      c.detach();
    }
    float sumallprice = 0;
    for (int i = 0; i < pointcount; i++) {
      Row r = new Row();
      r.appendChild(new Label(Integer.toString(idpro.get(i))));
      r.appendChild(new Label(nameproduct.get(i)));
      r.appendChild(new Label(Integer.toString(qty.get(i))));
      r.appendChild(new Label(Integer.toString(unitprice.get(i))));
      r.appendChild(new Label(Integer.toString(price.get(i))));
      r.appendChild(new Label(namecus.get(i)));
      Button but = new Button("Delete");
      but.setId("" + i);
      but.addEventListener(
          "onClick",
          new EventListener() {
            public void onEvent(Event ee) {
              nameproduct.remove(Integer.parseInt(ee.getTarget().getId()));
              qty.remove(Integer.parseInt(ee.getTarget().getId()));
              unitprice.remove(Integer.parseInt(ee.getTarget().getId()));
              price.remove(Integer.parseInt(ee.getTarget().getId()));
              namecus.remove(Integer.parseInt(ee.getTarget().getId()));
              pointcount--;
              txtsum.setValue("0");
              txtvat.setValue("0");
              idsumprice.setValue("0");
              showgrid();
            }
          });
      r.appendChild(but);
      Component v = find(this.getPage(), "#showsell > rows").get(0);
      v.appendChild(r);
      sumallprice = sumallprice + price.get(i);
      float vatc1;
      String vatc2;
      for (Customereng vc : Customereng.findAllCustomerengs()) {
        vatc2 = vc.getTax();
        vatc1 = Float.parseFloat(vatc2);

        float vat = (sumallprice * vatc1) / 100;
        float sumtotal = vat + sumallprice;
        txtsum.setValue(Float.toString(sumallprice));
        txtvat.setValue(Float.toString(vat));
        idsumprice.setValue(Float.toString(sumtotal));
      }
    }
  }
  private void createSaveBtn() {
    if (!embed) {
      saveBtn = new Button("保存");
      saveBtn.addEventListener(
          Events.ON_CLICK,
          new EventListener<MouseEvent>() {

            @Override
            public void onEvent(MouseEvent event) throws Exception {
              saveValue();
            }
          });
      mainPanel.appendChild(saveBtn);
    }
  }
  @Override
  public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);

    GenericValue userLogin =
        (GenericValue) comp.getDesktop().getSession().getAttribute("userLogin");

    GenericDelegator delegator = (GenericDelegator) userLogin.getDelegator();
    if (delegator == null) GenericDelegator.getGenericDelegator("default");

    GenericValue person = userLogin.getRelatedOne("Person");

    Map<String, Object> allFields = person.getAllFields();

    int count = 0;

    Collection<Component> leftHalf = new LinkedList<Component>();
    Collection<Component> rightHalf = new LinkedList<Component>();
    Label label = null;
    Label labelDesc = null;
    for (String key : allFields.keySet()) {

      Object obj = allFields.get(key);
      label = new Label();
      labelDesc = new Label();
      labelDesc.setValue(key);
      label.setValue(obj != null ? obj.toString() : "");
      Hbox hbox = new Hbox(new Component[] {labelDesc, label});
      if (count % 2 == 0) {
        leftHalf.add(hbox);
      } else {
        rightHalf.add(hbox);
      }
      count++;
    }

    Vbox vbox_1 = new org.zkoss.zul.Vbox(leftHalf.toArray(new Component[leftHalf.size()]));
    Vbox vbox_2 = new org.zkoss.zul.Vbox(rightHalf.toArray(new Component[rightHalf.size()]));
    comp.appendChild(vbox_1);
    comp.appendChild(vbox_2);
  }
  private void inicializar() {
    contenedor.getChildren().clear();
    gridResultados = new Grid();
    gridResultados.setMold("paging");
    gridResultados.setPageSize(20);
    auxheadResultados = new Auxhead();
    columnsResultados = new Columns();

    Auxheader auxheader = new Auxheader();
    auxheader.setAlign("center");
    if (tipo_examen.equals(TIPO_PARACLINICO)) {
      auxheader.setLabel("REGISTROS DE RESULTADOS PARACLINICOS");
    } else if (tipo_examen.equals(TIPO_VALORACION_OBSTETRICA)) {
      auxheader.setLabel("REGISTROS DE VALORACION OBSTETRICA");
    }
    auxheader.setColspan(3);
    auxheadResultados.appendChild(auxheader);

    gridResultados.appendChild(auxheadResultados);

    Column column = new Column("");
    if (tipo_examen.equals(TIPO_PARACLINICO)) {
      column.setLabel("Paraclinico");
    } else if (tipo_examen.equals(TIPO_VALORACION_OBSTETRICA)) {
      column.setLabel("V. obstetrica");
    }
    column.setWidth("170px");
    columnsResultados.appendChild(column);

    column = new Column("Fecha");
    column.setWidth("120px");
    columnsResultados.appendChild(column);

    column = new Column("Resultado");
    column.setWidth("120px");
    columnsResultados.appendChild(column);

    gridResultados.appendChild(columnsResultados);

    Frozen frozen = new Frozen();
    frozen.appendChild(new Div());
    frozen.setColumns(3);

    gridResultados.appendChild(frozen);

    rowsResultado = new Rows();

    Map<String, Object> parametros = new HashMap<String, Object>();
    parametros.put("codigo_empresa", zkWindow.codigo_empresa);
    parametros.put("codigo_sucursal", zkWindow.codigo_sucursal);
    parametros.put("codigo_historia", pcodigo_historia);
    parametros.put("tipo_examen", tipo_examen);

    List<Phistorias_paraclinicos> listado =
        zkWindow.getServiceLocator().getPhistorias_paraclinicosService().listar(parametros);

    for (Phistorias_paraclinicos phistorias_paraclinicos : listado) {
      Row row_fila = new Row();
      Cell celda =
          Utilidades.obtenerCell(
              phistorias_paraclinicos.getPexamenes_paraclinicos().getNombre(),
              Textbox.class,
              true,
              true);
      row_fila.appendChild(celda);

      celda = Utilidades.obtenerCell(null, Datebox.class, false, false);
      Datebox datebox_fecha = (Datebox) celda.getFirstChild();
      datebox_fecha.setId(
          "datebox_fecha_"
              + tipo_examen
              + "_"
              + pcodigo_historia
              + "_"
              + phistorias_paraclinicos.getCodigo_examen());
      row_fila.appendChild(celda);

      celda = Utilidades.obtenerCell("", Textbox.class, true, false);
      Textbox textbox_resultado = (Textbox) celda.getFirstChild();
      textbox_resultado.setId(
          "textbox_resultado_"
              + tipo_examen
              + "_"
              + pcodigo_historia
              + "_"
              + phistorias_paraclinicos.getCodigo_examen());
      final Popup popupResultados =
          generarPopupResultados(
              textbox_resultado, false, phistorias_paraclinicos.getPexamenes_paraclinicos());
      textbox_resultado.setPopup(popupResultados);
      row_fila.appendChild(celda);

      row_fila.setValue(phistorias_paraclinicos);
      rowsResultado.appendChild(row_fila);
    }

    gridResultados.appendChild(rowsResultado);

    contenedor.appendChild(gridResultados);
  }
  public Popup generarPopupResultados(
      Textbox textboxResultado, boolean readonly, Pexamenes_paraclinicos pexamenes_paraclinicos) {
    // final Image image = (Image)form.getFellow("img_"+id_alumno);
    final Textbox tbxRes = textboxResultado;
    // popup.setId("popupResultados_" + key);
    Vlayout vlayout = new Vlayout();

    if (pexamenes_paraclinicos.getNormal_anormal().equals("S")) {
      String valor_na = (String) tbxRes.getAttribute("VALOR_NORMAL_ANORMAL");
      String valor_descripcion_na = (String) tbxRes.getAttribute("VALOR_DESCRIPCION_NA");
      final Radiogroup radiogroup_anormal = new Radiogroup();
      Radio radio_normal = new Radio("Normal");
      radio_normal.setValue("N");
      radiogroup_anormal.appendChild(radio_normal);
      radiogroup_anormal.appendChild(new Space());
      Radio radio_anormal = new Radio("Anormal");
      radio_anormal.setValue("A");
      radiogroup_anormal.appendChild(radio_anormal);

      vlayout.appendChild(radiogroup_anormal);

      final Textbox textbox_anormal = new Textbox();
      textbox_anormal.setWidth("400px");
      textbox_anormal.setRows(4);
      textbox_anormal.setVisible(false);

      if (valor_na != null) {
        if (valor_na.equals("S")) {
          radio_normal.setChecked(true);
          radio_anormal.setChecked(false);
          textbox_anormal.setVisible(true);
        } else {
          radio_anormal.setChecked(true);
          radio_normal.setChecked(false);
          textbox_anormal.setVisible(false);
        }
      } else {
        radio_normal.setChecked(true);
        radio_anormal.setChecked(false);
        textbox_anormal.setVisible(false);
      }

      if (valor_descripcion_na != null) {
        textbox_anormal.setValue(valor_descripcion_na);
      }

      radiogroup_anormal.addEventListener(
          Events.ON_CHECK,
          new EventListener<Event>() {

            @Override
            public void onEvent(Event arg0) throws Exception {
              Radio radio_seleccionado = radiogroup_anormal.getSelectedItem();
              if (radio_seleccionado != null) {
                if (radio_seleccionado.getValue().toString().equals("A")) {
                  textbox_anormal.setVisible(true);
                } else {
                  textbox_anormal.setVisible(false);
                }
                tbxRes.setAttribute(
                    "VALOR_NORMAL_ANORMAL", radio_seleccionado.getValue().toString());
              }
            }
          });

      textbox_anormal.addEventListener(
          Events.ON_CHANGING,
          new EventListener<Event>() {

            @Override
            public void onEvent(Event arg0) throws Exception {
              InputEvent inputEvent = (InputEvent) arg0;
              tbxRes.setAttribute("VALOR_DESCRIPCION_NA", inputEvent.getValue());
            }
          });

      vlayout.appendChild(textbox_anormal);
    }

    final Textbox textbox = new Textbox();
    textbox.setWidth("400px");
    textbox.setRows(8);

    vlayout.appendChild(new Label("Resultado paraclinico"));
    vlayout.appendChild(textbox);
    textbox.setValue(tbxRes.getValue());
    textbox.addEventListener(
        "onChanging",
        new EventListener() {

          @Override
          public void onEvent(Event event) throws Exception {
            InputEvent inputevent = (InputEvent) event;
            tbxRes.setValue(inputevent.getValue());
          }
        });
    final Popup popup = new Popup();
    popup.addEventListener(
        Events.ON_OPEN,
        new EventListener<Event>() {

          @Override
          public void onEvent(Event event) throws Exception {
            textbox.setValue(tbxRes.getValue());
            textbox.setFocus(true);
          }
        });
    popup.appendChild(vlayout);
    contenedor.appendChild(popup);
    return popup;
  }
 @Override
 protected ILabelElement createItemComponent(Component parent) {
   DefaultDropDownMenuItem item = new DefaultDropDownMenuItem();
   parent.appendChild(item);
   return item;
 }