Example #1
0
    // @Override
    public void render(Page page, Writer out) throws IOException {
      final Desktop desktop = _exec.getDesktop();

      out.write("<script type=\"text/javascript\">zkpb('");
      out.write(page.getUuid());
      out.write("','");
      out.write(desktop.getId());
      out.write("','");
      out.write(getContextURI());
      out.write("','");
      out.write(desktop.getUpdateURI(null));
      out.write("','");
      out.write(desktop.getRequestPath());
      out.write('\'');

      String style = page.getStyle();
      if (style != null && style.length() > 0) {
        out.write(",{style:'");
        out.write(style);
        out.write("'}");
      }

      out.write(");zkpe();</script>\n");

      for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) {
        // HtmlPageRenders.outStandalone(_exec, root, out);
      }
    }
 /**
  * Returns parent component with this type
  *
  * @param <T> searching type
  * @param component child component
  * @param type parent type
  * @return found parent
  */
 protected <T> T getParentComponent(final Component component, final Class<T> type) {
   Component comp = component;
   while (!(type.isInstance(comp)) && comp.getParent() != null) {
     comp = comp.getParent();
   }
   return (comp == null || !(type.isInstance(comp))) ? null : type.cast(comp);
 }
Example #3
0
 /** Get converted value and original value of this Binding. */
 private Object[] getAttributeValues(Component comp) {
   if (!isSavable()
       || _attr.startsWith("_")
       || DataBinder.isTemplate(comp)
       || comp.getPage() == null) {
     return null; // cannot save, a control attribute, or a detached component, skip!
   }
   Object rawval = null;
   try {
     rawval = Fields.get(comp, _attr);
   } catch (NoSuchMethodException ex) {
     // Bug #1813278, Annotations do not work with xhtml tags
     if (comp instanceof DynamicPropertied) {
       final DynamicPropertied dpcomp = (DynamicPropertied) comp;
       if (dpcomp.hasDynamicProperty(_attr)) {
         rawval = dpcomp.getDynamicProperty(_attr);
       } else {
         throw UiException.Aide.wrap(ex);
       }
     } else if (comp.getAttributes()
         .containsKey(
             _attr)) { // Feature #2855116. Get value from component custom-attribute(also a
                       // variable in ZK5).
       rawval = comp.getAttribute(_attr);
     } else {
       throw UiException.Aide.wrap(ex);
     }
   }
   try {
     final Object val = (_converter == null) ? rawval : _converter.coerceToBean(rawval, comp);
     return val == TypeConverter.IGNORE ? null : new Object[] {val, rawval};
   } catch (ClassCastException ex) {
     throw UiException.Aide.wrap(ex);
   }
 }
Example #4
0
  public void afterComponentAttached(Component comp, Page page) {
    if (comp.getDesktop() != null) {
      // check if this component already binded
      Binder selfBinder = BinderUtil.getBinder(comp);
      if (selfBinder == null) {
        // check if parent exists any binder
        Binder parentBinder = BinderUtil.getBinder(comp, true);

        // post event to let the binder to handle binding later
        if (parentBinder != null && (parentBinder instanceof BinderImpl)) {
          // ZK-603, ZK-604, ZK-605
          // register internal ON_BIND_INIT event listener to delay the timing of init and loading
          // bindings
          comp.addEventListener(
              10000,
              BinderImpl.ON_BIND_INIT,
              new EventListener<Event>() {
                @Override
                public void onEvent(Event event) throws Exception {
                  final Component comp = event.getTarget();
                  comp.removeEventListener(BinderImpl.ON_BIND_INIT, this);
                  // ZK-611 have wrong binding on a removed treecell in a template
                  // if it was detached, ignore it
                  if (comp.getPage() == null) {
                    return;
                  }

                  final Binder innerBinder = BinderUtil.getBinder(comp);
                  if (innerBinder
                      != null) { // it was already handled by innerBinder, ignore it
                    return;
                  }

                  // ZK-1640 command send 2 wrong ViewModel
                  // check if there any parent binder again, don't use out-side parentBinder, it is
                  // not correct
                  Binder binder = BinderUtil.getBinder(comp, true);
                  if (binder == null) {
                    return;
                  }

                  if (binder instanceof AnnotateBinder) {
                    new AnnotateBinderHelper(binder).initComponentBindings(comp);
                  }

                  binder.loadComponent(comp, true);

                  // [Dennis,20120925], this code was added when fixing issue zk-739,
                  // but , inside binder.initComponentBindings, it shall do this already, I am not
                  // sure why.
                  if (comp.getAttribute(BinderImpl.VAR) != null)
                    BinderUtil.markHandling(comp, binder);
                }
              });
          // post ON_BIND_INIT event
          Events.postEvent(new Event(BinderImpl.ON_BIND_INIT, comp));
        }
      }
    }
  }
