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.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java

License:Apache License

public ProductForm(SampleCrudLogic sampleCrudLogic) {
    viewLogic = sampleCrudLogic;/*  w ww . j  av a  2  s. c om*/
    addStyleName("product-form-wrapper");
    setId("product-form");
    productName.setWidth("100%");

    price.setConverter(new EuroConverter());

    stockCount.setWidth("80px");

    availability.setNullSelectionAllowed(false);
    availability.setTextInputAllowed(false);
    for (Availability s : Availability.values()) {
        availability.addItem(s);
    }

    category.setWidth("100%");

    saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    cancelButton.addStyleName("cancel");
    removeButton.addStyleName(ValoTheme.BUTTON_DANGER);

    VerticalLayout layout = new VerticalLayout();
    layout.setHeight("100%");
    layout.setSpacing(true);
    layout.addStyleName("form-layout");

    HorizontalLayout priceAndStock = new HorizontalLayout(price, stockCount);
    priceAndStock.setSpacing(true);
    priceAndStock.setWidth("100%");
    price.setWidth("100%");
    stockCount.setWidth("100%");
    availability.setWidth("100%");

    layout.addComponent(productName);
    layout.addComponent(priceAndStock);
    layout.addComponent(availability);
    layout.addComponent(category);

    CssLayout expander = new CssLayout();
    expander.addStyleName("expander");
    layout.addComponent(expander);
    layout.setExpandRatio(expander, 1);

    layout.addComponent(saveButton);
    layout.addComponent(cancelButton);
    layout.addComponent(removeButton);

    addComponent(layout);

    fieldGroup = new BeanFieldGroup<Product>(Product.class);
    fieldGroup.bindMemberFields(this);

    // perform validation and enable/disable buttons while editing
    ValueChangeListener valueListener = new ValueChangeListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            formHasChanged();
        }
    };
    for (Field<?> f : fieldGroup.getFields()) {
        f.addValueChangeListener(valueListener);
    }

    fieldGroup.addCommitHandler(new CommitHandler() {

        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void preCommit(CommitEvent commitEvent) throws CommitException {
        }

        @Override
        public void postCommit(CommitEvent commitEvent) throws CommitException {
            DataService.get().updateProduct(fieldGroup.getItemDataSource().getBean());
        }
    });

    saveButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                fieldGroup.commit();

                // only if validation succeeds
                Product product = fieldGroup.getItemDataSource().getBean();
                viewLogic.saveProduct(product);
            } catch (CommitException e) {
                Notification n = new Notification("Please re-check the fields", Type.ERROR_MESSAGE);
                n.setDelayMsec(500);
                n.show(getUI().getPage());
            }
        }
    });

    cancelButton.setClickShortcut(KeyCode.ESCAPE);
    cancelButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            viewLogic.cancelProduct();
        }
    });

    removeButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Product product = fieldGroup.getItemDataSource().getBean();
            viewLogic.deleteProduct(product);
        }
    });
}

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();/*w  w w.j a v a2s. co  m*/

    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);
    addComponent(viewContainer);
    setExpandRatio(viewContainer, 1);
    setSizeFull();
}

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

License:Apache License

public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);//from w ww  .  j  a  v a2  s .c o m
    Label title = new Label("My CRUD");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() {

        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            VaadinSession.getCurrent().getSession().invalidate();
            Page.getCurrent().reload();
        }
    });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button("Menu", new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:com.mycollab.mobile.module.project.ui.ProjectCommentInputView.java

License:Open Source License

private void prepareUploadField() {
    statusWrapper = new CssLayout();
    statusWrapper.setWidth("100%");
    statusWrapper.setStyleName("upload-status-wrap");
    receiver = createReceiver();/* ww  w. j ava2s . co  m*/

    uploadField = new MultiUpload();
    uploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.BUTTON_UPLOAD));
    uploadField.setImmediate(true);
    uploadField.setHandler(new MobileUploadHandler());
}

From source file:com.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java

License:Open Source License

