コード例 #1
0
  private Component buildSparkCards() {
    CssLayout sparks = new CssLayout();
    sparks.addStyleName("sparks");
    sparks.setWidth("100%");
    Responsive.makeResponsive(sparks);

    float totalKm = getTotalKm();
    SparkCard worldTripsSparkCard =
        new SparkCard("trips around the world", Float.toString(totalKm / ECUATOR_LENGTH_KM));
    sparks.addComponent(worldTripsSparkCard);

    SparkCard moonTripsSparkCard =
        new SparkCard("trips to the moon", Float.toString(totalKm / DISTANCE_TO_THE_MOON_KM));
    sparks.addComponent(moonTripsSparkCard);

    float totalCalories = getTotalCalories();

    SparkCard burgersBurnedSparkCard =
        new SparkCard("burgers burned", Float.toString(totalCalories / CALORIES_PER_BURGER));
    sparks.addComponent(burgersBurnedSparkCard);

    SparkCard biersBurnedSparkCard =
        new SparkCard("beers burned", Long.toString(Math.round(totalCalories / CALORIES_PER_BEER)));
    sparks.addComponent(biersBurnedSparkCard);

    return sparks;
  }
コード例 #2
0
  public VerticalTabsheet(boolean isLeft) {
    CssLayout contentLayout = new CssLayout();
    new Restrain(contentLayout).setMinHeight("100%");

    navigatorWrapper = new CssLayout();
    navigatorWrapper.setStyleName("navigator-wrap");
    navigatorContainer = new VerticalLayout();
    navigatorWrapper.addComponent(navigatorContainer);

    contentWrapper = new VerticalLayout();
    contentWrapper.setStyleName("container-wrap");
    contentWrapper.setWidth("100%");

    tabContainer = new CssLayout();
    tabContainer.setWidth("100%");
    contentWrapper.addComponent(tabContainer);

    if (isLeft) {
      contentLayout.addComponent(navigatorWrapper);
      contentLayout.addComponent(contentWrapper);

    } else {
      contentLayout.addComponent(contentWrapper);
      contentLayout.addComponent(navigatorWrapper);
    }

    this.setCompositionRoot(contentLayout);
    this.setStyleName(TABSHEET_STYLENAME);
  }
コード例 #3
0
  private Component buildSparklines() {
    CssLayout sparks = new CssLayout();
    sparks.addStyleName("sparks");
    sparks.setWidth("100%");
    Responsive.makeResponsive(sparks);

    SparklineChart s =
        new SparklineChart("Traffic", "K", "", DummyDataGenerator.chartColors[0], 22, 20, 80);
    sparks.addComponent(s);

    s =
        new SparklineChart(
            "Revenue / Day", "M", "$", DummyDataGenerator.chartColors[2], 8, 89, 150);
    sparks.addComponent(s);

    s =
        new SparklineChart(
            "Checkout Time", "s", "", DummyDataGenerator.chartColors[3], 10, 30, 120);
    sparks.addComponent(s);

    s =
        new SparklineChart(
            "Theater Fill Rate", "%", "", DummyDataGenerator.chartColors[5], 50, 34, 100);
    sparks.addComponent(s);

    return sparks;
  }
