Example usage for com.vaadin.ui CssLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile/*from  www .j a va 2 s .  com*/
 */
protected void buildInformationPanel(AudioFile audioFile) {
    if (bottom == null) {
        this.bottom = new HorizontalLayout();
        bottom.setWidth("100%");
        content.addComponent(bottom);

        VerticalLayout side = new VerticalLayout();
        side.setMargin(true);
        side.setSpacing(true);
        side.setWidth("170px");
        bottom.addComponent(side);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createPlayImage(audioFile, audioFile.getCover()));
        side.addComponent(musicFile);

        side.addComponent(setFavorite());
        side.addComponent(setRate());

        Component details = addDetails(audioFile);
        bottom.addComponent(details);
        bottom.setExpandRatio(details, 1);

    } else {
        bottom.removeAllComponents();
        content.removeComponent(bottom);
        this.bottom = null;
        buildInformationPanel(audioFile);
    }

}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java

License:Apache License

public ProductForm(SampleCrudLogic sampleCrudLogic) {
    viewLogic = sampleCrudLogic;/*from   www  .  java  2s  .  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  av  a  2  s .  c o  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.mycollab.module.project.view.settings.ComponentListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");

    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);/*from   ww w .j  a v a 2s  . c o  m*/

    this.selectOptionButton = new SelectionOptionButton(tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.settings.ProjectRoleListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);/*  w  w w  .  java 2s  . c  o  m*/

    selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.ROLES)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(this.tableActionControls, this.selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_LEFT);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.settings.VersionListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);/*from   w w  w.j  a  v  a2s.co m*/

    this.selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java

License:Open Source License

@Override
protected void doSearch() {
    totalCount = projectActivityStreamService.getTotalActivityStream(
            ((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest).getSearchCriteria());
    totalPage = (totalCount - 1) / searchRequest.getNumberOfItems() + 1;
    if (searchRequest.getCurrentPage() > totalPage) {
        searchRequest.setCurrentPage(totalPage);
    }/*from w  ww .j a va 2  s.com*/

    if (totalPage > 1) {
        if (controlBarWrapper != null) {
            removeComponent(controlBarWrapper);
        }
        this.addComponent(createPageControls());
    } else {
        if (getComponentCount() == 2) {
            removeComponent(getComponent(1));
        }
    }

    List<ProjectActivityStream> currentListData = projectActivityStreamService
            .getProjectActivityStreams((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest);
    this.listContainer.removeAllComponents();
    Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();

    CssLayout currentFeedBlock = new CssLayout();
    AuditLogRegistry auditLogRegistry = AppContextUtil.getSpringBean(AuditLogRegistry.class);

    try {
        for (ProjectActivityStream activityStream : currentListData) {
            if (ProjectTypeConstants.PAGE.equals(activityStream.getType())) {
                ProjectPageService pageService = AppContextUtil.getSpringBean(ProjectPageService.class);
                Page page = pageService.getPage(activityStream.getTypeid(), UserUIContext.getUsername());
                if (page != null) {
                    activityStream.setNamefield(page.getSubject());
                }
            }

            Date itemCreatedDate = activityStream.getCreatedtime();

            if (!DateUtils.isSameDay(currentDate, itemCreatedDate)) {
                currentFeedBlock = new CssLayout();
                currentFeedBlock.setStyleName("feed-block");
                feedBlocksPut(currentDate, itemCreatedDate, currentFeedBlock);
                currentDate = itemCreatedDate;
            }
            StringBuilder content = new StringBuilder();
            String itemType = ProjectLocalizationTypeMap.getType(activityStream.getType());
            String assigneeParam = buildAssigneeValue(activityStream);
            String itemParam = buildItemValue(activityStream);

            if (ActivityStreamConstants.ACTION_CREATE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_CREATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
            } else if (ActivityStreamConstants.ACTION_UPDATE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_UPDATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append(auditLogRegistry.generatorDetailChangeOfActivity(activityStream));
                }
            } else if (ActivityStreamConstants.ACTION_COMMENT.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_COMMENT_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append("<p><ul><li>\"").append(
                            StringUtils.trimHtmlTags(activityStream.getAssoAuditLog().getChangeset(), 200))
                            .append("\"</li></ul></p>");
                }
            } else if (ActivityStreamConstants.ACTION_DELETE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_DELETE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
            }
            Label actionLbl = new Label(content.toString(), ContentMode.HTML);
            CssLayout streamWrapper = new CssLayout();
            streamWrapper.setWidth("100%");
            streamWrapper.addStyleName("stream-wrapper");
            streamWrapper.addComponent(actionLbl);
            currentFeedBlock.addComponent(streamWrapper);
        }
    } catch (Exception e) {
        throw new MyCollabException(e);
    }
}

