Example usage for com.vaadin.ui Component addAttachListener

List of usage examples for com.vaadin.ui Component addAttachListener

Introduction

In this page you can find the example usage for com.vaadin.ui Component addAttachListener.

Prototype

public Registration addAttachListener(AttachListener listener);

Source Link

Document

Add a listener for connector attach events.

Usage

From source file:info.magnolia.ui.framework.app.DefaultAppView.java

License:Open Source License

@Override
public void setTheme(String themeName) {
    String stylename = String.format("app-%s", themeName);
    final String themeUrl = String.format("../%s/styles.css", themeName);

    final Component vaadinComponent = asVaadinComponent();
    vaadinComponent.addStyleName(stylename);
    vaadinComponent.addAttachListener(new AttachListener() {

        @Override/*from   w  w w . j a v  a2s.  c  o m*/
        public void attach(AttachEvent event) {
            ThemeResource res = new ThemeResource(themeUrl);
            CSSInject cssInject = new CSSInject(vaadinComponent.getUI());
            cssInject.addStyleSheet(res);
        }
    });
}