private void displayItem() {
    mainLayout.removeAllComponents();//from  w  w  w  . j  a v a 2s  .  c  o m
    MHorizontalLayout messageBlock = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(bean.getPostedUserAvatarId(), 32);
    userAvatarImg.addStyleName(UIConstants.CIRCLE_BOX);
    messageBlock.addComponent(userAvatarImg);

    CssLayout rightCol = new CssLayout();
    rightCol.setWidth("100%");

    MHorizontalLayout metadataRow = new MHorizontalLayout().withFullWidth();

    ELabel userNameLbl = new ELabel(bean.getFullPostedUserName()).withStyleName(UIConstants.META_INFO);
    userNameLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    CssLayout userNameWrap = new CssLayout(userNameLbl);

    ELabel messageTimePost = new ELabel().prettyDateTime(bean.getPosteddate())
            .withStyleName(UIConstants.META_INFO).withWidthUndefined();
    metadataRow.with(userNameWrap, messageTimePost).withAlign(messageTimePost, Alignment.TOP_RIGHT)
            .expand(userNameWrap);

    rightCol.addComponent(metadataRow);

    CssLayout titleRow = new CssLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(bean.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(StringUtils.trimHtmlTags(bean.getMessage()));
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService.getContents(AttachmentUtils.getProjectEntityAttachmentPath(
            MyCollabUI.getAccountId(), bean.getProjectid(), ProjectTypeConstants.MESSAGE, "" + bean.getId()));
    if (CollectionUtils.isNotEmpty(attachments)) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

        for (Content attachment : attachments) {
            attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment));
        }
        rightCol.addComponent(attachmentPanel);
    }

    messageBlock.with(rightCol).expand(rightCol);
    mainLayout.addComponent(messageBlock);

    Label commentTitleLbl = new Label();
    Component section = FormSectionBuilder.build(FontAwesome.COMMENT, commentTitleLbl);
    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(ProjectTypeConstants.MESSAGE,
            bean.getId() + "", bean.getProjectid(), true);
    int numComments = commentDisplay.getNumComments();
    commentTitleLbl.setValue(UserUIContext.getMessage(GenericI18Enum.OPT_COMMENTS_VALUE, numComments));

    mainLayout.addComponent(section);
    mainLayout.addComponent(commentDisplay);
    this.setToolbar(commentDisplay.getCommentBox());
}

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

License:Open Source License

public ProjectDashboardViewImpl() {
    super();/*from w  w w  .j a  v  a2s  .c  om*/
    this.setCaption(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_DASHBOARD));
    this.setRightComponent(buildRightComponent());
    mainLayout = new CssLayout();
    mainLayout.setSizeFull();
    mainLayout.setStyleName("project-dashboard");
    this.setContent(mainLayout);
}

From source file:com.mycollab.mobile.module.user.view.LoginViewImpl.java

License:Open Source License

private void initUI() {
    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null,
            AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150));
    contentLayout.addComponent(mainLogo);

    CssLayout welcomeTextWrapper = new CssLayout();
    ELabel welcomeText = new ELabel(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN))
                    .withStyleName("h1");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeText);

    final EmailField emailField = new EmailField();
    new Dom(emailField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL));
    emailField.setWidth("100%");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    new Dom(pwdField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.FORM_PASSWORD));
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD),
            true);//from   ww w.  j a  va 2 s .  c  o m
    rememberPassword.setWidth("100%");
    contentLayout.addComponent(rememberPassword);

    MButton signInBtn = new MButton(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN),
            clickEvent -> {
                try {
                    LoginViewImpl.this.fireEvent(new ViewEvent<>(LoginViewImpl.this, new UserEvent.PlainLogin(
                            emailField.getValue(), pwdField.getValue(), rememberPassword.getValue())));
                } catch (Exception e) {
                    throw new MyCollabException(e);
                }
            }).withStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(signInBtn);

    this.addComponent(contentLayout);
}

From source file:com.mycollab.mobile.shell.view.MainView.java

License:Open Source License

public MainView() {
    super();//from ww w .jav a 2 s.c  o  m
    this.setSizeFull();

    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    welcomeTextWrapper.setHeight("15px");
    contentLayout.addComponent(welcomeTextWrapper);

    Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)));
    crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    crmButton.setWidth("100%");

    contentLayout.addComponent(crmButton);

    Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)));
    pmButton.setWidth("100%");
    pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(pmButton);

    this.addComponent(contentLayout);
}

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

License:Open Source License

public void previewItem(final B item) {
    this.beanItem = item;

    CssLayout content = new CssLayout();
    content.addComponent(new MHorizontalLayout(ELabel.h2(initFormHeader())).withMargin(true)
            .withStyleName("border-bottom").withFullWidth());
    content.addComponent(previewForm);// w w w  .  j a va2 s.  c  o m

    ComponentContainer buttonControls = createButtonControls();
    if (buttonControls instanceof VerticalLayout) {
        NavigationBarQuickMenu editBtn = new NavigationBarQuickMenu();
        editBtn.setContent(buttonControls);
        this.setRightComponent(editBtn);
    } else if (buttonControls instanceof HorizontalLayout) {
        if (StringUtils.isNotBlank(getType()) && !SiteConfiguration.isCommunityEdition()) {
            favoriteBtn = new MButton("", clickEvent -> toggleFavorite()).withIcon(FontAwesome.HEART)
                    .withStyleName(UIConstants.CIRCLE_BOX);
            ((HorizontalLayout) buttonControls).addComponent(favoriteBtn, 0);
        }
        this.setRightComponent(buttonControls);
    } else {
        throw new MyCollabException("Not support controls " + buttonControls);
    }

    if (favoriteBtn != null) {
        if (isFavorite()) {
            favoriteBtn.addStyleName("favorite-btn-selected");
        } else {
            favoriteBtn.addStyleName("favorite-btn");
        }
    }

    initRelatedComponents();

    ComponentContainer toolbarContent = createBottomPanel();
    if (toolbarContent != null) {
        content.addComponent(toolbarContent);
    }
    this.setContent(content);

    previewForm.setFormLayoutFactory(initFormLayoutFactory());
    previewForm.setBeanFormFieldFactory(initBeanFormFieldFactory());
}

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();//from   w  ww. j av  a  2  s .c o  m

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