Example usage for com.vaadin.ui HorizontalLayout HorizontalLayout

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

Introduction

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

Prototype

public HorizontalLayout() 

Source Link

Document

Constructs an empty HorizontalLayout.

Usage

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

License:Open Source License

private ComponentContainer createButtonControls() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);// w w  w .j av a  2 s. co m
    layout.setStyleName("addNewControl");

    Button convertButton = new Button(AppContext.getMessage(LeadI18nEnum.BUTTON_CONVERT_LEAD),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class);
                    lead.setStatus("Converted");
                    leadService.updateWithSession(lead, AppContext.getUsername());
                    Opportunity opportunity = null;
                    if (opportunityForm != null && opportunityForm.isVisible()) {
                        if (opportunityForm.validateForm()) {
                            opportunity = opportunityForm.getBean();
                        }
                    }

                    leadService.convertLead(lead, opportunity, AppContext.getUsername());
                    LeadConvertInfoWindow.this.close();
                    EventBusFactory.getInstance()
                            .post(new LeadEvent.GotoRead(LeadConvertInfoWindow.this, lead.getId()));
                }
            });
    convertButton.setStyleName(UIConstants.THEME_GREEN_LINK);
    layout.addComponent(convertButton);
    layout.setComponentAlignment(convertButton, Alignment.MIDDLE_CENTER);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    LeadConvertInfoWindow.this.close();

                }
            });
    cancelButton.setStyleName(UIConstants.THEME_GRAY_LINK);
    layout.addComponent(cancelButton);
    layout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    return layout;
}

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

License:Open Source License

public LeadListNoItemView() {

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("case-noitem");
    layout.setWidth("800px");
    layout.setSpacing(true);/*from ww w  .j a v a 2 s .  c o  m*/
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    layout.setMargin(true);

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

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

    Label body = new Label(AppContext.getMessage(LeadI18nEnum.VIEW_NO_ITEM_HINT));
    body.setWidthUndefined();
    layout.addComponent(body);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            EventBusFactory.getInstance().post(new LeadEvent.GotoAdd(this, null));
        }
    });

    HorizontalLayout links = new HorizontalLayout();

    links.addComponent(btCreateContact);
    btCreateContact.addStyleName(UIConstants.THEME_GREEN_LINK);

    /*
     * Label or = new Label("Or"); or.setStyleName("h2");
     * links.addComponent(or);
     * 
     * Button btImportContact = new Button("Import Leads", new
     * Button.ClickListener() { private static final long serialVersionUID =
     * 1L;
     * 
     * @Override public void buttonClick(ClickEvent arg0) {
     * UI.getCurrent().addWindow(new CaseImportWindow()); } });
     * 
     * btImportContact.addStyleName(UIConstants.THEME_GRAY_LINK);
     * 
     * 
     * links.addComponent(btImportContact);
     */
    links.setSpacing(true);

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

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

License:Open Source License

@Override
public void display(SimpleOpportunity opportunity) {
    this.opportunity = opportunity;
    this.removeAllComponents();
    this.setMargin(new MarginInfo(false, true, true, true));
    this.addStyleName("oppcontact-role-edit");

    AddViewLayout2 previewLayout = new AddViewLayout2("Add or Edit Contact Roles",
            CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
    this.addComponent(previewLayout);

    ComponentContainer actionControls = createButtonControls();
    if (actionControls != null) {
        previewLayout.addControlButtons(actionControls);
    }/*from w  w  w.  j  av  a2  s  .  c  o m*/

    contactRoleList = new ContactOpportunityList();
    previewLayout.addBody(contactRoleList);

    Button addMoreContactRolesBtn = new Button("Add more contact roles", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            SimpleContactOpportunityRel contactRole = new SimpleContactOpportunityRel();
            ContactRoleRowComp row = new ContactRoleRowComp(contactRole);
            contactRoleList.addRow(row);
        }
    });
    addMoreContactRolesBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    HorizontalLayout buttonControls = new HorizontalLayout();
    buttonControls.addComponent(addMoreContactRolesBtn);
    buttonControls.setMargin(new MarginInfo(true, true, true, true));

    previewLayout.addBody(buttonControls);
}

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

License:Open Source License