コード例 #4
0
  private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");
    slot.addStyleName("max");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);

    card.addComponents(content);
    slot.addComponent(card);
    return slot;
  }
  @Override
  public void attach() {
    setSizeFull();
    addStyleName(Reindeer.PANEL_LIGHT);

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setSizeFull();
    layout.addStyleName("loadbalancer-tab");
    layout.setSpacing(false);
    layout.setMargin(false);

    // スプリットパネル
    SplitPanel splitPanel = new SplitPanel();
    splitPanel.setOrientation(SplitPanel.ORIENTATION_VERTICAL);
    splitPanel.setSplitPosition(40);
    splitPanel.setSizeFull();
    layout.addComponent(splitPanel);

    // スプリットパネル上段
    VerticalLayout upperLayout = new VerticalLayout();
    upperLayout.setSizeFull();
    upperLayout.setSpacing(false);
    upperLayout.setMargin(false);

    CssLayout upperTopLayout = new CssLayout();
    Label label = new Label(ViewProperties.getCaption("label.loadbalancer"));
    upperTopLayout.setWidth("100%");
    upperTopLayout.setMargin(true);
    upperTopLayout.addStyleName("loadbalancer-table-label");
    upperTopLayout.addComponent(label);
    upperTopLayout.setHeight("28px");
    upperLayout.addComponent(upperTopLayout);

    loadBalancerTable = new LoadBalancerTable(sender);
    loadBalancerTable.setContainerDataSource(new LoadBalancerDtoContainer());
    upperLayout.addComponent(loadBalancerTable);
    loadBalancerTable.addListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            tableRowSelected(event);
          }
        });

    loadBalancerButtonsBottom = new LoadBalancerButtonsBottom(sender);
    upperLayout.addComponent(loadBalancerButtonsBottom);
    upperLayout.setExpandRatio(loadBalancerTable, 10);
    splitPanel.addComponent(upperLayout);

    // スプリットパネル下段
    loadBalancerDesc = new LoadBalancerDesc(sender);
    splitPanel.addComponent(loadBalancerDesc);
  }
コード例 #6
0
  protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    CssLayout csslayout = new CssLayout();
    csslayout.setHeight(24, UNITS_PIXELS);
    csslayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(csslayout);

    inputField = new TextField();
    inputField.setWidth(100, UNITS_PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
    inputField.focus();
    csslayout.addComponent(inputField);
    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
  }
コード例 #7
0
  public FileSearchResultComponent() {
    this.resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName(UIConstants.THEME_COMP_HEADER);

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

    headerWrapper.addComponent(headerLayout);
    this.addComponent(headerWrapper);

    final Embedded headerIcon = new Embedded();
    headerIcon.setSource(MyCollabResource.newResource("icons/16/search.png"));
    headerLayout.addComponent(headerIcon);
    headerLayout.setComponentAlignment(headerIcon, Alignment.MIDDLE_LEFT);

    this.searchHeader = new Label();
    headerLayout.addComponent(this.searchHeader);
    headerLayout.setComponentAlignment(this.searchHeader, Alignment.MIDDLE_LEFT);
    headerLayout.setExpandRatio(this.searchHeader, 1.0f);

    final Button backButton =
        new Button(
            "Back to dashboard",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                backView();
              }
            });
    backButton.addStyleName(UIConstants.THEME_BLUE_LINK);
    headerLayout.addComponent(backButton);

    this.resourceTable = new ResourceTableDisplay();
    this.resourceTable.setWidth("100%");

    this.bodyLayout = new VerticalLayout();
    this.bodyLayout.addComponent(this.resourceTable);
    this.addComponent(this.bodyLayout);
    this.setMargin(true);
  }
コード例 #8
0
  public void setSearchCriteria(final S criteria) {
    this.searchCriteria = criteria;

    final JFreeChart chart = createChart();
    final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart);

    removeAllComponents();
    final CssLayout borderWrap = new CssLayout();
    borderWrap.addComponent(chartWrapper);
    borderWrap.setStyleName("chart-wrapper");
    borderWrap.setHeight(height + "px");
    borderWrap.setWidth(width + "px");
    chartWrapper.setHeight(height + "px");
    chartWrapper.setWidth(width + "px");
    chartWrapper.setGraphHeight(height);
    chartWrapper.setGraphWidth(width);
    this.addComponent(borderWrap);
    // this.setComponentAlignment(chartWrapper, Alignment.MIDDLE_CENTER);
    final Component legendBox = createLegendBox();
    legendBox.setWidth(width + "px");
    this.addComponent(legendBox);
    this.setComponentAlignment(legendBox, Alignment.MIDDLE_CENTER);
  }
コード例 #9
0
      @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;
      }
