Пример #1
0
        public void render(Listitem item, final Object data) {
          final Listbox listbox = (Listbox) item.getParent();
          final Template tm = listbox.getTemplate("model");
          if (tm == null) {
            item.setLabel(Objects.toString(data));
            item.setValue(data);
          } else {
            final Component[] items =
                tm.create(
                    listbox,
                    item,
                    new VariableResolver() {
                      public Object resolveVariable(String name) {
                        return "each".equals(name) ? data : null;
                      }
                    });
            if (items.length != 1)
              throw new UiException(
                  "The model template must have exactly one item, not " + items.length);

            final Listitem nli = (Listitem) items[0];
            if (nli.getValue() == null) // template might set it
            nli.setValue(data);
            item.setAttribute("org.zkoss.zul.model.renderAs", nli);
            // indicate a new item is created to replace the existent one
            item.detach();
          }
        }
  public void listarParameter() {
    lbxParameter.getChildren().clear();

    Listitem listitem = new Listitem();
    // listitem.setValue("id_manual");
    // listitem.setLabel("Id_manual");
    // lbxParameter.appendChild(listitem);

    // listitem = new Listitem();
    listitem.setValue("manual");
    listitem.setLabel("Manual");
    lbxParameter.appendChild(listitem);

    // listitem = new Listitem();
    // listitem.setValue("tipo_manual");
    // listitem.setLabel("Tipo_manual");
    // lbxParameter.appendChild(listitem);
    //
    // listitem = new Listitem();
    // listitem.setValue("tipo_moneda");
    // listitem.setLabel("Tipo_moneda");
    // lbxParameter.appendChild(listitem);

    if (lbxParameter.getItemCount() > 0) {
      lbxParameter.setSelectedIndex(0);
    }
  }
Пример #3
0
 @Override
 public void render(final Listitem item, final Object data) throws Exception {
   CodeTable renderedAuthority = (CodeTable) data;
   Users user = (Users) ((Listitem) getParentComponent(item, Listitem.class)).getValue();
   List<Authority> authorityCollection = user.getAuthorityCollection();
   boolean select = false;
   for (Authority authority : authorityCollection) {
     CodeTable usersAuthority = authority.getAuthority();
     if (renderedAuthority.getCode().equals(usersAuthority.getCode())) {
       select = true;
       break;
     }
   }
   Bandbox bandbox = (Bandbox) getParentComponent(item, Bandbox.class);
   if (select) {
     if (bandbox.getText().length() > 0) {
       bandbox.setText(bandbox.getText() + ", ");
     }
     bandbox.setText(bandbox.getText() + renderedAuthority.getCode());
   }
   user.setAuthorities(bandbox.getText());
   item.setValue(data);
   item.setSelected(select);
   item.setLabel(renderedAuthority.getCode());
 }
        @Override
        public void render(Listitem item, Object data) {
            Resource resource = (Resource) data;
            item.setValue(data);

            item.appendChild(new Listcell(resource.getShortDescription()));
        }
