Source Code Cross Referenced for CycleButton.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » 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 » gwtext 2.01 » com.gwtext.client.widgets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:        package com.gwtext.client.widgets;
009:
010:        import com.google.gwt.core.client.JavaScriptObject;
011:        import com.gwtext.client.widgets.event.ButtonListener;
012:        import com.gwtext.client.widgets.event.CycleButtonListener;
013:        import com.gwtext.client.widgets.menu.CheckItem;
014:
015:        /**
016:         * A specialized SplitButton that contains a menu of {@link CheckItem} elements. The button automatically cycles through
017:         * each menu item on click, raising the button's change event (or calling the button's changeHandler function, if supplied)
018:         * for the active menu item. Clicking on the arrow section of the button displays the dropdown menu just like a normal SplitButton.
019:         * <p/>
020:         * <pre>
021:         * <code>
022:         * <p/>
023:         * CycleButtonConfig config = new CycleButtonConfig();
024:         * config.setShowText(true);
025:         * config.setPrependText("View as ");
026:         * config.addItem(new CheckItem("text only", true));
027:         * config.addItem(new CheckItem("HTML", false));
028:         *
029:         * config.setChangeHandler(new CycleButtonHandler() {
030:         *     public void execute(CycleButton self, CheckItem item) {
031:         *         MessageBox.alert("Change View", item.getText());
032:         *     }
033:         * });
034:         * <p/>
035:         * CycleButton button = new CycleButton(config);
036:         *  </code>
037:         * </pre>
038:         */
039:        public class CycleButton extends SplitButton {
040:
041:            /*	private static JavaScriptObject configPrototype;
042:
043:             static {
044:             init();
045:             }
046:
047:             private static native void init() *//*-{
048:                    var c = new $wnd.Ext.CycleButton();
049:                    @com.gwtext.client.widgets.CycleButton::configPrototype = c.initialConfig;
050:                }-*//*;
051:
052:
053:                protected JavaScriptObject getConfigPrototype() {
054:            		return configPrototype;
055:            	}*/
056:
057:            public String getXType() {
058:                return "cycle";
059:            }
060:
061:            /**
062:             * Create a new CycleButton.
063:             */
064:            public CycleButton() {
065:            }
066:
067:            /**
068:             * Create a new CycleButton.
069:             *
070:             * @param listener the button listener
071:             */
072:            public CycleButton(CycleButtonListener listener) {
073:                super (null, listener);
074:            }
075:
076:            /**
077:             * Create a new CycleButton.
078:             *
079:             * @param listener the button listener
080:             * @param icon icon image path
081:             */
082:            public CycleButton(CycleButtonListener listener, String icon) {
083:                super (null, listener, icon);
084:            }
085:
086:            public CycleButton(JavaScriptObject jsObj) {
087:                super (jsObj);
088:            }
089:
090:            private static CycleButton instance(JavaScriptObject jsObj) {
091:                return new CycleButton(jsObj);
092:            }
093:
094:            protected native JavaScriptObject create(JavaScriptObject config) /*-{
095:                   return new $wnd.Ext.CycleButton(config);
096:               }-*/;
097:
098:            /**
099:             * Gets the currently active menu item.
100:             *
101:             * @return the active menu item
102:             */
103:            public native CheckItem getActiveItem() /*-{
104:                   var button = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
105:                   var item = button.getActiveItem();
106:                   var itemJ = @com.gwtext.client.widgets.menu.CheckItem::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(item);
107:                   return itemJ;
108:               }-*/;
109:
110:            /**
111:             * Sets the button's active menu item.
112:             *
113:             * @param item the item to activate
114:             */
115:            public native void setActiveItem(CheckItem item) /*-{
116:                   var button = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
117:                   var itemJS = item.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
118:                   button.setActiveItem(itemJS);
119:               }-*/;
120:
121:            /**
122:             * Sets the button's active menu item.
123:             *
124:             * @param item         the item to activate
125:             * @param supressEvent true to prevent the button's change event from firing (defaults to false)
126:             */
127:            public native void setActiveItem(CheckItem item,
128:                    boolean supressEvent) /*-{
129:                   var button = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
130:                   var itemJS = item.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
131:                   button.setActiveItem(itemJS, supressEvent);
132:               }-*/;
133:
134:            /**
135:             * This is normally called internally on button click, but can be called externally to advance the button's active
136:             * item programmatically to the next one in the menu. If the current item is the last one in the menu the active item
137:             * will be set to the first item in the menu.
138:             */
139:            public native void toggleSelected() /*-{
140:                   var button = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
141:                   button.toggleSelected();
142:               }-*/;
143:
144:            /**
145:             * Add a CycleButton Listener.
146:             *
147:             * @param listener the listener
148:             */
149:            public native void addListener(CycleButtonListener listener)/*-{
150:
151:                    this.@com.gwtext.client.widgets.SplitButton::addListener(Lcom/gwtext/client/widgets/event/SplitButtonListener;)(listener);
152:                    var buttonJ = this;
153:
154:                    this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('change',
155:                            function(source, item) {
156:            					var itemJ = @com.gwtext.client.widgets.menu.CheckItem::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(item);
157:                                listener.@com.gwtext.client.widgets.event.CycleButtonListener::onChange(Lcom/gwtext/client/widgets/CycleButton;Lcom/gwtext/client/widgets/menu/CheckItem;)(buttonJ, itemJ);
158:                            }
159:                    );
160:                }-*/;
161:
162:            //--- config properties  ---
163:
164:            /**
165:             * Add a CheckItem config object to be used when creating the button's menu items.
166:             *
167:             * @param item check item config
168:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
169:             */
170:            public void addItem(CheckItem item) throws IllegalStateException {
171:                if (isRendered()) {
172:                    throw new IllegalStateException(
173:                            "Items can be added to the CycleButton only prior to render.");
174:                }
175:                addItemPreRender(item);
176:            }
177:
178:            private native void addItemPreRender(CheckItem item)
179:                    throws IllegalStateException/*-{
180:            		var config = this.@com.gwtext.client.widgets.Component::config;
181:                    var itemJS = item.@com.gwtext.client.widgets.Component::config;
182:                    if(!config.items) {
183:                        config.items = @com.gwtext.client.util.JavaScriptObjectHelper::createJavaScriptArray()();
184:                    }
185:                    config.items.push(itemJS);
186:                }-*/;
187:
188:            /**
189:             * A static string to prepend before the active item's text when displayed as the button's text
190:             * (only applies when showText = true, defaults to '').
191:             *
192:             * @param prependText the prepend text
193:             */
194:            public void setPrependText(String prependText) {
195:                setAttribute("prependText", prependText, true, true);
196:            }
197:
198:            /**
199:             * @return the prepend text
200:             */
201:            public String getPrependText() {
202:                return getAttribute("prependText");
203:            }
204:
205:            /**
206:             * True to display the active item's text as the button text (defaults to false).
207:             *
208:             * @param showText true to display item's text
209:             */
210:            public void setShowText(boolean showText) {
211:                setAttribute("showText", showText, true, true);
212:            }
213:
214:            /**
215:             * @return the show text
216:             */
217:            public String getShowText() {
218:                return getAttribute("showText");
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.