public SearchForm(DataSource userDS) {

    setDataSource(userDS);
    setTop(20);
    setCellPadding(6);
    setNumCols(7);
    setStyleName("defaultBorder");

    findUser = new ButtonItem("Find");
    findUser.setIcon("silk/find.png");
    findUser.setWidth(70);
    findUser.setEndRow(false);

    TextItem searchWord = new TextItem("searchWord", "Search Word");
    searchWord.setEndRow(false);
    searchWord.addKeyPressHandler(
        new KeyPressHandler() {

          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              findUser.fireEvent(new ClickEvent(null));
            }
          }
        });

    searchCondition = new ComboBoxItem("searchCondition", "Select");
    LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
    data.put("userId", "User ID");
    data.put("userName", "User Name");
    searchCondition.setValueMap(data);
    searchCondition.setValue("userId");

    setItems(findUser, searchCondition, searchWord);
  }
  public EventViewerWindow() {
    super();

    setTitle(AppMessages.EVENT_VIEWER_LABEL);
    setShortcutIcon(AppImages.EVENT_DETAIL_SHORTCUT);
    setHeaderIcon(AppImages.EVENT_DETAIL_ICON);

    stack = new SectionStack();
    stack.setVisibilityMode(VisibilityMode.MULTIPLE);

    SectionStackSection findSection = new SectionStackSection("Find");
    findSection.setExpanded(true);

    final DynamicForm form = new SearchForm();
    form.setNumCols(7);
    form.setHeight(35);
    form.setTop(15);
    form.setCellPadding(10);

    TextItem actIdItem = new TextItem();
    actIdItem.setTitle("Activity ID");
    TextItem contextItem = new TextItem();
    contextItem.setTitle("Context");
    ButtonItem findBtn = new ButtonItem("Search");
    findBtn.setStartRow(false);
    findBtn.setIcon(AppImages.SEARCH_ICON);
    findBtn.setWidth("125px");

    form.setFields(actIdItem, contextItem, findBtn);
    findSection.addItem(form);

    SectionStackSection resultSection = new SectionStackSection("Activities");
    resultSection.setExpanded(true);

    grid = new ListGrid();
    grid.setShowAllRecords(true);
    grid.setHeight(300);

    ListGridField actId = new ListGridField("activityId", "ID", 40);
    ListGridField actDate = new ListGridField("activityDate", "Date", 150);
    ListGridField actCtx = new ListGridField("activityContext", "Context", 220);
    ListGridField actDesc = new ListGridField("activityDescription", "Description");

    grid.setFields(actId, actCtx, actDesc, actDate);
    grid.setData(getData());

    resultSection.addItem(grid);

    SectionStackSection detailSection = new SectionStackSection("Activity Detail");
    detailSection.setExpanded(true);

    stack.addSection(findSection);
    stack.addSection(resultSection);
    stack.addSection(detailSection);

    this.addItem(stack);
  }
