Example usage for com.vaadin.ui CssLayout CssLayout

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

Introduction

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

Prototype

public CssLayout() 

Source Link

Document

Constructs an empty CssLayout.

Usage

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

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);//  www .java 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();

    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")) {

                    }
                } else {

                }
            }
        }
    }

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

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

                systemMailService.sendHTMLMail(AppContext.getUser().getEmail(),
                        AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                        tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                        subject.getValue(), noteArea.getValue(), emailAttachmentSource);
                MailFormWindow.this.close();
            } else {
                NotificationUtil.showErrorNotification(
                        "Your email is empty value, please fulfil it before sending email!");
            }
        }
    });
    sendBtn.setIcon(FontAwesome.SEND);
    sendBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
}

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

License:Open Source License

private Component buildComponentFromNotification(AbstractNotification item) {
    final MHorizontalLayout wrapper = new MHorizontalLayout();
    wrapper.setData(item);// ww w  .  j  a va2 s  .  co  m
    wrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    if (item instanceof NewUpdateAvailableNotification) {
        final NewUpdateAvailableNotification notification = (NewUpdateAvailableNotification) item;
        Span spanEl = new Span();
        spanEl.appendText(
                AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, notification.getVersion()));
        Label lbl = new Label(FontAwesome.INFO_CIRCLE.getHtml() + " " + spanEl.write(), ContentMode.HTML);
        lbl.setWidth("100%");
        CssLayout lblWrapper = new CssLayout();
        lblWrapper.addComponent(lbl);
        wrapper.addComponent(lblWrapper);
        wrapper.expand(lblWrapper);
        if (AppContext.isAdmin()) {
            Button upgradeBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            UI.getCurrent().addWindow(new UpgradeConfirmWindow(notification.getVersion(),
                                    notification.getManualDownloadLink(), notification.getInstallerFile()));
                            NotificationComponent.this.setPopupVisible(false);
                        }
                    });
            upgradeBtn.addStyleName(UIConstants.BUTTON_BLOCK);
            wrapper.addComponent(upgradeBtn);
        }
    } else if (item instanceof RequestUploadAvatarNotification) {
        wrapper.addComponent(new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " "
                + AppContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPLOAD_AVATAR), ContentMode.HTML));
        Button uploadAvatarBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPLOAD_AVATAR),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                        NotificationComponent.this.setPopupVisible(false);
                    }
                });
        uploadAvatarBtn.setStyleName(UIConstants.BUTTON_BLOCK);
        wrapper.add(uploadAvatarBtn);
    } else if (item instanceof SmtpSetupNotification) {
        Button smtpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_SETUP),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" }));
                        NotificationComponent.this.setPopupVisible(false);
                    }
                });
        smtpBtn.setStyleName(UIConstants.BUTTON_BLOCK);
        Label lbl = new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " "
                + AppContext.getMessage(ShellI18nEnum.ERROR_NO_SMTP_SETTING), ContentMode.HTML);
        MCssLayout lblWrapper = new MCssLayout(lbl);
        wrapper.with(lblWrapper, smtpBtn).expand(lblWrapper);
    } else {
        LOG.error("Do not render notification " + item);
    }
    return wrapper;
}

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

License:Open Source License

public void addOption(Button btn) {
    CssLayout wrap = new CssLayout();
    btn.setWidth("100%");
    btn.setDescription(btn.getCaption());
    btn.addStyleName("action");
    wrap.addStyleName("action-wrap");
    wrap.addComponent(btn);//from   w  w w .  j a v a  2  s  . c o  m
    ((ComponentContainer) this.getCompositionRoot()).addComponent(wrap);
}

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

License:Open Source License

public void addDangerOption(Component btn) {
    CssLayout wrap = new CssLayout();
    btn.setWidth("100%");
    btn.addStyleName("action");
    wrap.addStyleName("action-wrap danger");
    wrap.addComponent(btn);//from  w ww .  j  a v a 2  s .  c  o  m
    ((ComponentContainer) this.getCompositionRoot()).addComponent(wrap);
}

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

License:Open Source License

public RightSidebarLayout() {
    this.setStyleName("rightsidebar-layout");
    this.setWidth("100%");

    contentWrap = new CssLayout();
    contentWrap.setStyleName("content-wrap");
    contentWrap.setWidth("100%");
    this.addComponent(contentWrap);

    sidebarWrap = new CssLayout();
    sidebarWrap.setStyleName("sidebar-wrap");
    sidebarWrap.setWidth("250px");
    this.addComponent(sidebarWrap);
}

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

License:Open Source License

