Example usage for com.vaadin.ui GridLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:at.jku.ce.adaptivetesting.vaadin.ui.MainUI.java

License:LGPL

public MainUI() {
    // Make the web-app large
    setSizeFull();//ww  w.j a v  a2 s.co m
    // Set the layout for the bottom
    // Create a 3rd party licence button with a click listener
    final Button licences = new Button("Lizenzen");
    licences.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 32642854872179636L;

        @Override
        public void buttonClick(ClickEvent event) {
            LogHelper.logInfo("Opened LicenceWindow");
            LicenceWindow licenceWindow = new LicenceWindow();
            licenceWindow.addCloseListener(new CloseListener() {

                private static final long serialVersionUID = 7874342882437355680L;

                @Override
                public void windowClose(CloseEvent e) {
                    event.getButton().setEnabled(true);
                }
            });
            getUI().addWindow(licenceWindow);
            // Disable sender
            event.getButton().setEnabled(false);
        }

    });
    Label copyright = new HtmlLabel(
            "<i> Reisisoft & JKU 2014 - " + new GregorianCalendar().get(Calendar.YEAR) + "</i>");
    /* Button openLog = new Button("Open Log", (ClickListener) event -> {
       Navigator navigator = getUI().getNavigator();
       assert navigator != null;
       navigator.navigateTo(Views.Log.toString());
            
    });*/
    // Add the flowLayout at position 1 (second element) -> centered
    // Add everthing to flowlayout
    GridLayout southLayout = new GridLayout(3, 1);
    southLayout.setWidth("100%");
    southLayout.addComponent(licences, 0, 0);
    // southLayout.addComponent(openLog, 1, 0);
    southLayout.addComponent(copyright, 2, 0);
    // Add southlayout to the main Layout
    addComponent(southLayout);
    setComponentAlignment(southLayout, Alignment.BOTTOM_CENTER);
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.MainUI.java

License:LGPL

public MainUI() {
    // Make the web-app large
    setSizeFull();//from  www  . j a  v  a 2  s .  com
    // Set the layout for the bottom
    // Create a 3rd party licence button with a click listener
    final Button licences = new Button("Show 3rd party licences");
    licences.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 32642854872179636L;

        @Override
        public void buttonClick(ClickEvent event) {
            LogHelper.logInfo("Opened LicenceWindow");
            LicenceWindow licenceWindow = new LicenceWindow();
            licenceWindow.addCloseListener(new CloseListener() {

                private static final long serialVersionUID = 7874342882437355680L;

                @Override
                public void windowClose(CloseEvent e) {
                    event.getButton().setEnabled(true);
                }
            });
            getUI().addWindow(licenceWindow);
            // Disable sender
            event.getButton().setEnabled(false);
        }

    });
    Label copyright = new HtmlLabel(
            "<i> Reisisoft 2014 - " + new GregorianCalendar().get(Calendar.YEAR) + "</i>");
    Button openLog = new Button("Open Log", (ClickListener) event -> {
        Navigator navigator = getUI().getNavigator();
        assert navigator != null;
        navigator.navigateTo(Views.Log.toString());

    });
    // Add the flowLayout at position 1 (second element) -> centered
    // Add everthing to flowlayout
    GridLayout southLayout = new GridLayout(3, 1);
    southLayout.setWidth("100%");
    southLayout.addComponent(licences, 0, 0);
    southLayout.addComponent(openLog, 1, 0);
    southLayout.addComponent(copyright, 2, 0);
    // Add southlayout to the main Layout
    addComponent(southLayout);
    setComponentAlignment(southLayout, Alignment.BOTTOM_CENTER);
}

From source file:com.cerebro.provevaadin.Equipment.java

public Equipment() {
    GridLayout contentSx = new GridLayout(15, 18);
    contentSx.setId("equip_body");
    contentSx.setHeight("600px");
    contentSx.setWidth("300px");

    FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
    Image helmet = new Image("Helmet", helmetFile);
    helmet.setHeight("100px");
    contentSx.addComponent(helmet, 8, 0);

    sinistra.setContent(contentSx);/*  www  . ja v a 2s .c o m*/
    //        root.setWidth("300px");
    //        root.setHeight("600px");
    //        
    //        FileResource bodyMaleFile = new FileResource(new File(basepath + "body-male.jpg"));
    //        FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
    //        
    //        Image image = new Image("MaleBody", bodyMaleFile);
    //        image.setWidth(root.getWidth(), root.getWidthUnits());
    //        Image helmet = new Image("Helmet", helmetFile);
    //        helmet.setHeight("100px");
    //        
    //        root.addComponent(image, "left: 0px; top: 0px;");
    //        root.addComponent(helmet, "left: 50%; top: 100px");
    //        
    //        sinistra.setContent(root);
    //        
    //        
    //        destra.setContent(rootDx);
    //        
    this.addComponents(sinistra, destra);
}

