@Override
  public void init(QuickNewJobPresenter p) {
    this.presenter = p;

    newParametersButton.setText(constants.Add_Parameter());
    createButton.setText(constants.Create());
    jobNameLabel.setText(constants.Name());
    jobDueLabel.setText(constants.Due_On());
    jobTypeLabel.setText(constants.Type());
    dataTriesLabel.setText(constants.Retries());

    myParametersGrid.setHeight("200px");

    // Set the message to display when the table is empty.
    myParametersGrid.setEmptyTableWidget(new Label(constants.No_Parameters_added_yet()));

    initGridColumns();

    long now = System.currentTimeMillis();
    jobDueDate.setEnabled(true);

    jobDueDate.setValue(now);

    jobDueDateTime.setValue(UTCDateBox.date2utc(new Date()));
  }
예제 #2
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");
   }
 }
예제 #3
0
  private Widget getMainPanel() {
    SimplePanel panel = new SimplePanel();
    panel.setWidth("100%");
    panel.setHeight("100%");

    dataGrid = new DataGrid<RuleInfo>(MAX_RULES, RuleInfo.KEY_PROVIDER);
    dataGrid.setHeight(MAIN_HEIGHT);

    Column<RuleInfo, String> columnName =
        addColumn(
            new TextCell(),
            "Rule Name",
            new GetValue<String>() {
              public String getValue(RuleInfo rule) {
                return rule.getName();
              }
            },
            null);

    Column<RuleInfo, String> ruleType =
        addColumn(
            new TextCell(),
            "Type",
            new GetValue<String>() {
              public String getValue(RuleInfo rule) {
                return rule.getType().toUpperCase();
              }
            },
            null);

    Column<RuleInfo, ImageResource> ruleEnabled =
        addColumn(
            new ImageResourceCell(),
            "Enabled",
            new GetValue<ImageResource>() {
              public ImageResource getValue(RuleInfo rule) {
                if (rule.isEnabled()) {
                  return PgStudio.Images.trueBox();
                }
                return PgStudio.Images.falseBox();
              }
            },
            null);

    Column<RuleInfo, ImageResource> instead =
        addColumn(
            new ImageResourceCell(),
            "Instead",
            new GetValue<ImageResource>() {
              public ImageResource getValue(RuleInfo rule) {
                if (rule.isInstead()) {
                  return PgStudio.Images.trueBox();
                }
                return PgStudio.Images.falseBox();
              }
            },
            null);

    dataGrid.setColumnWidth(columnName, "200px");
    dataGrid.setColumnWidth(ruleType, "120px");
    dataGrid.setColumnWidth(ruleEnabled, "100px");
    dataGrid.setColumnWidth(instead, "100px");

    ruleType.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    ruleEnabled.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    instead.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    dataGrid.setLoadingIndicator(new Image(PgStudio.Images.spinner()));

    dataProvider.addDataDisplay(dataGrid);

    dataGrid.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        (new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            RuleInfo rule = selectionModel.getSelectedObject();
            ruleDef.setText(rule.getDefinition());
          }
        }));

    panel.add(dataGrid);

    return panel.asWidget();
  }
예제 #4
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

          }
        });
  }