Example usage for com.vaadin.ui HorizontalLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.cavisson.gui.dashboard.components.controls.ComboBoxes.java

License:Apache License

public ComboBoxes() {
    setMargin(true);/*w  w  w.  ja va2s .  c o m*/

    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(ValoThemeUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ValoThemeUI.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(ValoThemeUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ValoThemeUI.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(ValoThemeUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY);
    combo.addStyleName("color1");
    row.addComponent(combo);

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

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

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

    combo = new ComboBox("Large");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ValoThemeUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ValoThemeUI.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(ValoThemeUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY);
    combo.addStyleName("tiny");
    row.addComponent(combo);

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

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel windows() {
    Panel p = new Panel("Dialogs");
    VerticalLayout content = new VerticalLayout() {
        final Window win = new Window("Window Caption");
        String prevHeight = "300px";
        boolean footerVisible = true;
        boolean autoHeight = false;
        boolean tabsVisible = false;
        boolean toolbarVisible = false;
        boolean footerToolbar = false;
        boolean toolbarLayout = false;
        String toolbarStyle = null;

        VerticalLayout windowContent() {
            VerticalLayout root = new VerticalLayout();

            if (toolbarVisible) {
                MenuBar menuBar = MenuBars.getToolBar();
                menuBar.setSizeUndefined();
                menuBar.setStyleName(toolbarStyle);
                Component toolbar = menuBar;
                if (toolbarLayout) {
                    menuBar.setWidth(null);
                    HorizontalLayout toolbarLayout = new HorizontalLayout();
                    toolbarLayout.setWidth("100%");
                    toolbarLayout.setSpacing(true);
                    Label label = new Label("Tools");
                    label.setSizeUndefined();
                    toolbarLayout.addComponents(label, menuBar);
                    toolbarLayout.setExpandRatio(menuBar, 1);
                    toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT);
                    toolbar = toolbarLayout;
                }/* ww w.  jav a 2 s . com*/
                toolbar.addStyleName("v-window-top-toolbar");
                root.addComponent(toolbar);
            }

            Component content = null;

            if (tabsVisible) {
                TabSheet tabs = new TabSheet();
                tabs.setSizeFull();
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                tabs.addTab(l, "Selected");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "Another");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "One more");
                tabs.addStyleName("padded-tabbar");
                tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        try {
                            Thread.sleep(600);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });
                content = tabs;
            } else if (!autoHeight) {
                Panel p = new Panel();
                p.setSizeFull();
                p.addStyleName("borderless");
                if (!toolbarVisible || !toolbarLayout) {
                    p.addStyleName("scroll-divider");
                }
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                p.setContent(l);
                content = p;
            } else {
                content = new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML);
                root.setMargin(true);
            }

            root.addComponent(content);

            if (footerVisible) {
                HorizontalLayout footer = new HorizontalLayout();
                footer.setWidth("100%");
                footer.setSpacing(true);
                footer.addStyleName("v-window-bottom-toolbar");

                Label footerText = new Label("Footer text");
                footerText.setSizeUndefined();

                Button ok = new Button("OK");
                ok.addStyleName("primary");

                Button cancel = new Button("Cancel");

                footer.addComponents(footerText, ok, cancel);
                footer.setExpandRatio(footerText, 1);

                if (footerToolbar) {
                    MenuBar menuBar = MenuBars.getToolBar();
                    menuBar.setStyleName(toolbarStyle);
                    menuBar.setWidth(null);
                    footer.removeAllComponents();
                    footer.addComponent(menuBar);
                }

                root.addComponent(footer);
            }

            if (!autoHeight) {
                root.setSizeFull();
                root.setExpandRatio(content, 1);
            }

            return root;
        }

        {
            setSpacing(true);
            setMargin(true);
            win.setWidth("380px");
            win.setHeight(prevHeight);
            win.setClosable(false);
            win.setResizable(false);
            win.setContent(windowContent());
            win.setCloseShortcut(KeyCode.ESCAPE, null);

            Command optionsCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Footer")) {
                        footerVisible = selectedItem.isChecked();
                    }
                    if (selectedItem.getText().equals("Auto Height")) {
                        autoHeight = selectedItem.isChecked();
                        if (!autoHeight) {
                            win.setHeight(prevHeight);
                        } else {
                            prevHeight = win.getHeight() + win.getHeightUnits().toString();
                            win.setHeight(null);
                        }
                    }
                    if (selectedItem.getText().equals("Tabs")) {
                        tabsVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top")) {
                        toolbarVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Footer")) {
                        footerToolbar = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top layout")) {
                        toolbarLayout = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Borderless")) {
                        toolbarStyle = selectedItem.isChecked() ? "borderless" : null;
                    }

                    win.setContent(windowContent());
                }
            };

            MenuBar options = new MenuBar();
            options.setCaption("Content");
            options.addItem("Auto Height", optionsCommand).setCheckable(true);
            options.addItem("Tabs", optionsCommand).setCheckable(true);
            MenuItem option = options.addItem("Footer", optionsCommand);
            option.setCheckable(true);
            option.setChecked(true);
            options.addStyleName("small");
            addComponent(options);

            options = new MenuBar();
            options.setCaption("Toolbars");
            options.addItem("Footer", optionsCommand).setCheckable(true);
            options.addItem("Top", optionsCommand).setCheckable(true);
            options.addItem("Top layout", optionsCommand).setCheckable(true);
            options.addItem("Borderless", optionsCommand).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            Command optionsCommand2 = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Caption")) {
                        win.setCaption(selectedItem.isChecked() ? "Window Caption" : null);
                    } else if (selectedItem.getText().equals("Closable")) {
                        win.setClosable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Resizable")) {
                        win.setResizable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Modal")) {
                        win.setModal(selectedItem.isChecked());
                    }
                }
            };

            options = new MenuBar();
            options.setCaption("Options");
            MenuItem caption = options.addItem("Caption", optionsCommand2);
            caption.setCheckable(true);
            caption.setChecked(true);
            options.addItem("Closable", optionsCommand2).setCheckable(true);
            options.addItem("Resizable", optionsCommand2).setCheckable(true);
            options.addItem("Modal", optionsCommand2).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            final Button show = new Button("Open Window", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    getUI().addWindow(win);
                    win.center();
                    win.focus();
                    event.getButton().setEnabled(false);
                }
            });
            show.addStyleName("primary");
            addComponent(show);

            final CheckBox hidden = new CheckBox("Hidden");
            hidden.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    win.setVisible(!hidden.getValue());
                }
            });
            addComponent(hidden);

            win.addCloseListener(new CloseListener() {
                @Override
                public void windowClose(final CloseEvent e) {
                    show.setEnabled(true);
                }
            });
        }
    };
    p.setContent(content);
    return p;

}