Example #5
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;
 }
Example #6
0
 /*package*/ boolean isRealVisible() {
   if (!isVisible()) return false;
   Component comp = getParent();
   if (comp == null) return true;
   if (!(comp instanceof Treeitem)) return comp.isVisible();
   Treeitem item = (Treeitem) comp;
   return item.isOpen() && item.isRealVisible();
 }
 private void addPart(Component btn) {
   CfgInfo cfgInfo = (CfgInfo) btn.getAttribute("cfgInfo");
   CfgValue newPartValue = CfgParser.buildCfgValue(cfgInfo, null, 1, 1);
   btn.setParent(null);
   if (buttonPanel.getChildren().isEmpty()) {
     addBtn.setVisible(false);
   }
   addValue_(newPartValue);
 }
Example #8
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;
 }
 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);
 }
  public void doAfterCompose(Component EditSalaryHeadWindow) throws Exception {
    super.doAfterCompose(EditSalaryHeadWindow);

    GenericDelegator delegator =
        HrmsInfrastructure.getDelegator(); // GenericDelegator.getGenericDelegator("default");
    /*
     * EntityCondition condition = EntityCondition.makeCondition("enumTypeId",
     * EntityOperator.EQUALS, "CLAIM_TYPE");
     */
    EntityCondition currencyCondition =
        EntityCondition.makeCondition("uomTypeId", EntityOperator.EQUALS, "CURRENCY_MEASURE");

    Set<String> SalaryHeadTypeToDisplay = new HashSet();
    Set<String> currencyTypeToDisplay = new HashSet();
    Set<String> SalaryComputationTypeToDisplay = new HashSet();

    SalaryHeadTypeToDisplay.add("salaryHeadTypeId");
    SalaryHeadTypeToDisplay.add("description");

    currencyTypeToDisplay.add("uomId");
    currencyTypeToDisplay.add("description");

    SalaryComputationTypeToDisplay.add("salaryComputationTypeId");
    SalaryComputationTypeToDisplay.add("description");
    // =====================SalaryHeadType==============================
    List<GenericValue> salaryHeadType =
        delegator.findList("SalaryHeadType", null, SalaryHeadTypeToDisplay, null, null, false);
    salaryHeadType.add(0, null);
    SimpleListModel salaryHeadTypeList = new SimpleListModel(salaryHeadType);

    Listbox applySalaryHeadType = (Listbox) EditSalaryHeadWindow.getFellow("applySalaryHeadType");
    applySalaryHeadType.setModel(salaryHeadTypeList);
    applySalaryHeadType.setItemRenderer(new SalaryHeadTypeRenderer());
    // =====================UOM===CURRENCY==============================
    List<GenericValue> currency =
        delegator.findList("Uom", currencyCondition, currencyTypeToDisplay, null, null, false);
    currency.add(0, null);
    SimpleListModel currencyList = new SimpleListModel(currency);

    Listbox currencyListBox = (Listbox) EditSalaryHeadWindow.getFellow("applyCurrencyUomId");
    currencyListBox.setModel(currencyList);
    currencyListBox.setItemRenderer(new CurrencyRenderer());
    // =====================SalaryComputationType==============================
    List<GenericValue> SalaryComputationType =
        delegator.findList(
            "SalaryComputationType", null, SalaryComputationTypeToDisplay, null, null, false);
    SalaryComputationType.add(0, null);
    SimpleListModel SalaryComputationTypeList = new SimpleListModel(SalaryComputationType);

    Listbox SalaryComputationTypeListBox =
        (Listbox) EditSalaryHeadWindow.getFellow("applyComputationType");
    SalaryComputationTypeListBox.setModel(SalaryComputationTypeList);
    SalaryComputationTypeListBox.setItemRenderer(new SalaryComputationTypeRenderer());
    // ========================================================================
  }
  private void buildDivFieldsFromEntity(ComposerController<?> composer) {
    //		AnnotateDataBinder binder = new AnnotateDataBinder(crudFormWindow);
    //		binder.bindBean("controller2", composer);

    if (divFields.getChildren().size() == 0) {
      List<Component> list = new ArrayList<Component>(divFields.getChildren());
      for (Component c : list) {
        c.detach();
      }
      d = new Div();
      g = new Grid();
      d.appendChild(g);

      binder = new AnnotateDataBinder(g);
      binder.bindBean("controller2", composer);
      Columns c = new Columns();
      Column col1 = new Column();
      col1.setWidth("120px");
      Column col2 = new Column();
      col2.setAlign("left");
      c.appendChild(col1);
      c.appendChild(col2);
      Rows r = new Rows();
      Textbox t;
      Checkbox checkbox;
      for (ManagedBeanField field : composer.getListColumns()) {
        if (field.isVisible()) {
          Row row = new Row();
          row.appendChild(new Label(Labels.getLabel(field.getFieldCaption())));
          String fieldName = "controller2." + field.getFieldName() + "";

          if (field.getFieldType().equalsIgnoreCase("boolean")) {
            checkbox = new Checkbox();
            binder.addBinding(checkbox, "checked", fieldName);
            row.appendChild(checkbox);

          } else {
            t = new Textbox();

            t.setWidth("98%");

            binder.addBinding(t, "value", fieldName);
            row.appendChild(t);
          }
          r.appendChild(row);
        }
      }
      g.appendChild(r);

      d.setParent(this.divFields);
      // binder.loadAll();
    }
    binder.loadComponent(g);
    // binder.saveAll();
  }
 public void onRenderComponents(final Row row) {
   final Component lastChild = row.getLastChild(); // image button remove
   final RowModel model = getModelFromComponent(row);
   for (int i = 0; i < DLFilterOperator.MAX_ARITY; ++i) { // remove all
     lastChild.getPreviousSibling().setParent(null);
   }
   for (int i = 0; i < DLFilterOperator.MAX_ARITY; ++i) { // insert all
     row.insertBefore(model.getPosition(i + 1), lastChild);
   }
   LOGGER.debug("Components have been rendered.");
 }
 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 updateChosenKeysIndex() {
   List<Component> rowsList = rows.getChildren();
   for (Component component : rowsList) {
     Component child = component.getLastChild();
     if (child instanceof Selectbox) {
       Selectbox selectbox = (Selectbox) child;
       int index = Integer.parseInt(selectbox.getId());
       chosenKeysIndex[index] = selectbox.getSelectedIndex();
     }
   }
 }
