Source Code Cross Referenced for Button.java in  » Ajax » MyGWT » net » mygwt » ui » client » widget » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » MyGWT » net.mygwt.ui.client.widget 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * MyGWT Widget Library
003:         * Copyright(c) 2007, MyGWT.
004:         * licensing@mygwt.net
005:         * 
006:         * http://mygwt.net/license
007:         */
008:        package net.mygwt.ui.client.widget;
009:
010:        import net.mygwt.ui.client.Events;
011:        import net.mygwt.ui.client.MyDOM;
012:        import net.mygwt.ui.client.Style;
013:        import net.mygwt.ui.client.event.BaseEvent;
014:        import net.mygwt.ui.client.event.SelectionListener;
015:        import net.mygwt.ui.client.event.TypedListener;
016:        import net.mygwt.ui.client.util.Markup;
017:
018:        import com.google.gwt.user.client.DOM;
019:        import com.google.gwt.user.client.Element;
020:
021:        /**
022:         * A standard push button.
023:         * 
024:         * <dl>
025:         * <dt>Events:</dt>
026:         * 
027:         * <dd><b>Select</b> : (widget)<br>
028:         * <div>Fires after the button is selected.</div>
029:         * <ul>
030:         * <li>widget : this</li>
031:         * </ul>
032:         * </dd>
033:         * 
034:         * <dt><b>CSS:</b></dt>
035:         * <dd>.my-btn (the button itself)</dd>
036:         * <dd>.my-btn .my-btn-text (the button text)</dd>
037:         * </dl>
038:         */
039:        public class Button extends Item {
040:
041:            private int buttonId;
042:            private String name;
043:            private int tabIndex = Style.DEFAULT;
044:
045:            /**
046:             * Creates a new button.
047:             */
048:            public Button() {
049:                baseStyle = "my-btn";
050:            }
051:
052:            /**
053:             * Creates a new button with the given text.
054:             * 
055:             * @param text the button's text
056:             */
057:            public Button(String text) {
058:                this ();
059:                setText(text);
060:            }
061:
062:            /**
063:             * Creates a new button with the given text and specified event listener.
064:             * 
065:             * @param text the button's text
066:             * @param listener the selection listener
067:             */
068:            public Button(String text, SelectionListener listener) {
069:                this (text);
070:                addSelectionListener(listener);
071:            }
072:
073:            /**
074:             * Adds a listener interface to receive selection events.
075:             * 
076:             * @param listener the listener to add
077:             */
078:            public void addSelectionListener(SelectionListener listener) {
079:                TypedListener tl = new TypedListener(listener);
080:                addListener(Events.Select, tl);
081:            }
082:
083:            /**
084:             * Returns the button's id. The button id differs from the component id as it
085:             * does not have to be unique and is typically used when grouping sets of buttons.
086:             * 
087:             * @return the button id
088:             */
089:            public int getButtonId() {
090:                return buttonId;
091:            }
092:
093:            /**
094:             * Returns button's name.
095:             * 
096:             * @return the button name
097:             */
098:            public String getName() {
099:                return name;
100:            }
101:
102:            /**
103:             * Removes a previously added listener.
104:             * 
105:             * @param listener the listener to be removed
106:             */
107:            public void removeSelectionListener(SelectionListener listener) {
108:                unhook(Events.Select, listener);
109:            }
110:
111:            /**
112:             * Sets the button's id.
113:             * 
114:             * @param id the button id
115:             */
116:            public void setButtonId(int id) {
117:                this .buttonId = id;
118:            }
119:
120:            public void setIconStyle(String style) {
121:                addStyleName("my-btn-icon");
122:                super .setIconStyle(style);
123:            }
124:
125:            /**
126:             * Sets the button's name.
127:             * 
128:             * @param name the button name
129:             */
130:            public void setName(String name) {
131:                this .name = name;
132:                if (rendered) {
133:                    DOM.setElementProperty(getElement(), "name", name);
134:                }
135:            }
136:
137:            /**
138:             * Sets the button's tab index.
139:             * 
140:             * @param index the tab index
141:             */
142:            public void setTabIndex(int index) {
143:                this .tabIndex = index;
144:                if (isRendered()) {
145:                    DOM.setElementPropertyInt(textElem, "tabIndex", index);
146:                }
147:            }
148:
149:            protected Element getFocusElement() {
150:                return textElem;
151:            }
152:
153:            protected String getTemplate() {
154:                return Markup.BUTTON;
155:            }
156:
157:            protected void onClick(BaseEvent be) {
158:                super .onClick(be);
159:                fireEvent(Events.Select);
160:            }
161:
162:            protected void onDisable() {
163:                super .onDisable();
164:                DOM.setElementProperty(textElem, "disabled", "true");
165:            }
166:
167:            protected void onEnable() {
168:                super .onEnable();
169:                DOM.setElementProperty(textElem, "disabled", "");
170:            }
171:
172:            protected void onMouseDown(BaseEvent be) {
173:                super .onMouseDown(be);
174:                MyDOM.setFocus(textElem, true);
175:            }
176:
177:            protected void onRender() {
178:                super .onRender();
179:                setDisabledStyle(baseStyle + "-disabled");
180:                if (name != null) {
181:                    setName(name);
182:                }
183:                if (tabIndex != Style.DEFAULT) {
184:                    setTabIndex(tabIndex);
185:                }
186:            }
187:
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.