public VerticalTabsheet(boolean isLeft) {
    CssLayout contentLayout = new CssLayout();
    new Restrain(contentLayout).setMinHeight("100%");

    navigatorWrapper = new CssLayout();
    navigatorWrapper.setStyleName("navigator-wrap");
    navigatorContainer = new VerticalLayout();
    navigatorWrapper.addComponent(navigatorContainer);

    contentWrapper = new VerticalLayout();
    contentWrapper.setStyleName("container-wrap");
    contentWrapper.setWidth("100%");

    tabContainer = new CssLayout();
    tabContainer.setWidth("100%");
    contentWrapper.addComponent(tabContainer);

    if (isLeft) {
        contentLayout.addComponent(navigatorWrapper);
        contentLayout.addComponent(contentWrapper);

    } else {//  ww  w .  ja v a2s . co m
        contentLayout.addComponent(contentWrapper);
        contentLayout.addComponent(navigatorWrapper);
    }

    this.setCompositionRoot(contentLayout);
    this.setStyleName(TABSHEET_STYLENAME);
}

From source file:com.etest.valo.ComboBoxes.java

License:Apache License

public ComboBoxes() {
    setMargin(true);/*www  .  j  av a  2  s .c om*/

    Label h1 = new Label("Combo Boxes");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    ComboBox combo = new ComboBox("Normal");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png"));
    row.addComponent(combo);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName("v-component-group");
    row.addComponent(group);

    combo = new ComboBox();
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.setWidth("240px");
    group.addComponent(combo);
    Button today = new Button("Do It");
    group.addComponent(today);

    combo = new ComboBox("Explicit size");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setWidth("260px");
    combo.setHeight("60px");
    row.addComponent(combo);

    combo = new ComboBox("No text input allowed");
    combo.setInputPrompt("You can click here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setTextInputAllowed(false);
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    row.addComponent(combo);

    combo = new ComboBox("Error");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(combo);

    combo = new ComboBox("Error, borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Disabled");
    combo.setInputPrompt("You can't type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setEnabled(false);
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("color1");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("color2");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("color3");
    row.addComponent(combo);

    combo = new ComboBox("Small");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("small");
    row.addComponent(combo);

    combo = new ComboBox("Large");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("large");
    row.addComponent(combo);

    combo = new ComboBox("Borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Tiny");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("tiny");
    row.addComponent(combo);

    combo = new ComboBox("Huge");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(MainUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    combo.addStyleName("huge");
    row.addComponent(combo);
}

From source file:com.etest.valo.CommonParts.java

License:Apache License

Panel loadingIndicators() {
    Panel p = new Panel("Loading Indicator");
    final VerticalLayout content = new VerticalLayout();
    p.setContent(content);//  ww w  .j a  v a2s  . com
    content.setSpacing(true);
    content.setMargin(true);
    content.addComponent(new Label("You can test the loading indicator by pressing the buttons."));

    CssLayout group = new CssLayout();
    group.setCaption("Show the loading indicator for");
    group.addStyleName("v-component-group");
    content.addComponent(group);
    Button loading = new Button("0.8");
    loading.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(loading);

    Button delay = new Button("3");
    delay.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(delay);

    Button wait = new Button("15");
    wait.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
            }
        }
    });
    wait.addStyleName("last");
    group.addComponent(wait);
    Label label = new Label("&nbsp;&nbsp; seconds", ContentMode.HTML);
    label.setSizeUndefined();
    group.addComponent(label);

    Label spinnerDesc = new Label(
            "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added.");
    spinnerDesc.addStyleName("small");
    spinnerDesc.setCaption("Spinner");
    content.addComponent(spinnerDesc);

    if (!MainUI.isTestMode()) {
        final Label spinner = new Label();
        spinner.addStyleName("spinner");

        Button showSpinnerButton = new Button("Show spinner", new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                content.replaceComponent(event.getComponent(), spinner);
            }
        });
        content.addComponent(showSpinnerButton);
    }

    return p;
}

From source file:com.github.mjvesa.herd.HerdIDE.java

License:Apache License

private Component constructFileNameAndSaveButton() {

    CssLayout cl = new CssLayout();
    fileName = createFileName();/*w w w . j  ava  2  s.c o  m*/
    cl.addComponent(fileName);
    cl.addComponent(createSaveFileButton());
    return cl;
}

From source file:com.github.moscaville.contactsdb.ValoSideBarUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    super.init(vaadinRequest);
    CssLayout header = new CssLayout();

    MenuBar menuBar = new MenuBar();
    header.addComponent(menuBar);/*from w  w  w .j  av a  2 s.c om*/

    MenuBar.MenuItem settingsItem = menuBar.addItem("", FontAwesome.WRENCH, null);

    sideBar.setHeader(header);
    //categories = categoryController.loadItems(100, 0, new CategoryRecord());
    //representatives = representativeController.loadItems(100, 0, new RepresentativeRecord());
}