private ComponentContainer createButtonControls() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from   w  w  w  .j  a  va 2 s  . c o  m*/
    layout.setMargin(true);

    HorizontalLayout buttonWrapper = new HorizontalLayout();
    buttonWrapper.setWidthUndefined();
    buttonWrapper.setSpacing(true);

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

        @Override
        public void buttonClick(ClickEvent event) {
            updateContactRoles();
        }
    });
    updateBtn.setIcon(FontAwesome.SAVE);
    updateBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    buttonWrapper.addComponent(updateBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    ViewState viewState = HistoryViewManager.back();

                    if (viewState instanceof NullViewState) {
                        EventBusFactory.getInstance().post(new ContactEvent.GotoList(this, null));
                    }

                }
            });
    cancelBtn.setIcon(FontAwesome.TIMES);
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonWrapper.addComponent(cancelBtn);

    layout.addComponent(buttonWrapper);
    layout.setComponentAlignment(buttonWrapper, Alignment.MIDDLE_CENTER);

    return layout;
}

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

License:Open Source License

@Override
protected Component generateTopControls() {
    HorizontalLayout controlsBtnWrap = new HorizontalLayout();
    controlsBtnWrap.setWidth("100%");

    HorizontalLayout notesWrap = new HorizontalLayout();
    notesWrap.setWidth("100%");
    notesWrap.setSpacing(true);//from   ww w  . jav a  2s . c  o m
    Label noteLbl = new Label("Note: ");
    noteLbl.setSizeUndefined();
    noteLbl.setStyleName("list-note-lbl");
    notesWrap.addComponent(noteLbl);

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (int i = 0; i < CrmDataTypeFactory.getOpportunityContactRoleList().length; i++) {
        Label note = new Label(CrmDataTypeFactory.getOpportunityContactRoleList()[i]);
        note.setStyleName("note-label");
        note.addStyleName(colormap.get(CrmDataTypeFactory.getOpportunityContactRoleList()[i]));
        note.setSizeUndefined();

        noteBlock.addComponent(note);
    }
    notesWrap.addComponent(noteBlock);
    notesWrap.setExpandRatio(noteBlock, 1.0f);

    controlsBtnWrap.addComponent(notesWrap);

    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption("Add/Edit Contacts' Role");
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            EventBusFactory.getInstance().post(new OpportunityEvent.GotoContactRoleEdit(this, opportunity));
        }
    });
    final Button selectBtn = new Button("Select from existing contacts", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final OpportunityContactSelectionWindow contactsWindow = new OpportunityContactSelectionWindow(
                    OpportunityContactListComp.this);
            final ContactSearchCriteria criteria = new ContactSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(contactsWindow);
            contactsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");
    VerticalLayout buttonControlLayout = new VerticalLayout();
    buttonControlLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlLayout);

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

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

License:Open Source License

public OpportunityListNoItemView() {

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("case-noitem");
    layout.setWidth("800px");
    layout.setSpacing(true);/*from  w  w  w. j a  v a  2  s .  c  om*/
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    layout.setMargin(true);

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

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

    Label body = new Label(AppContext.getMessage(OpportunityI18nEnum.VIEW_NO_ITEM_HINT));
    body.setWidthUndefined();
    layout.addComponent(body);

    Button btCreateContact = new Button(AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new OpportunityEvent.GotoAdd(this, null));
                }
            });

    HorizontalLayout links = new HorizontalLayout();

    links.addComponent(btCreateContact);
    btCreateContact.addStyleName(UIConstants.THEME_GREEN_LINK);

    /*
     * Label or = new Label("Or"); or.setStyleName("h2");
     * links.addComponent(or);
     * 
     * Button btImportContact = new Button("Import Leads", new
     * Button.ClickListener() { private static final long serialVersionUID =
     * 1L;
     * 
     * @Override public void buttonClick(ClickEvent arg0) {
     * UI.getCurrent().addWindow(new CaseImportWindow()); } });
     * 
     * btImportContact.addStyleName(UIConstants.THEME_GRAY_LINK);
     * 
     * 
     * links.addComponent(btImportContact);
     */
    links.setSpacing(true);

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

From source file:com.esofthead.mycollab.module.file.view.components.AbstractResourceMovingWindow.java

License:Open Source License

