Source Code Cross Referenced for ExpandItem.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:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *     Darrell Meyer <darrell@mygwt.net> - derived implementation
011:         *******************************************************************************/package net.mygwt.ui.client.widget;
012:
013:        import net.mygwt.ui.client.Events;
014:        import net.mygwt.ui.client.event.BaseEvent;
015:        import net.mygwt.ui.client.event.Listener;
016:
017:        import com.google.gwt.user.client.DOM;
018:        import com.google.gwt.user.client.Timer;
019:        import com.google.gwt.user.client.ui.WidgetHelper;
020:
021:        /**
022:         * A item in a <code>ExpandBar</code>.
023:         * 
024:         * <dl>
025:         * <dt><b>Events:</b></dt>
026:         * 
027:         * <dd><b>BeforeExpand</b> : (widget)<br>
028:         * <div>Fires before an item is expanded. Listeners can set the
029:         * <code>doit</code> field to <code>false</code> to cancel the expand.</div>
030:         * <ul>
031:         * <li>widget : this</li>
032:         * </ul>
033:         * </dd>
034:         * 
035:         * <dd><b>BeforeCollapse</b> : (widget)<br>
036:         * <div>Fires before an item is collapsed. Listeners can set the
037:         * <code>doit</code> field to <code>false</code> to cancel the collapse.</div>
038:         * <ul>
039:         * <li>widget : this</li>
040:         * </ul>
041:         * </dd>
042:         * 
043:         * <dd><b>Expand</b> : (widget)<br>
044:         * <div>Fires after an item has been expanded.</div>
045:         * <ul>
046:         * <li>widget : this</li>
047:         * </ul>
048:         * </dd>
049:         * 
050:         * <dd><b>Collapse</b> : (widget)<br>
051:         * <div>Fires ater a item is collapsed.</div>
052:         * <ul>
053:         * <li>widget : this</li>
054:         * </ul>
055:         * </dd>
056:         * 
057:         * <dt><b>CSS:</b></dt>
058:         * <dd>.my-expand-item (the item itself)</dd>
059:         * <dd>.my-expand-item-hdr (the item header)</dd>
060:         * <dd>.my-expand-item-hdr-text (the header text)</dd>
061:         * </dl>
062:         */
063:        public class ExpandItem extends Component {
064:
065:            protected WidgetContainer content;
066:            protected IconButton collapseBtn;
067:
068:            boolean expanded;
069:            ExpandBar parent;
070:            Item header;
071:            private boolean expandOnAttach;
072:
073:            /**
074:             * Creates a new expand item.
075:             */
076:            public ExpandItem() {
077:                baseStyle = "my-expand-item";
078:                header = new Item() {
079:                    protected void onClick(BaseEvent be) {
080:                        super .onClick(be);
081:                        if (parent.headerCollapse) {
082:                            setExpanded(!isExpanded());
083:                        }
084:                    }
085:                };
086:                content = new WidgetContainer();
087:                content.setStyleAttribute("position", "relative");
088:            }
089:
090:            /**
091:             * Returns the item's content container.
092:             * 
093:             * @return the content container
094:             */
095:            public WidgetContainer getContainer() {
096:                return content;
097:            }
098:
099:            /**
100:             * Returns the item's header.
101:             * 
102:             * @return the header
103:             */
104:            public Item getHeader() {
105:                return header;
106:            }
107:
108:            /**
109:             * Returns the item's text.
110:             * 
111:             * @return the text
112:             */
113:            public String getText() {
114:                return header.getText();
115:            }
116:
117:            /**
118:             * Returns <code>true</code> if the item is expanded, and <code>false</code>
119:             * otherwise.
120:             * 
121:             * @return the expanded state
122:             */
123:            public boolean isExpanded() {
124:                return expanded;
125:            }
126:
127:            /**
128:             * Sets the expanded state of the item.
129:             * 
130:             * @param expanded the new expanded state
131:             */
132:            public void setExpanded(boolean expanded) {
133:                if (!isAttached()) {
134:                    if (expanded) {
135:                        expandOnAttach = true;
136:                    }
137:                    return;
138:                }
139:                if (expanded) {
140:                    if (parent.fireEvent(Events.BeforeExpand, parent, this )
141:                            && fireEvent(Events.BeforeExpand)) {
142:                        this .expanded = expanded;
143:                        parent.expand(this );
144:                    }
145:                } else {
146:                    if (parent.fireEvent(Events.BeforeCollapse, parent, this )
147:                            && fireEvent(Events.BeforeCollapse)) {
148:                        this .expanded = expanded;
149:                        parent.collapse(this );
150:                    }
151:                }
152:
153:            }
154:
155:            public void setHeight(int height) {
156:                header.setHeight(height);
157:            }
158:
159:            /**
160:             * Sets the item's icon style.
161:             * 
162:             * @param iconStyle the icon style
163:             */
164:            public void setIconStyle(String iconStyle) {
165:                header.setIconStyle(iconStyle);
166:            }
167:
168:            /**
169:             * Sets the item's text.
170:             * 
171:             * @param text the text
172:             */
173:            public void setText(String text) {
174:                header.setText(text);
175:            }
176:
177:            protected void doAttachChildren() {
178:                WidgetHelper.doAttach(header);
179:                WidgetHelper.doAttach(content);
180:
181:                content.layout();
182:            }
183:
184:            protected void doDetachChildren() {
185:                WidgetHelper.doDetach(header);
186:                WidgetHelper.doDetach(content);
187:            }
188:
189:            protected void onLoad() {
190:                if (expandOnAttach) {
191:                    expandOnAttach = false;
192:                    Timer t = new Timer() {
193:                        public void run() {
194:                            setExpanded(true);
195:                        }
196:                    };
197:                    t.schedule(200);
198:                }
199:            }
200:
201:            protected void onRender() {
202:                setElement(DOM.createDiv());
203:                setStyleName(baseStyle);
204:
205:                collapseBtn = new ToolButton("my-tool-plus");
206:                collapseBtn.addListener(Events.Click, new Listener() {
207:                    public void handleEvent(BaseEvent be) {
208:                        setExpanded(!isExpanded());
209:                        be.stopEvent();
210:                    }
211:                });
212:
213:                header.baseStyle = baseStyle + "-hdr";
214:                header.addWidget(collapseBtn);
215:
216:                DOM.appendChild(getElement(), header.getElement());
217:                DOM.appendChild(getElement(), content.getElement());
218:
219:                content.setStyleName(baseStyle + "-body");
220:                content.setVisible(false);
221:
222:                header.setWidth("100%");
223:
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.