예제 #1
0
  /**
   * Update the rows retrieved label based on the search results.
   *
   * @param dc
   */
  private void updateRowsRetrieved(DataClass[] dc) {
    if (dc.length >= 1) {

      String numEntries = dc[0].getAttribute("numEntries");
      String complete = dc[0].getAttribute("complete");

      if (complete != null && !complete.equals("COMPLETE")) {
        i_rowsRetrievedLabel.setContents(ROWS_RETRIEVED_TITLE + "<b> " + numEntries + "</b>+");
      } else {
        i_rowsRetrievedLabel.setContents(ROWS_RETRIEVED_TITLE + " <b>" + numEntries + "</b>");
      }

      String searchText = i_searchTextItem.getValueAsString();
      if (searchText == null || searchText.length() == 0) {
        i_rowsRetrievedLabel.setContents("");
      }
    } else {
      i_rowsRetrievedLabel.setContents(ROWS_RETRIEVED_TITLE + " <b>0</b>");
    }
  }
예제 #2
0
  public void build(DataSource entityDataSource, DataSource... additionalDataSources) {
    VLayout leftVerticalLayout = new VLayout();
    leftVerticalLayout.setID("customerLeftVerticalLayout");
    leftVerticalLayout.setHeight100();
    leftVerticalLayout.setWidth("50%");
    leftVerticalLayout.setShowResizeBar(true);

    listDisplay =
        new DynamicEntityListView(
            BLCMain.getMessageManager().getString("customerListTitle"),
            entityDataSource,
            false,
            false);
    leftVerticalLayout.addMember(listDisplay);

    dynamicFormDisplay =
        new DynamicFormView(
            BLCMain.getMessageManager().getString("customerDetailsTitle"), entityDataSource);
    dynamicFormDisplay.setWidth("50%");
    ToolStrip toolbar = dynamicFormDisplay.getToolbar();
    toolbar.addFill();
    Label label = new Label();
    label.setContents(BLCMain.getMessageManager().getString("resetPasswordPrompt"));
    label.setWrap(false);
    toolbar.addMember(label);

    updateLoginButton = new ToolStripButton();
    updateLoginButton.setIcon(
        GWT.getModuleBaseURL() + "sc/skins/Enterprise/images/headerIcons/settings.png");
    updateLoginButton.setDisabled(true);
    toolbar.addButton(updateLoginButton);
    toolbar.addSpacer(6);

    addMember(leftVerticalLayout);
    addMember(dynamicFormDisplay);
  }
