aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/client/WidgetMap.java
blob: d9df64b8d02f1fc91133a8e362f8226f33c5fb50 (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
37
38
39
40
41
/*
@ITMillApache2LicenseForJavaFiles@
 */
package com.vaadin.terminal.gwt.client;

import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar;
import com.vaadin.terminal.gwt.client.ui.VPasswordField;
import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical;
import com.vaadin.terminal.gwt.client.ui.VTextArea;
import com.vaadin.terminal.gwt.client.ui.VWindow;

public abstract class WidgetMap {

    public Paintable instantiate(Class<? extends Paintable> classType) {
        /*
         * Yes, this (including the generated) may look very odd code, but due
         * the nature of GWT, we cannot do this with reflect. Luckily this is
         * mostly written by WidgetSetGenerator, here are just some hacks. Extra
         * instantiation code is needed if client side widget has no "native"
         * counterpart on client side.
         */
        if (VSplitPanelVertical.class == classType) {
            return new VSplitPanelVertical();
        } else if (VTextArea.class == classType) {
            return new VTextArea();

        } else if (VDateFieldCalendar.class == classType) {
            return new VDateFieldCalendar();
        } else if (VPasswordField.class == classType) {
            return new VPasswordField();
        } else if (VWindow.class == classType) {
            return new VWindow();
        } else {
            return null; // let generated type handle this
        }
    }

    public abstract Class<? extends Paintable> getImplementationByServerSideClassName(
            String fullyqualifiedName);

}