Example usage for com.vaadin.ui HorizontalLayout setWidth

List of usage examples for com.vaadin.ui HorizontalLayout setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.esofthead.mycollab.module.project.view.task.UnresolvedTaskByPriorityWidget.java

License:Open Source License

public void setSearchCriteria(final TaskSearchCriteria searchCriteria) {
    this.searchCriteria = searchCriteria;
    this.bodyContent.removeAllComponents();
    final ProjectTaskService taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
    final int totalCount = taskService.getTotalCount(searchCriteria);
    final List<GroupItem> groupItems = taskService.getPrioritySummary(searchCriteria);
    final TaskPriorityClickListener listener = new TaskPriorityClickListener();

    if (!groupItems.isEmpty()) {
        for (final TaskPriority priority : OptionI18nEnum.task_priorities) {
            boolean isFound = false;
            for (final GroupItem item : groupItems) {
                if (priority.name().equals(item.getGroupid())) {
                    isFound = true;//w w  w.  j  a v a2s .  c o  m
                    final HorizontalLayout priorityLayout = new HorizontalLayout();
                    priorityLayout.setSpacing(true);
                    priorityLayout.setWidth("100%");
                    final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener);
                    final Resource iconPriority = new ExternalResource(
                            ProjectResources.getIconResourceLink12ByTaskPriority(priority.name()));
                    userLbl.setIcon(iconPriority);
                    userLbl.setWidth("110px");
                    userLbl.setStyleName("link");

                    priorityLayout.addComponent(userLbl);
                    final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount,
                            totalCount - item.getValue(), false);
                    indicator.setWidth("100%");
                    priorityLayout.addComponent(indicator);
                    priorityLayout.setExpandRatio(indicator, 1.0f);

                    this.bodyContent.addComponent(priorityLayout);
                }
            }

            if (!isFound) {
                final HorizontalLayout priorityLayout = new HorizontalLayout();
                priorityLayout.setSpacing(true);
                priorityLayout.setWidth("100%");
                final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener);
                final Resource iconPriority = new ExternalResource(
                        ProjectResources.getIconResourceLink12ByTaskPriority(priority.name()));
                userLbl.setIcon(iconPriority);
                userLbl.setWidth("110px");
                userLbl.setStyleName("link");
                priorityLayout.addComponent(userLbl);
                final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false);
                indicator.setWidth("100%");
                priorityLayout.addComponent(indicator);
                priorityLayout.setExpandRatio(indicator, 1.0f);

                this.bodyContent.addComponent(priorityLayout);
            }
        }

    }
}

From source file:com.esofthead.mycollab.module.project.view.TimeTrackingSummaryViewImpl.java

License:Open Source License

