public void createBasicLayout() {
      this.messagePanelBody.removeAllComponents();
      this.messagePanelBody.addComponent(this.messageSearchPanel);

      final Button createMessageBtn =
          new Button(
              LocalizationHelper.getMessage(MessageI18nEnum.NEW_MESSAGE_ACTION),
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  TopMessagePanel.this.createAddMessageLayout();
                }
              });
      createMessageBtn.setEnabled(
          CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MESSAGES));
      createMessageBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
      createMessageBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png"));
      createMessageBtn.setEnabled(
          CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MESSAGES));

      this.messagePanelBody.addComponent(createMessageBtn);
      this.messagePanelBody.setComponentAlignment(createMessageBtn, Alignment.MIDDLE_RIGHT);
    }
Example #2
0
 @Override
 protected String initFormTitle() {
   // check if there is converted lead associates with this contact
   LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class);
   SimpleLead lead =
       leadService.findConvertedLeadOfContact(beanItem.getId(), AppContext.getAccountId());
   if (lead != null) {
     return "<h2>"
         + beanItem.getContactName()
         + LocalizationHelper.getMessage(
             LeadI18nEnum.CONVERT_FROM_LEAD_TITLE,
             CrmResources.getResourceLink(CrmTypeConstants.LEAD),
             CrmLinkGenerator.generateCrmItemLink(CrmTypeConstants.LEAD, lead.getId()),
             lead.getLeadName())
         + "</h2>";
   } else {
     return beanItem.getContactName();
   }
 }
  private HorizontalLayout createSearchTopPanel() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setSpacing(true);
    layout.setMargin(true);

    final Image titleIcon =
        new Image(null, MyCollabResource.newResource("icons/24/project/component.png"));
    layout.addComponent(titleIcon);
    layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_LEFT);

    final Label componenttitle = new Label("Components");
    componenttitle.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(componenttitle);
    layout.setExpandRatio(componenttitle, 1.0f);
    layout.setComponentAlignment(componenttitle, Alignment.MIDDLE_LEFT);

    final Button createBtn =
        new Button(
            LocalizationHelper.getMessage(BugI18nEnum.NEW_COMPONENT_ACTION),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final Button.ClickEvent event) {
                EventBus.getInstance().fireEvent(new BugComponentEvent.GotoAdd(this, null));
              }
            });
    createBtn.setEnabled(
        CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
    createBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
    createBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png"));

    UiUtils.addComponent(layout, createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
  }
  private void showTaskGroupInfo() {
    if (this.isDisplayTaskListInfo) {
      this.layoutHelper = new GridFormLayoutHelper(2, 3, "100%", "180px", Alignment.MIDDLE_LEFT);
      this.layoutHelper.getLayout().setWidth("100%");
      this.layoutHelper.getLayout().addStyleName("colored-gridlayout");
      this.layoutHelper.getLayout().setMargin(false);
      this.addComponent(this.layoutHelper.getLayout());

      final Label descLbl =
          (Label)
              this.layoutHelper.addComponent(
                  new Label(), "Description", 0, 0, 2, "100%", Alignment.TOP_RIGHT);
      descLbl.setContentMode(ContentMode.HTML);
      descLbl.setValue(StringUtils.preStringFormat(this.taskList.getDescription()));

      this.layoutHelper.addComponent(
          new ProjectUserFormLinkField(
              this.taskList.getOwner(),
              this.taskList.getOwnerAvatarId(),
              this.taskList.getOwnerFullName()),
          LocalizationHelper.getMessage(GenericI18Enum.FORM_ASSIGNEE_FIELD),
          0,
          1,
          Alignment.TOP_RIGHT);

      final DefaultFormViewFieldFactory.FormLinkViewField milestoneLink =
          new DefaultFormViewFieldFactory.FormLinkViewField(
              this.taskList.getMilestoneName(),
              new Button.ClickListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                  EventBus.getInstance()
                      .fireEvent(
                          new MilestoneEvent.GotoRead(
                              this, TaskDisplayComponent.this.taskList.getMilestoneid()));
                }
              },
              MyCollabResource.newResource("icons/16/project/milestone.png"));
      this.layoutHelper.addComponent(
          milestoneLink,
          LocalizationHelper.getMessage(TaskI18nEnum.FORM_PHASE_FIELD),
          1,
          1,
          Alignment.TOP_RIGHT);

      this.taskListProgress =
          (ProgressPercentageIndicator)
              this.layoutHelper.addComponent(
                  new ProgressPercentageIndicator(this.taskList.getPercentageComplete()),
                  "Progress",
                  0,
                  2);
      this.taskListProgress.setWidth("100px");

      HorizontalLayout taskNumberProgress = new HorizontalLayout();
      taskNumberProgress.setSpacing(true);
      taskNumberProgress =
          (HorizontalLayout)
              this.layoutHelper.addComponent(taskNumberProgress, "Number of open tasks", 1, 2);

      this.taskNumberLbl =
          new Label(
              "(" + this.taskList.getNumOpenTasks() + "/" + this.taskList.getNumAllTasks() + ")");
      taskNumberProgress.addComponent(this.taskNumberLbl);
    }

    this.taskDisplay =
        new TaskTableDisplay(
            new String[] {
              "id", "taskname", "startdate", "deadline", "percentagecomplete", "assignUserFullName"
            },
            new String[] {
              "",
              LocalizationHelper.getMessage(TaskI18nEnum.TABLE_TASK_NAME_HEADER),
              LocalizationHelper.getMessage(TaskI18nEnum.TABLE_START_DATE_HEADER),
              LocalizationHelper.getMessage(TaskI18nEnum.TABLE_DUE_DATE_HEADER),
              LocalizationHelper.getMessage(TaskI18nEnum.TABLE_PER_COMPLETE_HEADER),
              LocalizationHelper.getMessage(TaskI18nEnum.TABLE_ASSIGNEE_HEADER)
            });
    this.addComponent(this.taskDisplay);

    this.taskDisplay.addTableListener(
        new ApplicationEventListener<TableClickEvent>() {
          private static final long serialVersionUID = 1L;

          @Override
          public Class<? extends ApplicationEvent> getEventType() {
            return TableClickEvent.class;
          }

          @Override
          public void handle(final TableClickEvent event) {
            final SimpleTask task = (SimpleTask) event.getData();
            if ("taskname".equals(event.getFieldName())) {
              EventBus.getInstance()
                  .fireEvent(new TaskEvent.GotoRead(TaskDisplayComponent.this, task.getId()));
            } else if ("closeTask".equals(event.getFieldName())
                || "reopenTask".equals(event.getFieldName())
                || "pendingTask".equals(event.getFieldName())
                || "deleteTask".equals(event.getFieldName())) {
              TaskDisplayComponent.this.removeAllComponents();
              final ProjectTaskListService taskListService =
                  ApplicationContextUtil.getSpringBean(ProjectTaskListService.class);
              TaskDisplayComponent.this.taskList =
                  taskListService.findById(
                      TaskDisplayComponent.this.taskList.getId(), AppContext.getAccountId());
              TaskDisplayComponent.this.showTaskGroupInfo();
            }
          }
        });

    this.createTaskBtn =
        new Button(
            LocalizationHelper.getMessage(TaskI18nEnum.NEW_TASK_ACTION),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

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

                TaskDisplayComponent.this.removeAllComponents();

                final TaskAddPopup taskAddView =
                    new TaskAddPopup(TaskDisplayComponent.this, TaskDisplayComponent.this.taskList);
                if (TaskDisplayComponent.this.layoutHelper != null) {
                  TaskDisplayComponent.this.addComponent(
                      TaskDisplayComponent.this.layoutHelper.getLayout(), 0);
                  TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 1);
                  TaskDisplayComponent.this.addComponent(taskAddView, 2);
                } else {
                  TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 0);
                  TaskDisplayComponent.this.addComponent(taskAddView, 1);
                }
                TaskDisplayComponent.this.removeComponent(TaskDisplayComponent.this.createTaskBtn);
              }
            });
    this.createTaskBtn.setEnabled(
        CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    this.createTaskBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png"));
    this.createTaskBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
    final VerticalLayout taskGroupFooter = new VerticalLayout();
    taskGroupFooter.setMargin(true);
    taskGroupFooter.addStyleName("task-list-footer");
    taskGroupFooter.addComponent(this.createTaskBtn);
    taskGroupFooter.setComponentAlignment(this.createTaskBtn, Alignment.MIDDLE_RIGHT);
    this.addComponent(taskGroupFooter);

    this.taskDisplay.setItems(this.taskList.getSubTasks());
  }
  private void displayUserAvatar() {
    this.userAvatar.removeAllComponents();
    this.userAvatar.addStyleName("avatar-pass-wrapper");
    this.userAvatar.setMargin(true);
    final Image cropField =
        UserAvatarControlFactory.createUserAvatarEmbeddedComponent(
            AppContext.getUserAvatarId(), 100);

    final HorizontalLayout avatarAndPass = new HorizontalLayout();
    avatarAndPass.setSpacing(true);
    avatarAndPass.setWidth("100%");
    avatarAndPass.addComponent(cropField);
    final Button btnChangePassword =
        new Button(
            LocalizationHelper.getMessage(UserI18nEnum.BUTTON_CHANGE_PASSWORD),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.user));
              }
            });
    final VerticalLayout passLayout = new VerticalLayout();
    passLayout.setMargin(new MarginInfo(true, false, false, false));
    final Label userName = new Label(AppContext.getSession().getDisplayName());
    userName.setStyleName("h1");
    passLayout.addComponent(userName);
    passLayout.addComponent(btnChangePassword);
    btnChangePassword.setStyleName("link");
    passLayout.setComponentAlignment(btnChangePassword, Alignment.MIDDLE_LEFT);
    avatarAndPass.addComponent(passLayout);
    avatarAndPass.setComponentAlignment(passLayout, Alignment.TOP_LEFT);
    avatarAndPass.setExpandRatio(passLayout, 1.0f);

    this.userAvatar.addComponent(avatarAndPass);

    final UploadField avatarUploadField =
        new UploadField() {
          private static final long serialVersionUID = 1L;

          @Override
          protected void updateDisplay() {
            byte[] imageData = (byte[]) this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
              imageData = ImageUtil.convertJpgToPngFormat(imageData);
              if (imageData == null) {
                throw new UserInvalidInputException("Do not support image format for avatar");
              } else {
                mimeType = "image/png";
              }
            }

            if (mimeType.equals("image/png")) {
              EventBus.getInstance()
                  .fireEvent(new ProfileEvent.GotoUploadPhoto(ProfileReadViewImpl.this, imageData));
            } else {
              throw new UserInvalidInputException(
                  "Upload file does not have valid image format. The supported formats are jpg/png");
            }
          }
        };
    avatarUploadField.setButtonCaption("Change Avatar");
    avatarUploadField.setFieldType(FieldType.BYTE_ARRAY);
    this.userAvatar.addComponent(avatarUploadField);
  }
      @Override
      public Layout getLayout() {
        final ReadViewLayout accountAddLayout =
            new ReadViewLayout(
                "User Information", MyCollabResource.newResource("icons/22/user/menu_profile.png"));
        accountAddLayout.setWidth("100%");
        final VerticalLayout layout = new VerticalLayout();

        layout.addComponent(userAvatar);

        final CssLayout basicInformationHeader = new CssLayout();
        basicInformationHeader.setWidth("100%");
        basicInformationHeader.addStyleName("info-block-header");
        final Label basicInformationHeaderLbl = new Label("Basic Information");
        basicInformationHeaderLbl.setStyleName("h2");
        basicInformationHeaderLbl.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS);
        basicInformationHeader.addComponent(basicInformationHeaderLbl);

        final CssLayout contactInformationHeader = new CssLayout();
        contactInformationHeader.setWidth("100%");
        contactInformationHeader.addStyleName("info-block-header");
        final Label contactInformationHeaderLbl = new Label("Contact Information");
        contactInformationHeaderLbl.setStyleName("h2");
        contactInformationHeaderLbl.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS);
        contactInformationHeader.addComponent(contactInformationHeaderLbl);

        final CssLayout advanceInfoHeader = new CssLayout();
        advanceInfoHeader.setWidth("100%");
        advanceInfoHeader.addStyleName("info-block-header");
        final Label advanceInfoHeaderLbl = new Label("Advanced Information");
        advanceInfoHeaderLbl.setStyleName("h2");
        advanceInfoHeaderLbl.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS);
        advanceInfoHeader.addComponent(advanceInfoHeaderLbl);

        this.basicInformation =
            new GridFormLayoutHelper(1, 6, "100%", "167px", Alignment.MIDDLE_LEFT);
        this.basicInformation.getLayout().setMargin(false);
        this.basicInformation.getLayout().setWidth("100%");
        this.basicInformation.getLayout().addStyleName("colored-gridlayout");

        this.contactInformation =
            new GridFormLayoutHelper(1, 5, "100%", "167px", Alignment.MIDDLE_LEFT);
        this.contactInformation.getLayout().setMargin(false);
        this.contactInformation.getLayout().setWidth("100%");
        this.contactInformation.getLayout().addStyleName("colored-gridlayout");

        this.advanceInformation =
            new GridFormLayoutHelper(1, 3, "100%", "167px", Alignment.MIDDLE_LEFT);
        this.advanceInformation.getLayout().setMargin(false);
        this.advanceInformation.getLayout().setWidth("100%");
        this.advanceInformation.getLayout().addStyleName("colored-gridlayout");

        layout.addComponent(basicInformationHeader);
        layout.addComponent(this.basicInformation.getLayout());
        final Button btnChangeBasicInfo =
            new Button(
                LocalizationHelper.getMessage(GenericI18Enum.BUTTON_EDIT_LABEL),
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new BasicInfoChangeWindow(PreviewForm.this.user));
                  }
                });
        btnChangeBasicInfo.addStyleName("link");
        basicInformationHeader.addComponent(btnChangeBasicInfo);

        layout.addComponent(contactInformationHeader);
        layout.addComponent(this.contactInformation.getLayout());
        final Button btnChangeContactInfo =
            new Button(
                LocalizationHelper.getMessage(GenericI18Enum.BUTTON_EDIT_LABEL),
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new ContactInfoChangeWindow(PreviewForm.this.user));
                  }
                });
        btnChangeContactInfo.addStyleName("link");
        contactInformationHeader.addComponent(btnChangeContactInfo);

        layout.addComponent(advanceInfoHeader);
        layout.addComponent(this.advanceInformation.getLayout());
        final Button btnChangeAdvanceInfo =
            new Button(
                LocalizationHelper.getMessage(GenericI18Enum.BUTTON_EDIT_LABEL),
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new AdvancedInfoChangeWindow(PreviewForm.this.user));
                  }
                });
        btnChangeAdvanceInfo.addStyleName("link");
        advanceInfoHeader.addComponent(btnChangeAdvanceInfo);

        accountAddLayout.addBody(layout);
        return accountAddLayout;
      }