private void constructBody() {
    MVerticalLayout contentLayout = new MVerticalLayout().withSpacing(true).withMargin(true);
    this.setContent(contentLayout);

    final HorizontalLayout resourceContainer = new HorizontalLayout();
    resourceContainer.setSizeFull();/*from   ww  w .ja  v a 2  s  . c o  m*/

    this.folderTree = new TreeTable();
    this.folderTree.setMultiSelect(false);
    this.folderTree.setSelectable(true);
    this.folderTree.setImmediate(true);
    this.folderTree.addContainerProperty("Name", String.class, "");
    this.folderTree.addContainerProperty("Date Modified", String.class, "");
    this.folderTree.setColumnWidth("Date Modified", UIConstants.TABLE_DATE_TIME_WIDTH);
    this.folderTree.setColumnExpandRatio("Name", 1.0f);
    this.folderTree.setWidth("100%");

    resourceContainer.addComponent(this.folderTree);

    this.folderTree.addExpandListener(new Tree.ExpandListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void nodeExpand(final ExpandEvent event) {
            final Folder expandFolder = (Folder) event.getItemId();
            // load externalResource if currentExpandFolder is
            // rootFolder
            if (rootPath.equals(expandFolder.getPath())) {
                List<ExternalDrive> externalDrives = externalDriveService
                        .getExternalDrivesOfUser(AppContext.getUsername());
                for (ExternalDrive externalDrive : externalDrives) {
                    ExternalFolder externalMapFolder = new ExternalFolder("/");
                    externalMapFolder.setStorageName(externalDrive.getStoragename());
                    externalMapFolder.setExternalDrive(externalDrive);
                    externalMapFolder.setName(externalDrive.getFoldername());

                    Calendar cal = GregorianCalendar.getInstance();
                    cal.setTime(externalDrive.getCreatedtime());

                    externalMapFolder.setCreated(cal);
                    expandFolder.addChild(externalMapFolder);

                    AbstractResourceMovingWindow.this.folderTree
                            .addItem(
                                    new Object[] { externalMapFolder.getName(),
                                            AppContext
                                                    .formatDateTime(externalMapFolder.getCreated().getTime()) },
                                    externalMapFolder);

                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(externalMapFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox.png"));
                    AbstractResourceMovingWindow.this.folderTree.setItemCaption(externalMapFolder,
                            externalMapFolder.getName());
                    AbstractResourceMovingWindow.this.folderTree.setParent(externalMapFolder, expandFolder);
                }
            }
            if (expandFolder instanceof ExternalFolder) {
                List<ExternalFolder> subFolders = externalResourceService.getSubFolders(
                        ((ExternalFolder) expandFolder).getExternalDrive(), expandFolder.getPath());
                for (final Folder subFolder : subFolders) {
                    expandFolder.addChild(subFolder);
                    Date dateTime = ((ExternalFolder) subFolder).getExternalDrive().getCreatedtime();

                    AbstractResourceMovingWindow.this.folderTree.addItem(
                            new Object[] { subFolder.getName(), AppContext.formatDateTime(dateTime) },
                            subFolder);

                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(subFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox_subfolder.png"));
                    AbstractResourceMovingWindow.this.folderTree.setItemCaption(subFolder, subFolder.getName());
                    AbstractResourceMovingWindow.this.folderTree.setParent(subFolder, expandFolder);
                }
            } else {
                final List<Folder> subFolders = AbstractResourceMovingWindow.this.resourceService
                        .getSubFolders(expandFolder.getPath());

                AbstractResourceMovingWindow.this.folderTree.setItemIcon(expandFolder,
                        MyCollabResource.newResource("icons/16/ecm/folder_open.png"));

                if (subFolders != null) {
                    for (final Folder subFolder : subFolders) {
                        expandFolder.addChild(subFolder);
                        AbstractResourceMovingWindow.this.folderTree.addItem(
                                new Object[] { subFolder.getName(),
                                        AppContext.formatDateTime(subFolder.getCreated().getTime()) },
                                subFolder);

                        AbstractResourceMovingWindow.this.folderTree.setItemIcon(subFolder,
                                MyCollabResource.newResource("icons/16/ecm/folder_close.png"));
                        AbstractResourceMovingWindow.this.folderTree.setItemCaption(subFolder,
                                subFolder.getName());
                        AbstractResourceMovingWindow.this.folderTree.setParent(subFolder, expandFolder);
                    }
                }
            }
        }
    });

    this.folderTree.addCollapseListener(new Tree.CollapseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void nodeCollapse(final CollapseEvent event) {
            final Folder collapseFolder = (Folder) event.getItemId();
            if (collapseFolder instanceof ExternalFolder) {
                if (collapseFolder.getPath().equals("/"))
                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox.png"));
                else
                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox_subfolder.png"));
            } else {
                AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                        MyCollabResource.newResource("icons/16/ecm/folder_close.png"));
            }
            for (Folder folder : collapseFolder.getChilds()) {
                recursiveRemoveSubItem(folder);
            }
        }

        private void recursiveRemoveSubItem(Folder collapseFolder) {
            List<Folder> childs = collapseFolder.getChilds();
            if (childs.size() > 0) {
                for (final Folder subFolder : childs) {
                    recursiveRemoveSubItem(subFolder);
                }
                AbstractResourceMovingWindow.this.folderTree.removeItem(collapseFolder);
            } else {
                AbstractResourceMovingWindow.this.folderTree.removeItem(collapseFolder);
            }
        }
    });

    this.folderTree.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(final ItemClickEvent event) {
            AbstractResourceMovingWindow.this.baseFolder = (Folder) event.getItemId();
        }
    });

    contentLayout.addComponent(resourceContainer);
    displayFiles();

    HorizontalLayout controlGroupBtnLayout = new HorizontalLayout();
    controlGroupBtnLayout.setSpacing(true);

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

        @Override
        public void buttonClick(ClickEvent event) {
            if (resourceEditting != null) {
                try {
                    resourceMover.moveResource(resourceEditting, baseFolder, AppContext.getUsername(),
                            AppContext.getAccountId());

                    displayAfterMoveSuccess(AbstractResourceMovingWindow.this.baseFolder, false);
                } finally {
                    AbstractResourceMovingWindow.this.close();
                }
            } else if (!CollectionUtils.isEmpty(lstResEditting)) {
                boolean checkingFail = false;
                for (Resource res : lstResEditting) {
                    try {
                        resourceMover.moveResource(res, baseFolder, AppContext.getUsername(),
                                AppContext.getAccountId());
                    } catch (Exception e) {
                        checkingFail = true;
                    }
                }
                AbstractResourceMovingWindow.this.close();
                displayAfterMoveSuccess(AbstractResourceMovingWindow.this.baseFolder, checkingFail);
            }
        }

    });
    moveBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlGroupBtnLayout.addComponent(moveBtn);
    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            AbstractResourceMovingWindow.this.close();
        }
    });
    cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    controlGroupBtnLayout.addComponent(cancelBtn);

    contentLayout.with(controlGroupBtnLayout).withAlign(controlGroupBtnLayout, Alignment.MIDDLE_CENTER);
}