@Override
public void display() {
    projects = ApplicationContextUtil.getSpringBean(ProjectService.class)
            .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(projects)) {
        itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class);

        final CssLayout headerWrapper = new CssLayout();
        headerWrapper.setWidth("100%");
        headerWrapper.setStyleName("projectfeed-hdr-wrapper");

        HorizontalLayout loggingPanel = new HorizontalLayout();

        HorizontalLayout controlBtns = new HorizontalLayout();
        controlBtns.setMargin(new MarginInfo(true, false, true, false));

        final Label layoutHeader = new Label(
                ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking",
                ContentMode.HTML);
        layoutHeader.addStyleName("h2");

        final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
        header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader);

        final CssLayout contentWrapper = new CssLayout();
        contentWrapper.setWidth("100%");
        contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER);

        headerWrapper.addComponent(header);
        this.addComponent(headerWrapper);
        contentWrapper.addComponent(controlBtns);

        MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%");

        contentWrapper.addComponent(controlsPanel);
        contentWrapper.addComponent(loggingPanel);
        this.addComponent(contentWrapper);

        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*  w  w w. j av  a 2 s . c  o  m*/
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        controlBtns.addComponent(backBtn);

        VerticalLayout selectionLayoutWrapper = new VerticalLayout();
        selectionLayoutWrapper.setWidth("100%");
        selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel");
        controlsPanel.addComponent(selectionLayoutWrapper);

        final GridLayout selectionLayout = new GridLayout(9, 2);
        selectionLayout.setSpacing(true);
        selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        selectionLayout.setMargin(true);
        selectionLayoutWrapper.addComponent(selectionLayout);

        Label fromLb = new Label("From:");
        fromLb.setWidthUndefined();
        selectionLayout.addComponent(fromLb, 0, 0);

        this.fromDateField = new PopupDateFieldExt();
        this.fromDateField.setResolution(Resolution.DAY);
        this.fromDateField.setDateFormat(AppContext.getUserDateFormat());
        this.fromDateField.setWidth("100px");
        selectionLayout.addComponent(this.fromDateField, 1, 0);

        Label toLb = new Label("To:");
        toLb.setWidthUndefined();
        selectionLayout.addComponent(toLb, 2, 0);

        this.toDateField = new PopupDateFieldExt();
        this.toDateField.setResolution(Resolution.DAY);
        this.toDateField.setDateFormat(AppContext.getUserDateFormat());
        this.toDateField.setWidth("100px");
        selectionLayout.addComponent(this.toDateField, 3, 0);

        Label groupLb = new Label("Group:");
        groupLb.setWidthUndefined();
        selectionLayout.addComponent(groupLb, 0, 1);

        this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER);
        this.groupField.setWidth("100px");
        selectionLayout.addComponent(this.groupField, 1, 1);

        Label sortLb = new Label("Sort:");
        sortLb.setWidthUndefined();
        selectionLayout.addComponent(sortLb, 2, 1);

        this.orderField = new ItemOrderComboBox();
        this.orderField.setWidth("100px");
        selectionLayout.addComponent(this.orderField, 3, 1);

        Label projectLb = new Label("Project:");
        projectLb.setWidthUndefined();
        selectionLayout.addComponent(projectLb, 4, 0);

        this.projectField = new UserInvolvedProjectsListSelect();
        initListSelectStyle(this.projectField);
        selectionLayout.addComponent(this.projectField, 5, 0, 5, 1);

        Label userLb = new Label("User:");
        userLb.setWidthUndefined();
        selectionLayout.addComponent(userLb, 6, 0);

        this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds());
        initListSelectStyle(this.userField);
        selectionLayout.addComponent(this.userField, 7, 0, 7, 1);

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

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        fromDate = fromDateField.getValue();
                        toDate = toDateField.getValue();
                        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
                        searchTimeReporting();
                    }
                });
        queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

        selectionLayout.addComponent(queryBtn, 8, 0);

        loggingPanel.setWidth("100%");
        loggingPanel.setHeight("80px");
        loggingPanel.setSpacing(true);

        totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML);
        totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG);
        totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL);
        loggingPanel.addComponent(totalHoursLoggingLabel);
        loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f);
        loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT);

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

            @Override
            public void buttonClick(ClickEvent event) {
                exportButtonControl.setPopupVisible(true);

            }
        });
        exportButtonControl = new SplitButton(exportBtn);
        exportButtonControl.setWidthUndefined();
        exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
        exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

        VerticalLayout popupButtonsControl = new VerticalLayout();
        exportButtonControl.setContent(popupButtonsControl);

        Button exportPdfBtn = new Button("Pdf");
        FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
        pdfDownloader.extend(exportPdfBtn);
        exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
        exportPdfBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportPdfBtn);

        Button exportExcelBtn = new Button("Excel");
        FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
        excelDownloader.extend(exportExcelBtn);
        exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
        exportExcelBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportExcelBtn);

        controlBtns.addComponent(exportButtonControl);
        controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT);
        controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT);
        controlBtns.setSizeFull();

        this.timeTrackingWrapper = new VerticalLayout();
        this.timeTrackingWrapper.setWidth("100%");
        contentWrapper.addComponent(this.timeTrackingWrapper);

        Calendar date = new GregorianCalendar();
        date.set(Calendar.DAY_OF_MONTH, 1);

        fromDate = date.getTime();
        date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH));
        toDate = date.getTime();

        fromDateField.setValue(fromDate);
        toDateField.setValue(toDate);

        searchCriteria = new ItemTimeLoggingSearchCriteria();

        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
    } else {
        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

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

        Label infoLbl = new Label("You are not involved in any project yet to track time working");
        infoLbl.setWidthUndefined();
        contentWrapper.setMargin(true);
        contentWrapper.addComponent(infoLbl);
        contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER);

        contentWrapper.addComponent(backBtn);
        contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER);
        this.addComponent(contentWrapper);
        this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfileReadViewImpl.java