コード例 #10
0
    @Override
    public Component generateRow(final SimpleMessage message, final int rowIndex) {
      final HorizontalLayout messageLayout = new HorizontalLayout();
      messageLayout.setStyleName("message");
      messageLayout.setSpacing(true);
      if (message.getIsstick() != null && message.getIsstick()) {
        messageLayout.addStyleName("important-message");
      }
      messageLayout.setWidth("100%");
      VerticalLayout userBlock = new VerticalLayout();
      userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER);
      userBlock.setWidth("80px");
      userBlock.setSpacing(true);
      userBlock.addComponent(
          UserAvatarControlFactory.createUserAvatarButtonLink(
              message.getPostedUserAvatarId(), message.getFullPostedUserName()));
      Label userName = new Label(message.getFullPostedUserName());
      userName.setStyleName("user-name");
      userBlock.addComponent(userName);
      messageLayout.addComponent(userBlock);

      final CssLayout rowLayout = new CssLayout();
      rowLayout.setStyleName("message-container");
      rowLayout.setWidth("100%");
      final Button title =
          new Button(
              message.getTitle(),
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  EventBus.getInstance()
                      .fireEvent(
                          new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId()));
                }
              });

      title.setWidth("550px");
      title.setStyleName("link");
      title.addStyleName(UIConstants.WORD_WRAP);

      final HorizontalLayout messageHeader = new HorizontalLayout();
      messageHeader.setStyleName("message-header");
      messageHeader.setMargin(new MarginInfo(true, true, false, true));
      final VerticalLayout leftHeader = new VerticalLayout();

      title.addStyleName("message-title");
      leftHeader.addComponent(title);

      final HorizontalLayout rightHeader = new HorizontalLayout();
      rightHeader.setSpacing(true);

      final Label timePostLbl =
          new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate()));
      timePostLbl.setSizeUndefined();
      timePostLbl.setStyleName("time-post");

      final HorizontalLayout notification = new HorizontalLayout();
      notification.setStyleName("notification");
      notification.setSizeUndefined();
      notification.setSpacing(true);
      if (message.getCommentsCount() > 0) {
        final HorizontalLayout commentNotification = new HorizontalLayout();
        final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount()));
        commentCountLbl.setStyleName("comment-count");
        commentCountLbl.setSizeUndefined();
        commentNotification.addComponent(commentCountLbl);
        final Image commentIcon =
            new Image(null, MyCollabResource.newResource("icons/16/project/message.png"));
        commentNotification.addComponent(commentIcon);

        notification.addComponent(commentNotification);
      }
      ResourceService attachmentService =
          ApplicationContextUtil.getSpringBean(ResourceService.class);
      List<Content> attachments =
          attachmentService.getContents(
              AttachmentUtils.getProjectEntityAttachmentPath(
                  AppContext.getAccountId(),
                  message.getProjectid(),
                  AttachmentType.PROJECT_MESSAGE,
                  message.getId()));
      if (attachments != null && !attachments.isEmpty()) {
        final HorizontalLayout attachmentNotification = new HorizontalLayout();
        final Label attachmentCountLbl = new Label(Integer.toString(attachments.size()));
        attachmentCountLbl.setStyleName("attachment-count");
        attachmentCountLbl.setSizeUndefined();
        attachmentNotification.addComponent(attachmentCountLbl);
        final Image attachmentIcon =
            new Image(null, MyCollabResource.newResource("icons/16/attachment.png"));
        attachmentNotification.addComponent(attachmentIcon);

        notification.addComponent(attachmentNotification);
      }

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

                @Override
                public void buttonClick(ClickEvent event) {
                  ConfirmDialogExt.show(
                      UI.getCurrent(),
                      LocalizationHelper.getMessage(
                          GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()),
                      LocalizationHelper.getMessage(
                          GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE),
                      LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL),
                      LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL),
                      new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(final ConfirmDialog dialog) {
                          if (dialog.isConfirmed()) {
                            final MessageService messageService =
                                ApplicationContextUtil.getSpringBean(MessageService.class);
                            messageService.removeWithSession(
                                message.getId(),
                                AppContext.getUsername(),
                                AppContext.getAccountId());
                            MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria);
                          }
                        }
                      });
                }
              });
      deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png"));
      deleteBtn.addStyleName("link");
      deleteBtn.setEnabled(
          CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES));

      rightHeader.addComponent(timePostLbl);
      rightHeader.addComponent(deleteBtn);
      rightHeader.setExpandRatio(timePostLbl, 1.0f);

      messageHeader.addComponent(leftHeader);
      messageHeader.setExpandRatio(leftHeader, 1.0f);
      messageHeader.addComponent(rightHeader);
      messageHeader.setWidth("100%");

      rowLayout.addComponent(messageHeader);

      final Label messageContent =
          new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML);
      messageContent.setStyleName("message-body");
      rowLayout.addComponent(messageContent);

      if (notification.getComponentCount() > 0) {
        VerticalLayout messageFooter = new VerticalLayout();
        messageFooter.setWidth("100%");
        messageFooter.setStyleName("message-footer");
        messageFooter.addComponent(notification);
        messageFooter.setMargin(true);
        messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
      }

      messageLayout.addComponent(rowLayout);
      messageLayout.setExpandRatio(rowLayout, 1.0f);

      return messageLayout;
    }