From source file:com.cavisson.gui.dashboard.components.controls.DateFields.java

License:Apache License

public DateFields() {
    setMargin(true);/*w w  w. ja  va  2s .  co  m*/

    Label h1 = new Label("Date Fields");
    h1.addStyleName("h1");
    addComponent(h1);

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

    DateField date = new DateField("Default resolution");
    setDate(date);
    row.addComponent(date);

    date = new DateField("Error");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(date);

    date = new DateField("Error, borderless");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    date.addStyleName("borderless");
    row.addComponent(date);

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

    final DateField date2 = new DateField();
    group.addComponent(date2);

    Button today = new Button("Today", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            date2.setValue(new Date());
        }
    });
    group.addComponent(today);

    date = new DateField("Default resolution, explicit size");
    setDate(date);
    row.addComponent(date);
    date.setWidth("260px");
    date.setHeight("60px");

    date = new DateField("Second resolution");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    row.addComponent(date);

    date = new DateField("Minute resolution");
    setDate(date);
    date.setResolution(Resolution.MINUTE);
    row.addComponent(date);

    date = new DateField("Hour resolution");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    row.addComponent(date);

    date = new DateField("Disabled");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    date.setEnabled(false);
    row.addComponent(date);

    date = new DateField("Day resolution");
    setDate(date);
    date.setResolution(Resolution.DAY);
    row.addComponent(date);

    date = new DateField("Month resolution");
    setDate(date);
    date.setResolution(Resolution.MONTH);
    row.addComponent(date);

    date = new DateField("Year resolution");
    setDate(date);
    date.setResolution(Resolution.YEAR);
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color1");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color2");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color3");
    row.addComponent(date);

    date = new DateField("Small");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("small");
    row.addComponent(date);

    date = new DateField("Large");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("large");
    row.addComponent(date);

    date = new DateField("Borderless");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("borderless");
    row.addComponent(date);

    date = new DateField("Week numbers");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    date = new DateField("US locale");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    date.setLocale(new Locale("en", "US"));
    row.addComponent(date);

    date = new DateField("Custom format");
    setDate(date);
    date.setDateFormat("E dd/MM/yyyy");
    row.addComponent(date);

    date = new DateField("Tiny");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("tiny");
    row.addComponent(date);

    date = new DateField("Huge");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("huge");
    row.addComponent(date);

    date = new InlineDateField("Date picker");
    setDate(date);
    row.addComponent(date);

    date = new InlineDateField("Date picker with week numbers");
    setDate(date);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);
}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

