Example usage for com.vaadin.ui CssLayout setSizeFull

List of usage examples for com.vaadin.ui CssLayout setSizeFull

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

@SuppressWarnings("serial")
private void initUI() {

    final VerticalLayout root = new VerticalLayout();
    root.setMargin(false);/*from   ww w . j  ava2 s .  co m*/
    setContent(root);

    // createTopBar();
    // Changed with menuBar -- under testing
    createMenuBar();
    // Changed with custom layout using bootstrap -- under testing
    // createHeaderMenu();

    final UserFolder<File> userFolder = new UserFolder<File>();
    final long polling = 20000;
    int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //Buttons
    final NativeButton inboxInvoices = new NativeButton("Invoices (" + inboxInvoicesNum + ")");
    final NativeButton outboxInvoices = new NativeButton("Invoices (" + outboxInvoicesNum + ")");
    final NativeButton draftInvoices = new NativeButton("Invoices (" + draftInvoicesNum + ")");

    //thread
    final Thread tFolderCount = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                while (true) {
                    int countDrafts = um.countItemsInSpace(um.getDrafts());
                    int countInbox = um.countItemsInSpace(um.getInbox());
                    int countOutbox = um.countItemsInSpace(um.getOutbox());
                    synchronized (MainWindow.this.getApplication()) {
                        String labelD = draftInvoices.getCaption();
                        labelD = labelD.replaceFirst("[\\d]+", "" + countDrafts);
                        draftInvoices.setCaption(labelD);

                        String labelI = inboxInvoices.getCaption();
                        labelI = labelI.replaceFirst("[\\d]+", "" + countInbox);
                        inboxInvoices.setCaption(labelI);

                        String labelO = outboxInvoices.getCaption();
                        labelO = labelO.replaceFirst("[\\d]+", "" + countOutbox);
                        outboxInvoices.setCaption(labelO);

                        itemsPanel.reloadTable(userFolder);
                    }
                    Thread.sleep(polling);
                }
            } catch (InterruptedException e) {
                System.out.println("Thread folders interrupted!!!");
            }
        }
    });

    // ------ START: Left NavBar -------
    final CssLayout leftNavBar = new CssLayout();
    leftNavBar.setStyleName("sidebar-menu");
    leftNavBar.setSizeFull();
    leftNavBar.setWidth("220px");

    // User theUser = (User) getApplication().getUser();
    final Label homeLbl = new Label("HOME");
    homeLbl.addStyleName("blue");
    leftNavBar.addComponent(homeLbl);

    leftNavBar.addComponent(new Label("INBOX"));
    final NativeButton catalogueBtn = new NativeButton("Catalogue");
    leftNavBar.addComponent(catalogueBtn);
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    //inboxInvoices = new NativeButton ("Invoices ("+inboxInvoicesNum+")");
    inboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            inboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getInbox()) + ")");
            userFolder.setFolder(um.getInbox().getFolder());
            userFolder.setName(um.getInbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(inboxInvoices);

    leftNavBar.addComponent(new Label("DRAFTS"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    //draftInvoices = new NativeButton ("Invoices ("+draftInvoicesNum+")");
    draftInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            draftInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getDrafts()) + ")");
            userFolder.setFolder(um.getDrafts().getFolder());
            userFolder.setName(um.getDrafts().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(draftInvoices);

    leftNavBar.addComponent(new Label("OUTBOX"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //outboxInvoices = new NativeButton ("Invoices ("+outboxInvoicesNum+")");
    outboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            outboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getOutbox()) + ")");
            userFolder.setFolder(um.getOutbox().getFolder());
            userFolder.setName(um.getOutbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(outboxInvoices);

    leftNavBar.addComponent(new Label("SETTINGS"));
    leftNavBar.addComponent(new NativeButton("My Profile"));
    leftNavBar.addComponent(new NativeButton("Customers"));
    leftNavBar.addComponent(new NativeButton("Suppliers"));

    final Embedded peppolLogoImg = new Embedded(null, new ExternalResource("img/peppol_logo.png"));

    peppolLogoImg.setStyleName("logo");
    leftNavBar.addComponent(peppolLogoImg);

    middleContentLayout.addComponent(leftNavBar);

    /*Button refreshButton = new Button("Refresh");
    refreshButton.addListener(new Button.ClickListener() {
      @Override
      public void buttonClick(ClickEvent event) {
         int draftInvoices = um.countItemsInSpace(um.getDrafts());
         invoices.setCaption("Invoices ("+draftInvoices+")");
      }
    });
    leftNavBar.addComponent(refreshButton);*/

    //workaround so that thread refreshes UI. It seems that when a ProgressIndicator is present,
    //all components receive server side refreshes
    ProgressIndicator p = new ProgressIndicator();
    p.setPollingInterval((int) polling);
    p.setWidth("0px");
    p.setHeight("0px");
    leftNavBar.addComponent(p);

    showInitialMainContent(null);
    draftInvoices.click();
    tFolderCount.start();
    draftInvoices.addStyleName("v-bold-nativebuttoncaption");
}

From source file:by.bigvova.MainUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    EventBus.register(this);
    getPage().setTitle("FoodNote");
    UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU"));
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override/* w ww .j a v  a2 s  . c  o m*/
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    sideBar.setHeader(new CssLayout() {
        {
            Label header = new Label("<span>Food</span>Note", ContentMode.HTML);
            header.setWidth(100, Unit.PERCENTAGE);
            header.setHeightUndefined();
            addComponent(header);
            addComponent(buildUserMenu());
        }
    });
    sideBar.getHeader().setStyleName("branding");
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());

    setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}

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