License:Open Source License

private void displayUserAvatar() {
    this.userAvatar.removeAllComponents();
    final Image cropField = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(AppContext.getUserAvatarId(), 100);
    userAvatar.addComponent(cropField);//w w w  . j  ava 2 s . co  m

    this.avatarAndPass.removeAllComponents();
    avatarAndPass.addComponent(userAvatar);

    User user = formItem.getUser();

    final VerticalLayout basicLayout = new VerticalLayout();
    basicLayout.setSpacing(true);

    final HorizontalLayout userWrapper = new HorizontalLayout();

    final Label userName = new Label(AppContext.getSession().getDisplayName());
    userName.setStyleName("h1");
    userWrapper.addComponent(userName);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new BasicInfoChangeWindow(formItem.getUser()));
                }
            });
    btnChangeBasicInfo.setStyleName("link");
    HorizontalLayout btnChangeBasicInfoWrapper = new HorizontalLayout();
    btnChangeBasicInfoWrapper.setWidth("40px");
    btnChangeBasicInfoWrapper.addComponent(btnChangeBasicInfo);
    btnChangeBasicInfoWrapper.setComponentAlignment(btnChangeBasicInfo, Alignment.MIDDLE_RIGHT);
    userWrapper.addComponent(btnChangeBasicInfoWrapper);
    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_BIRTHDAY) + ": "
            + AppContext.formatDate(user.getDateofbirth())));
    basicLayout.addComponent(
            new MHorizontalLayout(new Label(AppContext.getMessage(UserI18nEnum.FORM_EMAIL) + ": "),
                    new LabelLink(user.getEmail(), "mailto:" + user.getEmail())));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_TIMEZONE) + ": "
            + TimezoneMapper.getTimezone(user.getTimezone()).getDisplayName()));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_LANGUAGE) + ": "
            + AppContext.getMessage(LangI18Enum.class, user.getLanguage())));

    HorizontalLayout passwordWrapper = new HorizontalLayout();
    passwordWrapper
            .addComponent(new Label(AppContext.getMessage(ShellI18nEnum.FORM_PASSWORD) + ": ***********"));

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

        @Override
        public void buttonClick(final ClickEvent event) {
            UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.user));
        }
    });
    btnChangePassword.setStyleName("link");
    HorizontalLayout btnChangePasswordWrapper = new HorizontalLayout();
    btnChangePasswordWrapper.setWidth("50px");
    btnChangePasswordWrapper.addComponent(btnChangePassword);
    btnChangePasswordWrapper.setComponentAlignment(btnChangePassword, Alignment.MIDDLE_RIGHT);
    passwordWrapper.addComponent(btnChangePasswordWrapper);
    basicLayout.addComponent(passwordWrapper);
    basicLayout.setComponentAlignment(passwordWrapper, Alignment.MIDDLE_LEFT);

    avatarAndPass.addComponent(basicLayout);
    avatarAndPass.setComponentAlignment(basicLayout, Alignment.TOP_LEFT);
    avatarAndPass.setExpandRatio(basicLayout, 1.0f);

    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")) {
                EventBusFactory.getInstance()
                        .post(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.addStyleName("upload-field");
    avatarUploadField.setButtonCaption(AppContext.getMessage(UserI18nEnum.BUTTON_CHANGE_AVATAR));
    avatarUploadField.setSizeUndefined();
    avatarUploadField.setFieldType(FieldType.BYTE_ARRAY);
    this.userAvatar.addComponent(avatarUploadField);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  w ww . jav a2  s. c  om
public void setSearchCriteria(UserSearchCriteria searchCriteria) {
    UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
    List<SimpleUser> userAccountList = userService
            .findPagableListByCriteria(new SearchRequest<>(searchCriteria, 0, Integer.MAX_VALUE));

    this.removeAllComponents();
    this.setSpacing(true);
    HorizontalLayout header = new HorizontalLayout();
    header.setStyleName(UIConstants.HEADER_VIEW);
    header.setWidth("100%");
    header.setMargin(new MarginInfo(true, false, true, false));
    Button createBtn = new Button("Invite user", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null));
        }
    });
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);

    header.addComponent(createBtn);
    header.setComponentAlignment(createBtn, Alignment.MIDDLE_RIGHT);
    this.addComponent(header);

    CssLayout contentLayout = new CssLayout();
    contentLayout.setWidth("100%");
    for (SimpleUser userAccount : userAccountList) {
        contentLayout.addComponent(generateMemberBlock(userAccount));
    }
    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java

