示例#1
0
  @Override
  public void addHandler(final PTInstruction addHandler, final UIService uiService) {

    if (HANDLER.KEY_.DATE_VALUE_CHANGE_HANDLER.equals(addHandler.getString(HANDLER.KEY))) {
      final DateBox dateBox = cast();
      final TextBox textBox = dateBox.getTextBox();
      dateBox.addValueChangeHandler(
          new ValueChangeHandler<Date>() {

            @Override
            public void onValueChange(final ValueChangeEvent<Date> event) {
              triggerEvent(addHandler, uiService, dateBox);
            }
          });
      textBox.addValueChangeHandler(
          new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(final ValueChangeEvent<String> event) {
              triggerEvent(addHandler, uiService, dateBox);
            }
          });
    } else {
      super.addHandler(addHandler, uiService);
    }
  }
示例#2
0
 /**
  * Defines that the field shall notify value changes
  *
  * @param eventBus the event bus that will be used to fire the value change events
  */
 public void notifyChanges(final EventBus eventBus) {
   if (eventBus != null) {
     dateBox.addValueChangeHandler(
         new ValueChangeHandler<Date>() {
           @Override
           public void onValueChange(ValueChangeEvent<Date> arg0) {
             eventBus.fireEvent(new FieldValueChangeEvent(ImogDateBox.this));
           }
         });
   }
 }
示例#3
0
  private void setupSessionsDateRange() {
    DateTimeFormat format =
        DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.YEAR_MONTH_NUM_DAY);

    sessionsFrom.setFormat(new DateBox.DefaultFormat(format));
    sessionsTo.setFormat(new DateBox.DefaultFormat(format));

    sessionsFrom
        .getTextBox()
        .addValueChangeHandler(new EmptyDateBoxValueChangePropagator(sessionsFrom));
    sessionsTo
        .getTextBox()
        .addValueChangeHandler(new EmptyDateBoxValueChangePropagator(sessionsTo));

    final ValueChangeHandler<Date> valueChangeHandler =
        new ValueChangeHandler<Date>() {

          @Override
          public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
            sessionIdsTextBox.setValue(null);
            Date fromDate = sessionsFrom.getValue();
            Date toDate = sessionsTo.getValue();

            if (fromDate == null || toDate == null) {
              sessionDataProvider.addDataDisplayIfNotExists(sessionsDataGrid);
              sessionDataForDatePeriodAsyncProvider.removeDataDisplayIfNotExists(sessionsDataGrid);

              return;
            }

            sessionDataForDatePeriodAsyncProvider.setDateRange(fromDate, toDate);

            sessionDataProvider.removeDataDisplayIfNotExists(sessionsDataGrid);
            sessionDataForSessionIdsAsyncProvider.removeDataDisplayIfNotExists(sessionsDataGrid);
            sessionDataForDatePeriodAsyncProvider.addDataDisplayIfNotExists(sessionsDataGrid);
          }
        };

    sessionsTo.addValueChangeHandler(valueChangeHandler);
    sessionsFrom.addValueChangeHandler(valueChangeHandler);
  }
  /**
   * Die onLoad-Methode wird verwendet um in der Seite die verschiedenen Panels anzuordnen. Sie
   * startet beim Ausführen der Seite, da sie das Pendant zur <code>main()</code>-Methode einer
   * normalen Java Applikation darstellt
   */
  public void onLoad() {
    vonDateBox.setFormat(new DateBox.DefaultFormat(dF));
    bisDateBox.setFormat(new DateBox.DefaultFormat(dF));
    final HTML headline =
        new HTML(
            " <div class='"
                + "subline"
                + "'><h2>Reportgenerator 2: Alle Nachrichten je Zeitraum anzeigen </h2></div> ");
    // final HTML subtext = new HTML(" <div class='"+ "subtext"+ "'><h4> Der Report 2 gibt alle
    // Nachrichten in einen bestimmten Zeitraum aus  </h4></div> ");

    // Die Panels werden anschaulich angeordnet

    reportPanel.add(ueberSchrift2);
    reportPanel2.add(reportPanel2_left);
    reportPanel2.add(reportPanel2_right);
    reportPanel2_left.add(subSchrift2);
    reportPanel2_left.add(vonDateBox);
    reportPanel2_left.add(bisDateBox);
    reportPanel2_left.add(report2Generieren);
    report2Generieren.setStylePrimaryName("neueNchrichtBtn");

    reportPanel2_right.add(headline);
    //	reportPanel2_right.add(subtext);

    reportPanel2_right.add(beschreibung2);
    reportPanel.add(reportPanel2);

    /*
     * Das RootPanel wird gesäubert und die verschiedenen Elemente für
     * Report 2 zugeordnet.
     */
    RootPanel.get("content").clear();
    RootPanel.get("content_left").clear();
    RootPanel.get("content_right").clear();
    RootPanel.get("content_right").add(reportPanel2_right);
    RootPanel.get("content_left").add(reportPanel2_left);

    /*
     * Der jeweilige Zeitraum wird ausgewählt.
     */
    vonDateBox.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          @Override
          public void onValueChange(ValueChangeEvent<Date> event) {}
        });

    bisDateBox.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          @Override
          public void onValueChange(ValueChangeEvent<Date> event) {}
        });
    /*
     * Der Button <code>report2Generieren</code> bekommt eine Funktion,
     * damit der Report 2 generiert werden kann.
     */
    report2Generieren.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (vonDateBox.getValue() == null || bisDateBox.getValue() == null) {
              Window.alert("Bitte beide Datumfelder befüllen");
            } else {

              RootPanel.get("content_left").clear();
              RootPanel.get("content_right").clear();

              VerticalPanel ladenPanel = new VerticalPanel();
              ladenPanel.setStylePrimaryName("ladenPanel");

              Image ladenImg = new Image("laden.gif");
              ladenImg.setStylePrimaryName("ladenImg");
              ladenPanel.add(ladenImg);

              HTML ladenLabel =
                  new HTML(
                      "<h1> Bitte warten <h1><br /><h3>Bitte warte einen Augenblick bis der Report generiert wurde. Vielen Dank.</h3>");
              ladenPanel.add(ladenLabel);

              RootPanel.get("content").add(ladenPanel);

              nutzer = TellMeReport.gibEingeloggterBenutzer().getUser();
              NutzerDataProvider.gib(1)
                  .report2Generieren(
                      nutzer,
                      new Timestamp(vonDateBox.getValue().getTime()),
                      new Timestamp(bisDateBox.getValue().getTime()));
            }
          }
        });
  }