Пример #5
0
 public void viewReport() throws Exception {
   try {
     JadwalDosenDAO dao = new JadwalDosenDAOImpl();
     if (cmbNamaDosen.getValue() != null
         && cmbProgdi.getValue() != null
         && !cmbTahun.getSelectedItem().getValue().toString().isEmpty()
         && cmbSemester.getValue() != null) {
       datas =
           dao.getJadwalDosen(
               (Dosen) cmbNamaDosen.getSelectedItem().getValue(),
               (ProgramStudi) cmbProgdi.getSelectedItem().getValue(),
               cmbTahun.getSelectedItem().getValue().toString(),
               Integer.valueOf(cmbSemester.getSelectedItem().getValue().toString()));
       lstData.getItems().clear();
       for (JadwalDosen jd : datas) {
         Listitem item = new Listitem();
         item.setValue(jd);
         item.appendChild(new Listcell(jd.getJam()));
         item.appendChild(new Listcell(jd.getSenin()));
         item.appendChild(new Listcell(jd.getSelasa()));
         item.appendChild(new Listcell(jd.getRabu()));
         item.appendChild(new Listcell(jd.getKamis()));
         item.appendChild(new Listcell(jd.getJumat()));
         item.appendChild(new Listcell(jd.getSabtu()));
         lstData.appendChild(item);
       }
       btnExport.setDisabled(false);
     } else {
       Messagebox.show("Silahkan Input Parameter dengan benar");
       btnExport.setDisabled(true);
     }
   } catch (Exception ex) {
     Messagebox.show("Telah terjadi kesalahan..");
   }
 }
  public void listarParameter() {
    lbxParameter.getChildren().clear();

    Listitem listitem = new Listitem();
    listitem.setValue("codigo");
    listitem.setLabel("Codigo");
    lbxParameter.appendChild(listitem);

    listitem = new Listitem();
    listitem.setValue("numero_solicitud");
    listitem.setLabel("Numero_solicitud");
    lbxParameter.appendChild(listitem);

    if (lbxParameter.getItemCount() > 0) {
      lbxParameter.setSelectedIndex(0);
    }
  }
Пример #7
0
  public void render(Listitem item, Object data) throws Exception {
    SecRole role = (SecRole) data;
    Listcell listCell = new Listcell(role.getName());
    listCell.setParent(item);

    item.setValue(role.getId());
    item.setAttribute(Constants.DATA, data);
  }
  public void listarParameter() {
    lbxParameter.getChildren().clear();

    Listitem listitem = new Listitem();
    listitem.setValue("codigo_ficha");
    listitem.setLabel("Codigo_ficha");
    lbxParameter.appendChild(listitem);

    listitem = new Listitem();
    listitem.setValue("identificacion");
    listitem.setLabel("Identificacion");
    lbxParameter.appendChild(listitem);

    if (lbxParameter.getItemCount() > 0) {
      lbxParameter.setSelectedIndex(0);
    }
  }
Пример #9
0
    @Override
    public void render(Listitem item, Object data) throws Exception {
      if (data == null) return;
      Jxkh_BusinessIndicator type = (Jxkh_BusinessIndicator) data;
      item.setValue(type);
      Listcell c0 = new Listcell();
      if (type.getKbName() == null) {
        c0.setLabel("--请选择--");
      } else {
        c0.setLabel(type.getKbName());
      }
      item.appendChild(c0);

      if (item.getIndex() == 0) item.setSelected(true);
    }
Пример #10
0
 public void render(Listitem item, Object data) throws Exception {
   WkTUser u = (WkTUser) data;
   Integer status = Integer.parseInt(u.getKuStatus());
   String[] statsString = {"未审查", "正常", "查封"};
   item.setValue(u);
   item.setHeight("25px");
   Listcell c0 = new Listcell(item.getIndex() + 1 + "");
   Listcell c1 = new Listcell(u.getKuLid());
   Listcell c2 = new Listcell(u.getKuName());
   Listcell c3 = new Listcell(u.getKuEmail());
   Listcell c4 = new Listcell(statsString[status]);
   Listcell c5 = new Listcell(DateUtil.getDateString(u.getKuRegdate()));
   Listcell c6 = new Listcell(DateUtil.getTimeString(u.getKuLtime()));
   Button b = new Button("角色");
   Listcell c7 = new Listcell();
   c7.appendChild(b);
   b.addEventListener(
       Events.ON_CLICK,
       new EventListener() {
         public void onEvent(Event event) throws Exception {
           Listitem c = (Listitem) event.getTarget().getParent().getParent();
           WkTUser u = (WkTUser) c.getValue();
           final UserRoleSelectWindow w =
               (UserRoleSelectWindow)
                   Executions.createComponents(
                       "/admin/system/user/userRoleSelect.zul", null, null);
           w.doHighlighted();
           w.initWindow(u);
         }
       });
   c7.setTooltiptext("点击进行角色管理");
   c1.addEventListener(Events.ON_CLICK, new InnerListener());
   c2.addEventListener(Events.ON_CLICK, new InnerListener());
   c1.setTooltiptext("点击进行用户编辑");
   c2.setTooltiptext("点击进行用户编辑");
   item.appendChild(c0);
   item.appendChild(c1);
   item.appendChild(c2);
   item.appendChild(c3);
   item.appendChild(c4);
   item.appendChild(c5);
   item.appendChild(c6);
   item.appendChild(c7);
 }
    @Override
    public void render(Listitem item, Object data) throws Exception {

      ApplicationNews applicationNews = (ApplicationNews) data;

      Listcell lc;

      lc = new Listcell();
      Label lb = new Label();
      lb.setParent(lc);
      lb.setValue(ZksampleDateFormat.getDateFormater().format(applicationNews.getDate()));
      lc.setParent(item);

      lc = new Listcell(applicationNews.getText().toString());
      lc.setParent(item);

      item.setValue(data);
      // ComponentsCtrl.applyForward(item,
      // "onDoubleClick=onDoubleClicked");
    }