public void init() {
    Label h1 = new Label("Menu Bars");
    h1.addStyleName("h1");
    addComponent(h1);//  w  w  w.j  a v a 2  s  . co  m

    MenuBar menuBar = getMenuBar();
    menuBar.setCaption("Normal style");
    addComponent(menuBar);

    menuBar = getMenuBar();
    menuBar.setCaption("Small style");
    menuBar.addStyleName("small");
    addComponent(menuBar);

    menuBar = getMenuBar();
    menuBar.setCaption("Borderless style");
    menuBar.addStyleName("borderless");
    addComponent(menuBar);

    menuBar = getMenuBar();
    menuBar.setCaption("Small borderless style");
    menuBar.addStyleName("borderless");
    menuBar.addStyleName("small");
    addComponent(menuBar);

    Label h2 = new Label("Drop Down Button");
    h2.addStyleName("h2");
    addComponent(h2);

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

    wrap.addComponent(getMenuButton("Normal", false));

    MenuBar split = getMenuButton("Small", false);
    split.addStyleName("small");
    wrap.addComponent(split);

    split = getMenuButton("Borderless", false);
    split.addStyleName("borderless");
    wrap.addComponent(split);

    split = getMenuButton("Themed", false);
    split.addStyleName("color1");
    wrap.addComponent(split);

    split = getMenuButton("Small", false);
    split.addStyleName("color1");
    split.addStyleName("small");
    wrap.addComponent(split);

    h2 = new Label("Split Button");
    h2.addStyleName("h2");
    addComponent(h2);

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

    wrap.addComponent(getMenuButton("Normal", true));

    split = getMenuButton("Small", true);
    split.addStyleName("small");
    wrap.addComponent(split);

    split = getMenuButton("Borderless", true);
    split.addStyleName("borderless");
    wrap.addComponent(split);

    split = getMenuButton("Themed", true);
    split.addStyleName("color1");
    wrap.addComponent(split);

    split = getMenuButton("Small", true);
    split.addStyleName("color1");
    split.addStyleName("small");
    wrap.addComponent(split);
}

From source file:com.cavisson.gui.dashboard.components.controls.NativeSelects.java

License:Apache License

public NativeSelects() {
    setMargin(true);//from www  . j  a  v a  2 s . c om

    Label h1 = new Label("Selects");
    h1.addStyleName("h1");
    addComponent(h1);

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

    NativeSelect select = new NativeSelect("Drop Down Select");
    row.addComponent(select);

    ListSelect list = new ListSelect("List Select");
    list.setNewItemsAllowed(true);
    row.addComponent(list);

    TwinColSelect tcs = new TwinColSelect("TwinCol Select");
    tcs.setLeftColumnCaption("Left Column");
    tcs.setRightColumnCaption("Right Column");
    tcs.setNewItemsAllowed(true);
    row.addComponent(tcs);

    TwinColSelect tcs2 = new TwinColSelect("Sized TwinCol Select");
    tcs2.setLeftColumnCaption("Left Column");
    tcs2.setRightColumnCaption("Right Column");
    tcs2.setNewItemsAllowed(true);
    tcs2.setWidth("280px");
    tcs2.setHeight("200px");
    row.addComponent(tcs2);

    for (int i = 1; i <= 10; i++) {
        select.addItem("Option " + i);
        list.addItem("Option " + i);
        tcs.addItem("Option " + i);
        tcs2.addItem("Option " + i);
    }
}

From source file:com.cavisson.gui.dashboard.components.controls.Panels.java

License:Apache License

