View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.widgets;
17  
18  import org.kuali.student.common.ui.client.widgets.impl.KSButtonImpl;
19  
20  import com.google.gwt.core.client.GWT;
21  import com.google.gwt.event.dom.client.ClickHandler;
22  import com.google.gwt.event.dom.client.MouseOutHandler;
23  import com.google.gwt.event.dom.client.MouseOverHandler;
24  import com.google.gwt.event.shared.HandlerRegistration;
25  
26  /**
27   * KSButton wraps gwt Button.  This class provides most of the same functionality, but sets KS css styles
28   * for its default look and a variety of button events (for improved browser compatibility and customizability).
29   * An image can be also be added to a KSButton (an improvement over gwt Button).
30   * 
31   * @author Kuali Student Team
32   *
33   */
34  public class KSButton extends KSButtonAbstract{
35  	
36  	KSButtonAbstract button = GWT.create(KSButtonImpl.class);
37  	
38  	public boolean isEnabled() {
39  		return button.isEnabled();
40  	}
41  
42  	public void setEnabled(boolean enabled) {
43  		button.setEnabled(enabled);
44  	}
45  	
46  	public KSButton(){
47  		this.init();
48  		this.initWidget(button);
49  	}
50  	
51  	public KSButton(String text, ClickHandler handler){
52  		this.init(text, handler);
53  		this.initWidget(button);
54  	}	
55  	
56  	public KSButton(String text){
57  		this.init(text);
58  		this.initWidget(button);
59  	}
60  	
61  	public KSButton(String text, ButtonStyle style){
62  		this.init(text, style);
63  		this.initWidget(button);
64  	}
65  
66      public KSButton(String text, ButtonStyle style, ClickHandler handler){
67          this.init(text, style, handler);
68          this.initWidget(button);
69      }   
70      
71      public void setText(String text){
72          button.setText(text);
73      }
74      
75  	@Override
76  	public HandlerRegistration addClickHandler(ClickHandler handler) {
77  		return button.addClickHandler(handler);
78  	}
79  
80  	@Override
81  	public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
82  		return button.addMouseOverHandler(handler);
83  	}
84  
85  	@Override
86  	public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
87  		return button.addMouseOutHandler(handler);
88  	}
89  
90      @Override
91      public void init() {
92          button.init();
93      }	
94  	
95  	@Override
96  	public void init(String text) {
97  		button.init(text);
98  	}
99  
100 	@Override
101 	public void init(String text, ButtonStyle style) {
102 		button.init(text, style);		
103 	}
104 
105     public void init(String text, ButtonStyle style, ClickHandler handler) {
106         button.init(text, style, handler);       
107     }	
108 	
109 	@Override
110 	public void init(String text, ClickHandler handler) {
111 		button.init(text, handler);
112 	}
113 	
114     @Override
115     public void addStyleName(String style) {
116         button.addStyleName(style);
117     }
118 
119     @Override
120     public void removeStyleName(String style) {
121         button.removeStyleName(style);
122     }
123 
124     @Override
125     public void setStyleName(String style) {
126         button.setStyleName(style);
127     }	
128 }