Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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

License:Open Source License

public GanttChartTaskContainer() {
    taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
    constructGanttChart();// w w  w  . ja  v  a2  s  .c  o  m
    Panel controls = createControls();
    this.setStyleName("gantt-view");
    this.addComponent(controls);
    HorizontalLayout mainLayout = new HorizontalLayout();
    mainLayout.setWidth("100%");
    mainLayout.setStyleName("gantt-wrap");
    mainLayout.addComponent(taskTable);
    mainLayout.addComponent(gantt);
    this.addComponent(mainLayout);
}

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

License:Open Source License

private Panel createControls() {

    Panel panel = new Panel();
    panel.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout controls = new HorizontalLayout();
    controls.setSpacing(true);/*from   w ww.  j  a  va 2  s  . co  m*/
    controls.setMargin(true);
    panel.setContent(controls);

    start = new DateField(AppContext.getMessage(TaskI18nEnum.FORM_START_DATE));
    start.setValue(gantt.getStartDate());
    start.setResolution(Resolution.DAY);
    start.setImmediate(true);
    start.addValueChangeListener(startDateValueChangeListener);

    end = new DateField(AppContext.getMessage(TaskI18nEnum.FORM_END_DATE));
    end.setValue(gantt.getEndDate());
    end.setResolution(Resolution.DAY);
    end.setImmediate(true);
    end.addValueChangeListener(endDateValueChangeListener);

    reso = new NativeSelect("Resolution");
    reso.setNullSelectionAllowed(false);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Day);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Week);
    reso.setValue(gantt.getResolution());
    reso.setImmediate(true);
    reso.addValueChangeListener(resolutionValueChangeListener);

    controls.addComponent(start);
    controls.addComponent(end);
    controls.addComponent(reso);
    panel.setStyleName(UIConstants.THEME_NO_BORDER);

    return panel;
}

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

License:Open Source License

public TaskGroupNoItemView() {
    this.setMargin(new MarginInfo(true, false, false, false));
    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("taskgroup-noitem");
    layout.setSpacing(true);/*  w ww . jav a 2s.c om*/
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    layout.setMargin(true);

    Image image = new Image(null, MyCollabResource.newResource("icons/48/project/tasklist.png"));
    layout.addComponent(image);

    Label title = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_TITLE));
    title.addStyleName("h2");
    title.setWidthUndefined();
    layout.addComponent(title);

    Label body = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_HINT));
    body.setWidthUndefined();
    layout.addComponent(body);

    Button createTaskGroupBtn = new Button(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    final TaskGroupAddWindow taskListWindow = new TaskGroupAddWindow(null);
                    UI.getCurrent().addWindow(taskListWindow);
                }
            });
    createTaskGroupBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));

    HorizontalLayout links = new HorizontalLayout();

    links.addComponent(createTaskGroupBtn);
    createTaskGroupBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    links.setSpacing(true);

    layout.addComponent(links);
    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.TOP_CENTER);
}

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

License:Open Source License

private void constructHeader() {
    CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName("taskgroup-header");

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);// w  w  w  .j ava 2s.  c  o  m
    header.setWidth("100%");
    Label headerLbl = new Label("All Tasks");
    headerLbl.setStyleName("h2");
    header.addComponent(headerLbl);
    header.setComponentAlignment(headerLbl, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(headerLbl, 1.0f);

    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);

    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);
    header.addComponent(saveOrderBtn);
    header.setComponentAlignment(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<ProjectTaskListService, TaskListSearchCriteria, SimpleTaskList>(null,
            ApplicationContextUtil.getSpringBean(ProjectTaskListService.class), TaskListRowDisplayHandler.class,
            ddLayout);
    this.addComponent(taskLists);
}

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

License:Open Source License

public void setSearchCriteria(final TaskSearchCriteria searchCriteria) {
    this.searchCriteria = searchCriteria;
    this.bodyContent.removeAllComponents();
    ProjectTaskService projectTaskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
    int totalCountItems = projectTaskService.getTotalCount(searchCriteria);
    final List<GroupItem> groupItems = projectTaskService.getAssignedDefectsSummary(searchCriteria);

    if (!groupItems.isEmpty()) {
        for (final GroupItem item : groupItems) {
            final HorizontalLayout assigneeLayout = new HorizontalLayout();
            assigneeLayout.setSpacing(true);
            assigneeLayout.setWidth("100%");

            final String assignUser = item.getGroupid();
            String assignUserFullName = item.getGroupid() == null ? "" : item.getGroupname();

            if (assignUserFullName == null || assignUserFullName.trim().equals("")) {
                String displayName = item.getGroupid();
                int index = displayName != null ? displayName.indexOf("@") : 0;
                if (index > 0) {
                    assignUserFullName = displayName.substring(0, index);
                } else {
                    assignUserFullName = AppContext.getMessage(TaskI18nEnum.OPT_UNDEFINED_USER);
                }//  w w  w . ja  v  a  2s.c o  m
            }

            final TaskAssigneeLink userLbl = new TaskAssigneeLink(assignUser, item.getExtraValue(),
                    assignUserFullName);
            assigneeLayout.addComponent(userLbl);
            final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCountItems,
                    totalCountItems - item.getValue(), false);
            indicator.setWidth("100%");
            assigneeLayout.addComponent(indicator);
            assigneeLayout.setExpandRatio(indicator, 1.0f);
            this.bodyContent.addComponent(assigneeLayout);
        }

    }
}

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 va 2s.c om*/
                    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/*from   ww w  .  j  a v 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);/*from w  w  w.  j  a v a 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.RoleListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from   w  w w . j a va2s . c  om*/
    layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);

    this.selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    final Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE));

    this.tableActionControls = new DefaultMassItemActionHandlersContainer();
    if (AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)) {
        tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete",
                AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }
    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O,
            "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION,
            FontAwesome.FILE_EXCEL_O, "export", "export.xlsx",
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O,
            "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    layout.addComponent(this.tableActionControls);
    layout.addComponent(this.selectedItemsNumberLabel);
    layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//  ww  w . java  2 s  . c o m
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);
}