From source file:com.esofthead.mycollab.module.file.view.components.FileDashboardComponent.java

License:Open Source License

public HorizontalLayout constructHeader() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setSpacing(true);/*from w w  w. ja va 2s.com*/
    layout.setMargin(true);

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

    final Label searchtitle = new Label("Files");
    searchtitle.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(searchtitle);
    layout.setComponentAlignment(searchtitle, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(searchtitle, 1.0f);
    return layout;
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);/*  w  ww.j a v a2s.  co  m*/
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

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

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.esofthead.mycollab.module.project.ui.components.AbstractPreviewItemComp2.java

License:Open Source License

public AbstractPreviewItemComp2(String headerText, Resource iconResource) {
    if (iconResource != null)
        this.titleIcon = new Image(null, iconResource);
    this.addComponent(constructHeader(headerText));

    previewForm = initPreviewForm();/*from   w  ww.ja  v  a2 s  .  c o m*/
    ComponentContainer actionControls = createButtonControls();
    if (actionControls != null) {
        actionControls.addStyleName("control-buttons");
        addHeaderRightContent(actionControls);
    }

    CssLayout contentWrapper = new CssLayout();
    contentWrapper.setStyleName("content-wrapper");

    previewLayout = new ReadViewLayout("");

    contentWrapper.addComponent(previewLayout);

    bodyContainer = new HorizontalLayout();
    bodyContainer.setSizeFull();
    bodyContainer.setStyleName("readview-body-wrap");

    bodyContent = new VerticalLayout();
    bodyContent.addComponent(previewForm);
    bodyContainer.addComponent(bodyContent);
    bodyContainer.setExpandRatio(bodyContent, 1);

    sidebarContent = new VerticalLayout();
    sidebarContent.setWidth("250px");
    sidebarContent.setSpacing(true);
    sidebarContent.setStyleName("readview-sidebar");
    bodyContainer.addComponent(sidebarContent);

    FloatingComponent floatSidebar = FloatingComponent.floatThis(sidebarContent);
    floatSidebar.setContainerId("main-body");

    previewLayout.addBody(bodyContainer);

    this.addComponent(contentWrapper);
}