示例#3
0
  public ListaVentas(final Sgc_capa_web mainWindow) {

    String PATH_IMG = "/sgc_capa_web/images/";
    VLayout layout = new VLayout(10);
    layout.setBackgroundColor("#006633");
    final ListGrid facturaGrid = new ListGrid();

    facturaGrid.setWidth(500);
    facturaGrid.setHeight(224);
    facturaGrid.setShowAllRecords(true);
    facturaGrid.setAlternateRecordStyles(true);
    facturaGrid.setShowEdges(true);
    facturaGrid.setBorder("0px");
    facturaGrid.setBodyStyleName("normal");
    facturaGrid.setLeaveScrollbarGap(false);
    facturaGrid.setBackgroundColor("#99ffcc");

    /*-Buscar ------------------------------*/
    DynamicForm buscarFields = new DynamicForm();
    // buscarFields.setBackgroundColor("#99ffcc");
    buscarFields.setItemLayout(FormLayoutType.ABSOLUTE);

    final TextItem codigoText = new TextItem("codigo");
    codigoText.setWrapTitle(false);
    codigoText.setLeft(10);
    codigoText.setWidth(43);
    codigoText.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if ("Enter".equals(event.getKeyName())) {
              /* buscar por el campo correspondiente */
              if (codigoText.getValue() != null) {

                Factura factura = new Factura();
                factura.setId(Integer.parseInt(codigoText.getValue().toString()));
                listar(facturaGrid, factura, "codigo");
              }
            }
          }
        });

    ButtonItem buscarButton = new ButtonItem("find", "");
    buscarButton.setIcon("view.png");
    buscarButton.setWidth(50);
    buscarButton.setLeft(443);
    buscarButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            /* buscar por el campo correspondiente */
            Factura factura = new Factura();

            if (codigoText.getValue() != null)
              factura.setId(Integer.parseInt(codigoText.getValue().toString()));
            /*if(nombreusuarioText.getValue() != null)
            cliente.setNombreusuario(nombreusuarioText.getValue().toString());*/
            listar(facturaGrid, factura, "nombre");
          }
        });

    buscarFields.setFields(codigoText, buscarButton);
    /*--------------------------------------*/

    ListGridField codigoField = new ListGridField("codigo", "Codigo");
    ListGridField fechaField = new ListGridField("fecha", "Fecha");
    ListGridField numeroField = new ListGridField("numero", "Numero");
    ListGridField pendienteField = new ListGridField("pendiente", "Pendiente");
    ListGridField saldoField = new ListGridField("saldo", "Saldo");
    ListGridField editarField = new ListGridField("edit", "Editar");
    ListGridField borrarField = new ListGridField("remove", "Borrar");

    codigoField.setAlign(Alignment.CENTER);
    editarField.setAlign(Alignment.CENTER);
    borrarField.setAlign(Alignment.CENTER);

    editarField.setType(ListGridFieldType.IMAGE);
    borrarField.setType(ListGridFieldType.IMAGE);

    editarField.setImageURLPrefix(PATH_IMG);
    borrarField.setImageURLPrefix(PATH_IMG);

    editarField.setImageURLSuffix(".png");
    borrarField.setImageURLSuffix(".png");

    facturaGrid.addCellClickHandler(
        new CellClickHandler() {
          @Override
          public void onCellClick(CellClickEvent event) {
            ListGridRecord record = event.getRecord();
            int col = event.getColNum();
            if (col > 4) {

              Factura factura = new Factura();
              factura.setId(record.getAttributeAsInt("codigo"));
              factura.setFecha(record.getAttributeAsDate("fecha"));
              factura.setNumero(Integer.parseInt(record.getAttribute("numero")));
              factura.setPendiente(record.getAttribute("pendiente"));
              factura.setSaldo(Double.parseDouble(record.getAttribute("saldo")));

              if (col == 5) {
                /* Editar */

                new VentaDetalle(factura, mainWindow);

              } else {
                /* Borrar */

                FacturaServiceAsync service = GWT.create(FacturaService.class);
                ServiceDefTarget serviceDef = (ServiceDefTarget) service;
                serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "facturaService");
                try {
                  service.eliminar(
                      record.getAttributeAsInt("codigo"),
                      new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                          Window.alert(
                              "Ocurrio un error y no se puedo eliminar (objeto referenciado)"); // "
                          // +
                          // caught.getClass().getName() + " " + caught.getMessage()) ;
                        }

                        @Override
                        public void onSuccess(Void result) {
                          new ListaVentas(mainWindow);
                        }
                      });
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          }
        });

    codigoField.setWidth(50);
    fechaField.setWidth(180);
    numeroField.setWidth(50);
    pendienteField.setWidth(50);
    saldoField.setWidth(50);
    facturaGrid.setFields(
        codigoField, fechaField, numeroField, pendienteField, saldoField, editarField, borrarField);
    facturaGrid.setCanResizeFields(true);

    ButtonItem button = new ButtonItem("add", "Agregar");
    button.setStartRow(false);
    button.setWidth(80);
    button.setIcon("add.png");
    button.setAlign(Alignment.CENTER);
    button.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            new VentaDetalle(mainWindow);
          }
        });

    listar(facturaGrid, new Factura(), "nombre");

    Label label = new Label();
    label.setBackgroundColor("#99ffcc");
    label.setHeight(30);
    label.setWidth(500);
    label.setPadding(10);
    label.setAlign(Alignment.CENTER);
    label.setValign(VerticalAlignment.CENTER);
    label.setWrap(false);
    label.setShowEdges(true);
    label.setContents("<div style='color:black;font-size:15'><b>Lista de Ventas</b></div>");

    layout.addMember(label);
    layout.addMember(buscarFields);
    layout.addMember(facturaGrid);

    DynamicForm form = new DynamicForm();
    // form.setBackgroundColor("#99ffcc");
    form.setWidth(300);
    form.setItems(button);
    layout.addMember(form);
    mainWindow.showDialog(layout);
  }
