Пример #1
0
  public DetailEditPanel2(NApplication app, Detail d) {
    super();
    this.detail = d;
    this.app = app;

    text = new RichTextArea();
    text.setWidth("100%");
    addComponent(text);

    patternBar = new GridLayout();
    patternBar.setWidth("100%");

    refreshPatternBar();
    refreshProperties();

    addComponent(patternBar);

    patternList.setWidth("100%");
    patternList.setHeight("100%");
    addComponent(patternList);

    HorizontalLayout bottomPanel = new HorizontalLayout();
    {
      Button cancelButton = new Button("Cancel");
      cancelButton.addListener(
          new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
              cancel();
            }
          });
      bottomPanel.addComponent(cancelButton);

      Button saveButton = new Button("Save");
      saveButton.addListener(
          new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
              controlsToObject();
              save();
            }
          });
      bottomPanel.addComponent(saveButton);
    }
    bottomPanel.setMargin(true);
    addComponent(bottomPanel);
    setComponentAlignment(bottomPanel, Alignment.TOP_RIGHT);
  }
Пример #2
0
  private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
      for (String mail : lstMail) {
        if (StringUtils.isNotBlank(mail)) {
          if (mail.indexOf("<") > -1) {
            String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
            if (strMail != null && !strMail.equalsIgnoreCase("null")) {}

          } else {

          }
        }
      }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setWidth("100%");

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    controlsLayout.addComponent(uploadExt);
    controlsLayout.setExpandRatio(uploadExt, 1.0f);

    controlsLayout.setSpacing(true);

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

              @Override
              public void buttonClick(ClickEvent event) {
                MailFormWindow.this.close();
              }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn =
        new Button(
            "Send",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {

                if (tokenFieldMailTo.getListRecipient().size() <= 0
                    || subject.getValue().equals("")) {
                  NotificationUtil.showErrorNotification(
                      "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
                  return;
                }
                if (AppContext.getUser().getEmail() != null
                    && AppContext.getUser().getEmail().length() > 0) {
                  ExtMailService systemMailService =
                      ApplicationContextUtil.getSpringBean(ExtMailService.class);

                  List<File> listFile = attachments.files();
                  List<EmailAttachementSource> emailAttachmentSource = null;
                  if (listFile != null && listFile.size() > 0) {
                    emailAttachmentSource = new ArrayList<>();
                    for (File file : listFile) {
                      emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                  }

                  systemMailService.sendHTMLMail(
                      AppContext.getUser().getEmail(),
                      AppContext.getUser().getDisplayName(),
                      tokenFieldMailTo.getListRecipient(),
                      tokenFieldMailCc.getListRecipient(),
                      tokenFieldMailBcc.getListRecipient(),
                      subject.getValue().toString(),
                      noteArea.getValue().toString(),
                      emailAttachmentSource);
                  MailFormWindow.this.close();
                } else {
                  NotificationUtil.showErrorNotification(
                      "Your email is empty value, please fulfil it before sending email!");
                }
              }
            });
    sendBtn.setIcon(FontAwesome.SEND);
    sendBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
  }
Пример #3
0
    private void createAddMessageLayout() {
      this.messagePanelBody.removeAllComponents();

      final VerticalLayout addMessageWrapper = new VerticalLayout();
      addMessageWrapper.setSpacing(true);
      addMessageWrapper.setWidth("500px");

      final RichTextArea ckEditorTextField = new RichTextArea();
      final AttachmentPanel attachments = new AttachmentPanel();
      final TextField titleField = new TextField();

      final HorizontalLayout titleLayout = new HorizontalLayout();
      titleLayout.setSpacing(true);
      final Label titleLbl = new Label("Title: ");
      titleLbl.setWidth(SIZE_UNDEFINED, Sizeable.Unit.PIXELS);

      titleField.setWidth("100%");
      titleField.setNullRepresentation("");
      titleField.setRequired(true);
      titleField.setRequiredError("Please enter a Title");

      titleLayout.addComponent(titleLbl);
      titleLayout.addComponent(titleField);
      titleLayout.setExpandRatio(titleField, 1.0f);
      titleLayout.setWidth("100%");

      addMessageWrapper.addComponent(titleLayout);
      addMessageWrapper.setComponentAlignment(titleLayout, Alignment.MIDDLE_LEFT);

      ckEditorTextField.setWidth("100%");
      ckEditorTextField.setHeight("200px");
      addMessageWrapper.addComponent(ckEditorTextField);
      addMessageWrapper.setExpandRatio(ckEditorTextField, 1.0f);
      addMessageWrapper.addComponent(attachments);
      addMessageWrapper.setComponentAlignment(ckEditorTextField, Alignment.MIDDLE_CENTER);

      final HorizontalLayout controls = new HorizontalLayout();
      controls.setWidth("100%");
      controls.setSpacing(true);

      final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
      controls.addComponent(uploadExt);
      controls.setExpandRatio(uploadExt, 1.0f);
      controls.setComponentAlignment(uploadExt, Alignment.MIDDLE_LEFT);

      final CheckBox chkIsStick = new CheckBox("Is Stick");
      controls.addComponent(chkIsStick);
      controls.setComponentAlignment(chkIsStick, Alignment.MIDDLE_CENTER);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                  TopMessagePanel.this.createBasicLayout();
                }
              });
      cancelBtn.setStyleName("link");
      controls.addComponent(cancelBtn);
      controls.setComponentAlignment(cancelBtn, Alignment.MIDDLE_CENTER);

      final Button saveBtn =
          new Button(
              "Post",
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final Message message = new Message();
                  message.setProjectid(CurrentProjectVariables.getProjectId());
                  message.setPosteddate(new GregorianCalendar().getTime());
                  if (!titleField.getValue().toString().trim().equals("")) {
                    message.setTitle(titleField.getValue());
                    message.setMessage(ckEditorTextField.getValue());
                    message.setPosteduser(AppContext.getUsername());
                    message.setSaccountid(AppContext.getAccountId());
                    message.setIsstick(chkIsStick.getValue());
                    MessageListViewImpl.this.fireSaveItem(message);

                    String attachmentPath =
                        AttachmentUtils.getProjectEntityAttachmentPath(
                            AppContext.getAccountId(),
                            message.getProjectid(),
                            AttachmentType.PROJECT_MESSAGE,
                            message.getId());
                    attachments.saveContentsToRepo(attachmentPath);
                  } else {
                    titleField.addStyleName("errorField");
                    NotificationUtil.showErrorNotification("Title must be not null!");
                  }
                }
              });
      saveBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
      controls.addComponent(saveBtn);
      controls.setComponentAlignment(saveBtn, Alignment.MIDDLE_CENTER);

      addMessageWrapper.addComponent(controls);
      addMessageWrapper.setComponentAlignment(controls, Alignment.MIDDLE_CENTER);
      this.messagePanelBody.addComponent(addMessageWrapper);
    }