public interface AccountTableFieldDef {

  public static TableViewField selected =
      new TableViewField("", "selected", UIConstants.TABLE_CONTROL_WIDTH);

  public static TableViewField action =
      new TableViewField("", "id", UIConstants.TABLE_ACTION_CONTROL_WIDTH);

  public static TableViewField accountname =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_NAME_HEADER),
          "accountname",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField city =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_CITY_HEADER),
          "city",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField phoneoffice =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_OFFICE_PHONE_HEADER),
          "phoneoffice",
          UIConstants.TABLE_M_LABEL_WIDTH);

  public static TableViewField email =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_EMAIL_ADDRESS_HEADER),
          "email",
          UIConstants.TABLE_EMAIL_WIDTH);

  public static TableViewField assignUser =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_ASSIGNED_USER_HEADER),
          "assignUserFullName",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField website =
      new TableViewField(
          LocalizationHelper.getMessage(CrmCommonI18nEnum.TABLE_WEBSITE_HEADER),
          "website",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField type =
      new TableViewField(
          LocalizationHelper.getMessage(AccountI18nEnum.FORM_TYPE),
          "type",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField ownership =
      new TableViewField(
          LocalizationHelper.getMessage(AccountI18nEnum.FORM_OWNERSHIP),
          "ownership",
          UIConstants.TABLE_X_LABEL_WIDTH);

  public static TableViewField fax =
      new TableViewField(
          LocalizationHelper.getMessage(AccountI18nEnum.FORM_FAX),
          "fax",
          UIConstants.TABLE_M_LABEL_WIDTH);
}
    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);
    }