public Canvas getViewPanel() {

    final TabSet tabSet = new TabSet();
    tabSet.setTabBarPosition(Side.TOP);

    // required so that the select item doesnt touch the tab pane
    tabSet.setTabBarThickness(25);
    tabSet.setTabBarAlign(Side.LEFT);
    tabSet.setWidth(400);
    tabSet.setHeight(200);

    final Tab statusTab = new Tab("Status");

    final Canvas statusPane = new Canvas();
    statusTab.setPane(statusPane);
    tabSet.addTab(statusTab);

    SelectItem selectItem = new SelectItem();
    selectItem.setValueMap("Development", "Staging", "Production");
    selectItem.setShowTitle(false);

    selectItem.setDefaultValue("Development");
    selectItem.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            statusPane.setContents(
                event.getValue()
                    + ": <span style='color:green;font-weight:bold'>Normal</span><br>");
          }
        });

    DynamicForm form = new DynamicForm();
    // form.setHeight(1);
    form.setPadding(0);
    form.setMargin(0);
    form.setCellPadding(1);
    form.setNumCols(1);
    form.setFields(selectItem);

    tabSet.setTabBarControls(TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER, form);
    return tabSet;
  }
  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();
          }
        });
  }
Exemplo n.º 3
0
  private void buildInstallInfoCanvas(AgentInstallInfo info) {
    DynamicForm infoForm = new DynamicForm();
    infoForm.setMargin(20);
    infoForm.setWidth100();
    infoForm.setHeight100();

    HeaderItem infoHeader = new HeaderItem();
    infoHeader.setValue(MSG.view_remoteAgentInstall_installInfo());

    StaticTextItem version = new StaticTextItem("version", MSG.common_title_version());
    version.setValue(info.getVersion());

    StaticTextItem path = new StaticTextItem("path", MSG.common_title_path());
    path.setValue(info.getPath());

    StaticTextItem owner = new StaticTextItem("owner", MSG.common_title_owner());
    owner.setValue(info.getOwner());

    StaticTextItem config = new StaticTextItem("config", MSG.common_title_configuration());
    config.setValue(info.getConfigurationStartString());

    CanvasItem listCanvas = new CanvasItem();
    listCanvas.setShowTitle(false);
    listCanvas.setColSpan(2);

    VLayout listLayout = new VLayout(0);
    listLayout.setWidth100();
    listLayout.setHeight100();

    ListGrid listGrid =
        new ListGrid() {
          @Override
          protected Canvas getExpansionComponent(ListGridRecord record) {
            Canvas canvas = super.getExpansionComponent(record);
            canvas.setPadding(5);
            return canvas;
          }
        };
    listGrid.setWidth100();
    listGrid.setHeight100();
    listGrid.setCanExpandRecords(true);
    listGrid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
    listGrid.setDetailField("result");
    ListGridField step = new ListGridField("description", MSG.view_remoteAgentInstall_step());
    ListGridField result = new ListGridField("result", MSG.view_remoteAgentInstall_result());
    ListGridField resultCode =
        new ListGridField("resultCode", MSG.view_remoteAgentInstall_resultCode(), 90);
    ListGridField duration = new ListGridField("duration", MSG.common_title_duration(), 90);
    listGrid.setFields(step, result, resultCode, duration);
    listGrid.setData(getStepRecords(info));

    listLayout.addMember(listGrid);
    listCanvas.setCanvas(listLayout);

    // Replace the current info with just the install steps
    for (Canvas canvas : this.getChildren()) {
      canvas.markForDestroy();
    }

    createAgentStatusTextItem();
    infoForm.setFields(infoHeader, version, path, owner, config, agentStatusText, listCanvas);

    addMember(infoForm);

    this.setMembersMargin(1);
    this.markForRedraw();
  }
  private void prepareDetailsSection(SectionStack stack, ServerPlugin plugin) {
    DynamicForm form = new DynamicForm();
    form.setMargin(10);
    form.setWidth100();
    form.setWrapItemTitles(false);
    form.setNumCols(4);

    StaticTextItem nameItem = new StaticTextItem("name", MSG.common_title_name());
    nameItem.setValue(plugin.getName());

    StaticTextItem displayNameItem =
        new StaticTextItem("displayName", MSG.common_title_display_name());
    displayNameItem.setValue(plugin.getDisplayName());

    StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
    versionItem.setValue(plugin.getVersion());

    StaticTextItem md5Item = new StaticTextItem("MD5", "MD5");
    md5Item.setValue(plugin.getMD5());

    StaticTextItem pathItem = new StaticTextItem("path", MSG.common_title_path());
    pathItem.setValue(plugin.getPath());

    StaticTextItem ampsItem =
        new StaticTextItem("ampsVersion", "AMPS " + MSG.common_title_version());
    ampsItem.setValue(plugin.getAmpsVersion());

    StaticTextItem descItem = new StaticTextItem("desc", MSG.common_title_description());
    descItem.setValue(plugin.getDescription());

    StaticTextItem mtimeItem = new StaticTextItem("mtime", MSG.common_title_lastUpdated());
    mtimeItem.setValue(
        TimestampCellFormatter.format(
            Long.valueOf(plugin.getMtime()), TimestampCellFormatter.DATE_TIME_FORMAT_MEDIUM));

    StaticTextItem kindItem = new StaticTextItem("kind", MSG.common_title_kind());
    switch (plugin.getDeployment()) {
      case AGENT:
        kindItem.setValue(MSG.view_admin_plugins_agent());
        break;
      case SERVER:
        kindItem.setValue(MSG.view_admin_plugins_server());
        break;
    }

    CanvasItem enabledItem = new CanvasItem("enabled", MSG.common_title_enabled());
    Img img = new Img(ImageManager.getAvailabilityIcon(plugin.isEnabled()), 16, 16);
    enabledItem.setCanvas(img);

    StaticTextItem typeItem = new StaticTextItem("type", MSG.common_title_type());
    typeItem.setValue(plugin.getType());

    form.setItems(
        displayNameItem,
        nameItem,
        versionItem,
        ampsItem,
        md5Item,
        kindItem,
        descItem,
        pathItem,
        mtimeItem,
        enabledItem,
        typeItem);

    SectionStackSection section = new SectionStackSection(MSG.common_title_details());
    section.setExpanded(true);
    section.setItems(form);

    detailsSection = section;
    ++initSectionCount;

    return;
  }
