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:org.lucidj.smartbox_renderer.SmartBoxRenderer.java

License:Apache License

private void init_toolbar() {
    cell_toolbar = new CssLayout();

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");
    group.addStyleName("ui-toolbar-spacer");

    Button run = new Button();
    run.setHtmlContentAllowed(true);/*w ww . ja v a  2  s . c  om*/
    String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>";
    run.setCaption(
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">"
                    + ico3 + "</svg>");
    run.addStyleName("tiny");
    group.addComponent(run);

    run.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            source.fireEvent(this, "run");
        }
    });

    run.addShortcutListener(new ShortcutListener("Run", ShortcutAction.KeyCode.ENTER,
            new int[] { ShortcutAction.ModifierKey.CTRL }) {
        @Override
        public void handleAction(Object sender, Object target) {
            // The shortcuts (while active on toolbar) are global, however for
            // Ctrl+Enter this becomes counter-intuitive. This way, we filter
            // it to avoid running things from outside the edition field.
            if (target == commands) {
                source.fireEvent(this, "run");
            }
        }
    });

    Button stop = new Button();
    stop.setIcon(FontAwesome.STOP);
    stop.addStyleName("tiny");
    group.addComponent(stop);

    stop.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            source.fireEvent(this, "stop");
        }
    });

    cell_toolbar.addComponent(group);
}

From source file:org.lucidj.ui.gauss.GaussUI.java

License:Apache License

private void initAppLayout() {
    vAppLayout.setSizeFull();//from  w  w w.  jav a 2 s  .  co m
    vAppLayout.setWidth("100%");

    {
        initToolbarArea();
        vAppLayout.addComponent(hToolbarArea);
    }

    {
        hsMenuContents.setSizeFull();
        hsMenuContents.addStyleName("ui-main-splitpanel");
        vAppLayout.addComponent(hsMenuContents);
        vAppLayout.setExpandRatio(hsMenuContents, 1.0f);
    }

    // Accordion menu
    {
        // Create the logical menu
        main_menu = menu_manager.newMenuInstance(null);
        main_menu.setEventListener(this);

        // Create the menu renderer
        main_menu_renderer = rendererFactory.newRenderer(main_menu);
        main_menu_renderer.setWidth(100, Unit.PERCENTAGE);
        main_menu_renderer.setHeightUndefined();

        // Add the rendered component into navigation panel
        acMenu = create_multipanel();
        acMenu.addStyleName("ui-navigation-panel");
        acMenu.setWidth(100, Unit.PERCENTAGE);
    }

    emptyContents = new CssLayout();
    emptyContents.addStyleName("fancy-grid-background");
    set_contents(emptyContents);

    emptySidebar.addStyleName("fancy-grid-background");
    hsContentsSidebar.setSecondComponent(emptySidebar);
    show_sidebar(false);

    hsMenuContents.setFirstComponent(acMenu);
    hsMenuContents.setSecondComponent(hsContentsSidebar);
    hsMenuContents.setMinSplitPosition(MIN_LEFT_PANEL_WIDTH_PX, Unit.PIXELS);
    hsMenuContents.setSplitPosition(get_default_left_panel_width(), Sizeable.Unit.PIXELS);
}

From source file:org.lucidj.ui.gauss.GaussUI.java

License:Apache License