public Panels() {
    setMargin(true);//  w ww .  j  av  a  2s.  co m

    Label h1 = new Label("Panels & Layout panels");
    h1.addStyleName("h1");
    addComponent(h1);

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

    Panel panel = new Panel("Normal");
    panel.setIcon(testIcon.get());
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Sized");
    panel.setIcon(testIcon.get());
    panel.setWidth("10em");
    panel.setHeight("250px");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color1");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color2");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color3");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Borderless style");
    panel.setIcon(testIcon.get());
    panel.addStyleName("borderless");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Borderless + scroll divider");
    panel.setIcon(testIcon.get());
    panel.addStyleName("borderless");
    panel.addStyleName("scroll-divider");
    panel.setContent(panelContentScroll());
    panel.setHeight("17em");
    row.addComponent(panel);

    panel = new Panel("Well style");
    panel.setIcon(testIcon.get());
    panel.addStyleName("well");
    panel.setContent(panelContent());
    row.addComponent(panel);

    CssLayout layout = new CssLayout();
    layout.setIcon(testIcon.get());
    layout.setCaption("Panel style layout");
    layout.addStyleName("card");
    layout.addComponent(panelContent());
    row.addComponent(layout);

    layout = new CssLayout();
    layout.addStyleName("card");
    row.addComponent(layout);
    HorizontalLayout panelCaption = new HorizontalLayout();
    panelCaption.addStyleName("v-panel-caption");
    panelCaption.setWidth("100%");
    // panelCaption.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label label = new Label("Panel style layout");
    panelCaption.addComponent(label);
    panelCaption.setExpandRatio(label, 1);

    Button action = new Button();
    action.setIcon(FontAwesome.PENCIL);
    action.addStyleName("borderless-colored");
    action.addStyleName("small");
    action.addStyleName("icon-only");
    panelCaption.addComponent(action);
    MenuBar dropdown = new MenuBar();
    dropdown.addStyleName("borderless");
    dropdown.addStyleName("small");
    MenuItem addItem = dropdown.addItem("", FontAwesome.CHEVRON_DOWN, null);
    addItem.setStyleName("icon-only");
    addItem.addItem("Settings", null);
    addItem.addItem("Preferences", null);
    addItem.addSeparator();
    addItem.addItem("Sign Out", null);
    panelCaption.addComponent(dropdown);

    layout.addComponent(panelCaption);
    layout.addComponent(panelContent());
    layout.setWidth("14em");

    layout = new CssLayout();
    layout.setIcon(testIcon.get());
    layout.setCaption("Well style layout");
    layout.addStyleName("well");
    layout.addComponent(panelContent());
    row.addComponent(layout);
}

From source file:com.cavisson.gui.dashboard.components.controls.PopupViews.java

License:Apache License

public PopupViews() {
    setMargin(true);/*  w ww  .  j  av a 2s  .c om*/

    Label h1 = new Label("Popup Views");
    h1.addStyleName("h1");
    addComponent(h1);

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

    PopupView pv = new PopupView(new Content() {
        @Override
        public Component getPopupComponent() {
            return new VerticalLayout() {
                {
                    setMargin(true);
                    setWidth("300px");
                    addComponent(new Label(
                            "Fictum,  deserunt mollit anim laborum astutumque! Magna pars studiorum, prodita quaerimus."));
                }
            };
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "Click to view";
        }
    });
    row.addComponent(pv);
    pv.setHideOnMouseOut(true);
    pv.setCaption("Hide on mouse-out");

    pv = new PopupView(new Content() {
        int count = 0;

        @Override
        public Component getPopupComponent() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {

            }
            return new VerticalLayout() {
                {
                    setMargin(true);
                    addComponent(new Label("<h3>Thanks for waiting!</h3><p>You've opened this popup <b>"
                            + ++count + " time" + (count > 1 ? "s" : " only") + "</b>.</p>", ContentMode.HTML));
                }
            };
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "Show slow loading content";
        }
    });
    row.addComponent(pv);
    pv.setHideOnMouseOut(false);
    pv.setCaption("Hide on click-outside");
}

From source file:com.cavisson.gui.dashboard.components.controls.Sliders.java

License:Apache License

public Sliders() {
    setMargin(true);//from  www. j a  v a  2  s  .  com

    Label h1 = new Label("Sliders");
    h1.addStyleName("h1");
    addComponent(h1);

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

    Slider slider = new Slider("Horizontal");
    slider.setValue(50.0);
    row.addComponent(slider);

    slider = new Slider("Horizontal, sized");
    slider.setValue(50.0);
    slider.setWidth("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color1");
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color2");
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color3");
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("no-indicator");
    row.addComponent(slider);

    slider = new Slider("With ticks (not in IE8 & IE9)");
    slider.setValue(3.0);
    slider.setWidth("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    row.addComponent(slider);

    slider = new Slider("Toggle imitation");
    slider.setWidth("50px");
    slider.setResolution(0);
    slider.setMin(0);
    slider.setMax(1);
    row.addComponent(slider);

    slider = new Slider("Vertical");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Vertical, sized");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    slider.setHeight("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color1");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color2");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color3");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("no-indicator");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("With ticks");
    slider.setValue(3.0);
    slider.setHeight("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Disabled");
    slider.setValue(50.0);
    slider.setEnabled(false);
    row.addComponent(slider);

    h1 = new Label("Progress Bars");
    h1.addStyleName("h1");
    addComponent(h1);

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

    pb = new ProgressBar();
    pb.setCaption("Default");
    pb.setWidth("300px");
    // pb.setValue(0.6f);
    row.addComponent(pb);

    pb2 = new ProgressBar();
    pb2.setCaption("Point style");
    pb2.setWidth("300px");
    pb2.addStyleName("point");
    // pb2.setValue(0.6f);
    row.addComponent(pb2);

    if (!ValoThemeUI.isTestMode()) {
        ProgressBar pb3 = new ProgressBar();
        pb3.setIndeterminate(true);
        pb3.setCaption("Indeterminate");
        row.addComponent(pb3);
    }
}