Example #15
0
  public void onEvent(Event e) throws Exception {
    Component component = e.getTarget();

    if (component.equals(confirmPanel.getButton(ConfirmPanel.A_OK))) dispose();
    else if (component instanceof Tab) {
      if (tabbox.getSelectedIndex() == 1) initReservedOrderedTab(true);
      else if (tabbox.getSelectedIndex() == 2) initReservedOrderedTab(false);
      else if (tabbox.getSelectedIndex() == 3) initUnconfirmedTab();
      else if (tabbox.getSelectedIndex() == 4) initAtpTab();
    }
  }
  @Override
  public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);

    lb_user_org_list.setItemRenderer(new UserOrganizationSearchListitemRenderer());
    manageButtons();
    btn_back.setHref(globalUtils.getGlobalPropValue(Commons.URL_SECURITY_ADMIN));
    comp.setAttribute(comp.getId() + "Control", this, true);
    binder = new AnnotateDataBinder(comp);
    binder.loadAll();
  }
Example #17
0
  private void processAllComponentsBindings(Component comp) {
    final Binder selfBinder = (Binder) comp.getAttribute(BinderImpl.BINDER);
    // check if a component was binded already(by any binder)
    if (selfBinder != null) // this component already binded ! skip all of its children
    return;

    processComponentBindings0(comp);
    for (final Iterator<Component> it = comp.getChildren().iterator(); it.hasNext(); ) {
      final Component kid = it.next();
      processAllComponentsBindings(kid); // recursive to each child
    }
  }
 public Datebox getDateboxFecha(
     String pcodigo_historia, String tipo_examen, String codigo_examen) {
   Datebox datebox_fecha = null;
   if (contenedor.hasFellow(
       "datebox_fecha_" + tipo_examen + "_" + pcodigo_historia + "_" + codigo_examen)) {
     datebox_fecha =
         (Datebox)
             contenedor.getFellow(
                 "datebox_fecha_" + tipo_examen + "_" + pcodigo_historia + "_" + codigo_examen);
   }
   return datebox_fecha;
 }
 @Override
 public void doAfterCompose(Component comp) throws Exception {
   super.doAfterCompose(comp);
   comp.setAttribute(comp.getId() + "Ctrl", this, true);
   newCustomerRadio.addEventListener(
       Events.ON_SELECT,
       new EventListener<Event>() {
         @Override
         public void onEvent(Event arg0) throws Exception {
           newCustomerRadio.setSelected(false);
         }
       });
 }
