Package com.vaadin.server.Page

Examples of com.vaadin.server.Page.Styles


                // Get the new background color
                Color color = event.getColor();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new background color
                styles.add(".v-app .v-textarea.text-label { background-color:"
                        + color.getCSS() + "; }");
            }
        });
        return bgColor;
    }
View Full Code Here


                // Get the new text color
                Color color = event.getColor();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new color as a style
                styles.add(".v-app .v-textarea.text-label { color:"
                        + color.getCSS() + "; }");
            }
        });

        return textColor;
View Full Code Here

            public void valueChange(ValueChangeEvent event) {
                // Get the new font family
                String fontFamily = select.getValue().toString();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new font size as a style. We need .v-app to
                // override Vaadin's default styles here
                styles.add(".v-app .v-textarea.text-label { font-family:"
                        + fontFamily + "; }");
            }
        });

        return select;
View Full Code Here

            public void valueChange(ValueChangeEvent event) {
                // Get the new font size
                Integer fontSize = (Integer) select.getValue();

                // Get the stylesheet of the page
                Styles styles = Page.getCurrent().getStyles();

                // inject the new font size as a style. We need .v-app to
                // override Vaadin's default styles here
                styles.add(".v-app .v-textarea.text-label { font-size:"
                        + String.valueOf(fontSize) + "px; }");
            }
        });

        return select;
View Full Code Here

public class CSSInjectTest extends TestBase {

    @Override
    protected void setup() {

        final Styles stylesheet = Page.getCurrent().getStyles();

        // Inject some resources initially
        final StreamResource initialResource = new StreamResource(
                new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(
                                ".hello, .world { color:silver; }".getBytes());
                    }
                }, "mystyles-" + System.currentTimeMillis() + ".css");
        stylesheet.add(initialResource);

        Label hello = new Label(
                "<span class='hello'>Hello</span> <span class='world'>world</span>",
                ContentMode.HTML);
        addComponent(hello);

        final TextArea cssToInject = new TextArea();
        cssToInject.setImmediate(true);
        addComponent(cssToInject);

        Button inject = new Button("Inject!", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                stylesheet.add(cssToInject.getValue());
                cssToInject.setValue("");
            }
        });
        addComponent(inject);

        Button injectRandom = new Button("Inject as resource!",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {

                        final String css = cssToInject.getValue();

                        stylesheet.add(new StreamResource(
                                new StreamResource.StreamSource() {

                                    @Override
                                    public InputStream getStream() {
                                        return new ByteArrayInputStream(css
                                                .getBytes());
                                    }
                                }, UUID.randomUUID().toString() + ".css"));

                        cssToInject.setValue("");
                    }
                });
        addComponent(injectRandom);

        addComponent(new Button("Inject initial again!",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        stylesheet.add(initialResource);
                    }
                }));
    }
View Full Code Here

TOP

Related Classes of com.vaadin.server.Page.Styles

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.