Exemplo n.º 5
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);
          }
        });
  }
Exemplo n.º 6
0
  /** This is the entry point method. */
  public void onModuleLoad() {

    final HelpCanvas help1 = new HelpCanvas("help1");
    final HelpCanvas help2 = new HelpCanvas("help2");

    HLayout layout = new HLayout();
    layout.setMembersMargin(20);

    final SectionStack sectionStack = new SectionStack();
    sectionStack.setVisibilityMode(VisibilityMode.MUTEX);
    sectionStack.setWidth(800);
    sectionStack.setHeight(600);

    SectionStackSection section1 = new SectionStackSection("Settings for Stream Recorder");
    section1.setExpanded(true);
    section1.setResizeable(false);

    // VLayout layout = new VLayout(25);

    layout.setAlign(Alignment.CENTER);
    layout.setMargin(23);
    layout.setWidth("93%");

    final DataSource dataSource = SettingsDS.getInstance();

    final DynamicForm form = new DynamicForm();
    form.setIsGroup(true);
    form.setGroupTitle("Update");
    form.setNumCols(4);
    form.setDataSource(dataSource);
    form.setMargin(1);

    final ListGrid listGrid = new ListGrid();
    listGrid.setWidth100();
    listGrid.setHeight(130);
    listGrid.setDataSource(dataSource);
    listGrid.setAutoFetchData(true);
    listGrid.addRecordClickHandler(
        new RecordClickHandler() {
          public void onRecordClick(RecordClickEvent event) {
            form.reset();
            form.editSelectedData(listGrid);
          }
        });

    section1.addItem(listGrid);
    section1.addItem(form);

    IButton butt = new IButton("Save");
    butt.setMargin(2);

    butt.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            form.saveData();
          }
        });
    section1.addItem(butt);

    Button button = new Button("Hello from Admin");
    button.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            Services.getHelloService()
                .hello(
                    "Admin",
                    new AsyncCallback<Void>() {

                      @Override
                      public void onFailure(Throwable caught) {
                        // TODO Auto-generated method stub

                      }

                      @Override
                      public void onSuccess(Void result) {
                        // TODO Auto-generated method stub

                      }
                    });
          }
        });

    sectionStack.addSection(section1);

    SectionStackSection section2 = new SectionStackSection("Help 1");
    section2.setExpanded(true);
    section2.setCanCollapse(true);

    section2.addItem(help1);
    sectionStack.addSection(section2);
    // SectionStackSection section3 = new SectionStackSection("Help 2");
    // section3.setExpanded(true);
    // section3.setCanCollapse(true);
    // section3.addItem(help2);
    // sectionStack.addSection(section3);

    // IButton resizeButton = new IButton("Resize Help 1");
    // resizeButton.setWidth(150);
    // resizeButton.addClickHandler(new ClickHandler() {
    // public void onClick(ClickEvent event) {
    // help1.setHeight(200);
    // }
    // });

    layout.addMember(sectionStack);

    // VLayout buttons = new VLayout(25);
    // buttons.setMembersMargin(10);
    // buttons.addMember(resizeButton);

    // layout.addMember(buttons);

    layout.addMember(button);
    layout.draw();

    // RootPanel.get().add(topTabSet);
  }