From source file:com.cms.utils.CommonUtils.java

public static void setBasicAttributeLayout(GridLayout gridLayout, String caption, boolean isCollapseable) {
    gridLayout.setWidth("100%");
    gridLayout.setHeight("-1px");
    gridLayout.setImmediate(true);//from www .jav a 2  s  . co  m
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    if (isCollapseable && !DataUtil.isStringNullOrEmpty(caption)) {
        gridLayout.setStyleName("custom-feildset");
        gridLayout.setCaption(MakeURL.makeURLForGrid(caption));
        gridLayout.setCaptionAsHtml(isCollapseable);
    }
}

From source file:com.cms.view.ListStaffDepartment.java

public ListStaffDepartment() {
    super(BundleUtils.getString("caption.title.listDept"), BundleUtils.getString("caption.title.listEmp"));
    mainLayout.setSplitPosition(30, Unit.PERCENTAGE);
    setCompositionRoot(mainLayout);//from w  w w. java2  s. c  o m
    //khoi tao cac thanh phan
    //khoi tao form search
    searchDepartmentForm = new DepartmentSearchPanel();
    //khoi tao table ui
    tblListDepartmentUI = new CommonTableFilterPanel();

    //100316 NgocND6 chuyen quyen quan ly hang hoa
    btnTransferRoleCusts = new Button(TRANSFERROLE);
    btnTransferRoleCusts.setIcon(new ThemeResource("img/transfer_icon.png"));
    //them cac component vao layout
    GridLayout horizontalLayout = new GridLayout(2, 1);
    horizontalLayout.setWidth("-1px");
    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    //btn search
    btnSearchDept = new Button(Constants.BUTTON_SEARCH);
    btnSearchDept.setIcon(new ThemeResource(Constants.ICON.SEARCH));
    horizontalLayout.addComponent(btnSearchDept, 0, 0);
    //btn refresh
    btnRefreshDept = new Button(Constants.BUTTON_REFRESH);
    btnRefreshDept.setIcon(new ThemeResource(Constants.ICON.RESET));
    horizontalLayout.addComponent(btnRefreshDept, 1, 0);
    //add component
    leftLayout.addComponent(searchDepartmentForm);
    leftLayout.addComponent(horizontalLayout);
    leftLayout.addComponent(tblListDepartmentUI);
    leftLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    leftLayout.setMargin(true);

    //===============right==========================
    searchStaffForm = new StaffSearchPanel();
    //khoi tao table ui
    tblListStaffUI = new CommonTableFilterPanel();

    btnAddMapStaffCustomer = new Button(BundleUtils.getString("staff.customer.map"));
    btnAddMapStaffCustomer.setDescription(BundleUtils.getString("staff.customer.map"));
    btnAddMapStaffCustomer.setIcon(new ThemeResource(Constants.ICON.IMPORT));

    btnAssignRole = new Button(BundleUtils.getString("assign.roles.button"));
    btnAssignRole.setIcon(FontAwesome.ANCHOR);
    //them cac component vao layout
    GridLayout horizontalLayout2 = new GridLayout(3, 1);
    horizontalLayout2.setWidth("-1px");
    horizontalLayout2.setMargin(true);
    horizontalLayout2.setSpacing(true);
    //NgocND6 tao layout de add button chuyen quyen cho nhan vien
    GridLayout gridLayout = new GridLayout(3, 1);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.addComponent(btnAssignRole, 0, 0);
    //        gridLayout.addComponent(btnAddMapStaffCustomer, 1, 0);
    gridLayout.addComponent(btnTransferRoleCusts, 2, 0);
    //Tam thoi an nut phan bo lai khach hang
    btnTransferRoleCusts.setVisible(false);
    //btn search emp
    btnSearchEmp = new Button(Constants.BUTTON_SEARCH);
    btnSearchEmp.setIcon(new ThemeResource(Constants.ICON.SEARCH));
    horizontalLayout2.addComponent(btnSearchEmp, 0, 0);
    //btn refresh emp
    btnRefreshEmp = new Button(Constants.BUTTON_REFRESH);
    btnRefreshEmp.setIcon(new ThemeResource(Constants.ICON.RESET));
    horizontalLayout2.addComponent(btnRefreshEmp, 1, 0);
    //

    //add component
    rightLayout.addComponent(searchStaffForm);
    rightLayout.addComponent(horizontalLayout2);
    rightLayout.addComponent(tblListStaffUI);
    rightLayout.setComponentAlignment(horizontalLayout2, Alignment.MIDDLE_CENTER);
    rightLayout.addComponent(gridLayout);
    rightLayout.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER);
    rightLayout.setMargin(true);
    //=============

    this.listDeptAndStaffController = new ListDeptAndStaffController(this);
}

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

