View Javadoc

1   /*
2    * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.gwtwidgets.client.wwrapper;
18  
19  import com.google.gwt.user.client.DOM;
20  import com.google.gwt.user.client.Element;
21  import com.google.gwt.user.client.Event;
22  import com.google.gwt.user.client.ui.Button;
23  import com.google.gwt.user.client.ui.ClickListener;
24  
25  public class WButton extends Button implements WrappedWidget
26  {
27      private static final String WIDGET_TYPE = "button";
28  
29      public WButton (String id)
30          throws ElementNotFoundException
31      {
32          super();
33          
34          Element e = DOM.getElementById(id);
35          
36          if (e == null) {
37              throw new ElementNotFoundException(id);
38          }
39          
40          setElement(e);
41          sinkEvents(Event.ONCLICK);
42          WBuilder.resetElement(this);
43      }
44  
45      public WButton (Element element)
46      {
47          super();
48          setElement(element);
49          sinkEvents(Event.ONCLICK);
50          WBuilder.resetElement(this);
51      }
52  
53      public String getWidgetType ()
54      {
55          return WIDGET_TYPE;
56      }
57      
58      public void addClickListener(ClickListener listener) 
59      {
60          super.addClickListener(listener);
61      }
62  
63  }