Example usage for com.vaadin.ui CssLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:org.vaadin.spring.samples.navigation.NavigationUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();/*from   w  w  w  .j  a  v  a2  s.  c o  m*/
    root.setMargin(true);
    root.setSpacing(true);
    setContent(root);

    final CssLayout navigationBar = new CssLayout();
    navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navigationBar.addComponent(createNavigationButton("Prototype Scoped View", PrototypeScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("UI Scoped View", UIScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("View Scoped View", ViewScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("Access Control", AccessControlView.VIEW_NAME));
    root.addComponent(navigationBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    viewProvider.setAccessDeniedViewClass(AccessDeniedView.class);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.setErrorView(new ErrorView()); // You can still create the error view yourself if you want to.
    navigator.addProvider(viewProvider);
}

From source file:org.vaadin.spring.samples.security.ui.login.views.LoginView.java

License:Apache License

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");

    Label welcome = new Label("Welcome");
    welcome.setSizeUndefined();/*from w w  w .  j a  v  a  2 s  .c  om*/
    welcome.addStyleName(ValoTheme.LABEL_H4);
    welcome.addStyleName(ValoTheme.LABEL_COLORED);
    labels.addComponent(welcome);

    Label title = new Label("Security-Sample");
    title.setSizeUndefined();
    title.addStyleName(ValoTheme.LABEL_H3);
    title.addStyleName(ValoTheme.LABEL_LIGHT);
    labels.addComponent(title);
    return labels;
}

From source file:org.vaadin.spring.samples.sidebar.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);

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

    MenuBar.MenuItem useLargeIconsItem = settingsItem.addItem("Use large icons", new MenuBar.Command() {
        @Override// ww w.  ja  v a 2s.com
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            sideBar.setLargeIcons(selectedItem.isChecked());
        }
    });
    useLargeIconsItem.setCheckable(true);

    MenuBar.MenuItem showLogoItem = settingsItem.addItem("Show logo", new MenuBar.Command() {

        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                showLogo();
            } else {
                hideLogo();
            }
        }
    });
    showLogoItem.setCheckable(true);

    sideBar.setHeader(header);
}

From source file:org.vaadin.spring.sidebar.components.ValoSideBar.java

License:Apache License

@Override
protected CssLayout createCompositionRoot() {
    CssLayout layout = new CssLayout();
    layout.addStyleName(ValoTheme.MENU_PART);
    if (largeIcons) {
        layout.addStyleName(ValoTheme.MENU_PART_LARGE_ICONS);
    }/*from ww w. j  a  v a 2 s. com*/
    layout.setWidth(null);
    layout.setHeight("100%");
    if (logo != null) {
        layout.addComponent(logo);
    }
    if (headerLayout != null) {
        layout.addComponent(headerLayout);
    }
    return layout;
}

From source file:org.vaadin.tori.component.DebugControlPanel.java

License:Apache License

private Component createPostControl(final Method setter, final List<Post> posts) throws Exception {
    if (posts == null || posts.isEmpty()) {
        final Label label = new Label(getNameForCheckBox(setter));
        label.setEnabled(false);/*w ww .j  a va 2 s  .co  m*/
        return label;
    }

    Component content = new CustomComponent() {
        {
            final CssLayout root = new CssLayout();
            root.addStyleName("postselect-content");
            root.addStyleName(setter.getName());
            setCompositionRoot(root);
            root.setWidth("100%");
            setWidth("400px");

            root.addComponent(new Label(setter.getName()));

            for (final Post post : posts) {
                final Method getter = getGetterFrom(setter);
                final boolean getterValue = (Boolean) getter.invoke(authorizationService, post.getId());

                final String authorName = post.getAuthor().getDisplayedName();

                String postBody = post.getBodyRaw();
                if (postBody.length() > 20) {
                    postBody = postBody.substring(0, 20);
                }

                final CheckBox checkbox = new CheckBox(authorName + " :: " + postBody);
                checkbox.setValue(getterValue);
                checkbox.addValueChangeListener(new PostCheckboxListener(post, setter));
                checkbox.setImmediate(true);
                checkbox.setWidth("100%");
                root.addComponent(checkbox);
            }
        }
    };
    final PopupView popup = new PopupView(getNameForCheckBox(setter), content);
    popup.setHideOnMouseOut(false);
    popup.setHeight(30.0f, Unit.PIXELS);
    return popup;
}

From source file:org.vaadin.tori.component.RecentBar.java

License:Apache License