License:Open Source License

private Component generateMemberBlock(final SimpleUser member) {
    CssLayout memberBlock = new CssLayout();
    memberBlock.addStyleName("member-block");

    VerticalLayout blockContent = new VerticalLayout();
    HorizontalLayout blockTop = new HorizontalLayout();
    blockTop.setSpacing(true);/*from  ww  w .  j av a 2  s. c om*/
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100);
    blockTop.addComponent(memberAvatar);

    VerticalLayout memberInfo = new VerticalLayout();

    HorizontalLayout layoutButtonDelete = new HorizontalLayout();
    layoutButtonDelete.setVisible(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));
    layoutButtonDelete.setWidth("100%");

    Label emptylb = new Label("");
    layoutButtonDelete.addComponent(emptylb);
    layoutButtonDelete.setExpandRatio(emptylb, 1.0f);

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

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.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()) {
                                UserService userService = ApplicationContextUtil
                                        .getSpringBean(UserService.class);
                                userService.pendingUserAccounts(Arrays.asList(member.getUsername()),
                                        AppContext.getAccountId());
                                EventBusFactory.getInstance()
                                        .post(new UserEvent.GotoList(UserListViewImpl.this, null));
                            }
                        }
                    });
        }
    });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    layoutButtonDelete.addComponent(deleteBtn);

    memberInfo.addComponent(layoutButtonDelete);

    ButtonLink userAccountLink = new ButtonLink(member.getDisplayName());
    userAccountLink.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new UserEvent.GotoRead(UserListViewImpl.this, member.getUsername()));
        }
    });
    userAccountLink.setWidth("100%");
    userAccountLink.setHeight("100%");

    memberInfo.addComponent(userAccountLink);

    Label memberEmailLabel = new Label(
            "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML);
    memberEmailLabel.addStyleName("member-email");
    memberEmailLabel.setWidth("100%");
    memberInfo.addComponent(memberEmailLabel);

    Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getRegisteredtime()));
    memberSinceLabel.addStyleName("member-email");
    memberSinceLabel.setWidth("100%");
    memberInfo.addComponent(memberSinceLabel);

    if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getRegisterstatus())) {
        final VerticalLayout waitingNotLayout = new VerticalLayout();
        Label infoStatus = new Label("Waiting for accept invitation");
        infoStatus.addStyleName("member-email");
        waitingNotLayout.addComponent(infoStatus);

        ButtonLink resendInvitationLink = new ButtonLink("Resend Invitation", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
                userService.updateUserAccountStatus(member.getUsername(), member.getAccountId(),
                        RegisterStatusConstants.VERIFICATING);
                waitingNotLayout.removeAllComponents();
                Label statusEmail = new Label("Sending invitation email");
                statusEmail.addStyleName("member-email");
                waitingNotLayout.addComponent(statusEmail);
            }
        });
        resendInvitationLink.setStyleName("link");
        resendInvitationLink.addStyleName("member-email");
        waitingNotLayout.addComponent(resendInvitationLink);
        memberInfo.addComponent(waitingNotLayout);
    } else if (RegisterStatusConstants.ACTIVE.equals(member.getRegisterstatus())) {
        Label lastAccessTimeLbl = new Label("Logged in "
                + DateTimeUtils.getPrettyDateValue(member.getLastaccessedtime(), AppContext.getUserLocale()));
        lastAccessTimeLbl.addStyleName("member-email");
        memberInfo.addComponent(lastAccessTimeLbl);
    } else if (RegisterStatusConstants.VERIFICATING.equals(member.getRegisterstatus())) {
        Label infoStatus = new Label("Sending invitation email");
        infoStatus.addStyleName("member-email");
        memberInfo.addComponent(infoStatus);
    }

    blockTop.addComponent(memberInfo);
    blockTop.setExpandRatio(memberInfo, 1.0f);
    blockTop.setWidth("100%");
    blockContent.addComponent(blockTop);

    if (member.getRoleid() != null) {
        String memberRoleLinkPrefix = "<a href=\""
                + AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()) + "\"";
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        if (member.getIsAccountOwner() != null && member.getIsAccountOwner()) {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        } else {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color:gray;font-size:12px;\">"
                    + member.getRoleName() + "</a>");
        }
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else if (member.getIsAccountOwner() != null && member.getIsAccountOwner() == Boolean.TRUE) {
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        memberRole.setValue("<a style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else {
        Label lbl = new Label();
        lbl.setHeight("10px");
        blockContent.addComponent(lbl);
    }
    blockContent.setWidth("100%");

    memberBlock.addComponent(blockContent);

    return memberBlock;
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserTableDisplay.java

License:Open Source License

public UserTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(UserService.class), SimpleUser.class, requiredColumn,
            displayColumns);//w w  w  . j a  va 2 s  .  c  om

    this.addGeneratedColumn("selected", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            final SimpleUser user = UserTableDisplay.this.getBeanByIndex(itemId);
            final CheckBoxDecor cb = new CheckBoxDecor("", user.isSelected());
            cb.setImmediate(true);
            cb.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    UserTableDisplay.this.fireSelectItemEvent(user);
                }
            });

            user.setExtraData(cb);
            return cb;
        }
    });

    this.addGeneratedColumn("username", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleUser user = UserTableDisplay.this.getBeanByIndex(itemId);
            UserLink b = new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName(), false);

            b.addClickListener(new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    fireTableEvent(new TableClickEvent(UserTableDisplay.this, user.getUsername(), "username"));
                }
            });

            if (RegisterStatusConstants.ACTIVE.equals(user.getRegisterstatus())) {
                return b;
            } else {
                HorizontalLayout layout = new HorizontalLayout();
                layout.setWidth("100%");
                layout.setSpacing(true);

                if (RegisterStatusConstants.DELETE.equals(user.getRegisterstatus())) {
                    layout.addComponent(b);
                    Label statusLbl = new Label("(Removed)");
                    layout.addComponent(statusLbl);
                    layout.addComponent(statusLbl);
                } else {
                    HorizontalLayout userLayout = new HorizontalLayout();
                    userLayout.addComponent(b);
                    userLayout.setWidth("100%");

                    Label statusLbl = new Label("(Waiting for accept)");
                    userLayout.addComponent(statusLbl);
                    userLayout.setExpandRatio(statusLbl, 1.0f);

                    layout.addComponent(userLayout);
                    layout.setExpandRatio(userLayout, 1.0f);

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            UserAccountInvitationMapper userAccountInvitationMapper = ApplicationContextUtil
                                    .getSpringBean(UserAccountInvitationMapper.class);
                            UserAccountInvitation invitation = new UserAccountInvitation();
                            invitation.setAccountid(user.getAccountId());
                            invitation.setCreatedtime(new GregorianCalendar().getTime());
                            invitation.setUsername(user.getUsername());
                            invitation.setInvitationstatus(
                                    (user.getRegisterstatus() == null) ? RegisterStatusConstants.VERIFICATING
                                            : user.getRegisterstatus());
                            userAccountInvitationMapper.insert(invitation);

                        }
                    });
                    resendBtn.addStyleName("link");
                    layout.addComponent(resendBtn);
                }
                return layout;
            }
        }
    });

    this.addGeneratedColumn("email", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, Object itemId, Object columnId) {
            SimpleUser user = UserTableDisplay.this.getBeanByIndex(itemId);
            return new EmailLink(user.getEmail());
        }
    });

    this.addGeneratedColumn("lastaccessedtime", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleUser user = UserTableDisplay.this.getBeanByIndex(itemId);
            Label dateLbl = new Label(
                    DateTimeUtils.getPrettyDateValue(user.getLastaccessedtime(), AppContext.getUserLocale()));
            return dateLbl;
        }
    });
}