コード例 #11
0
    @Override
    public Component generateBlock(final SimpleOpportunity opportunity, int blockIndex) {
      CssLayout beanBlock = new CssLayout();
      beanBlock.addStyleName("bean-block");
      beanBlock.setWidth("350px");

      VerticalLayout blockContent = new VerticalLayout();
      MHorizontalLayout blockTop = new MHorizontalLayout().withWidth("100%");
      CssLayout iconWrap = new CssLayout();
      iconWrap.setStyleName("icon-wrap");
      FontIconLabel opportunityIcon =
          new FontIconLabel(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
      iconWrap.addComponent(opportunityIcon);
      blockTop.addComponent(iconWrap);

      VerticalLayout opportunityInfo = new VerticalLayout();
      opportunityInfo.setSpacing(true);

      MButton btnDelete = new MButton(FontAwesome.TRASH_O);
      btnDelete.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
              ConfirmDialogExt.show(
                  UI.getCurrent(),
                  AppContext.getMessage(
                      GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                  AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                  AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                  AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                  new ConfirmDialog.Listener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClose(ConfirmDialog dialog) {
                      if (dialog.isConfirmed()) {
                        ContactService contactService =
                            ApplicationContextUtil.getSpringBean(ContactService.class);
                        ContactOpportunity associateOpportunity = new ContactOpportunity();
                        associateOpportunity.setContactid(contact.getId());
                        associateOpportunity.setOpportunityid(opportunity.getId());
                        contactService.removeContactOpportunityRelationship(
                            associateOpportunity, AppContext.getAccountId());
                        ContactOpportunityListComp.this.refresh();
                      }
                    }
                  });
            }
          });

      btnDelete.addStyleName(UIConstants.BUTTON_ICON_ONLY);

      blockContent.addComponent(btnDelete);
      blockContent.setComponentAlignment(btnDelete, Alignment.TOP_RIGHT);

      Label opportunityName =
          new Label(
              String.format(
                  "Name: <a href='%s%s'>%s</a>",
                  SiteConfiguration.getSiteUrl(AppContext.getUser().getSubdomain()),
                  CrmLinkGenerator.generateCrmItemLink(
                      CrmTypeConstants.OPPORTUNITY, opportunity.getId()),
                  opportunity.getOpportunityname()),
              ContentMode.HTML);

      opportunityInfo.addComponent(opportunityName);

      Label opportunityAmount =
          new Label("Amount: " + (opportunity.getAmount() != null ? opportunity.getAmount() : ""));
      if (opportunity.getCurrency() != null && opportunity.getAmount() != null) {
        opportunityAmount.setValue(
            opportunityAmount.getValue() + opportunity.getCurrency().getSymbol());
      }
      opportunityInfo.addComponent(opportunityAmount);

      Label opportunitySaleStage =
          new Label(
              "Sale Stage: "
                  + (opportunity.getSalesstage() != null ? opportunity.getSalesstage() : ""));
      opportunityInfo.addComponent(opportunitySaleStage);

      ELabel opportunityExpectedCloseDate =
          new ELabel(
                  "Expected Closed Date: "
                      + AppContext.formatPrettyTime(opportunity.getExpectedcloseddate()))
              .withDescription(AppContext.formatDate(opportunity.getExpectedcloseddate()));
      opportunityInfo.addComponent(opportunityExpectedCloseDate);

      blockTop.with(opportunityInfo).expand(opportunityInfo);
      blockContent.addComponent(blockTop);

      blockContent.setWidth("100%");

      beanBlock.addComponent(blockContent);
      return beanBlock;
    }