License:Open Source License

@Override
public void displayDashboard() {
    mainLayout.removeAllComponents();/*from   w w  w.  ja v  a 2 s .c  o  m*/
    SimpleProject currentProject = CurrentProjectVariables.getProject();
    VerticalLayout projectInfo = new VerticalLayout();
    projectInfo.setStyleName("project-info-layout");
    projectInfo.setWidth("100%");
    projectInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label projectIcon = new Label("<span aria-hidden=\"true\" data-icon=\"&#xe614\"></span>");
    projectIcon.setStyleName("project-icon");
    projectIcon.setContentMode(ContentMode.HTML);
    projectIcon.setWidthUndefined();
    projectInfo.addComponent(projectIcon);

    Label projectName = new Label(StringUtils.trim(currentProject.getName(), 50, true));
    projectName.setWidth("100%");
    projectName.setStyleName("project-name");
    projectInfo.addComponent(projectName);

    GridLayout projectModulesList = new GridLayout(2, 3);
    projectModulesList.setStyleName("project-modules-layout");
    projectModulesList.setWidth("100%");
    projectModulesList.setSpacing(true);
    projectModulesList.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MESSAGE), "&#xf04f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MILESTONE), "&#xf075;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK), "&#xe60f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG), "&#xf188;"));

    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_FILE), "&#xf017;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_RISK), "&#xf02d;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_PROBLEM), "&#xf0d2;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_TIME), "&#xe612;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_STANDAUP), "&#xf0c0;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_USERS), "&#xe601;"), 0, 2,
            1, 2);

    mainLayout.addComponent(projectInfo);
    mainLayout.addComponent(projectModulesList);
}

From source file:com.esofthead.mycollab.module.crm.ui.components.PeopleInfoComp.java

License:Open Source License

public void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(new MarginInfo(true, false, true, true));

    Label peopleInfoHeader = new Label(
            FontAwesome.USER.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE),
            ContentMode.HTML);//from w ww.jav  a  2  s . co  m
    peopleInfoHeader.setStyleName("info-hdr");
    this.addComponent(peopleInfoHeader);

    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, false, true));
    try {
        Label createdLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE));
        createdLbl.setSizeUndefined();
        layout.addComponent(createdLbl, 0, 0);

        String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser");
        String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId");
        String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName");

        UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName);
        layout.addComponent(createdUserLink, 1, 0);
        layout.setColumnExpandRatio(1, 1.0f);

        Label assigneeLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE));
        assigneeLbl.setSizeUndefined();
        layout.addComponent(assigneeLbl, 0, 1);
        String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser");
        String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId");
        String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName");

        UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName);
        layout.addComponent(assignUserLink, 1, 1);
    } catch (Exception e) {
        LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean));
    }

    this.addComponent(layout);

}

From source file:com.esofthead.mycollab.module.crm.view.CrmToolbar.java

License:Open Source License