private void initToolbarArea() {
    hToolbarArea.setStyleName("ui-toolbar-area");
    hToolbarArea.setSizeUndefined();//from   w w w.  j  a v  a2 s .  c  om
    hToolbarArea.setWidth("100%");

    CssLayout home_buttons = new CssLayout();
    home_buttons.setStyleName("ui-toolbar-area-home");
    home_buttons.setWidth(get_default_left_panel_width(), Sizeable.Unit.PIXELS);
    home_buttons.setId("_home_buttons");

    final Button toggle_menu = new Button();
    toggle_menu.setWidth(3, Unit.EM);
    toggle_menu.setIcon(FontAwesome.CHEVRON_DOWN);
    toggle_menu.addStyleName("tiny");
    toggle_menu.addStyleName("link");
    toggle_menu.addStyleName("ui-toolbar-spacer");
    toggle_menu.addStyleName("ui-toggle-button");
    toggle_menu.setId("_toggle_menu");
    home_buttons.addComponent(toggle_menu);

    toggle_menu.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (!hsMenuContents.isLocked()) {
                default_left_panel_width_px = (int) hsMenuContents.getSplitPosition();
                acMenu.setVisible(false);
                hsMenuContents.setMinSplitPosition(0, Unit.PIXELS);
                hsMenuContents.setSplitPosition(0, Sizeable.Unit.PIXELS);
                toggle_menu.setIcon(FontAwesome.CHEVRON_RIGHT);
                hsMenuContents.setLocked(true);
            } else {
                hsMenuContents.setLocked(false);
                acMenu.setVisible(true);
                hsMenuContents.setMinSplitPosition(MIN_LEFT_PANEL_WIDTH_PX, Unit.PIXELS);
                hsMenuContents.setSplitPosition(get_default_left_panel_width(), Unit.PIXELS);
                toggle_menu.setIcon(FontAwesome.CHEVRON_DOWN);
            }
        }
    });

    final Button home = new Button("Home");
    home.setIcon(FontAwesome.HOME);
    home.addStyleName("tiny");
    home.addStyleName("ui-toolbar-spacer");
    home.addStyleName("ui-toggle-button");
    home.setId("_home");
    home_buttons.addComponent(home);

    home.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            navigator.navigateTo("home");
        }
    });

    final Button new_button = new Button("New");
    new_button.setIcon(FontAwesome.EDIT);
    new_button.addStyleName("tiny");
    new_button.addStyleName("primary");
    new_button.addStyleName("ui-toggle-button");
    new_button.setId("_new");
    home_buttons.addComponent(new_button);
    new_button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            navigator.navigateTo("new");
        }
    });

    hToolbarArea.addComponent(home_buttons);

    hToolbarPlaceholder = new CssLayout();
    hToolbarPlaceholder.setSizeFull();
    hToolbarArea.addComponent(hToolbarPlaceholder);
    hToolbarArea.setExpandRatio(hToolbarPlaceholder, 1.0f);

    final Button eject_view = new Button();
    eject_view.setIcon(FontAwesome.EXTERNAL_LINK);
    eject_view.addStyleName("tiny");
    eject_view.addStyleName("link");
    eject_view.addStyleName("ui-toggle-button");
    eject_view.setId("_eject_view");
    hToolbarArea.addComponent(eject_view);

    eject_view.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("Not implemented", Notification.Type.HUMANIZED_MESSAGE);
        }
    });

    toggle_sidebar = new Button();
    toggle_sidebar.setWidth(3, Unit.EM);
    toggle_sidebar.addStyleName("tiny");
    toggle_sidebar.addStyleName("link");
    toggle_sidebar.addStyleName("ui-toolbar-spacer");
    toggle_sidebar.addStyleName("ui-toggle-button");
    toggle_sidebar.setId("_toggle_sidebar");
    hToolbarArea.addComponent(toggle_sidebar);

    toggle_sidebar.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            show_sidebar(!sidebar_visible());
        }
    });
}

From source file:org.lucidj.vaadinui.BaseVaadinUI.java

License:Apache License

private void initSystemToolbar() {
    desktop_canvas.setSizeFull();/*  w  w  w.j a  v a  2  s . com*/
    desktop_canvas.setWidth("100%");

    ui_header = new HorizontalLayout();
    {
        ui_header.setStyleName("ui-header-area");
        ui_header.setWidth(100, Sizeable.Unit.PERCENTAGE);
        ui_header.setHeightUndefined();
        ui_header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

        Label logo = new Label("&nbsp;", ContentMode.HTML);
        {
            logo.addStyleName("ui-header-logo");
            logo.setWidth(default_sidebar_width_pixels, Sizeable.Unit.PIXELS);
        }
        ui_header.addComponent(logo);

        HorizontalLayout header_components = new HorizontalLayout();
        {
            header_components.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE);
            header_components.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
            header_components.setSpacing(true);

            // Search component
            CssLayout search_component = new CssLayout();
            {
                search_component.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE);
                search_component.setWidthUndefined();
                search_component.addStyleName("v-component-group");
                search_component.addStyleName("ui-header-search");
                final ComboBox search_text = new ComboBox();
                {
                    search_text.setInputPrompt("Search or paste URL...");
                    //combo.setContainerDataSource(StringGenerator.generateContainer(200, false));
                    search_text.setNullSelectionAllowed(true);
                    search_text.setTextInputAllowed(true);
                    search_text.setNewItemsAllowed(true);
                    //combo.select(combo.getItemIds().iterator().next());
                    //combo.setItemCaptionPropertyId(StringGenerator.CAPTION_PROPERTY);
                    //combo.setItemIconPropertyId(StringGenerator.ICON_PROPERTY);

                    // TODO: SOMEDAY DISCOVER HOW TO EXPAND THIS GROUPED COMPONENT, AND THE CURE FOR CANCER
                    search_text.setWidth("480px");
                    search_text.addStyleName("invisible-focus");
                    search_text.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                            String search_args = (String) search_text.getValue();

                            if (search_args != null) {
                                fireEvent("search", search_text.getValue());
                                value_change_button_quirk = true;
                            }
                        }
                    });

                    // Handles the Enter key by activating on focus and deactivating on blur
                    final ShortcutListener handle_enter = new ShortcutListener("Enter",
                            ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object o, Object o1) {
                            value_change_button_quirk = false;
                            fireEvent("search", search_text.getValue());
                        }
                    };

                    search_text.addFocusListener(new FieldEvents.FocusListener() {
                        @Override
                        public void focus(FieldEvents.FocusEvent focusEvent) {
                            if (nested_focus_blur_bug_count++ == 0) {
                                search_text.addShortcutListener(handle_enter);
                            }
                        }
                    });

                    search_text.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent blurEvent) {
                            if (--nested_focus_blur_bug_count == 0) {
                                search_text.removeShortcutListener(handle_enter);
                            }
                        }
                    });

                }
                search_component.addComponent(search_text);

                Button search_button = new Button();
                {
                    search_button.setIcon(FontAwesome.SEARCH);
                    search_button.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            if (!value_change_button_quirk) {
                                fireEvent("search", search_text.getValue());
                            }
                            value_change_button_quirk = false;
                        }
                    });
                    search_button.addStyleName("invisible-focus");
                }
                search_component.addComponent(search_button);
            }
            header_components.addComponent(search_component);

            // User component
            user_component = new HorizontalLayout();
            {
                user_component.setStyleName("ui-header-user");
                user_component.setWidthUndefined();
            }
            header_components.addComponent(user_component);

            // I swear someday I'll learn CSS, AFTER implementing my own distributed
            // operating system with augmented reality interface and a machine learning kernel,
            // all written in Z80 assembly, as a preparation for the task.
            Label spacer = new Label();
            spacer.setWidthUndefined();
            header_components.addComponent(spacer);

            // Search expands
            header_components.setExpandRatio(search_component, 1.0f);
        }
        ui_header.addComponent(header_components);
        ui_header.setExpandRatio(header_components, 1.0f);
    }

    desktop_canvas.addComponent(ui_header);
    desktop_canvas.addComponent(empty_desktop);
    desktop_canvas.setExpandRatio(empty_desktop, 1.0f);
    setContent(desktop_canvas);
}