コード例 #12
0
  @Override
  public Component generateRow(final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout =
        new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, true, false))
            .withWidth("100%")
            .withStyleName("message");

    UserBlock memberBlock =
        new UserBlock(
            comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);

    CssLayout rowLayout = new CssLayout();
    rowLayout.setStyleName("message-container");
    rowLayout.setWidth("100%");

    MHorizontalLayout messageHeader =
        new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, false, true))
            .withWidth("100%")
            .withStyleName("message-header");
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel timePostLbl =
        new ELabel(
                AppContext.getMessage(
                    GenericI18Enum.EXT_ADDED_COMMENT,
                    comment.getOwnerFullName(),
                    AppContext.formatPrettyTime(comment.getCreatedtime())),
                ContentMode.HTML)
            .withDescription(AppContext.formatDateTime(comment.getCreatedtime()));

    timePostLbl.setSizeUndefined();
    timePostLbl.setStyleName("time-post");
    messageHeader.with(timePostLbl).expand(timePostLbl);

    // Message delete button
    Button msgDeleteBtn = new Button();
    msgDeleteBtn.setIcon(FontAwesome.TRASH_O);
    msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);
    messageHeader.addComponent(msgDeleteBtn);

    if (hasDeletePermission(comment)) {
      msgDeleteBtn.setVisible(true);
      msgDeleteBtn.addClickListener(
          new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(Button.ClickEvent event) {
              ConfirmDialogExt.show(
                  UI.getCurrent(),
                  AppContext.getMessage(
                      GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                  AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                  AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                  AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                  new ConfirmDialog.Listener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClose(ConfirmDialog dialog) {
                      if (dialog.isConfirmed()) {
                        CommentService commentService =
                            ApplicationContextUtil.getSpringBean(CommentService.class);
                        commentService.removeWithSession(
                            comment, AppContext.getUsername(), AppContext.getAccountId());
                        owner.removeRow(layout);
                      }
                    }
                  });
            }
          });
    } else {
      msgDeleteBtn.setVisible(false);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    messageContent.setStyleName("message-body");
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
      MVerticalLayout messageFooter =
          new MVerticalLayout()
              .withSpacing(false)
              .withWidth("100%")
              .withStyleName("message-footer");
      AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
      attachmentDisplay.setWidth("100%");
      messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT);
      rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
  }
コード例 #13
0
ファイル: MailFormWindow.java プロジェクト: gsccs/mycollab
  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);
  }
コード例 #14
0
  private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    toolbar.setSpacing(false);

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max =
        tools.addItem(
            "",
            FontAwesome.EXPAND,
            new Command() {

              @Override
              public void menuSelected(final MenuItem selectedItem) {
                if (!slot.getStyleName().contains("max")) {
                  selectedItem.setIcon(FontAwesome.COMPRESS);
                  toggleMaximized(slot, true);
                } else {
                  slot.removeStyleName("max");
                  selectedItem.setIcon(FontAwesome.EXPAND);
                  toggleMaximized(slot, false);
                }
              }
            });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.COG, null);
    root.addItem(
        "Configure",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });
    root.addSeparator();
    root.addItem(
        "Close",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
  }