License:Open Source License

private ComponentContainer createBody() {
    final CssLayout layout = new CssLayout();
    layout.setSizeFull();

    Label shortDescription = new Label(
            "<p>&nbsp;&nbsp;&nbsp;By clicking the \"Convert\" button, the following tasks will be done:</p>",
            ContentMode.HTML);/*from  w ww  .j  ava 2s . com*/
    layout.addComponent(shortDescription);

    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setMargin(new MarginInfo(false, true, true, true));
    infoLayout.setSpacing(true);

    String createAccountTxt = "Create Account: <span class='" + UIConstants.TEXT_BLUE + "'>"
            + lead.getAccountname() + "</span>";
    Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML);
    createAccountLbl.addStyleName(UIConstants.LABEL_CHECKED);
    infoLayout.addComponent(createAccountLbl);

    String createContactTxt = "Create Contact: <span class='" + UIConstants.TEXT_BLUE + "'>"
            + lead.getLastname() + (lead.getFirstname() != null ? " " + lead.getFirstname() : "") + "</span>";
    Label createContactLbl = new Label(createContactTxt, ContentMode.HTML);
    createContactLbl.addStyleName(UIConstants.LABEL_CHECKED);
    infoLayout.addComponent(createContactLbl);

    final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account");
    isCreateOpportunityChk.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean isSelected = isCreateOpportunityChk.getValue();
            if (isSelected) {
                opportunityForm = new LeadOpportunityForm();
                Opportunity opportunity = new Opportunity();

                // this is a trick to pass validation
                opportunity.setAccountid(0);
                opportunityForm.setBean(opportunity);
                layout.addComponent(opportunityForm);
            } else {
                layout.removeComponent(opportunityForm);
            }

        }
    });

    infoLayout.addComponent(isCreateOpportunityChk);

    layout.addComponent(infoLayout);
    return layout;
}

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

License:Open Source License

public static Component constructAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }//from w  ww.  j a  v a 2 s. c o m

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Image thumbnail = new Image(null);
    if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setSource(DEFAULT_SOURCE);
    } else {
        thumbnail.setSource(VaadinResourceManager.getResourceManager()
                .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE));
    }
    thumbnail.setDescription(docName);
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = -2853211588120500523L;

            @Override
            public void click(MouseEvents.ClickEvent event) {
                Resource previewResource = VaadinResourceManager.getResourceManager()
                        .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE);
                UI.getCurrent().addWindow(new AttachmentPreviewWindow(previewResource));
            }
        });
    }

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, 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.CONFIRM_DELETE_ATTACHMENT),
                    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()) {
                                ResourceService attachmentService = ApplicationContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceManager.getResourceManager().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    return attachmentLayout;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java

License:Open Source License

public void addAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/*from  ww  w.  j  a v a  2  s .c o m*/

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Link thumbnail = new Link();
    if (StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    } else {
        thumbnail.setIcon(VaadinResourceFactory.getInstance().getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getInstance().getResource(attachment.getPath()));
        new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true);
    }

    Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold"));
    Ul ul = new Ul()
            .appendChild(new Li().appendText("Size: " + FileUtils.getVolumeDisplay(attachment.getSize())))
            .setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(
            "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime())));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write());
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, 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, AppContext.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                    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()) {
                                ResourceService attachmentService = AppContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}