Пример #12
0
    @Override
    public void render(Listitem listItem, Object data, int paramInt) throws Exception {
      Entity entityItem = (Entity) data;
      listItem.setValue(entityItem);

      for (ManagedBeanField field : composer.getListColumns()) {
        if (field.isVisible()) {
          Listcell l = new Listcell();

          l.setLabel(String.valueOf(Reflection.getFieldValue(entityItem, field.getKey())));
          l.setParent(listItem);
        }
      }
      ((Button) cellOper.getChildren().get(0)).setId(null);
      ((Button) cellOper.getChildren().get(1)).setId(null);
      Listcell vOper = ((Listcell) cellOper.clone());
      vOper.setParent(listItem);
      // this.divListBox.appendChild(cellOper);

      // new Listcell(prod.getName()).setParent(listItem);
      // new Listcell(""+prod.getPrice()).setParent(listItem);
      // new Listcell(""+cartItem.getAmount()).setParent(listItem);

    }
Пример #13
0
  public void render(final Listitem item, final Object data, final int index) throws Exception {
    final Listbox listbox = (Listbox) item.getParent();
    final int size = listbox.getModel().getSize();
    // B70-ZK-2555: in order to handle dynamic template name
    final String subtype =
        item instanceof Listgroup ? "group" : item instanceof Listgroupfoot ? "groupfoot" : null;
    final Template tm = resolveTemplate(listbox, item, data, index, size, "model", subtype);
    if (tm == null) {
      item.setLabel(Objects.toString(data));
      item.setValue(data);
    } else {
      final ForEachStatus iterStatus =
          new AbstractForEachStatus() { // provide iteration status in this context
            private static final long serialVersionUID = 1L;

            public int getIndex() {
              return index;
            }

            public Object getCurrent() {
              return data;
            }

            public Integer getEnd() {
              return size;
            }
          };

      final String var = (String) tm.getParameters().get(EACH_ATTR);
      final String varnm = var == null ? EACH_VAR : var; // var is not specified, default to "each"
      final String itervar = (String) tm.getParameters().get(STATUS_ATTR);
      final String itervarnm =
          itervar == null
              ? (var == null ? EACH_STATUS_VAR : varnm + STATUS_POST_VAR)
              : itervar; // provide default value if not specified

      // bug 1188, EL when nested var and itervar
      Object oldVar = listbox.getAttribute(varnm);
      Object oldIter = listbox.getAttribute(itervarnm);
      listbox.setAttribute(varnm, data);
      listbox.setAttribute(itervarnm, iterStatus);

      final Component[] items = filterOutShadows(listbox, tm.create(listbox, item, null, null));

      // Bug ZK-2789: do not use setAttribute when actually trying to removeAttribute
      if (oldVar != null) {
        listbox.setAttribute(varnm, oldVar);
      } else {
        listbox.removeAttribute(varnm);
      }
      if (oldIter != null) {
        listbox.setAttribute(itervarnm, oldIter);
      } else {
        listbox.removeAttribute(itervarnm);
      }

      if (items.length != 1)
        throw new UiException("The model template must have exactly one item, not " + items.length);

      final Listitem nli = (Listitem) items[0];
      nli.setAttribute(BinderCtrl.VAR, varnm); // for the converter to get the value

      // ZK-2552
      recordRenderedIndex(listbox, items.length);
      nli.setAttribute(AbstractRenderer.IS_TEMPLATE_MODEL_ENABLED_ATTR, true);

      nli.setAttribute(
          AbstractRenderer.CURRENT_INDEX_RESOLVER_ATTR,
          new IndirectBinding() {
            public Binder getBinder() {
              return BinderUtil.getBinder(nli, true);
            }

            @SuppressWarnings("unchecked")
            public void setValue(BindELContext ctx, Object value) {
              int idx = BindListitemRenderer.this.getRenderedIndex(listbox, nli.getIndex());
              ListModel<?> listmodel = listbox.getListModel();
              if (idx >= 0 && idx < listmodel.getSize()) {
                if (listmodel instanceof ListModelArray) {
                  ((ListModelArray<Object>) listmodel).set(idx, value);
                } else if (listmodel instanceof ListModelList<?>) {
                  ((ListModelList<Object>) listmodel).set(idx, value);
                }
              } else {
                // out of range, should ignore to compatible with old version(when we didn't
                // implement save) or throw exception?
              }
            }

            public Component getComponent() {
              return nli;
            }

            public Object getValue(BindELContext ctx) {
              return listbox
                  .getModel()
                  .getElementAt(
                      BindListitemRenderer.this.getRenderedIndex(listbox, nli.getIndex()));
            }
          });
      addItemReference(
          listbox, nli, index, varnm); // kept the reference to the data, before ON_BIND_INIT

      nli.setAttribute(itervarnm, iterStatus);

      // sync open state
      if (nli instanceof Listgroup && item instanceof Listgroup) {
        ((Listgroup) nli).setOpen(((Listgroup) item).isOpen());
      }

      // ZK-1787 When the viewModel tell binder to reload a list, the other component that bind a
      // bean in the list will reload again
      // move TEMPLATE_OBJECT (was set in resoloveTemplate) to current for check in
      // addTemplateTracking
      Object obj = item.removeAttribute(TemplateResolver.TEMPLATE_OBJECT);
      // Bug ZK-2789: do not use setAttribute when actually trying to removeAttribute
      if (obj != null) {
        nli.setAttribute(TemplateResolver.TEMPLATE_OBJECT, obj);
      } else {
        nli.removeAttribute(TemplateResolver.TEMPLATE_OBJECT);
      }

      // add template dependency
      addTemplateTracking(listbox, nli, data, index, size);

      if (nli.getValue() == null) // template might set it
      nli.setValue(data);
      item.setAttribute(Attributes.MODEL_RENDERAS, nli);
      // indicate a new item is created to replace the existent one
      item.detach();
    }
  }