예제 #3
0
 public SavePanel(
     String saveTitle, ClickHandler saveClicked, String cancelTitle, ClickHandler cancelClicked) {
   if (saveTitle == null || saveTitle.trim().length() == 0)
     saveTitle = "OK"; // ClientSession.getInstance().getCaption("save");
   if (cancelTitle == null || cancelTitle.trim().length() == 0)
     cancelTitle = "Close"; // ClientSession.getInstance().getCaption("cancel");
   hl = new HLayout();
   hl.setAlign(Alignment.RIGHT);
   saveBtn = new IButton(saveTitle);
   saveBtn.addClickHandler(saveClicked);
   cancelBtn = new IButton(cancelTitle);
   cancelBtn.addClickHandler(cancelClicked);
   hl.addMember(saveBtn);
   hl.addMember(cancelBtn);
   hl.setWidth100();
   hl.setMembersMargin(10);
   hl.setHeight("30");
   Label l = new Label();
   l.setTitle("");
   l.setContents("");
   l.setWidth(0);
   hl.addMember(l);
   addMember(hl);
 }
 public void clearStatus() {
   status.setContents("");
 }
  public UserDetailTabPane(DataSource userDS, final ItemListGrid userListGrid) {

    this.userListGrid = userListGrid;
    setStyleName("defaultBorder");

    userViewer = new DetailViewer();
    userViewer.setDataSource(userDS);
    userViewer.setWidth100();
    userViewer.setMargin(25);
    userViewer.setEmptyMessage("Select an user to view its details");

    editorLabel = new Label();
    editorLabel.setWidth100();
    editorLabel.setHeight100();
    editorLabel.setAlign(Alignment.CENTER);
    editorLabel.setContents("Select an user to edit, or insert a new user into");

    insertLabel = new Label();
    insertLabel.setWidth100();
    insertLabel.setHeight100();
    insertLabel.setAlign(Alignment.CENTER);
    insertLabel.setContents("Insert a new user into");

    // update form
    editorForm = new DynamicForm();
    editorForm.setWidth(650);
    editorForm.setMargin(25);
    editorForm.setNumCols(4);
    editorForm.setCellPadding(5);
    editorForm.setAutoFocus(false);
    editorForm.setDataSource(userDS);
    editorForm.setUseAllDataSourceFields(true);

    userId = new StaticTextItem("userId", "User ID");
    userName = new TextItem("userName", "User Name");
    password = new PasswordItem("password", "Password");
    enabled = new CheckboxItem("enabled", "Enabled");

    userName.setRequired(true);
    password.setRequired(true);

    ButtonItem saveButton = new ButtonItem("saveUser", "Update user info.");
    saveButton.setAlign(Alignment.CENTER);
    saveButton.setWidth(100);
    saveButton.setColSpan(4);
    saveButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // editorForm.saveData();

            if (userId.getValue() == null) {
              return;
            }

            if (!editorForm.validate(false)) {
              return;
            }
            User user = new User();

            user.setUserId((String) userId.getValue());
            user.setUserName(userName.getValueAsString());
            user.setPassword(password.getValueAsString());
            user.setEnabled(enabled.getValueAsBoolean());

            userService.updateUser(
                user,
                new AsyncCallback<Void>() {
                  public void onFailure(Throwable caught) {
                    SC.say("Error", "Server side error occured. Contact your administrator.");
                  }

                  public void onSuccess(Void noAnswer) {
                    SC.say("Updated", "User info. is updated.");

                    userListGrid.invalidateCache();
                  }
                });
          }
        });

    editorForm.setFields(userId, userName, password, enabled, saveButton);
    editorForm.setColWidths(100, 200, 100, 200);

    // insert form
    insertForm = new DynamicForm();
    insertForm.setWidth(650);
    insertForm.setMargin(25);
    insertForm.setNumCols(4);
    insertForm.setCellPadding(5);
    insertForm.setAutoFocus(false);
    insertForm.setDataSource(userDS);
    insertForm.setUseAllDataSourceFields(true);

    userId4add = new TextItem("userId", "User ID");
    userName4add = new TextItem("userName", "User Name");
    password4add = new PasswordItem("password", "Password");
    enabled4add = new CheckboxItem("enabled", "Enabled");

    enabled4add.setValue(true);
    userId4add.setRequired(true);
    userName4add.setRequired(true);
    password4add.setRequired(true);

    ButtonItem addButton = new ButtonItem("addUser", "Add user info.");
    addButton.setAlign(Alignment.CENTER);
    addButton.setWidth(100);
    addButton.setColSpan(4);
    addButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {

            if (!insertForm.validate(false)) {
              return;
            }

            User user = new User();

            user.setUserId(userId4add.getValueAsString());
            user.setUserName(userName4add.getValueAsString());
            user.setPassword(password4add.getValueAsString());
            user.setEnabled(enabled4add.getValueAsBoolean());

            userService.addUser(
                user,
                new AsyncCallback<Void>() {
                  public void onFailure(Throwable caught) {
                    SC.say("Error", "Server side error occured. Contact your administrator.");
                  }

                  public void onSuccess(Void noAnswer) {
                    SC.say("Added", "User info. is added.");

                    userListGrid.invalidateCache();
                    insertForm.clearValues();
                  }
                });
          }
        });

    insertForm.setFields(userId4add, userName4add, password4add, enabled4add, addButton);
    insertForm.setColWidths(100, 200, 100, 200);

    // tab
    Tab viewTab = new Tab("View");
    viewTab.setIcon("silk/application_form.png");
    viewTab.setWidth(70);
    viewTab.setPane(userViewer);

    Tab editTab = new Tab("Edit");
    editTab.setIcon("demoApp/icon_edit.png");
    editTab.setWidth(70);
    editTab.setPane(editorForm);

    Tab insertTab = new Tab("Add");
    insertTab.setIcon("demoApp/icon_add.png");
    insertTab.setWidth(70);
    insertTab.setPane(insertForm);

    setTabs(viewTab, editTab, insertTab);

    addTabSelectedHandler(
        new TabSelectedHandler() {
          public void onTabSelected(TabSelectedEvent event) {
            updateDetails();
          }
        });
  }
 protected void showClientBuildDate() {
   String clientBuildDate = BLCMain.getMessageManager().getString("clientBuildDate");
   if (!clientBuildDate.equals("${clientBuildDate}")) {
     buildDateLabel.setContents("Build Date: " + clientBuildDate);
   }
 }
 private void changeLabel(Label label, String id, boolean hasFocus) {
   if (hasFocus) label.setContents(id + " has focus");
   else label.setContents("");
 }
