コード例 #1
0
      @Override
      public ComponentContainer getLayout() {
        final VerticalLayout layout = new VerticalLayout();
        this.informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 6);

        layout.addComponent(this.informationLayout.getLayout());

        final MHorizontalLayout controlsBtn =
            new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false));
        layout.addComponent(controlsBtn);

        final Button approveBtn =
            new Button(
                "Approve & Close",
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(Button.ClickEvent event) {

                    if (EditForm.this.validateForm()) {
                      // Save bug status and assignee
                      bug.setStatus(BugStatus.Verified.name());

                      BugService bugService =
                          ApplicationContextUtil.getSpringBean(BugService.class);
                      bugService.updateSelectiveWithSession(bug, AppContext.getUsername());

                      // Save comment
                      String commentValue = commentArea.getValue();
                      if (StringUtils.isNotBlank(commentValue)) {
                        CommentWithBLOBs comment = new CommentWithBLOBs();
                        comment.setComment(
                            Jsoup.clean(commentArea.getValue(), Whitelist.relaxed()));
                        comment.setCreatedtime(new GregorianCalendar().getTime());
                        comment.setCreateduser(AppContext.getUsername());
                        comment.setSaccountid(AppContext.getAccountId());
                        comment.setType(ProjectTypeConstants.BUG);
                        comment.setTypeid("" + bug.getId());
                        comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                        CommentService commentService =
                            ApplicationContextUtil.getSpringBean(CommentService.class);
                        commentService.saveWithSession(comment, AppContext.getUsername());
                      }

                      ApproveInputWindow.this.close();
                      callbackForm.refreshBugItem();
                    }
                  }
                });
        approveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        approveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        controlsBtn.with(approveBtn).withAlign(approveBtn, Alignment.MIDDLE_LEFT);

        Button cancelBtn =
            new Button(
                AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(Button.ClickEvent event) {
                    ApproveInputWindow.this.close();
                  }
                });
        cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
        controlsBtn.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_LEFT);

        layout.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
        return layout;
      }