Пример #14
0
    @Override
    public void render(Listitem item, Object data) throws Exception {

      if (data == null) return;
      final JXKH_QKLW meeting = (JXKH_QKLW) data;
      item.setValue(meeting);
      Listcell c0 = new Listcell();
      Listcell c1 = new Listcell(item.getIndex() + 1 + "");
      Listcell c2 =
          new Listcell(
              meeting.getLwName().length() <= 14
                  ? meeting.getLwName()
                  : meeting.getLwName().substring(0, 14) + "...");
      c2.setTooltiptext(meeting.getLwName());
      c2.setStyle("color:blue");
      c2.addEventListener(
          Events.ON_CLICK,
          new EventListener() {
            public void onEvent(Event event) throws Exception {
              Listitem item = (Listitem) event.getTarget().getParent();
              JXKH_QKLW meeting = (JXKH_QKLW) item.getValue();
              AddJournalWindow w =
                  (AddJournalWindow)
                      Executions.createComponents(
                          "/admin/personal/deptbusinessdata/artical/journal/addJournal.zul",
                          null,
                          null);
              try {
                w.setMeeting(meeting);
                w.setAudit("AUDIT");
                w.initWindow();
                w.doModal();
              } catch (SuspendNotAllowedException e) {
                e.printStackTrace();
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              if (isQuery) {
                onClick$query();
              } else {
                initWindow();
              }
            }
          });
      // 期刊类别
      Listcell c3 = new Listcell();
      if (meeting.getQkGrade() == null) c3.setLabel("");
      else c3.setLabel(meeting.getQkGrade().getKbName());
      // 积分年度
      Listcell c4 = new Listcell(meeting.getjxYear());
      // 该项得分
      Listcell c5 = new Listcell(meeting.getScore() == null ? "" : meeting.getScore().toString());
      // 填写人
      Listcell c6 = new Listcell();
      c6.setLabel(meeting.getLwWriter());
      // 审核状态
      Listcell c7 = new Listcell();
      c7.setTooltiptext("点击填写审核意见");
      if (meeting.getLwState() == null) {
        c7.setLabel("待审核");
        c7.setStyle("color:red");
      } else {
        switch (meeting.getLwState()) {
          case 0:
            c7.setLabel("待审核");
            c7.setStyle("color:red");
            break;
          case 1:
            c7.setLabel("部门通过");
            c7.setStyle("color:red");
            break;
          case 2:
            c7.setLabel("部门审核中");
            c7.setStyle("color:red");
            break;
          case 3:
            c7.setLabel("部门不通过");
            c7.setStyle("color:red");
            break;
          case 4:
            c7.setLabel("业务办通过");
            c7.setStyle("color:red");
            break;
          case 5:
            c7.setLabel("业务办不通过");
            c7.setStyle("color:red");
            break;
          case 6:
            c7.setLabel("归档");
            c7.setStyle("color:red");
            break;
          case 7:
            c7.setLabel("业务办暂缓通过");
            c7.setStyle("color:red");
            break;
        }
      }
      // 弹出审核意见事件
      c7.addEventListener(
          Events.ON_CLICK,
          new EventListener() {
            public void onEvent(Event event) throws Exception {
              AdviceWindow w =
                  (AdviceWindow)
                      Executions.createComponents(
                          "/admin/jxkh/audit/article/journal/advice.zul", null, null);
              try {
                w.setMeeting(meeting);
                w.initWindow();
                w.doModal();
              } catch (SuspendNotAllowedException e) {
                e.printStackTrace();
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              initWindow();
            }
          });
      item.appendChild(c0);
      item.appendChild(c1);
      item.appendChild(c2);
      item.appendChild(c3);
      item.appendChild(c4);
      item.appendChild(c5);
      item.appendChild(c6);
      item.appendChild(c7);
    }
Пример #15
0
  public ProfileComponent() {
    super();
    final PlayerProfileData player = getPlayerFacade().getCurrentPlayer();

    final Grid profileGrid = new Grid();
    profileGrid.setSclass("profileGrid");

    final Rows profileRows = new Rows();
    profileGrid.appendChild(profileRows);

    final Row idRow = new Row();
    idRow.setSclass("profileRow");
    idRow.appendChild(new Label(Labels.getLabel("profile.id")));
    idRow.appendChild(new Label(player.getId()));
    profileRows.appendChild(idRow);

    final Row nameRow = new Row();
    nameRow.setSclass("profileRow");
    nameRow.appendChild(new Label(Labels.getLabel("profile.name")));
    final Textbox nameBox = new Textbox(player.getName());
    nameBox.setConstraint(
        new SimpleConstraint(SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.noname")));
    nameRow.appendChild(nameBox);
    profileRows.appendChild(nameRow);

    final Row mailRow = new Row();
    mailRow.setSclass("profileRow");
    mailRow.appendChild(new Label(Labels.getLabel("profile.email")));
    final Textbox mailBox = new Textbox(player.getEMail());
    mailBox.setConstraint("/.+@.+\\.[a-z]+/: " + Labels.getLabel("register.error.noemail"));
    mailRow.appendChild(mailBox);
    profileRows.appendChild(mailRow);

    final Row pwdRow = new Row();
    pwdRow.setSclass("profileRow");
    pwdRow.appendChild(new Label(Labels.getLabel("profile.password")));
    final Textbox pwdBox = new Textbox(player.getPassword());
    // pwdBox.setConstraint(new SimpleConstraint(SimpleConstraint.NO_EMPTY,
    // Labels.getLabel("register.error.nopassword")));
    pwdBox.setType("password");
    pwdRow.appendChild(pwdBox);
    profileRows.appendChild(pwdRow);

    final Row pwd2Row = new Row();
    pwd2Row.setSclass("profileRow");
    pwd2Row.appendChild(new Label(Labels.getLabel("profile.passwordagain")));
    final Textbox pwd2Box = new Textbox(player.getPassword());
    pwd2Box.setConstraint(
        new Constraint() {
          @Override
          public void validate(final Component comp, final Object value)
              throws WrongValueException {
            if (!(pwdBox.getValue().equals(value))) {
              throw new WrongValueException(
                  comp, Labels.getLabel("register.error.unequalpassword"));
            }
          }
        });
    pwd2Box.setType("password");
    pwd2Row.appendChild(pwd2Box);
    profileRows.appendChild(pwd2Row);

    final Row countryRow = new Row();
    countryRow.setSclass("profileRow");
    countryRow.appendChild(new Label(Labels.getLabel("profile.country")));
    final Combobox countryBox = new Combobox();
    countryBox.setConstraint(
        new SimpleConstraint(
            SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.nocountry")));
    countryBox.setAutodrop(true);
    countryBox.setReadonly(true);
    fillCombo(countryBox, player.getLocale());
    countryRow.appendChild(countryBox);
    profileRows.appendChild(countryRow);

    final Row avCompetitionsRow = new Row();
    avCompetitionsRow.setSclass("competitionsRow");
    avCompetitionsRow.appendChild(new Label(Labels.getLabel("profile.availableCompetitions")));
    final Listbox listbox = new Listbox();
    listbox.setSclass("competitionsListbox");
    avCompetitionsRow.appendChild(listbox);
    listbox.setCheckmark(true);
    listbox.setMultiple(true);

    final List<CompetitionData> comps = getPlayerFacade().getAllCompetitions();
    for (final CompetitionData cmpData : comps) {
      final Listitem listItem = new Listitem(cmpData.getName());
      listItem.setValue(cmpData);
      listItem.setSelected(cmpData.isActive());
      listItem.setDisabled(
          !cmpData.isDeactivatable() || (cmpData.isCurrentCompetition() && comps.size() != 1));
      listbox.appendChild(listItem);
    }

    profileRows.appendChild(avCompetitionsRow);

    final Row buttonRow = new Row();
    buttonRow.setSclass("profileRow");
    final Button button = new Button(Labels.getLabel("profile.submit"));
    button.addEventListener(
        Events.ON_CLICK,
        new EventListener() {
          @Override
          public void onEvent(final Event event) {
            player.setEMail(mailBox.getValue());
            player.setName(nameBox.getValue());

            if (StringUtils.isNotBlank(pwdBox.getValue())
                && pwdBox.getValue().equals(pwd2Box.getValue())) {
              player.setPassword(pwdBox.getValue());
            }
            player.setLocale((Locale) countryBox.getSelectedItem().getValue());

            final List<CompetitionData> cmps = new ArrayList<CompetitionData>();
            for (final Object listItem : listbox.getSelectedItems()) {
              if (listItem instanceof Listitem) {
                final Object value = ((Listitem) listItem).getValue();
                if (value instanceof CompetitionData) {
                  cmps.add((CompetitionData) value);
                }
              }
            }

            getPlayerFacade().setActiveCompetitions(cmps);

            getPlayerFacade().updatePlayer(player);

            try {
              Messagebox.show(Labels.getLabel("profile.update.success"));
              // TODO proper update mechanism
              Executions.sendRedirect("/");
            } catch (final InterruptedException e) {
              LOG.warn("Error while showing messagebox: ", e);
            }
          }
        });
    buttonRow.appendChild(button);
    profileRows.appendChild(buttonRow);

    this.appendChild(profileGrid);

    final Div detailsDiv = new Div();
    detailsDiv.setSclass("rankingUserDetails");

    final Img img = new Img();
    final Div imgCnt = new Div();
    imgCnt.appendChild(img);
    imgCnt.setSclass("rankingUserDetailsImg");
    img.setDynamicProperty("src", player.getPictureUrl());
    detailsDiv.appendChild(imgCnt);

    final Button uploadButton = new Button(Labels.getLabel("profile.upload"));
    uploadButton.setSclass("btngreen profileUserDetailsUpload");
    detailsDiv.appendChild(uploadButton);

    uploadButton.addEventListener(
        Events.ON_CLICK,
        new EventListener() {

          @Override
          public void onEvent(final Event event) throws InterruptedException {
            final Object media = Fileupload.get();
            if (media instanceof Image) {
              final Image image = (Image) media;
              player.setPictureUrl(
                  getPlayerFacade().uploadProfilePicture(image.getByteData(), image.getName()));
              img.setDynamicProperty("src", player.getPictureUrl());
            } else if (media != null) {
              Messagebox.show("Not an image: " + media, "Error", Messagebox.OK, Messagebox.ERROR);
            }
          }
        });
    this.appendChild(detailsDiv);
  }
 public void render(Listitem item, Object data) {
   item.setLabel(Objects.toString(data));
   item.setValue(data);
 }
  public void cari() throws Exception {
    Connection conn = getConn();
    try {
      PerusahaanDAO dao = new PerusahaanDAOImpl(conn);
      List<Perusahaan> list = dao.gets((Kecamatan) cmbKecamatan.getSelectedItem().getValue());
      lstHasil.getItems().clear();
      int no = 1;
      for (final Perusahaan p : list) {
        Listitem item = new Listitem();
        item.setValue(p);
        item.appendChild(new Listcell(p.getNamaPerusahaan()));
        item.appendChild(new Listcell(p.getNamaPimpinan()));
        item.appendChild(
            new Listcell(
                p.getAlamatJalan()
                    + ", "
                    + p.getKota()
                    + " Telp: "
                    + p.getTelp()
                    + " Fax: "
                    + p.getFax()));
        Toolbarbutton btnDetail = new Toolbarbutton();
        btnDetail.setId("btnDetail" + (no++));
        btnDetail.setImage("/img/detail.png");
        btnDetail.setTooltiptext("Klik di sini untuk Detail dan Perubahan data");
        btnDetail.addEventListener(
            "onClick",
            new EventListener() {

              public void onEvent(Event event) throws Exception {
                // panggil form edit
                Window win =
                    (Window)
                        Executions.createComponents("/zul/admin/editPerusahaan.zul", null, null);
                Textbox txtIdPerusahaan = (Textbox) win.getFellow("txtIdPerusahaan");
                txtIdPerusahaan.setValue(p.getId());
                win.doModal();
                cari();
              }
            });

        Toolbarbutton btnHapus = new Toolbarbutton();
        btnHapus.setId("btnHapus" + no++);
        btnHapus.setImage("/img/delete.png");
        btnHapus.setTooltiptext("Klik untuk mengahapus Perusahaan");
        btnHapus.addEventListener(
            "onClick",
            new EventListener() {

              public void onEvent(Event event) throws Exception {
                if (Messagebox.show(
                        "Hapus?", "Konfirmasi", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION)
                    == Messagebox.YES) {
                  Connection connDel = getConn();
                  try {
                    PerusahaanDAO daoDel = new PerusahaanDAOImpl(connDel);
                    daoDel.delete(p.getId());
                    cari();
                  } catch (Exception ex) {
                    Messagebox.show(ex.getMessage());
                  } finally {
                    connDel.close();
                  }
                }
              }
            });

        Listcell cellAksi = new Listcell();
        cellAksi.appendChild(btnDetail);
        cellAksi.appendChild(new Space());
        cellAksi.appendChild(btnHapus);
        item.appendChild(cellAksi);
        lstHasil.appendChild(item);
      }
    } catch (Exception ex) {
      Messagebox.show(ex.getMessage());
    } finally {
      conn.close();
    }
  }
Пример #18
0
 @Override
 public void render(Listitem item, Node data, int index) throws Exception {
   item.setValue(data);
   new Listcell(data.getLabel()).setParent(item);
 }
  public void adicionarProcedimiento(Map<String, Object> pcd) {
    String codigo_cups = (String) pcd.get("codigo_cups");
    String nombre_procedimiento = (String) pcd.get("nombre_procedimiento");

    String codigo_manual = (String) pcd.get("codigo_manual");

    Double valor_defecto = 0D;

    String tipo = lbxTipo_manual.getSelectedItem().getValue().toString();

    if (tipo.equals(IConstantes.TIPO_MANUAL_SOAT)) {
      valor_defecto = (Double) pcd.get("porcentaje_defecto");
    } else if (tipo.equals(IConstantes.TIPO_MANUAL_ISS01)) {
      valor_defecto = (Double) pcd.get("valoriss01_defecto");
    } else if (tipo.equals(IConstantes.TIPO_MANUAL_ISS04)) {
      valor_defecto = (Double) pcd.get("valoriss04_defecto");
    }

    Listitem listitem = new Listitem();
    listitem.setValue(pcd);

    listitem.appendChild(new Listcell());
    listitem.appendChild(new Listcell(codigo_cups));

    Textbox tbxCodigo_manual = new Textbox(codigo_manual != null ? codigo_manual : codigo_cups);
    tbxCodigo_manual.setHflex("1");
    Listcell listcell = new Listcell();
    listcell.appendChild(tbxCodigo_manual);
    listitem.appendChild(listcell);

    Res.cargarAutomatica(tbxCodigo_manual, pcd, "codigo_manual", null);
    pcd.put("codigo_manual", codigo_manual != null ? codigo_manual : codigo_cups);

    Textbox tbxNombre = new Textbox(nombre_procedimiento);
    tbxNombre.setHflex("1");
    tbxNombre.setReadonly(true);
    listcell = new Listcell();
    listcell.appendChild(tbxNombre);
    listitem.appendChild(listcell);

    Double valor = (Double) pcd.get("valor");

    Doublebox dbxValor = new Doublebox();
    dbxValor.setValue(valor != null ? valor : valor_defecto);
    dbxValor.setHflex("1");
    listcell = new Listcell();
    listcell.appendChild(dbxValor);
    listitem.appendChild(listcell);

    Res.cargarAutomatica(dbxValor, pcd, "valor", null);
    pcd.put("valor", valor != null ? valor : valor_defecto);

    String grupo_uvr = (String) pcd.get("grupo_uvr");

    Textbox tbxGrupoUvr = new Textbox(grupo_uvr != null ? grupo_uvr : "");
    tbxGrupoUvr.setHflex("1");
    listcell = new Listcell();
    listcell.appendChild(tbxGrupoUvr);
    listitem.appendChild(listcell);

    Res.cargarAutomatica(tbxGrupoUvr, pcd, "grupo_uvr", null);
    pcd.put("grupo_uvr", grupo_uvr != null ? grupo_uvr : "");

    String nro_cuenta = (String) pcd.get("nro_cuenta");

    Textbox tbxNro_cuenta = new Textbox(nro_cuenta != null ? nro_cuenta : "");
    tbxNro_cuenta.setHflex("1");
    listcell = new Listcell();
    listcell.appendChild(tbxNro_cuenta);
    listitem.appendChild(listcell);

    Res.cargarAutomatica(tbxNro_cuenta, pcd, "nro_cuenta", null);
    pcd.put("nro_cuenta", nro_cuenta != null ? nro_cuenta : "");

    listboxProcedimientos.appendChild(listitem);
  }