示例#5
0
  @SuppressWarnings("unused")
  private HorizontalPanel getDatePanel() {
    HorizontalPanel panel = new HorizontalPanel();

    startDate.setFormat((new DateBox.DefaultFormat(DateTimeFormat.getFormat("dd/MM/yyyy"))));
    startDate.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            exp.setStartDate("" + ((DateBox) (event.getSource())).getTextBox().getValue());
          }
        });
    startDate
        .getTextBox()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              public void onValueChange(ValueChangeEvent<String> event) {
                String value = ((TextBox) (event.getSource())).getValue();
                exp.setStartDate(value.equals("") ? null : value);
              }
            });

    endDate.setFormat((new DateBox.DefaultFormat(DateTimeFormat.getFormat("dd/MM/yyyy"))));
    endDate.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            exp.setEndDate(((DateBox) (event.getSource())).getTextBox().getValue());
          }
        });
    endDate
        .getTextBox()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              public void onValueChange(ValueChangeEvent<String> event) {
                String value = ((TextBox) (event.getSource())).getValue();
                exp.setEndDate(value.equals("") ? null : value);
              }
            });

    final ListBox type = new ListBox();
    type.addItem(constants.exportCreate(), "create");
    type.addItem(constants.exportUpdate(), "update");
    type.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            if (type.getValue(type.getSelectedIndex()).length() > 0) {
              exp.setDateType(type.getValue(type.getSelectedIndex()));
            } else {
              exp.setDateType(null);
            }
          }
        });

    Grid table = new Grid(1, 5);
    table.setWidget(0, 0, type);
    table.setWidget(0, 1, new HTML(constants.exportFrom()));
    table.setWidget(0, 2, startDate);
    table.setWidget(0, 3, new HTML(constants.exportTo()));
    table.setWidget(0, 4, endDate);

    panel.add(table);

    return panel;
  }