Example #20
0
  /** Makes sure it is not draggable. */
  private void checkOverlappable(int mode) {
    if (!"false".equals(getDraggable()))
      throw new UiException(
          "Draggable window cannot be modal, overlapped, popup, or highlighted: " + this);

    if (mode == MODAL)
      for (Component comp = this; (comp = comp.getParent()) != null; )
        if (!comp.isVisible())
          throw new UiException(
              "One of its ancestors, "
                  + comp
                  + ", is not visible, so unable to be modal or highlighted");
  }
Example #21
0
  public void doListDataChange(ListDataEvent event) {
    // when this is called _model is never null
    final ListModel _model = _listbox.getModel();
    final int newsz = _model.getSize(), oldsz = _listbox.getItemCount();
    int min = event.getIndex0(), max = event.getIndex1(), cnt;

    switch (event.getType()) {
      case ListDataEvent.INTERVAL_ADDED:
        cnt = newsz - oldsz;
        if (cnt <= 0) throw new UiException("Adding causes a smaller list?");
        if ((oldsz <= 0 || cnt > INVALIDATE_THRESHOLD) && !inPagingMold()) _listbox.invalidate();
        // Bug 3147518: avoid memory leak
        // Also better performance (outer better than remove a lot)
        if (min < 0)
          if (max < 0) min = 0;
          else min = max - cnt + 1;
        if (min > oldsz) min = oldsz;

        ListitemRenderer renderer = null;
        final Component next = min < oldsz ? _listbox.getItemAtIndex(min) : null;
        while (--cnt >= 0) {
          if (renderer == null) renderer = (ListitemRenderer) getRealRenderer();
          _listbox.insertBefore(newUnloadedItem(renderer, min++), next);
        }
        break;

      case ListDataEvent.INTERVAL_REMOVED:
        cnt = oldsz - newsz;
        if (cnt <= 0) throw new UiException("Removal causes a larger list?");
        if (min >= 0) max = min + cnt - 1;
        else if (max < 0) max = cnt - 1; // 0 ~ cnt - 1		
        if (max > oldsz - 1) max = oldsz - 1;

        if ((newsz <= 0 || cnt > INVALIDATE_THRESHOLD) && !inPagingMold()) _listbox.invalidate();
        // Bug 3147518: avoid memory leak
        // Also better performance (outer better than remove a lot)

        // detach from end (due to groopfoot issue)
        Component comp = _listbox.getItemAtIndex(max);
        while (--cnt >= 0) {
          Component p = comp.getPreviousSibling();
          comp.detach();
          comp = p;
        }
        break;

      default: // CONTENTS_CHANGED
        syncModel(min, max);
    }
  }