public RecentBar() {
    if (messaging != null) {
        messaging.addUserAuthoredListener(this);
        ToriUI.getCurrent().addDetachListener(new DetachListener() {
            @Override/*from   w  w  w  . j  a  v a2 s  .  c  om*/
            public void detach(final DetachEvent event) {
                messaging.removeUserAuthoredListener(RecentBar.this);
            }
        });
    }

    addStyleName("recentbar");
    setWidth(100.0f, Unit.PERCENTAGE);
    setHeight(35.0f, Unit.PIXELS);

    CssLayout layout = new CssLayout();
    layout.setSizeFull();
    setCompositionRoot(layout);

    HorizontalLayout barLayout = new HorizontalLayout();
    barLayout.setMargin(new MarginInfo(false, true, false, true));
    barLayout.setSizeFull();
    addTitleLabel(barLayout);
    addNotificationsLayout(barLayout);
    addRecentLink(barLayout);
    if (dataSource.isLoggedInUser()) {
        addMyPostsLink(barLayout);
    }
    layout.addComponent(barLayout);

    floatingComponent.extend(floatingNotification);
    layout.addComponent(floatingNotification);
    floatingNotification.setId("floatingnotification");

    ToriScheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            refresh();
        }
    });
}

From source file:org.vaadin.tori.view.thread.PostComponent.java

License:Apache License

private void editPost() {
    final CssLayout editorWrapper = new CssLayout();
    editorWrapper.setSizeFull();//  w  w  w . j a  v  a2s  .co m
    ToriScheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            PostEditor postEditor = new PostEditor(post.getRawBody(), post.isFormatBBCode(),
                    PostComponent.this);
            editorWrapper.addComponent(postEditor);
            addStyleName("editing");
        }
    });
    getRpcProxy(PostComponentClientRpc.class).editPost(editorWrapper);
    if (editorComponent != null) {
        removeComponent(editorComponent);
    }
    editorComponent = editorWrapper;
    addComponent(editorComponent);
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

@Override
public void handle(final ActionContext actionContext) throws Exception {

    final UserAction ua = actionContext.getUserAction();
    final OpenGroupsApplication app = actionContext.getApp();

    ComponentContainer targetContainer = actionContext.getTargetContainer();
    targetContainer.removeAllComponents();
    targetContainer.addStyleName(OpenGroupsStyles.LIST_ACTIONS_CONTAINER);

    final Entity entity = actionContext.getEntity();
    /* reset filters */
    entity.resetFilters();/* w  w w. jav  a  2s.  co m*/

    // Panel listContainer = new Panel();
    // ((VerticalLayout)listContainer.getContent()).setMargin(false);

    CssLayout refreshButtonContainer = new CssLayout();
    // refreshButtonContainer.setSizeFull();
    //   refreshButtonContainer.setWidth("100%");
    refreshButtonContainer.addStyleName(OpenGroupsStyles.LIST_REFRESH_BAR);

    // final VerticalLayout listContainer = new VerticalLayout();

    final CssLayout listAndPageControlsContainer = new CssLayout();
    //   final VerticalLayout listAndPageControlsContainer = new VerticalLayout();

    listAndPageControlsContainer.addStyleName("list-container");
    // listAndPageControlsContainer.setSizeFull();
    //   listAndPageControlsContainer.setWidth("100%");

    Button refreshButton = new Button();
    refreshButton.setDescription(getMessage("refresh.list"));
    refreshButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.REFRESH, OpenGroupsIconsSet.MEDIUM));
    refreshButton.addStyleName(BaseTheme.BUTTON_LINK + " middle-right");
    refreshButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            refreshList(entity, ua, app, listAndPageControlsContainer, actionContext);
        }
    });

    targetContainer.addComponent(refreshButtonContainer);
    Component searchFilter = getSearchFilter(entity, ua, app, actionContext);
    searchFilter.addStyleName("middle-left");
    refreshButtonContainer.addComponent(searchFilter);
    refreshButtonContainer.addComponent(refreshButton);

    ComponentContainer filtersContainer = initFilters(entity, ua, app, actionContext);
    targetContainer.addComponent(filtersContainer);

    targetContainer.addComponent(listAndPageControlsContainer);
    int itemsCount = refreshList(entity, ua, app, listAndPageControlsContainer, actionContext);
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