public CrmToolbar() {
    super();//from  w  ww .  j a  v a 2  s. c  om
    this.setStyleName("crm-toolbar");
    this.setWidth("100%");
    this.setMargin(new MarginInfo(false, true, false, true));
    final NavigatorItemListener listener = new NavigatorItemListener();
    final Button homeBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DASHBOARD_HEADER),
            listener);
    homeBtn.setStyleName("link");
    addComponent(homeBtn);

    final Button accountList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACCOUNTS_HEADER),
            listener);
    accountList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_ACCOUNT));
    accountList.setStyleName("link");
    addComponent(accountList);

    final Button contactList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CONTACTS_HEADER),
            listener);
    contactList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CONTACT));
    contactList.setStyleName("link");
    addComponent(contactList);

    final Button campaignList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CAMPAIGNS_HEADER),
            listener);
    campaignList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CAMPAIGN));
    campaignList.setStyleName("link");
    addComponent(campaignList);

    final Button leadList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_LEADS_HEADER), listener);
    leadList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_LEAD));
    leadList.setStyleName("link");
    addComponent(leadList);

    final Button opportunityList = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_OPPORTUNTIES_HEADER), listener);
    opportunityList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_OPPORTUNITY));
    opportunityList.setStyleName("link");
    addComponent(opportunityList);

    final Button caseList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CASES_HEADER), listener);
    caseList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CASE));
    caseList.setStyleName("link");
    addComponent(caseList);

    final Button activitiesList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACTIVITIES_HEADER),
            listener);
    final boolean isActivityEnable = AppContext.canRead(RolePermissionCollections.CRM_MEETING)
            || AppContext.canRead(RolePermissionCollections.CRM_TASK)
            || AppContext.canRead(RolePermissionCollections.CRM_CALL);
    activitiesList.setEnabled(isActivityEnable);
    activitiesList.setStyleName("link");
    addComponent(activitiesList);

    addStyleName("h-sidebar-menu");

    final Button fileBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DOCUMENT_HEADER),
            listener);
    fileBtn.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_DOCUMENT));
    fileBtn.setStyleName("link");
    addComponent(fileBtn);

    final Button notificationBtn = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CRMNOTIFICATION_HEADER), listener);
    notificationBtn.setStyleName("link");
    addComponent(notificationBtn);

    addBtn = new PopupButton(AppContext.getMessage(CrmCommonI18nEnum.BUTTON_CREATE));
    final GridLayout addBtnLayout = new GridLayout(3, 2);
    addBtnLayout.setMargin(true);
    addBtnLayout.setWidth("370px");
    addBtnLayout.setSpacing(true);

    final ButtonLink newAccountBtn = new ButtonLink(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT),
            listener, false);
    newAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT));
    newAccountBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
    addBtnLayout.addComponent(newAccountBtn);

    final ButtonLink newContactBtn = new ButtonLink(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT),
            listener, false);
    newContactBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    newContactBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
    addBtnLayout.addComponent(newContactBtn);

    final ButtonLink newCampaignBtn = new ButtonLink(
            AppContext.getMessage(CampaignI18nEnum.BUTTON_NEW_CAMPAIGN), listener, false);
    newCampaignBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN));
    newCampaignBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN));
    addBtnLayout.addComponent(newCampaignBtn);

    final ButtonLink newOpportunityBtn = new ButtonLink(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), listener, false);
    newOpportunityBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    newOpportunityBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
    addBtnLayout.addComponent(newOpportunityBtn);

    final ButtonLink newLeadBtn = new ButtonLink(AppContext.getMessage(LeadI18nEnum.BUTTON_NEW_LEAD), listener,
            false);
    newLeadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD));
    newLeadBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));
    addBtnLayout.addComponent(newLeadBtn);

    final ButtonLink newCaseBtn = new ButtonLink(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE), listener,
            false);
    newCaseBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    newCaseBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CASE));
    addBtnLayout.addComponent(newCaseBtn);

    final ButtonLink newTaskBtn = new ButtonLink(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), listener,
            false);
    newTaskBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK));
    newTaskBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK));
    addBtnLayout.addComponent(newTaskBtn);

    final ButtonLink newCallBtn = new ButtonLink(AppContext.getMessage(CallI18nEnum.BUTTON_NEW_CALL), listener,
            false);
    newCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));
    newCallBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL));
    addBtnLayout.addComponent(newCallBtn);

    final ButtonLink newMeetingBtn = new ButtonLink(AppContext.getMessage(MeetingI18nEnum.BUTTON_NEW_MEETING),
            listener, false);
    newMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
    newMeetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));
    addBtnLayout.addComponent(newMeetingBtn);

    addBtn.setContent(addBtnLayout);
    addBtn.setStyleName("link");
    addBtn.addStyleName("quickadd-btn");
    addComponent(addBtn);

    setExpandRatio(addBtn, 1.0f);
    setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
}

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