From source file:com.klwork.explorer.ui.custom.DetailPanel.java

License:Apache License

public DetailPanel() {
    setSizeFull();//from  www .  j  a  va 2  s  .co m
    addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL);
    setMargin(true);

    CssLayout cssLayout = new CssLayout(); // Needed for rounded corners,
    cssLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL);
    cssLayout.setSizeFull();
    super.addComponent(cssLayout);

    mainPanel = new Panel();
    mainPanel.addStyleName(Reindeer.PANEL_LIGHT);
    mainPanel.setSizeFull();
    cssLayout.addComponent(mainPanel);

    // Use default layout
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setWidth(100, Unit.PERCENTAGE);
    verticalLayout.setMargin(true);
    mainPanel.setContent(verticalLayout);
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.MainScreen.java

License:Apache License

public MainScreen(MyUI ui) {

    setStyleName("main-screen");

    CssLayout viewContainer = new CssLayout();
    viewContainer.addStyleName("valo-content");
    viewContainer.setSizeFull();

    final Navigator navigator = new Navigator(ui, viewContainer);
    navigator.setErrorView(ErrorView.class);
    menu = new Menu(navigator);
    menu.addView(new SampleCrudView(), SampleCrudView.VIEW_NAME, SampleCrudView.VIEW_NAME, FontAwesome.EDIT);
    menu.addView(new AboutView(), AboutView.VIEW_NAME, AboutView.VIEW_NAME, FontAwesome.INFO_CIRCLE);

    navigator.addViewChangeListener(viewChangeListener);

    addComponent(menu);/*from ww  w  . j  av  a 2 s  .  c  o m*/
    addComponent(viewContainer);
    setExpandRatio(viewContainer, 1);
    setSizeFull();
}

From source file:com.mycollab.mobile.ui.AttachmentPreviewView.java

License:Open Source License

public AttachmentPreviewView() {
    CssLayout imgWrap = new CssLayout();
    imgWrap.setStyleName("image-wrap");
    imgWrap.setSizeFull();

    this.setStyleName("attachment-preview-view");
    this.setSizeFull();
    this.addComponent(imgWrap, "top: 0px left: 0px; z-index: 0;");

    backBtn = new NavigationButton(UserUIContext.getMessage(GenericI18Enum.M_BUTTON_BACK));
    backBtn.setStyleName("back-btn");

    this.addComponent(backBtn, "top: 15px; left: 15px; z-index: 1;");

    previewImage = new Image();
    imgWrap.addComponent(previewImage);/* ww w.j  ava2s  .  c o  m*/
}

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

License:Open Source License

private ComponentContainer createBody() {
    final CssLayout layout = new CssLayout();
    layout.setSizeFull();

    Label shortDescription = ELabel.html(
            "<p>&nbsp;&nbsp;&nbsp;By clicking the \"Convert\" button, the following tasks will be done:</p>");
    layout.addComponent(shortDescription);

    MVerticalLayout infoLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));

    String createAccountTxt = FontAwesome.CHECK.getHtml() + " Create Account: " + lead.getAccountname();
    Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML);
    infoLayout.addComponent(createAccountLbl);

    String createContactTxt = FontAwesome.CHECK.getHtml() + " Create Contact: " + lead.getLastname()
            + (lead.getFirstname() != null ? " " + lead.getFirstname() : "");
    Label createContactLbl = new Label(createContactTxt, ContentMode.HTML);
    infoLayout.addComponent(createContactLbl);

    final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account");
    isCreateOpportunityChk.addValueChangeListener(valueChangeEvent -> {
        Boolean isSelected = isCreateOpportunityChk.getValue();
        if (isSelected) {
            opportunityForm = new LeadOpportunityForm();
            Opportunity opportunity = new Opportunity();

            // this is a trick to pass validation
            opportunity.setAccountid(0);
            opportunityForm.setBean(opportunity);
            layout.addComponent(opportunityForm);
        } else {/*  w  w  w.  ja  va2  s .  c  o  m*/
            layout.removeComponent(opportunityForm);
        }
    });

    infoLayout.addComponent(isCreateOpportunityChk);
    layout.addComponent(infoLayout);
    return layout;
}

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