예제 #8
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);
  }
예제 #9
0
파일: ListaVentas.java 프로젝트: bau88/TPPW
  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);
  }
예제 #10
0
  /**
   * Creates this property editor.
   *
   * @param contents Contents view form.
   */
  public MixinValueEditor(Contents contents) {
    super(TITLE);
    this.contents = contents;

    setWidth(WIDTH);
    setHeight(HEIGHT);

    Columns h1 = new Columns(Align.CENTER, Align.CENTER);
    h1.setHeight(15);

    Label l1 = new Label();
    l1.setWidth(150);
    l1.setContents("Mixin Types");

    Label l2 = new Label();
    l2.setWidth(100);
    l2.setContents("");

    Label l3 = new Label();
    l3.setWidth(150);
    l3.setContents("Node's types");

    h1.addMember(l1);
    h1.addMember(l2);
    h1.addMember(l3);

    addMember(h1);

    Columns layout = new Columns(Align.CENTER, Align.CENTER);
    layout.setWidth100();

    mixTypes.setMultiple(true);
    mixTypes.setMultipleAppearance(MultipleAppearance.GRID);
    mixTypes.setWidth(150);
    mixTypes.setHeight(200);

    selectedTypes.setMultiple(true);
    selectedTypes.setMultipleAppearance(MultipleAppearance.GRID);
    selectedTypes.setWidth(150);
    selectedTypes.setHeight(200);

    DynamicForm f1 = new DynamicForm();
    f1.setItems(mixTypes);
    f1.setWidth(150);
    f1.setHeight(200);

    DynamicForm f2 = new DynamicForm();
    f2.setItems(selectedTypes);
    f2.setWidth(150);
    f2.setHeight(200);

    VLayout buttons = new VLayout();
    buttons.setLayoutAlign(Alignment.CENTER);
    buttons.setDefaultLayoutAlign(Alignment.CENTER);
    buttons.setAlign(Alignment.CENTER);
    buttons.setLayoutAlign(VerticalAlignment.CENTER);
    buttons.setWidth(50);

    layout.addMember(f1);
    layout.addMember(buttons);
    layout.addMember(f2);

    Button b1 = new Button(">>");
    b1.setWidth(30);
    b1.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
            allTypes = remove(allTypes, mixTypes.getValueAsString());
            nodeTypes = add(nodeTypes, mixTypes.getValueAsString());
            updateLists();
          }
        });

    Button b2 = new Button("<<");
    b2.setWidth(30);
    b2.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
            nodeTypes = remove(nodeTypes, selectedTypes.getValueAsString());
            allTypes = add(allTypes, selectedTypes.getValueAsString());
            updateLists();
          }
        });

    buttons.addMember(b1);
    buttons.addMember(b2);

    addMember(layout);

    Columns h3 = new Columns(Align.RIGHT, Align.CENTER);
    h3.setHeight(50);

    Button okButton = new Button("OK");
    okButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
            onConfirm(null);
            hide();
          }
        });

    Button cancelButton = new Button("Cancel");
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
            hide();
          }
        });

    h3.addMember(okButton);
    h3.addMember(cancelButton);

    addMember(h3);
  }