コード例 #15
0
ファイル: Depot.java プロジェクト: patterncat/mycollab
  public Depot(
      final Label titleLbl,
      final ComponentContainer headerElement,
      final ComponentContainer component,
      final String headerWidth,
      final String headerLeftWidth) {
    this.setStyleName("depotComp");
    this.setMargin(new MarginInfo(true, false, false, false));
    this.header = new HorizontalLayout();
    this.header.setStyleName("depotHeader");
    this.header.setWidth(headerWidth);
    this.bodyContent = component;
    if (headerElement != null) {
      this.headerContent = headerElement;
    } else {
      this.headerContent = new HorizontalLayout();
      ((HorizontalLayout) this.headerContent).setSpacing(true);
      ((HorizontalLayout) this.headerContent).setMargin(true);
      ((HorizontalLayout) this.headerContent).setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
      this.headerContent.setVisible(false);
    }

    this.headerContent.setStyleName("header-elements");
    this.headerContent.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS);
    // this.headerContent.setHeight("100%");
    this.headerContent.setSizeUndefined();

    this.addComponent(this.header);

    final VerticalLayout headerLeft = new VerticalLayout();
    this.headerLbl = titleLbl;
    this.headerLbl.setStyleName("h2");
    this.headerLbl.setWidth("100%");
    headerLeft.addComponent(this.headerLbl);
    headerLeft.setStyleName("depot-title");
    headerLeft.addLayoutClickListener(
        new LayoutClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void layoutClick(final LayoutClickEvent event) {
            Depot.this.isOpenned = !Depot.this.isOpenned;
            if (Depot.this.isOpenned) {
              Depot.this.bodyContent.setVisible(true);
              Depot.this.removeStyleName("collapsed");
            } else {
              Depot.this.bodyContent.setVisible(false);
              Depot.this.addStyleName("collapsed");
            }
          }
        });
    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerLeft);
    headerWrapper.setStyleName("header-wrapper");
    headerWrapper.setWidth(headerLeftWidth);
    this.header.addComponent(headerWrapper);
    this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT);
    this.header.addComponent(this.headerContent);
    this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT);
    this.header.setExpandRatio(headerWrapper, 1.0f);

    final CustomComponent customComp = new CustomComponent(this.bodyContent);
    customComp.setWidth("100%");
    this.bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
  }
コード例 #16
0
  @SuppressWarnings("serial")
  @Override
  public void editPhoto(final byte[] imageData) {
    this.removeAllComponents();
    LOG.debug("Receive avatar upload with size: " + imageData.length);
    try {
      originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
      throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox =
        new MHorizontalLayout()
            .withSpacing(true)
            .withMargin(new MarginInfo(false, true, true, false))
            .withWidth("100%");

    Resource defaultPhoto =
        UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.with(previewImage).withAlign(previewImage, Alignment.TOP_LEFT);

    VerticalLayout previewBoxRight = new VerticalLayout();
    previewBoxRight.setMargin(new MarginInfo(false, true, false, true));
    Label lbPreview =
        new Label(
            "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p>"
                + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
                + "When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxRight.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null));
              }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    Button acceptBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                if (scaleImageData != null && scaleImageData.length > 0) {
                  try {
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                    UserAvatarService userAvatarService =
                        ApplicationContextUtil.getSpringBean(UserAvatarService.class);
                    userAvatarService.uploadAvatar(
                        image, AppContext.getUsername(), AppContext.getUserAvatarId());
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                  } catch (IOException e) {
                    throw new MyCollabException("Error when saving user avatar", e);
                  }
                }
              }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    previewBoxRight.addComponent(controlBtns);
    previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);

    previewBox.addComponent(previewBoxRight);
    previewBox.setExpandRatio(previewBoxRight, 1.0f);

    this.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.addStyleName(UIConstants.PHOTO_CROPBOX);
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource =
        new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(
        new Property.ValueChangeListener() {

          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.getProperty().getValue();
            int x1 = newSelection.getXTopLeft();
            int y1 = newSelection.getYTopLeft();
            int x2 = newSelection.getXBottomRight();
            int y2 = newSelection.getYBottomRight();
            if (x2 > x1 && y2 > y1) {
              BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
              ByteArrayOutputStream outStream = new ByteArrayOutputStream();
              try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
              } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
              }
            }
          }
        });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");

    currentPhotoBox.addComponent(cropField);

    cropBox.addComponent(currentPhotoBox);

    this.addComponent(previewBox);
    this.addComponent(cropBox);
    this.setExpandRatio(cropBox, 1.0f);
  }