private ComponentContainer initFilters(Entity entity, UserAction ua, OpenGroupsApplication app,
        final ActionContext ac) {

    // VerticalLayout filtersLayoutWithCaption = new VerticalLayout();
    // filtersLayoutWithCaption.setWidth("100%");

    // Label filterLabel = new Label(getMessage("filter") + ":");
    // filtersLayoutWithCaption.addComponent(filterLabel);

    boolean hasFilters = false;
    CssLayout filtersLayout = new CssLayout();
    filtersLayout.addStyleName(OpenGroupsStyles.LIST_FILTERS_BAR);
    //   filtersLayout.setWidth("100%");
    //   filtersLayout.setSpacing(true);

    // filtersLayoutWithCaption.addComponent(filtersLayout);

    String complexType = ua.getTargetEntityComplexType();

    /* add depth filter */
    //   boolean allowRecursiveList = getAppConfigManager().getComplexEntityBooleanParam(
    //      ua.getTargetEntityComplexType(), ComplexEntityParam.ALLOW_RECURSIVE_LIST);
    ApplicationConfigManager appConfigManager = app.getAppConfigManager();
    boolean allowRecursiveList = appConfigManager.getTypeRelationBooleanConfigParam(ua.getTypeRelationId(),
            TypeRelationConfigParam.ALLOW_RECURSIVE_LIST);

    if (allowRecursiveList) {
        ComponentContainer listByDepthFilter = getListByDepthFilter(entity, ua, app, ac);
        listByDepthFilter.addStyleName("middle-left right-margin-10");
        filtersLayout.addComponent(listByDepthFilter);
        hasFilters = true;//from   ww w  .j ava  2 s . c  om
    }

    /* add status filter */
    if (app.getCurrentUser() != null
            && appConfigManager.getComplexEntityBooleanParam(complexType, ComplexEntityParam.ALLOW_STATUS)) {
        ComponentContainer statusFilter = getStatusFilter(entity, ua, app, ac);
        statusFilter.addStyleName("middle-left right-margin-10");
        filtersLayout.addComponent(statusFilter);
        hasFilters = true;
    }

    /* add global status filter */
    if (appConfigManager.getComplexEntityBooleanParam(complexType, ComplexEntityParam.ALLOW_STATUS)) {
        ComponentContainer globalStatusFilter = getGlobalStatusFilter(entity, ua, app, ac);
        globalStatusFilter.addStyleName("middle-left right-margin-10");
        filtersLayout.addComponent(globalStatusFilter);
        hasFilters = true;
    }

    /* add tag filter */
    if (appConfigManager.getComplexEntityBooleanParam(complexType, ComplexEntityParam.ALLOW_TAG)) {
        ComponentContainer tagsFilter = getTagsFilter(entity, ua, app, ac);
        tagsFilter.addStyleName("middle-left right-margin-10");
        filtersLayout.addComponent(tagsFilter);
        hasFilters = true;
    }

    //   GridLayout filtersContainer = new GridLayout(1, 1);
    //   if (hasFilters) {
    //       filtersContainer = new GridLayout(2, 1);
    //   }
    //   filtersContainer.setMargin(false);
    //   // filtersContainer.setSizeFull();
    //   filtersContainer.setWidth("100%");
    //   filtersContainer.setSpacing(true);
    //   filtersContainer.addStyleName(OpenGroupsStyles.LIST_FILTERS_BAR);
    //
    //   if (hasFilters) {
    //       filtersContainer.addComponent(filtersLayout, 0, 0);
    //       filtersContainer.setColumnExpandRatio(0, 1f);
    //       filtersContainer.setComponentAlignment(filtersLayout, Alignment.MIDDLE_LEFT);
    //   }

    /* add search filter */
    //   Component searchFilter = getSearchFilter(entity, ua, app, ac);
    //   searchFilter.addStyleName("middle-right");
    //   filtersContainer.addComponent(searchFilter);
    //   filtersContainer.setComponentAlignment(searchFilter, Alignment.MIDDLE_RIGHT);
    //
    //   return filtersContainer;

    //   filtersLayout.addComponent(searchFilter);
    return filtersLayout;
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

private ComponentContainer getListByDepthFilter(final Entity entity, final UserAction ua,
        final OpenGroupsApplication app, final ActionContext ac) {
    ComboBox select = new ComboBox();
    select.setImmediate(true);//from   w w w. j  a  v a 2  s .  c o m
    select.setNullSelectionAllowed(false);
    select.setNewItemsAllowed(false);
    select.setWidth("115px");
    String paramName = "depth";
    FilterOption f2 = new FilterOption(getMessage("list.first.level." + ua.getTargetEntityType().toLowerCase()),
            paramName, 0L);
    FilterOption f1 = new FilterOption(getMessage("list.all." + ua.getTargetEntityType().toLowerCase()),
            paramName, null);

    select.addItem(f1);
    select.addItem(f2);

    final Entity selectedEntity = entity;
    FilterOption currentFilter = selectedEntity.getFilter(paramName);
    if (currentFilter == null || !select.containsId(currentFilter)) {
        currentFilter = f1;
        selectedEntity.setFilter(currentFilter);
    }

    select.setValue(currentFilter);

    select.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            entity.getState().resetPageInfoForCurrentAction();
            selectedEntity.setFilter((FilterOption) event.getProperty().getValue());
            refreshList(entity, ua, app, selectedEntity.getState().getLastUsedContainer(), ac);
        }
    });

    CssLayout container = new CssLayout();
    Label label = new Label(getMessage("by.depth"));
    container.addComponent(label);
    container.addComponent(select);
    return container;

}