From source file:com.esofthead.mycollab.vaadin.ui.AbstractBeanBlockList.java

License:Open Source License

protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setWidth("100%");

    final HorizontalLayout controlBar = new HorizontalLayout();
    controlBar.setWidth("100%");
    this.controlBarWrapper.addComponent(controlBar);

    this.pageManagement = new HorizontalLayout();

    // defined layout here ---------------------------

    if (this.currentPage > 1) {
        final Button firstLink = new ButtonLink("1", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override//  www .j ava2  s.c o m
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(1);
            }
        }, false);
        firstLink.addStyleName("buttonPaging");
        this.pageManagement.addComponent(firstLink);
    }
    if (this.currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(ss1);
    }
    if (this.currentPage > 3) {
        final Button previous2 = new ButtonLink("" + (this.currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage - 2);
            }
        }, false);
        previous2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(previous2);
    }
    if (this.currentPage > 2) {
        final Button previous1 = new ButtonLink("" + (this.currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage - 1);
            }
        }, false);
        previous1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLink
    final Button current = new ButtonLink("" + this.currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage);
        }
    }, false);
    current.addStyleName("buttonPaging");
    current.addStyleName("buttonPagingcurrent");

    this.pageManagement.addComponent(current);
    final int range = this.totalPage - this.currentPage;
    if (range >= 1) {
        final Button next1 = new ButtonLink("" + (this.currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage + 1);
            }
        }, false);
        next1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        final Button next2 = new ButtonLink("" + (this.currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage + 2);
            }
        }, false);
        next2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        final Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        final Button last = new ButtonLink("" + this.totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.totalPage);
            }
        }, false);
        last.addStyleName("buttonPaging");
        this.pageManagement.addComponent(last);
    }

    this.pageManagement.setWidth(null);
    this.pageManagement.setSpacing(true);
    controlBar.addComponent(this.pageManagement);
    controlBar.setComponentAlignment(this.pageManagement, Alignment.MIDDLE_RIGHT);

    return this.controlBarWrapper;
}