예제 #11
0
 public void show(String name) {
   label.setContents("Repository: " + name);
   show();
 }
예제 #12
0
  public ReportReceiveLayout_2(final User currentUser) {
    setWidth(950);
    setHeight100();

    HLayout searchLayout = new HLayout();
    searchLayout.setHeight(20);

    final DynamicForm searchForm = new DynamicForm();
    searchForm.setWidth(450);
    searchForm.setHeight(30);
    searchForm.setMargin(5);
    searchForm.setNumCols(4);
    searchForm.setCellPadding(2);
    searchForm.setAutoFocus(true);
    searchForm.setSelectOnFocus(true);
    searchForm.setIsGroup(true);
    searchForm.setDataSource(TransferDS.getInstance());
    searchForm.setUseAllDataSourceFields(false);
    searchForm.setGroupTitle("ตัวกรอง");

    final SelectItem statusSelected = new SelectItem("status", "สถานะ");
    statusSelected.setWrapTitle(false);
    // statusSelected.setValueMap("รอแก้ไข", "รออนุมัติ", "อนุมัติแล้ว");
    statusSelected.setValueMap(TransferStatus.getValueMap());
    statusSelected.setAllowEmptyValue(true);
    statusSelected.setEmptyDisplayValue("ทั้งหมด");
    statusSelected.setOperator(OperatorId.EQUALS);
    final TextItem jidText = new TextItem("plan_id", "รหัสแผนการผลิต");
    jidText.setWrapTitle(false);
    jidText.setOperator(OperatorId.REGEXP);
    //		final TextItem smidText = new TextItem("smid", "รหัสช่าง");
    //		smidText.setWrapTitle(false);
    //		smidText.setOperator(OperatorId.REGEXP);

    //		final DynamicForm dateForm = new DynamicForm();
    //		dateForm.setWidth(300);
    //		dateForm.setHeight(30);
    //		dateForm.setMargin(5);
    //		dateForm.setNumCols(2);
    //		dateForm.setCellPadding(2);
    //		dateForm.setSelectOnFocus(true);
    //		dateForm.setIsGroup(true);
    //		dateForm.setGroupTitle("วันที่ขอโอนสินค้า");
    DateRange dateRange = new DateRange();
    dateRange.setRelativeStartDate(new RelativeDate("-1w"));
    dateRange.setRelativeEndDate(RelativeDate.TODAY);
    final DateItem from = new DateItem("create_from", "ตั้งแต่");
    final DateItem to = new DateItem("create_to", "ถึง");
    from.setDefaultChooserDate(dateRange.getStartDate());
    from.setDefaultValue(dateRange.getStartDate());
    from.setUseTextField(true);
    to.setDefaultChooserDate(dateRange.getEndDate());
    to.setDefaultValue(dateRange.getEndDate());
    to.setUseTextField(true);

    searchForm.setItems(jidText, statusSelected, from, to);
    // searchForm.setItems(planText, jidText);
    //        dateForm.setItems(from, to);

    final ListGrid orderListGrid = new ListGrid();

    orderListGrid.setAutoFetchData(true);
    orderListGrid.setCanMultiSort(true);
    orderListGrid.setShowRowNumbers(true);
    orderListGrid.setShowGridSummary(true);

    AdvancedCriteria criteria =
        new AdvancedCriteria(
            OperatorId.AND,
            new Criterion[] {
              // new Criterion("status", OperatorId.NOT_EQUAL, "3_to_next_process"),
              // new Criterion("created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(),
              // to.getValueAsDate())
              new Criterion(
                  "created_date",
                  OperatorId.BETWEEN_INCLUSIVE,
                  dateRange.getStartDate(),
                  dateRange.getEndDate())
            });
    orderListGrid.setCriteria(criteria);

    orderListGrid.setDataSource(TransferDS.getInstance());
    orderListGrid.setInitialSort(
        new SortSpecifier[] {
          new SortSpecifier("status", SortDirection.DESCENDING),
          new SortSpecifier("created_date", SortDirection.DESCENDING)
        });
    orderListGrid.setUseAllDataSourceFields(false);
    orderListGrid.setSelectionType(SelectionStyle.NONE);

    ListGridField transfer_id = new ListGridField("transfer_id", 100);
    transfer_id.setSummaryFunction(
        new SummaryFunction() {
          public Object getSummaryValue(Record[] records, ListGridField field) {
            return records.length + " รายการ";
          }
        });
    transfer_id.setShowGridSummary(true);

    ListGridField status = new ListGridField("status", 120);
    ListGridField plan_id = new ListGridField("plan_id", 100);
    ListGridField transfer_by = new ListGridField("transfer_by");
    ListGridField transfer_date = new ListGridField("transfer_date", 150);

    ListGridField total_weight = new ListGridField("total_sent_weight", 120);
    total_weight.setCellFormatter(FieldFormatter.getNumberFormat());
    total_weight.setAlign(Alignment.RIGHT);
    total_weight.setSummaryFunction(SummaryFunctionType.SUM);
    total_weight.setShowGridSummary(true);

    ListGridField total_amount = new ListGridField("total_sent_amount", 120);
    total_amount.setCellFormatter(FieldFormatter.getNumberFormat());
    total_amount.setAlign(Alignment.RIGHT);
    total_amount.setSummaryFunction(SummaryFunctionType.SUM);
    total_amount.setShowGridSummary(true);

    orderListGrid.setFields(
        transfer_date, transfer_id, status, plan_id, transfer_by, total_weight, total_amount);

    // orderListGrid.hideField("status");

    HLayout buttonLayout = new HLayout();
    buttonLayout.setMargin(10);
    buttonLayout.setMembersMargin(5);
    buttonLayout.setHeight(30);
    IButton searchButton = new IButton("ค้นหาคำขอโอนสินค้า");
    searchButton.setIcon("icons/16/reports-icon.png");
    searchButton.setWidth(170);
    searchButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Criterion search = new Criterion();
            search.addCriteria(searchForm.getValuesAsCriteria());
            AdvancedCriteria criteria =
                new AdvancedCriteria(
                    OperatorId.AND,
                    new Criterion[] {
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate()),
                      search
                    });
            reportDate.setContents(
                "ตั้งแต่วันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
                    + " ถึงวันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
            orderListGrid.fetchData(criteria);
            orderListGrid.deselectAllRecords();
          }
        });

    IButton listAllButton = new IButton("ล้างรายการค้นหา");
    listAllButton.setIcon("[SKIN]actions/refresh.png");
    listAllButton.setWidth(150);
    listAllButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            AdvancedCriteria criteria =
                new AdvancedCriteria(
                    OperatorId.AND,
                    new Criterion[] {
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate())
                    });
            searchForm.reset();
            reportDate.setContents(
                "ตั้งแต่วันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
                    + " ถึงวันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
            orderListGrid.fetchData(criteria);
            orderListGrid.deselectAllRecords();
          }
        });

    IButton printButton = new IButton("พิมพ์รายงาน");
    printButton.setIcon("icons/16/print.png");
    printButton.setWidth(120);

    buttonLayout.addMembers(searchButton, listAllButton, printButton);

    searchLayout.addMembers(searchForm);
    // reviseLayout.
    addMember(searchLayout);

    // reviseLayout.
    addMember(buttonLayout);

    final VLayout gridLayout = new VLayout();
    gridLayout.setWidth100();
    gridLayout.setHeight(500);
    Label text = new Label();
    text.setContents("รายงานการโอนสินค้าเข้าคลังสินค้า");
    text.setAlign(Alignment.CENTER);
    text.setHeight(10);
    text.setStyleName("printTitle");
    reportDate = new Label();
    reportDate.setContents(
        "ตั้งแต่วันที่ "
            + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
            + " ถึงวันที่ "
            + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
    reportDate.setAlign(Alignment.CENTER);
    reportDate.setHeight(10);
    reportDate.setStyleName("printDetails");

    gridLayout.addMember(text);
    gridLayout.addMember(reportDate);
    gridLayout.addMember(orderListGrid);
    addMember(gridLayout);

    printButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Canvas.showPrintPreview(gridLayout);
          }
        });
  }