コード例 #17
0
  private void constructHeader() {
    CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName("taskgroup-header");

    MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
    Label headerLbl = new Label("All Tasks");
    headerLbl.setStyleName("h2");
    header.with(headerLbl).withAlign(headerLbl, Alignment.MIDDLE_LEFT).expand(headerLbl);

    Button backToListBtn =
        new Button(
            "Back to dashboard",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new TaskListEvent.GotoTaskListScreen(this, null));
              }
            });
    backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    header.addComponent(backToListBtn);
    header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT);

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

              @Override
              public void buttonClick(Button.ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new TaskListEvent.SaveReoderTaskList(event, changeSet));
              }
            });
    saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    saveOrderBtn.setIcon(FontAwesome.SAVE);
    header.with(saveOrderBtn).withAlign(saveOrderBtn, Alignment.MIDDLE_RIGHT);

    headerWrapper.addComponent(header);

    this.addComponent(headerWrapper);

    final DDVerticalLayout ddLayout = new DDVerticalLayout();
    ddLayout.addStyleName("taskgroup-reorder");
    ddLayout.setComponentVerticalDropRatio(0.3f);
    ddLayout.setDragMode(LayoutDragMode.CLONE);
    ddLayout.setDropHandler(
        new DropHandler() {
          private static final long serialVersionUID = 1L;

          @Override
          public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
          }

          @Override
          public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable =
                (LayoutBoundTransferable) event.getTransferable();

            DDVerticalLayout.VerticalLayoutTargetDetails details =
                (DDVerticalLayout.VerticalLayoutTargetDetails) event.getTargetDetails();

            TaskListComponent comp = (TaskListComponent) transferable.getComponent();

            int currentIndex = ddLayout.getComponentIndex(comp);
            int newIndex = details.getOverIndex();

            ddLayout.removeComponent(comp);

            if (currentIndex > newIndex
                && details.getDropLocation() == VerticalDropLocation.BOTTOM) {
              newIndex++;
            }

            SimpleTaskList dropTaskList = comp.getTaskList();
            dropTaskList.setGroupindex(newIndex);
            changeSet.add(dropTaskList);
            ddLayout.addComponent(comp, newIndex);

            // change affected task list items
            for (int i = 0; i < ddLayout.getComponentCount(); i++) {
              TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i);
              SimpleTaskList affectedTaskList = affectedComp.getTaskList();
              affectedTaskList.setGroupindex(i);
              changeSet.add(affectedTaskList);
            }
          }
        });

    taskLists =
        new BeanList<>(
            null,
            ApplicationContextUtil.getSpringBean(ProjectTaskListService.class),
            TaskListRowDisplayHandler.class,
            ddLayout);
    this.addComponent(taskLists);
  }
コード例 #18
0
ファイル: DDTest6.java プロジェクト: ZOKOISC/vaadin
    public FileIcon(final File file) {
      super(new CssLayout());
      l = (CssLayout) getCompositionRoot();
      setWidth(null);
      l.setWidth(null);
      setDragStartMode(DragStartMode.WRAPPER); // drag all contained
      // components, not just the
      // one on it started
      this.file = file;
      Resource icon2 = file.getIcon();
      String name = file.getName();
      l.addComponent(new Embedded(null, icon2));
      l.addComponent(new Label(name));

      l.addListener(
          new LayoutClickListener() {
            @Override
            @SuppressWarnings("static-access")
            public void layoutClick(LayoutClickEvent event) {
              if (event.isDoubleClick()) {
                if (file instanceof Folder) {
                  get().tree1.setValue(file);
                } else {
                  String type = file.getType();
                  if (canDisplay(type)) {
                    DDTest6.get().openFile(file);
                  }
                }
              }
            }

            String[] knownTypes = new String[] {"image/png", "text/csv"};

            private boolean canDisplay(String type) {
              if (type != null) {
                for (String t : knownTypes) {
                  if (t.equals(type)) {
                    return true;
                  }
                }
              }
              return false;
            }
          });

      if (file instanceof Folder) {

        setDropHandler(
            new DropHandler() {

              @Override
              public AcceptCriterion getAcceptCriterion() {
                return new Not(SourceIsTarget.get());
              }

              @Override
              public void drop(DragAndDropEvent dropEvent) {
                File f = null;

                if (dropEvent.getTransferable().getSourceComponent() instanceof FileIcon) {
                  FileIcon new_name = (FileIcon) dropEvent.getTransferable().getSourceComponent();
                  f = new_name.file;
                } else if (dropEvent.getTransferable().getSourceComponent() == tree1) {
                  f = (File) ((DataBoundTransferable) dropEvent.getTransferable()).getItemId();
                }

                if (f != null) {
                  get().setParent(f, (Folder) FileIcon.this.file);
                }
              }
            });
      }
    }