License:Open Source License

private void constructBody() {
    MVerticalLayout contentLayout = new MVerticalLayout();
    new Restrain(contentLayout).setMaxHeight("600px");
    this.setContent(contentLayout);

    folderTree = new Tree();
    folderTree.setMultiSelect(false);// w  w  w. j ava  2  s .  c om
    folderTree.setSelectable(true);
    folderTree.setImmediate(true);
    folderTree.setSizeFull();

    folderTree.addExpandListener(expandEvent -> {
        final Folder expandFolder = (Folder) expandEvent.getItemId();
        // load externalResource if currentExpandFolder is rootFolder
        if (baseFolder.getPath().equals(expandFolder.getPath())) {
            List<ExternalDrive> externalDrives = externalDriveService
                    .getExternalDrivesOfUser(UserUIContext.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);
                folderTree.addItem(externalMapFolder);
                folderTree.setItemIcon(externalMapFolder, FontAwesome.DROPBOX);
                folderTree.setItemCaption(externalMapFolder, externalMapFolder.getName());
                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);
                folderTree.addItem(subFolder);
                folderTree.setItemIcon(subFolder, FontAwesome.DROPBOX);
                folderTree.setItemCaption(subFolder, subFolder.getName());
                folderTree.setParent(subFolder, expandFolder);
            }
        } else {
            final List<Folder> subFolders = resourceService.getSubFolders(expandFolder.getPath());
            folderTree.setItemIcon(expandFolder, FontAwesome.FOLDER_OPEN);

            if (subFolders != null) {
                for (final Folder subFolder : subFolders) {
                    String subFolderName = subFolder.getName();
                    if (!subFolderName.startsWith(".")) {
                        expandFolder.addChild(subFolder);
                        folderTree.addItem(subFolder);
                        folderTree.setItemIcon(subFolder, FontAwesome.FOLDER);
                        folderTree.setItemCaption(subFolder, subFolderName);
                        folderTree.setParent(subFolder, expandFolder);
                    }
                }
            }
        }
    });

    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) {
                folderTree.setItemIcon(collapseFolder, FontAwesome.DROPBOX);
            } else {
                folderTree.setItemIcon(collapseFolder, FontAwesome.FOLDER);
            }
            collapseFolder.getChilds().forEach(this::recursiveRemoveSubItem);
        }

        private void recursiveRemoveSubItem(Folder collapseFolder) {
            List<Folder> childFolders = collapseFolder.getChilds();
            if (childFolders.size() > 0) {
                childFolders.forEach(this::recursiveRemoveSubItem);
                folderTree.removeItem(collapseFolder);
            } else {
                folderTree.removeItem(collapseFolder);
            }
        }
    });

    folderTree.addItemClickListener(itemClickEvent -> baseFolder = (Folder) itemClickEvent.getItemId());

    CssLayout treeWrapper = new CssLayout(folderTree);
    treeWrapper.setSizeFull();
    contentLayout.addComponent(treeWrapper);
    displayFiles();

    MButton moveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_MOVE), clickEvent -> {
        if (!CollectionUtils.isEmpty(movedResources)) {
            boolean checkingFail = false;
            for (Resource res : movedResources) {
                try {
                    resourceMover.moveResource(res, baseFolder, UserUIContext.getUsername(),
                            MyCollabUI.getAccountId());
                } catch (Exception e) {
                    checkingFail = true;
                    LOG.error("Error", e);
                }
            }
            close();
            displayAfterMoveSuccess(baseFolder, checkingFail);
        }
    }).withIcon(FontAwesome.ARROWS).withStyleName(WebThemes.BUTTON_ACTION);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MHorizontalLayout controlGroupBtnLayout = new MHorizontalLayout(cancelBtn, moveBtn);
    contentLayout.with(controlGroupBtnLayout).withAlign(controlGroupBtnLayout, Alignment.MIDDLE_RIGHT);
}