Пример #1
0
 protected void displayProblems(ProblemAndSubmissionReceipt[] result) {
   if (result != null) {
     grid.setRowCount(result.length);
     grid.setRowData(Arrays.asList(result));
     grid.setWidth("100%");
     grid.setHeight(result.length * 50 + "px");
   }
 }
Пример #2
0
  public ExonDetailPanel() {
    dataGrid.setWidth("100%");
    initializeTable();
    dataProvider.addDataDisplay(dataGrid);
    dataGrid.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            if (selectionModel.getSelectedSet().isEmpty()) {
              exonEditContainer.setVisible(false);
            } else {
              exonEditContainer.setVisible(true);
              updateDetailData(selectionModel.getSelectedObject());
            }
          }
        });

    initWidget(ourUiBinder.createAndBindUi(this));
  }
Пример #3
0
  public SupplyLayout() {
    this.res = GWT.create(SupplyResources.class);
    res.style().ensureInjected();
    initWidget(uiBinder.createAndBindUi(this));
    final ListDataProvider<Supply> dataProvider = new ListDataProvider<Supply>();
    dataGrid.setMinimumTableWidth(150, Unit.PX);
    dataGrid.setWidth("100%");
    dataGrid.setHeight("450px");
    dataGrid.setAutoHeaderRefreshDisabled(true);
    dataGrid.setEmptyTableWidget(new Label("Нет данных"));

    ListHandler<Supply> sortHandler = new ListHandler<Supply>(dataProvider.getList());
    dataGrid.addColumnSortHandler(sortHandler);

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);
    pager.setPageSize(10);
    pager.setPageStart(0);
    panel.add(pager);
    final SelectionModel<Supply> selectionModel = new MultiSelectionModel<Supply>();
    dataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Supply>createDefaultManager());

    initTableColumns(selectionModel, sortHandler);

    // Верхняя панелька для поиск
    searchFlexTable = new FlexTable();
    cellFormatter = searchFlexTable.getFlexCellFormatter();
    searchFlexTable.setWidth("80%");
    searchFlexTable.setCellSpacing(5);
    searchFlexTable.setCellPadding(1);

    Label idLabel = new Label("Номер");
    final TextBox idTBox = new TextBox();
    searchFlexTable.setWidget(0, 0, idLabel);
    searchFlexTable.setWidget(0, 1, idTBox);

    Label addressLabel = new Label("Адрес");
    final TextBox addressTBox = new TextBox();
    searchFlexTable.setWidget(1, 0, addressLabel);
    searchFlexTable.setWidget(1, 1, addressTBox);

    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM).format(date);
            text.setText(dateString);
          }
        });

    // Set the default value
    // datePicker.setValue(new Date(), true);

    // Create a DateBox
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
    final DateBox dateBox = new DateBox();
    dateBox.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    Label dateLabel = new Label("Дата");

    searchFlexTable.setWidget(2, 0, dateLabel);
    searchFlexTable.setWidget(2, 1, dateBox);

    Label typeLabel = new Label("Тип");
    final ListBox typeLB = new ListBox();
    typeLB.addItem("");
    typeLB.addItem("В филиал");
    typeLB.addItem("На склад");
    searchFlexTable.setWidget(3, 0, typeLabel);
    searchFlexTable.setWidget(3, 1, typeLB);

    Label statusLabel = new Label("Статус");
    final ListBox statusLB = new ListBox();
    statusLB.addItem("");
    for (String type : StatusDict.getAsStringList()) {
      statusLB.addItem(type);
    }
    searchFlexTable.setWidget(4, 0, statusLabel);
    searchFlexTable.setWidget(4, 1, statusLB);
    cellFormatter.setRowSpan(5, 0, 2);
    Button search = new Button("Найти");
    searchFlexTable.setWidget(5, 0, search);

    search.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {

            // формируем карту с where statement:
            Map<String, String> whereMap = new HashMap<String, String>();
            if (idTBox.getText() != null && !"".equals(idTBox.getText()))
              whereMap.put("supid", idTBox.getText());
            if (addressTBox.getText() != null && !"".equals(addressTBox.getText()))
              whereMap.put("address", addressTBox.getText());
            if (dateBox.getTextBox().getText() != null
                && !"".equals(dateBox.getTextBox().getText()))
              whereMap.put("date", dateBox.getTextBox().getText());
            if (typeLB.getSelectedIndex() != 0) {
              if (typeLB.getSelectedIndex() == 1) whereMap.put("DeliveryDirection", "1");
              if (typeLB.getSelectedIndex() == 2) whereMap.put("DeliveryDirection", "0");
            }
            if (statusLB.getSelectedIndex() != 0)
              whereMap.put("SupStatusID", Integer.toString(statusLB.getSelectedIndex()));
            supplyService.getByConditions(
                whereMap,
                new AsyncCallback<List<Supply>>() {

                  @Override
                  public void onSuccess(List<Supply> result) {
                    if (result != null) {
                      dataProvider.getList().clear();
                      dataProvider.getList().addAll(result);
                      dataProvider.refresh();
                    }
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    Window.alert("Ошибка");
                  }
                });
          }
        });
    additionalPanel.add(searchFlexTable);

    // /////////////////////////////////////////////////////
    supplyService.getLast(
        10,
        new AsyncCallback<List<Supply>>() {

          @Override
          public void onSuccess(List<Supply> result) {
            if (result != null) {
              dataProvider.getList().addAll(result);
              dataProvider.addDataDisplay(dataGrid);
              dataProvider.refresh();
            }
          }

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

          }
        });
  }