ReservationWidgetSet.java
/* 
 * Copyright 2009 IT Mill 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.itmill.toolkit.demo.reservation.gwt.client;

import com.itmill.toolkit.demo.reservation.gwt.client.ui.ICalendarField;
import com.itmill.toolkit.demo.reservation.gwt.client.ui.IGoogleMap;
import com.itmill.toolkit.terminal.gwt.client.DefaultWidgetSet;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;

public class ReservationWidgetSet extends DefaultWidgetSet {
    @Override
    public Paintable createWidget(UIDL uidl) {
        final Class type = resolveWidgetType(uidl);
        if (IGoogleMap.class == type) {
            return new IGoogleMap();
        else if (ICalendarField.class == type) {
            return new ICalendarField();
        }

        return super.createWidget(uidl);
    }

    @Override
    protected Class resolveWidgetType(UIDL uidl) {
        final String tag = uidl.getTag();
        if ("googlemap".equals(tag)) {
            return IGoogleMap.class;
        else if ("calendarfield".equals(tag)) {
            return ICalendarField.class;
        }
        return super.resolveWidgetType(uidl);
    }

}