Example #22
0
  /// 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));
      }
    }
  }
Example #23
0
  private Component getEmergente(String nombre, Map<String, Object> param) throws Exception {
    log.info("Ejecutando m�todo [ getEmergente().. ]");
    log.debug("nombre ==>" + nombre);
    log.debug("param ==>" + param);

    AATEjecutable detalle = Utilidades.obtenerDetalle(nombre);
    Component component =
        Executions.createComponentsDirectly(detalle.getFuente(), null, null, param);
    if (component instanceof Window) {
      // AGREGAMOS EL TITULO DE LAS NOTIFICACIONES COMO UN ATRIBUTO
      component.setAttribute("TITULO_NOTIFICACIONES_GRITTER", ((Window) component).getTitle());
    }

    return component;
  }
 @Override
 public void doAfterCompose(Component comp) throws Exception {
     super.doAfterCompose(comp);
     comp.setVariable("assignedTaskQualityFormsController", this, true);
     messages = new MessagesForUser(messagesContainerTaskQualityForms);
     this.reloadTaskQualityForms();
 }
    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++;
        }
      }
    }
  @Override
  @SuppressWarnings("unchecked")
  public void doAfterCompose(final org.zkoss.zk.ui.Component comp) throws Exception {
    super.doAfterCompose(comp);
    comp.setAttribute("ctl", this, Component.SPACE_SCOPE);

    // save masterController
    masterController = (DLListboxExtController) arg.get("master");

    // save model, which is setted in the main model
    final NormalFilterModel modelFilter =
        (NormalFilterModel) arg.get(DLNormalFilterKeys.FILTERS.toString());

    // load informations about columns and data types
    modelTemplates = (NormalFilterModel) arg.get(DLNormalFilterKeys.TEMPLATES.toString());

    // sort by column labels
    java.util.Collections.sort(
        modelTemplates,
        new java.util.Comparator<NormalFilterUnitModel>() {

          public int compare(final NormalFilterUnitModel unit1, final NormalFilterUnitModel unit2) {
            return unit1.getLabel().compareTo(unit2.getLabel());
          }
        });

    for (NormalFilterUnitModel unit : modelFilter) {

      // if column was added manally, template might not be set - enforce template
      if (unit.getTemplate() == null)
        unit.setTemplate(modelTemplates.findUnitModelByColumnName(unit.getColumn()));

      rows.add(new RowModel(unit));
    }
  }
Example #27
0
 @Override
 public void doAfterCompose(Component comp) throws Exception {
   super.doAfterCompose(comp);
   winCardiaca.setAttribute(comp.getId() + "ctrl", this);
   servicioCardiaca = (ServicioCardiaca) SpringUtil.getBean("beanServicioCardiaca");
   apagarBotones();
 }
 private void setComposerRecursive(Component comp, Object composer) {
   if (comp instanceof IFormWindow)
     ((IFormWindow) comp).setComposer((ComposerController<?>) composer);
   List<Component> compList = comp.getChildren();
   for (Component vComp : compList) {
     setComposerRecursive(vComp, composer);
   }
 }
 public Textbox getTextboxFecha(
     String pcodigo_historia, String tipo_examen, String codigo_examen) {
   Textbox textbox_fecha = null;
   if (contenedor.hasFellow(
       "datebox_fecha_" + tipo_examen + "_" + pcodigo_historia + "_" + codigo_examen)) {
     textbox_fecha =
         (Textbox)
             contenedor.getFellow(
                 "textbox_resultado_"
                     + tipo_examen
                     + "_"
                     + pcodigo_historia
                     + "_"
                     + codigo_examen);
   }
   return textbox_fecha;
 }
 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));
   }
 }