aboutsummaryrefslogtreecommitdiffstats
path: root/AUTHORS.txt
Commit message (Expand)AuthorAgeFilesLines
* Add Hans Hillen to AUTHORS.txtJörn Zaefferer2011-07-191-0/+1
* Updated AUTHORS.txt with URLs to website and Github, thanks Ralphjzaefferer2010-03-221-2/+2
* added urlJörn Zaefferer2009-01-101-1/+1
* AUTHORS.txt: added Bohdan GanickyRichard Worth2009-01-081-1/+2
* authors.txt: Added Rich Caloggero, Colin Clark, Michelle D'Souza. Changed Mag...Richard Worth2009-01-031-1/+4
* Adding email to AUTHORS.txtEduardo Lundgren2008-12-291-1/+1
* fixed my name and Scott's in AUTHORS.txtJörn Zaefferer2008-12-221-2/+2
* set svn:eol-style to nativeRichard Worth2008-12-051-26/+26
* changed author url for Ca-Phun UngCa-Phun Ung2008-11-211-1/+1
* New file: AUTHORS.txt instead of having a single contributor's name in each f...Richard Worth2008-11-211-0/+26
>3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/*
 * Copyright 2000-2013 Vaadin Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.vaadin.tests.themes;

import com.vaadin.annotations.Theme;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.tests.util.PersonContainer;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Image;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;

@Theme("reindeer")
public class ThemeChangeOnTheFly extends AbstractTestUIWithLog {

    @Override
    protected void setup(VaadinRequest request) {
        Button inject = new Button("Inject blue background");
        inject.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                getPage().getStyles().add(
                        ".v-app { background: blue !important;}");

            }
        });
        addComponent(inject);

        GridLayout gl = new GridLayout(2, 4);
        gl.setCaption("Change theme by clicking a button");
        for (final String theme : new String[] { "reindeer", "runo",
                "chameleon", "base", null }) {
            Button b = new Button(theme);
            b.setId(theme + "");
            b.addClickListener(new ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    getUI().setTheme(theme);
                }
            });
            gl.addComponent(b);
        }

        Table t = new Table();
        PersonContainer pc = PersonContainer.createWithTestData();
        pc.addNestedContainerBean("address");
        t.setContainerDataSource(pc);
        gl.addComponent(t, 0, 3, 1, 3);
        gl.setRowExpandRatio(3, 1);

        gl.setWidth("500px");
        gl.setHeight("800px");

        HorizontalLayout images = new HorizontalLayout();
        images.setSpacing(true);

        Label l = new Label("Chameleon theme image in caption");
        l.setIcon(new ThemeResource("img/magnifier.png"));
        images.addComponent(l);
        Image image = new Image("Runo theme image", new ThemeResource(
                "icons/64/ok.png"));
        images.addComponent(image);
        image = new Image("Reindeer theme image", new ThemeResource(
                "button/img/left-focus.png"));
        images.addComponent(image);
        addComponent(images);
        addComponent(gl);

        getLayout().setSpacing(true);
    }

    @Override
    protected String getTestDescription() {
        return "Test that you can change theme on the fly";
    }

    @Override
    protected Integer getTicketNumber() {
        return 2874;
    }

}