From source file:com.mycollab.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legendBoxContent");
    mainLayout.setSizeUndefined();//ww w .j ava 2  s . co m
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true))
                .withStyleName("inline-block").withWidthUndefined();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final ELabel lblCircle = ELabel.html(color);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", UserUIContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        MButton btnLink = new MButton(StringUtils.trim(btnCaption, 25, true), clickEvent -> {
            if (key instanceof Key) {
                clickLegendItem(((Key) key).getKey());
            } else {
                clickLegendItem(key.toString());
            }
        }).withStyleName(WebThemes.BUTTON_LINK).withDescription(btnCaption);

        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.bodyeditor.BodyEditorViewImpl.java

License:Open Source License

private Layout createToolbarFormattingElements() {
    CssLayout wrapper = new CssLayout();
    wrapper.addStyleName("toolbar-elements");
    wrapper.addStyleName("toolbar-formatting");

    for (int i = 0; i < 4; i++) {
        Button addButton = new Button(null, new Button.ClickListener() {
            @Override/*from  w  ww .  j a va  2  s  .  c om*/
            public void buttonClick(Button.ClickEvent event) {
                notImplemented();
            }
        });
        addButton.setStyleName("toolbar-formatting-button");
        ThemeResource tableResource = new ThemeResource("img/placeholder.png");
        addButton.setIcon(tableResource);

        wrapper.addComponent(addButton);
    }

    return wrapper;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.bodyeditor.BodyEditorViewImpl.java

License:Open Source License

private Layout createToolbarContentElements() {
    ThemeResource placeHolder = new ThemeResource("img/placeholder.png");
    CssLayout wrapper = new CssLayout();
    wrapper.addStyleName("toolbar-elements");
    Button addTableButton = new Button("table", new Button.ClickListener() {
        @Override/*w ww  .  j a  v a2 s .  c o m*/
        public void buttonClick(Button.ClickEvent event) {
            notImplemented();
        }
    });
    addTableButton.setStyleName("ax-shape-button");
    ThemeResource tableResource = new ThemeResource("img/table.png");
    addTableButton.setIcon(tableResource);

    wrapper.addComponent(addTableButton);

    Button addRuleButton = new Button("rule", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            notImplemented();
        }
    });
    addRuleButton.setStyleName("ax-shape-button");
    addRuleButton.setIcon(placeHolder);

    wrapper.addComponent(addRuleButton);

    Button addParagraphButton = new Button("section", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            listener.createSection("Section");
        }
    });
    addParagraphButton.setStyleName("ax-shape-button");
    ThemeResource sectionResource = new ThemeResource("img/section_sign.gif");
    addParagraphButton.setIcon(sectionResource);

    wrapper.addComponent(addParagraphButton);

    Button addPullQuoteButton = new Button("pullquote", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            notImplemented();
        }
    });
    addPullQuoteButton.setStyleName("ax-shape-button");
    addPullQuoteButton.setIcon(placeHolder);

    wrapper.addComponent(addPullQuoteButton);
    return wrapper;
}