From source file:com.esofthead.mycollab.vaadin.ui.AbstractBeanPagedList.java

License:Open Source License

protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setStyleName(listControlStyle);
    this.controlBarWrapper.setWidth("100%");

    final HorizontalLayout controlBar = new HorizontalLayout();
    controlBar.setWidth("100%");
    this.controlBarWrapper.addComponent(controlBar);

    this.pageManagement = new HorizontalLayout();

    // defined layout here ---------------------------

    if (this.currentPage > 1) {
        final Button firstLink = new ButtonLink("1", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*from ww w  . j  a  v  a 2  s .  c  om*/
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(1);
            }
        }, false);
        firstLink.addStyleName("buttonPaging");
        this.pageManagement.addComponent(firstLink);
    }
    if (this.currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(ss1);
    }
    if (this.currentPage > 3) {
        final Button previous2 = new ButtonLink("" + (this.currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.currentPage - 2);
            }
        }, false);
        previous2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(previous2);
    }
    if (this.currentPage > 2) {
        final Button previous1 = new ButtonLink("" + (this.currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.currentPage - 1);
            }
        }, false);
        previous1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLink
    final Button current = new ButtonLink("" + this.currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.currentPage);
        }
    }, false);
    current.addStyleName("buttonPaging");
    current.addStyleName("buttonPagingcurrent");

    this.pageManagement.addComponent(current);
    final int range = this.totalPage - this.currentPage;
    if (range >= 1) {
        final Button next1 = new ButtonLink("" + (this.currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.currentPage + 1);
            }
        }, false);
        next1.addStyleName("buttonPaging");
        this.pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        final Button next2 = new ButtonLink("" + (this.currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.currentPage + 2);
            }
        }, false);
        next2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        final Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        this.pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        final Button last = new ButtonLink("" + this.totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanPagedList.this.pageChange(AbstractBeanPagedList.this.totalPage);
            }
        }, false);
        last.addStyleName("buttonPaging");
        this.pageManagement.addComponent(last);
    }

    this.pageManagement.setWidth(null);
    this.pageManagement.setSpacing(true);
    controlBar.addComponent(this.pageManagement);
    controlBar.setComponentAlignment(this.pageManagement, Alignment.MIDDLE_RIGHT);

    return this.controlBarWrapper;
}

