예제 #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
  @Override
  public void update(final PTInstruction update, final UIService uiService) {
    final MyDateBox dateBox = cast();

    if (update.containsKey(PROPERTY.VALUE)) {
      dateBox.getTextBox().setText(update.getString(PROPERTY.VALUE));
    } else if (update.containsKey(PROPERTY.DATE_FORMAT)) {
      final DefaultFormat format =
          new DefaultFormat(DateTimeFormat.getFormat(update.getString(PROPERTY.DATE_FORMAT)));
      dateBox.setFormat(format);
    } else if (update.containsKey(PROPERTY.DATE_FORMAT_PATTERN)) {
      dateBox.setFormat(
          new DefaultFormat(
              DateTimeFormat.getFormat(update.getString(PROPERTY.DATE_FORMAT_PATTERN))));
    } else if (update.containsKey(PROPERTY.ENABLED)) {
      dateBox.setEnabled(update.getBoolean(PROPERTY.ENABLED));
    } else if (update.containsKey(PROPERTY.MONTH)) {
      dateBox.setDefaultMonth(update.getString(PROPERTY.MONTH));
    } else {
      super.update(update, uiService);
    }
  }