示例#4
0
  public CargaProductoCompra(CompraDetalle compradetalle, final Sgc_capa_web mainWindow) {

    VLayout layout = new VLayout(10);

    final DynamicForm form = new DynamicForm();
    form.setBackgroundColor("#006633");
    form.setBorder("2px");
    form.setAutoFocus(true);
    form.setNumCols(3);
    form.setWidth(500);

    Label label = new Label();
    label.setBackgroundColor("#99ffcc");
    label.setHeight(30);
    label.setWidth(500);
    label.setPadding(10);
    label.setAlign(Alignment.CENTER);
    label.setValign(VerticalAlignment.CENTER);
    label.setWrap(false);
    label.setShowEdges(true);
    label.setContents(
        "<div style='color:black;font-size:15'><b>Carga de Productos de la Compra</b></div>");

    TextItem codigoText = new TextItem("codigo");
    codigoText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}");
    codigoText.setTitle("Codigo");
    codigoText.setDisabled(true);
    codigoText.setWrapTitle(false);

    final TextItem productoText = new TextItem("producto");
    productoText.setTitle("Producto");
    productoText.setDefaultValue(new Date());
    productoText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}");
    productoText.setWrapTitle(false);

    final TextItem cantidadText = new TextItem("cantidad");
    cantidadText.setTitle("Cantidad");
    cantidadText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}");
    cantidadText.setWrapTitle(false);

    final TextItem preciocompraText = new TextItem("preciocompra");
    preciocompraText.setTitle("Precio");
    preciocompraText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}");
    preciocompraText.setWrapTitle(false);

    ButtonItem button = new ButtonItem("save", "Aceptar");
    button.setStartRow(false);
    button.setWidth(80);
    button.setIcon("approve.png");
    button.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            CompraDetalleServiceAsync service = GWT.create(CompraDetalleService.class);
            ServiceDefTarget serviceDef = (ServiceDefTarget) service;
            serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "compradetalleService");
            CompraDetalle compradetalle = new CompraDetalle();
            compradetalle.setId_producto(Integer.parseInt(form.getValueAsString("producto")));
            compradetalle.setCantidad(Integer.parseInt(form.getValueAsString("cantidad")));
            compradetalle.setPrecioCompra(
                Double.parseDouble(form.getValueAsString("preciocompra")));
            // compra.setTotalCompra(Integer.parseInt("15000"));
            if (form.getValueAsString("codigo") != null) {
              compradetalle.setIdCompDet(Integer.valueOf(form.getValueAsString("codigo")));
            }

            try {
              service.guardar(
                  compradetalle,
                  new AsyncCallback<Void>() {

                    @Override
                    public void onFailure(Throwable caught) {
                      Window.alert(
                          "Ocurrio un error: "
                              + caught.getClass().getName()
                              + " "
                              + caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Void result) {
                      new CargaProductoCompra(mainWindow);
                    }
                  });
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    if (compradetalle != null) {
      codigoText.setDefaultValue(String.valueOf(compradetalle.getIdCompDet()));
      productoText.setDefaultValue(compradetalle.getId_producto());
      cantidadText.setDefaultValue(compradetalle.getCantidad());
      preciocompraText.setDefaultValue(((Object) compradetalle.getPrecioCompra()).toString());
    }

    form.setFields(codigoText, productoText, cantidadText, preciocompraText, button);
    layout.addMember(label);
    layout.addMember(form);
    mainWindow.showDialog(layout);
  }
  public DocumentSearchForm() {
    instance = this;
    setTop(20);
    setCellPadding(6);
    setNumCols(5);
    setStyleName("defaultBorder");
    setTitleOrientation(TitleOrientation.TOP);

    findItem = new ButtonItem("Find");
    findItem.setIcon("silk/find.png");
    findItem.setWidth(70);
    findItem.setEndRow(false);
    HashMap<String, String> listSqls = new HashMap<String, String>();
    listSqls.put("" + ClSelection.T_REGION, "" + ClSelection.T_REGION);
    listSqls.put(
        "" + ClSelection.T_DOC_STATUS,
        "" + ClSelection.T_DOC_STATUS + "_" + ClSelection.T_LANGUAGE + "_" + DocFlow.language_id);
    siDocStatus = new SelectItem("siDocStatus", "Doc Status");
    diStart = new CurrentTimeItem("diStart", "Start");
    diStart.setUseTextField(false);
    diEnd = new CurrentTimeItem("diEnd", "End");
    diEnd.setUseTextField(false);

    setCurrentDate();
    tiUserName = new TextItem("tiUserName", "User Name");
    iiZona = new IntegerItem("iiZona", "Zona");
    iiCustomer = new IntegerItem("iiCustomer", "Customer");
    tiContent = new TextItem("tiContent", "Content");
    tiDocId = new IntegerItem("tiDocId", "Doc ID");
    tiCancelary = new IntegerItem("tiCancelary", "Cancelary");
    DocFlow.docFlowService.getListTypesForDocument(
        listSqls,
        -1,
        new AsyncCallback<HashMap<String, ArrayList<ClSelectionItem>>>() {

          @Override
          public void onFailure(Throwable caught) {
            setResults(null);
          }

          @Override
          public void onSuccess(HashMap<String, ArrayList<ClSelectionItem>> result) {
            setResults(result);
          }
        });
    findItem.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            search(false);
          }
        });
    stDocCount = new StaticTextItem("stDocCount", "Result Count");

    if (true) {
      showStatusItem = new ButtonItem("showStatusItem", "Report");
      showStatusItem.setStartRow(false);
      showStatusItem.setEndRow(false);
      showStatusItem.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              Date dtStart = diStart.getValueAsDate();
              Date dtEnd = diEnd.getValueAsDate();
              int language = DocFlow.language_id;
              int doctype = docTypeId;
              long startdate = dtStart.getTime();
              long enddate = dtEnd.getTime();
              int userid =
                  DocFlow.hasPermition(PermissionNames.VIEW_ALL_DOCUMENTS) ? 0 : DocFlow.user_id;
              String _url =
                  "reportgenerator.jsp?language="
                      + language
                      + "&doctype="
                      + doctype
                      + "&startdate="
                      + startdate
                      + "&enddate="
                      + enddate
                      + "&userid="
                      + userid;
              ArrayList<String> criterias = createCriteria();
              String ret = "";
              Document doc = XMLParser.createDocument();
              Element rootElem = doc.createElement("DocDef");
              doc.appendChild(rootElem);

              for (String key : criterias) {
                Element val = doc.createElement("Val");
                val.setAttribute("V", key);
                rootElem.appendChild(val);
              }
              ret = doc.toString();
              _url += "&xml=" + URL.encode(ret);
              Window.open(
                  _url, "yourWindowName", "location=yes,resizable=yes,scrollbars=yess,status=yes");
            }
          });

      bashConfirm = new ButtonItem("bashConfirm", "Bash Confirm");
      bashConfirm.setStartRow(false);
      bashConfirm.setEndRow(false);
      bashConfirm.setDisabled(true);

      bashConfirm.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              WBashConfirmDocuments.showWindow(docTypeId);
            }
          });
    }
  }