From source file:com.esofthead.mycollab.vaadin.ui.FeedbackWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(2, 5);
    mainLayout.setMargin(true);/*from  w w  w.  j  av  a 2  s .c  om*/
    mainLayout.setSpacing(true);

    emailNameTextField = new TextField();
    emailNameTextField.setWidth("500px");
    Label emailName = new Label("Your name: ");

    mainLayout.addComponent(emailName, 0, 0);
    mainLayout.addComponent(emailNameTextField, 1, 0);

    emailTextField = new TextField();
    emailTextField.setWidth("500px");
    emailTextField.setRequired(true);
    Label emailLbl = new Label("Your email: ");

    mainLayout.addComponent(emailLbl, 0, 1);
    mainLayout.addComponent(emailTextField, 1, 1);

    subjectTextField = new TextField();
    subjectTextField.setWidth("500px");
    subjectTextField.setRequired(true);
    Label subjectLbl = new Label("Subject: ");

    mainLayout.addComponent(subjectLbl, 0, 2);
    mainLayout.addComponent(subjectTextField, 1, 2);

    final RichTextArea contentArea = new RichTextArea();
    contentArea.setImmediate(true);
    contentArea.setWidth(500, Sizeable.Unit.PIXELS);
    contentArea.setHeight(200, Sizeable.Unit.PIXELS);
    Label contentLbl = new Label("Your feedback: ");

    mainLayout.addComponent(contentLbl, 0, 3);
    mainLayout.addComponent(contentArea, 1, 3);

    initDefaultData();

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

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

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

    // Panel attachedFilepanel = new Panel();
    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setHeight("80px");
    contentLayout.setStyleName("noneBorder-panel");
    contentLayout.setSizeUndefined();

    contentLayout.addComponent(uploadExt);

    // attachedFilepanel.setContent(contentLayout);

    controlsLayout.addComponent(contentLayout);
    controlsLayout.setComponentAlignment(contentLayout, Alignment.BOTTOM_LEFT);
    controlsLayout.setExpandRatio(contentLayout, 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) {
                    FeedbackWindow.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) {
            String email = emailTextField.getValue().toString().trim();
            String subject = subjectTextField.getValue().toString().trim();
            if (!StringUtils.isValidEmail(email)) {
                NotificationUtil.showWarningNotification("The email is not valid, please check it again!");
                return;
            }
            if (!email.equals("") && !subject.equals("")) {
                ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class);
                List<File> listFile = attachments.getListFile();
                List<EmailAttachementSource> emailAttachmentSource = null;

                if (CollectionUtils.isNotEmpty(listFile)) {
                    emailAttachmentSource = new ArrayList<EmailAttachementSource>();
                    for (File file : listFile) {
                        emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                }

                String nameEmailFrom = emailNameTextField.getValue().toString().trim();
                nameEmailFrom = nameEmailFrom.equals("") ? email : nameEmailFrom;
                String toEmail = SiteConfiguration.getSendErrorEmail();

                FeedbackWindow.this.close();

                systemMailService.sendHTMLMail(email, nameEmailFrom,
                        Arrays.asList(new MailRecipientField(toEmail, toEmail)), null, null, subject,
                        contentArea.getValue().toString(), emailAttachmentSource);

            } else {
                NotificationUtil.showWarningNotification(
                        "The email field and subject field must be not empty! Please fulfil them before pressing enter button.");
            }
        }
    });
    sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 4, 1, 4);

    this.setContent(mainLayout);
}

From source file:com.esofthead.mycollab.vaadin.ui.MailFormWindow.java

License:Open Source License

private Layout createTextFieldMail(String title, Component component) {
    HorizontalLayout layout = new HorizontalLayout();
    Label lbTitle = new Label(title);
    lbTitle.setWidth("60px");
    lbTitle.setStyleName("lbmail");
    layout.addComponent(lbTitle);/*from   w w w.j a v a 2 s  .  c  o  m*/
    layout.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
    layout.addComponent(component);
    layout.setComponentAlignment(component, Alignment.MIDDLE_LEFT);
    layout.setWidth("100%");
    layout.setExpandRatio(component, 1.0f);
    return layout;
}