aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/demo/coverflow/gwt/client/CoverflowWidgetSet.java
blob: bbde2525405e4cbf8c7031ffce7d16209f02825d (plain)
1
2
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
/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.vaadin.demo.coverflow.gwt.client;

import com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow;
import com.vaadin.terminal.gwt.client.DefaultWidgetSet;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.UIDL;

public class CoverflowWidgetSet extends DefaultWidgetSet {
    /** Creates a widget according to its class name. */
    @Override
    public Paintable createWidget(UIDL uidl) {
        final Class<?> classType = resolveWidgetType(uidl);
        if (VCoverflow.class == classType) {
            return new VCoverflow();
        }

        // Let the DefaultWidgetSet handle creation of default widgets
        return super.createWidget(uidl);
    }

    /** Resolves UIDL tag name to class . */
    @Override
    protected Class<?> resolveWidgetType(UIDL uidl) {
        final String tag = uidl.getTag();
        if ("cover".equals(tag)) {
            return VCoverflow.class;
        }

        // Let the DefaultWidgetSet handle resolution of default widgets
        return super.resolveWidgetType(uidl);
    }
}