示例#6
0
  public DialogCarma(KarmaHome home, KarmaUser user) {
    super(false, true);
    this.homeParent = home;
    this.user = user;

    setHTML(CONSTANTS.this_html());

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    setWidget(verticalPanel);
    verticalPanel.setWidth("100%");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(5);
    verticalPanel.add(horizontalPanel);
    horizontalPanel.setWidth("100%");

    VerticalPanel verticalPanel_2 = new VerticalPanel();
    horizontalPanel.add(verticalPanel_2);
    verticalPanel_2.setSize("260", "110");

    Grid grid_1 = new Grid(3, 2);
    verticalPanel_2.add(grid_1);
    grid_1.setSize("", "100");

    Label label_10 = new Label(CONSTANTS.label_10_text());
    grid_1.setWidget(0, 0, label_10);
    grid_1.getCellFormatter().setWidth(0, 0, "100");

    listTypes = new ListBox();
    grid_1.setWidget(0, 1, listTypes);
    grid_1.getCellFormatter().setWidth(0, 1, "150");
    listTypes.setWidth("100%");
    ClientUtils.fillTypes(listTypes);

    Label label_11 = new Label(CONSTANTS.label_11_text());
    grid_1.setWidget(1, 0, label_11);

    tbPlate = new TextBox();
    tbPlate.setVisibleLength(10);
    grid_1.setWidget(1, 1, tbPlate);
    tbPlate.setWidth("100%");

    cbxForeign = new CheckBox(CONSTANTS.cbxForeign_text());
    grid_1.setWidget(2, 0, cbxForeign);
    cbxForeign.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showCountries();
          }
        });

    listCountry = new ListBox();
    grid_1.setWidget(2, 1, listCountry);
    listCountry.setWidth("100%");
    listCountry.setVisible(false);
    ClientUtils.fillCountries(listCountry);

    VerticalPanel verticalPanel_6 = new VerticalPanel();
    horizontalPanel.add(verticalPanel_6);
    verticalPanel_6.setSize("260", "110");

    Grid grid_2 = new Grid(3, 2);
    verticalPanel_6.add(grid_2);
    grid_2.setSize("", "100");

    Label label_15 = new Label(CONSTANTS.label_15_text());
    grid_2.setWidget(0, 0, label_15);
    grid_2.getCellFormatter().setWidth(0, 0, "50");

    date = new DateBox();
    date.setFormat(new DefaultFormat(DateTimeFormat.getFormat("yyyy-MM-dd HH:mm")));
    grid_2.setWidget(0, 1, date);
    grid_2.getCellFormatter().setWidth(0, 1, "200");
    date.setWidth("100%");
    date.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          @Override
          public void onValueChange(ValueChangeEvent<Date> event) {
            Date d = event.getValue();
            if (d.after(new Date())
                || d.before(new Date(System.currentTimeMillis() - 31536000000L))) {
              date.setValue(new Date());
              MsgMan.getInstance().showError(CONSTANTS.error_date1(), date);
            }
          }
        });

    Label label_16 = new Label(CONSTANTS.label_16_text());
    grid_2.setWidget(1, 0, label_16);

    taNotes = new TextArea();
    taNotes.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            updateCounter();
          }
        });
    taNotes.setSize("100%", "50");
    grid_2.setWidget(1, 1, taNotes);

    lblCounter = new Label("New label");
    lblCounter.addStyleName("counter");
    grid_2.setWidget(2, 1, lblCounter);
    grid_2.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    HorizontalPanel horizontalPanel_3 = new HorizontalPanel();
    horizontalPanel_3.setSpacing(5);
    horizontalPanel_3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    verticalPanel.add(horizontalPanel_3);
    verticalPanel.setCellHorizontalAlignment(
        horizontalPanel_3, HasHorizontalAlignment.ALIGN_CENTER);

    btnPuntuar = new Button("New button");
    horizontalPanel_3.add(btnPuntuar);
    btnPuntuar.setText(CONSTANTS.btnPuntuar_text());
    btnPuntuar.setWidth("100");

    Button btnCancel = new Button("New button");
    horizontalPanel_3.add(btnCancel);
    btnCancel.setText(CONSTANTS.btnCancel_text());
    btnCancel.setWidth("100");
    btnPuntuar.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            makeKarma();
          }
        });
    btnCancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            DialogCarma.this.hide();
          }
        });

    updateCounter();
  }