From source file:org.lunifera.ecview.servlet.mobile.impl.MobileUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    setTheme("mobiletheme");

    setStyleName(Reindeer.LAYOUT_BLUE);/*ww  w  .  j  a  va  2 s  .co  m*/
    VaadinObservables.getRealm(getUI());

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

    // initialize the UI
    getPage().addUriFragmentChangedListener(this);

    // notify about the current uri fragment
    renewHandle(getPage().getUriFragment());
    notifyHandle(getPage().getUriFragment());

    setTheme("mobiletheme");
}

From source file:org.lunifera.ecview.vaadin.ide.preview.web.EcviewMobilePreviewUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    setErrorHandler(new ErrorHandler() {
        @Override// w  w w  .  jav  a2  s .c  om
        public void error(com.vaadin.server.ErrorEvent event) {
            if (EcviewMobilePreviewUI.this.isClosing() || !EcviewMobilePreviewUI.this.isAttached()) {
                return;
            }
            UI.setCurrent(EcviewMobilePreviewUI.this);
            disconnectAndClose(event.getThrowable());
        }
    });

    if (!Activator.getMobilePreviewHandler().setPreviewUI(this)) {
        worksWithCopy = true;
    }

    setStyleName(Reindeer.LAYOUT_BLUE);
    VaadinObservables.getRealm(getUI());

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

    modelChanged();
}

From source file:org.lunifera.ecview.vaadin.ide.preview.web.EcviewPreviewUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    setErrorHandler(new ErrorHandler() {
        @Override//from   w  ww .jav  a 2s.c om
        public void error(com.vaadin.server.ErrorEvent event) {
            if (EcviewPreviewUI.this.isClosing() || !EcviewPreviewUI.this.isAttached()) {
                return;
            }
            UI.setCurrent(EcviewPreviewUI.this);
            disconnectAndClose(event.getThrowable());
        }
    });

    if (!Activator.getIDEPreviewHandler().setPreviewUI(this)) {
        worksWithCopy = true;
    }

    setStyleName(Reindeer.LAYOUT_BLUE);
    VaadinObservables.getRealm(getUI());

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

    modelChanged();
}

From source file:org.lunifera.example.vaadin.databinding.DatabindingDemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VaadinObservables.getRealm(getUI());

    CssLayout layout = new CssLayout();
    layout.setSizeFull();/*from  w  w w .  ja  va 2  s . com*/
    setContent(layout);

    TabSheet tabsheet = new TabSheet();
    tabsheet.setSizeFull();
    tabsheet.addTab(new ValueBindings(), "Value bindings");
    tabsheet.addTab(new SelectionBindings(), "Selection bindings");
    tabsheet.addTab(new LocaleBindings(), "Locales combo");
    try {
        tabsheet.addTab(new ECViewVerticalLayout(), "ECView Vertical");
        tabsheet.addTab(new ECViewHorizontalLayout(), "ECView Horizontal");
        tabsheet.addTab(new ECViewGridLayout(), "ECView Gridlayout");
        tabsheet.addTab(new ECViewTabSheet(), "ECView Tabsheet");
        tabsheet.addTab(new ECViewDatabinding(), "ECView Bindings");
    } catch (ContextException e) {
        e.printStackTrace();
    }
    layout.addComponent(tabsheet);
}