From source file:com.cavisson.gui.dashboard.components.controls.SplitPanels.java

License:Apache License

public SplitPanels() {
    setMargin(true);//w  ww  . j  a v  a 2 s.com

    Label h1 = new Label("Split Panels");
    h1.addStyleName("h1");
    addComponent(h1);

    addComponent(new Label(
            "Outlines are just to show the areas of the SplitPanels. They are not part of the actual component style."));

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    row.setMargin(new MarginInfo(true, false, false, false));
    addComponent(row);

    HorizontalSplitPanel sp = new HorizontalSplitPanel();
    sp.setCaption("Default style");
    sp.setWidth("400px");
    sp.setHeight(null);
    sp.setFirstComponent(getContent());
    sp.setSecondComponent(getContent());
    row.addComponent(sp);

    VerticalSplitPanel sp2 = new VerticalSplitPanel();
    sp2.setCaption("Default style");
    sp2.setWidth("300px");
    sp2.setHeight("200px");
    sp2.setFirstComponent(getContent());
    sp2.setSecondComponent(getContent());
    row.addComponent(sp2);

    sp = new HorizontalSplitPanel();
    sp.setCaption("Large style");
    sp.setWidth("300px");
    sp.setHeight("200px");
    sp.addStyleName("large");
    sp.setFirstComponent(getContent());
    sp.setSecondComponent(getContent());
    row.addComponent(sp);

    sp2 = new VerticalSplitPanel();
    sp2.setCaption("Large style");
    sp2.setWidth("300px");
    sp2.setHeight("200px");
    sp2.addStyleName("large");
    sp2.setFirstComponent(getContent());
    sp2.setSecondComponent(getContent());
    row.addComponent(sp2);
}

From source file:com.cavisson.gui.dashboard.components.controls.Tables.java

License:Apache License

public Tables() {
    setMargin(true);/* w  w  w  .j  a  v  a  2  s .  c  om*/
    setSpacing(true);

    Label h1 = new Label("Tables");
    h1.addStyleName("h1");
    addComponent(h1);

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

    wrap.addComponents(hierarchical, footer, sized, expandRatios, stripes, verticalLines, horizontalLines,
            borderless, headers, compact, small, rowIndex, rowCaption, rowIcon, componentsInCells);

    ValueChangeListener update = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (table == null) {
                table = new Table();
                table.setContainerDataSource(normalContainer);
                addComponent(table);
            }
            if (hierarchical.getValue() && table instanceof Table) {
                removeComponent(table);
                table = new TreeTable();
                table.setContainerDataSource(hierarchicalContainer);
                addComponent(table);
            } else if (!hierarchical.getValue() && table instanceof TreeTable) {
                removeComponent(table);
                table = new Table();
                table.setContainerDataSource(normalContainer);
                addComponent(table);
            }

            configure(table, footer.getValue(), sized.getValue(), expandRatios.getValue(), stripes.getValue(),
                    verticalLines.getValue(), horizontalLines.getValue(), borderless.getValue(),
                    headers.getValue(), compact.getValue(), small.getValue(), rowIndex.getValue(),
                    rowCaption.getValue(), rowIcon.getValue(), componentsInCells.getValue());
        }
    };

    hierarchical.addValueChangeListener(update);
    footer.addValueChangeListener(update);
    sized.addValueChangeListener(update);
    expandRatios.addValueChangeListener(update);
    stripes.addValueChangeListener(update);
    verticalLines.addValueChangeListener(update);
    horizontalLines.addValueChangeListener(update);
    borderless.addValueChangeListener(update);
    headers.addValueChangeListener(update);
    compact.addValueChangeListener(update);
    small.addValueChangeListener(update);
    rowIndex.addValueChangeListener(update);
    rowCaption.addValueChangeListener(update);
    rowIcon.addValueChangeListener(update);
    componentsInCells.addValueChangeListener(update);

    footer.setValue(false);

}