Exemplo n.º 7
0
  public DeliveryOrderLayout(final User currentUser) {
    // Tab reviseTab = new Tab("ข้อมูลใบแจ้งหนี้", "icons/16/search-good-icon.png");
    // VLayout reviseLayout = new VLayout();
    // reviseLayout.
    setWidth(750);
    // reviseLayout.
    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(DeliveryDS.getInstance());
    searchForm.setUseAllDataSourceFields(false);
    searchForm.setGroupTitle("ค้นหารายการนำส่งสินค้า");

    final TextItem deliveryText = new TextItem("delivery_id", "รหัสรายการนำส่งสินค้า");
    deliveryText.setWrapTitle(false);
    deliveryText.setOperator(OperatorId.REGEXP);
    final TextItem saleText = new TextItem("sale_id", "รหัสรายการขาย");
    saleText.setWrapTitle(false);
    saleText.setOperator(OperatorId.REGEXP);
    final SelectItem statusSelected = new SelectItem("issued_status", "สถานะ");
    statusSelected.setWrapTitle(false);
    // statusSelected.setValueMap("กำลังนำส่ง", "นำส่งแล้ว");
    statusSelected.setValueMap(DeliveryStatus.getIssueValueMap());
    statusSelected.setAllowEmptyValue(true);
    statusSelected.setEmptyDisplayValue("ทั้งหมด");
    statusSelected.setOperator(OperatorId.EQUALS);
    final TextItem cidText = new TextItem("cid", "รหัสลูกค้า");
    cidText.setWrapTitle(false);
    cidText.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("วันที่นำส่งสินค้า");
    dateForm.setGroupTitle("วันที่ออกใบนำส่งสินค้า");
    DateRange dateRange = new DateRange();
    dateRange.setRelativeStartDate(new RelativeDate("-7d"));
    dateRange.setRelativeEndDate(RelativeDate.TODAY);
    // final DateItem from = new DateItem("delivery_from" , "ตั้งแต่");
    // final DateItem to = new DateItem("delivery_to" , "ถึง");
    final DateItem from = new DateItem("created_from", "ตั้งแต่");
    final DateItem to = new DateItem("created_to", "ถึง");
    from.setDefaultChooserDate(dateRange.getStartDate());
    from.setDefaultValue(dateRange.getStartDate());
    from.setUseTextField(true);
    to.setDefaultChooserDate(dateRange.getEndDate());
    to.setDefaultValue(dateRange.getEndDate());
    to.setUseTextField(true);

    FromToValidate.addValidator(from, to);
    searchForm.setItems(deliveryText, statusSelected, saleText, cidText);
    // searchForm.setItems(Text, cidText, cnameText);
    dateForm.setItems(from, to);

    // final ListGrid deliveryListGrid = new EditorListGrid(new RequestViewWindow(), currentUser);
    final ListGrid deliveryListGrid = new ListGrid();

    deliveryListGrid.setAutoFetchData(true);
    deliveryListGrid.setCanMultiSort(true);
    // deliveryListGrid.setCriteria(new Criterion("status", OperatorId.NOT_EQUAL, "ยกเลิก"));

    deliveryListGrid.setDataSource(DeliveryDS.getInstance());
    deliveryListGrid.setInitialSort(
        new SortSpecifier[] {
          new SortSpecifier("issued_status", SortDirection.ASCENDING),
          new SortSpecifier("delivery", SortDirection.DESCENDING)
        });
    deliveryListGrid.setUseAllDataSourceFields(false);
    deliveryListGrid.setGroupByField("issued_status");
    deliveryListGrid.setGroupStartOpen(GroupStartOpen.ALL);

    ListGridField delivery_id = new ListGridField("delivery_id", 120);
    ListGridField sale_id = new ListGridField("sale_id", 100);
    // ListGridField quote_id = new ListGridField("quote_id" , 90);
    ListGridField cus_name = new ListGridField("cus_name", 180);
    ListGridField status = new ListGridField("issued_status");
    //		LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
    //		valueMap.put("3_approved", "approved");
    //		status.setValueMap(valueMap);
    ListGridField total_amount = new ListGridField("total_amount", 120);
    total_amount.setCellFormatter(FieldFormatter.getIntegerFormat());
    total_amount.setAlign(Alignment.RIGHT);
    //		ListGridField netInclusive = new ListGridField("netInclusive", 125);
    //		netInclusive.setCellFormatter(FieldFormatter.getPriceFormat());
    //		netInclusive.setAlign(Alignment.RIGHT);
    ListGridField delivery_date = new ListGridField("delivery", 120);
    //		created_date.setType(ListGridFieldType.DATE);
    //		created_date.setCellFormatter(new CellFormatter() {
    //
    //			@Override
    //			public String format(Object arg0, ListGridRecord arg1, int arg2, int arg3) {
    //			DateTimeFormat fmt = DateTimeFormat.getFormat("MM/dd/yyyy");
    //			return fmt.format(arg1.getAttributeAsDate("created_date"));
    //			}
    //		});

    //		ListGridField iconField = new ListGridField("viewDeliveryField", "เรียกดูรายการ", 80);

    deliveryListGrid.setFields(status, delivery_id, sale_id, cus_name, total_amount, delivery_date);

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

    HLayout buttonLayout = new HLayout();
    buttonLayout.setMargin(10);
    buttonLayout.setMembersMargin(5);
    buttonLayout.setHeight(30);
    IButton searchButton = new IButton("ค้นหารายการนำส่งสินค้า");
    searchButton.setIcon("icons/16/icon_view.png");
    searchButton.setWidth(150);
    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("delivery", OperatorId.BETWEEN_INCLUSIVE,
                      // from.getValueAsDate(), to.getValueAsDate()),
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate()),
                      search
                    });
            deliveryListGrid.fetchData(criteria);
            deliveryListGrid.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("delivery", OperatorId.BETWEEN_INCLUSIVE,
                      // from.getValueAsDate(), to.getValueAsDate())
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate())
                    });
            searchForm.reset();
            deliveryListGrid.fetchData(criteria);
            deliveryListGrid.deselectAllRecords();
          }
        });

    HLayout empty = new HLayout();
    empty.setWidth("*");
    IButton viewButton = new IButton("เรียกดูรายการ");
    viewButton.setIcon("icons/16/icon_view.png");
    viewButton.setWidth(150);
    viewButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            ListGridRecord selected = deliveryListGrid.getSelectedRecord();
            if (selected == null) {
              SC.warn("กรุณาเลือกรายการเบิกสินค้า");
              return;
            }
            RequestViewWindow deliveryWindow = new RequestViewWindow();
            deliveryWindow.show(selected, false, currentUser, 1);
          }
        });

    IButton receiveOrderButton = new IButton("เบิกจ่ายสินค้า");
    receiveOrderButton.setIcon("icons/16/actions-receive-icon.png");
    receiveOrderButton.setWidth(100);
    receiveOrderButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            ListGridRecord selected = deliveryListGrid.getSelectedRecord();
            if (selected == null) {
              SC.warn("กรุณาเลือกรายการเบิกสินค้า");
              return;
            }

            if (selected
                .getAttributeAsString("issued_status")
                .equalsIgnoreCase("0_product_request")) {
              RequestViewWindow deliveryWindow = new RequestViewWindow();
              deliveryWindow.show(selected, true, currentUser, 2);
            } else {
              SC.warn("จ่ายสินค้าแล้ว");
            }
          }
        });

    buttonLayout.addMembers(searchButton, listAllButton, empty, viewButton, receiveOrderButton);
    // buttonLayout.addMembers(searchButton, listAllButton);
    // reviseLayout.
    addMember(buttonLayout);

    VLayout gridLayout = new VLayout();
    gridLayout.setWidth100();
    gridLayout.setHeight(355);

    gridLayout.addMember(deliveryListGrid);
    // reviseLayout.
    addMember(gridLayout);

    // reviseTab.setPane(reviseLayout);
    // return reviseTab;
  }