License:Open Source License

private ComponentContainer constructMilestoneBox(final SimpleMilestone milestone) {
    final CssLayout layout = new CssLayout();
    layout.addStyleName(UIConstants.MILESTONE_BOX);
    layout.setWidth("100%");

    final LabelLink milestoneLink = new LabelLink(milestone.getName(),
            ProjectLinkBuilder.generateMilestonePreviewFullLink(milestone.getProjectid(), milestone.getId()));
    milestoneLink.setStyleName("link");
    milestoneLink.addStyleName("bold");
    milestoneLink.addStyleName(UIConstants.WORD_WRAP);
    milestoneLink.addStyleName("milestone-name");
    milestoneLink.setWidth("100%");

    MHorizontalLayout milestoneHeader = new MHorizontalLayout().withWidth("100%").with(milestoneLink)
            .expand(milestoneLink);/*from ww w .  j  ava2 s. c om*/

    PopupButton taskSettingPopupBtn = new PopupButton();
    taskSettingPopupBtn.setWidth("20px");
    MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("100px");

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

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoEdit(MilestoneListViewImpl.this, milestone));
                }
            });
    editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    editButton.setStyleName("link");
    filterBtnLayout.addComponent(editButton);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            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()) {
                                        MilestoneService projectTaskService = ApplicationContextUtil
                                                .getSpringBean(MilestoneService.class);
                                        projectTaskService.removeWithSession(milestone.getId(),
                                                AppContext.getUsername(), AppContext.getAccountId());
                                        milestones.remove(milestone);
                                        displayMilestones(milestones);
                                    }
                                }
                            });
                }
            });
    deleteBtn.setStyleName("link");
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES));
    filterBtnLayout.addComponent(deleteBtn);

    taskSettingPopupBtn.setIcon(FontAwesome.COG);
    taskSettingPopupBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    taskSettingPopupBtn.setContent(filterBtnLayout);

    milestoneHeader.addComponent(taskSettingPopupBtn);
    layout.addComponent(milestoneHeader);

    MHorizontalLayout spacing = new MHorizontalLayout().withHeight("8px").withWidth("100%");
    layout.addComponent(spacing);

    final GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 5, "100%", "80px");
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getStartdate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_START_DATE_FIELD), 0, 0, Alignment.MIDDLE_LEFT);
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getEnddate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_END_DATE_FIELD), 0, 1, Alignment.MIDDLE_LEFT);

    CssLayout linkWrapper = new CssLayout();
    linkWrapper.setWidth("100%");
    linkWrapper.addComponent(new ProjectUserLink(milestone.getOwner(), milestone.getOwnerAvatarId(),
            milestone.getOwnerFullName(), false, true));
    layoutHelper.addComponent(linkWrapper, AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 2,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressTask = new ProgressBarIndicator(milestone.getNumTasks(),
            milestone.getNumOpenTasks());
    progressTask.setWidth("100%");

    layoutHelper.addComponent(progressTask, AppContext.getMessage(MilestoneI18nEnum.FORM_TASK_FIELD), 0, 3,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressBug = new ProgressBarIndicator(milestone.getNumBugs(),
            milestone.getNumOpenBugs());
    progressBug.setWidth("100%");

    layoutHelper.addComponent(progressBug, AppContext.getMessage(MilestoneI18nEnum.FORM_BUG_FIELD), 0, 4,
            Alignment.MIDDLE_LEFT);
    final GridLayout milestoneInfoLayout = layoutHelper.getLayout();
    milestoneInfoLayout.setWidth("100%");
    milestoneInfoLayout.setMargin(false);
    milestoneInfoLayout.setSpacing(true);
    layout.addComponent(milestoneInfoLayout);

    return layout;
}

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

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);//from www  . jav a 2s.  c  o  m
    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();
    tokenFieldMailTo.setRequired(true);

    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")) {
                        tokenFieldMailTo.addToken(mail);
                    }
                } else {
                    tokenFieldMailTo.addToken(mail);
                }
            }
        }
    }

    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.getSession().getEmail() != null && AppContext.getSession().getEmail().length() > 0) {
                ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class);

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

                systemMailService.sendHTMLMail(AppContext.getSession().getEmail(),
                        AppContext.getSession().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.setStyleName(UIConstants.THEME_GREEN_LINK);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
}