예제 #13
0
  //    private final MapServiceInfoAsync mapServiceInfo = GWT.create(MapServiceInfo.class);
  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  public Authorization(final AsyncCallback<String> callback) {
    super(WINDOW_TITLE, WIDTH, HEIGHT, callback);

    this.setShowMinimizeButton(false);

    VLayout layout = new VLayout();
    layout.layoutChildren(null);

    accountForm = new DynamicForm();
    accountForm.setWidth100();
    accountForm.setPadding(5);
    //        backGround.setBorder("1px solid #ff0");
    TextItem login = new TextItem(CONTROL_LOGIN);
    login.setTitle(CAPTION_LOGIN);
    PasswordItem password = new PasswordItem(CONTROL_PASSWORD);
    password.setTitle(CAPTION_PASSWORD);

    password.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent keyPressEvent) {
            //                com.google.gwt.user.client.Window.alert("" +
            // keyPressEvent.getKeyName());
            if (keyPressEvent.getKeyName().equalsIgnoreCase("ENTER")) onOkClick();
          }
        });

    accountForm.setFields(login, password);

    Label linkRegistration = null;
    if (GWTViewer.config.withRegistration()) {
      linkRegistration = new Label();
      linkRegistration.setAlign(Alignment.RIGHT);
      linkRegistration.setStyleName(CSS_LABEL_LINK);
      linkRegistration.setHeight(20);
      linkRegistration.setWidth(265);
      linkRegistration.setContents(REGISTRATION);

      linkRegistration.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              callback.onSuccess(CMD_REGISTRATION);
              closeForm();
            }
          });
    }
    labelException = new Label();
    labelException.setAlign(Alignment.CENTER);
    labelException.setStyleName(CSS_LABEL_ERROR);
    labelException.setHeight(35);
    labelException.setWidth100();
    labelException.setMargin(5);
    //       labelException.setBorder("1px solid #0aa");
    labelException.setContents("");

    HLayout controlPanel = new HLayout();
    controlPanel.setHeight("30px");
    controlPanel.setLayoutLeftMargin(55);

    Button btnOk = null;
    btnOk = new Button("Ok");
    btnOk.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            onOkClick();
          }
        });
    Button btnClose = new Button(CAPTION_CLOSE);
    btnClose.setTop(10);
    btnClose.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            closeForm();
          }
        });
    controlPanel.addMember(btnOk);
    controlPanel.addMember(btnClose);

    layout.addMember(accountForm);
    if (linkRegistration != null) layout.addMember(linkRegistration);
    layout.addMember(labelException);
    layout.addMember(controlPanel);
    addItem(layout);
  }
예제 #14
0
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 private void onOkClick() {
   labelException.setContents("");
   if (!isEmpty()) userConnect();
   else labelException.setContents(EXCEPTION_EMPTY);
 }