示例#1
0
  /**
   * This constructor allows to use an existing form panel.
   *
   * @param type file input to use
   * @param status Customized status widget to use
   * @param submitButton Customized button which submits the form
   * @param form Customized form panel
   */
  public SingleUploader(
      FileInputType type, IUploadStatus status, Widget submitButton, FormPanel form) {
    super(type, form);

    final Uploader thisInstance = this;

    if (status == null) {
      status = new BaseUploadStatus();
      super.add(status.getWidget());
    }
    super.setStatusWidget(status);

    this.button = submitButton;
    if (submitButton != null) {
      submitButton.addStyleName("submit");
      if (submitButton instanceof HasClickHandlers) {
        ((HasClickHandlers) submitButton)
            .addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    thisInstance.submit();
                  }
                });
      }
      if (submitButton instanceof HasText) {
        ((HasText) submitButton).setText(I18N_CONSTANTS.uploaderSend());
      }
      // The user could have attached the button anywhere in the page.
      if (!submitButton.isAttached()) {
        super.add(submitButton);
      }
    }
  }
示例#2
0
 public void addSendButtonClickHandler(HasClickHandlers button) {
   button.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           sendMessage(getDisplay().getTextBox().getValue());
           getDisplay().getTextBox().setValue("");
         }
       });
 }
  protected void init() {

    /*
     * Title
     */
    HasValue<String> titleEditor = view.getTitleEditor();
    titleEditor.addValueChangeHandler(
        new BudgetFieldChangeHandler<String>() {
          @Override
          public void onValueChange(String value) {
            budget.setName(value);
          }
        });

    /*
     * Currency
     */
    HasValue<String> currencyEditor = view.getBaseCurrencyEditor();
    currencyEditor.addValueChangeHandler(
        new BudgetFieldChangeHandler<String>() {
          @Override
          public void onValueChange(String value) {
            budget.setBaseCurrency(value);
          }
        });

    /*
     * Period
     */
    HasValue<Date> fromEditor = view.getFromDateEditor();
    fromEditor.addValueChangeHandler(
        new BudgetFieldChangeHandler<Date>() {
          @Override
          public void onValueChange(Date value) {
            budget.setStartDate(value);
          }
        });

    HasValue<Date> toEditor = view.getToDateEditor();
    toEditor.addValueChangeHandler(
        new BudgetFieldChangeHandler<Date>() {
          @Override
          public void onValueChange(Date value) {
            budget.setEndDate(value);
          }
        });

    HasClickHandlers addIncomeButton = view.getAddIncomeButton();
    addIncomeButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addIncomeToBudget(view);
          }
        });

    HasClickHandlers addExpenseButton = view.getAddExpenseButton();
    addExpenseButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            addExpenseToBudget(view);
          }
        });

    isInitiated = true;
  }