Source Code Cross Referenced for ToolBar.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:
015:        import com.google.gwt.user.client.DOM;
016:        import com.google.gwt.user.client.ui.HorizontalPanel;
017:        import com.google.gwt.user.client.ui.WidgetHelper;
018:
019:        /**
020:         * A standard tool bar.
021:         * 
022:         * <dt><b>Events:</b></dt>
023:         * 
024:         * <dd><b>BeforeAdd</b> : (widget, item, index)<br>
025:         * <div>Fires before a item is added or inserted. Listeners can set the
026:         * <code>doit</code> field to <code>false</code> to cancel the action.</div>
027:         * <ul>
028:         * <li>widget : this</li>
029:         * <li>item : the item being added</li>
030:         * <li>index : the index at which the item will be added</li>
031:         * </ul>
032:         * </dd>
033:         * 
034:         * <dd><b>BeforeRemove</b> : (widget, item)<br>
035:         * <div>Fires before a item is removed. Listeners can set the <code>doit</code>
036:         * field to <code>false</code> to cancel the action.</div>
037:         * <ul>
038:         * <li>widget : this</li>
039:         * <li>item : the item being removed</li>
040:         * </ul>
041:         * </dd>
042:         * 
043:         * <dd><b>Add</b> : (widget, item, index)<br>
044:         * <div>Fires after a item has been added or inserted.</div>
045:         * <ul>
046:         * <li>widget : this</li>
047:         * <li>item : the item that was added</li>
048:         * <li>index : the index at which the item will be added</li>
049:         * </ul>
050:         * </dd>
051:         * 
052:         * <dd><b>Remove</b> : (widget, item)<br>
053:         * <div>Fires after a item has been removed.</div>
054:         * <ul>
055:         * <li>widget : this</li>
056:         * <li>item : the item being removed</li>
057:         * </ul>
058:         * </dd>
059:         * 
060:         * <dt><b>CSS:</b></dt>
061:         * <dd>my-toolbar (the tool bar)</dd>
062:         * </dl>
063:         * 
064:         * @see ToolItem
065:         */
066:        public class ToolBar extends Container {
067:
068:            private HorizontalPanel panel;
069:
070:            /**
071:             * Creates a new tool bar.
072:             */
073:            public ToolBar() {
074:                attachChildren = false;
075:                baseStyle = "my-toolbar";
076:            }
077:
078:            /**
079:             * Adds a item to the tool bar.
080:             * 
081:             * @param item the item to add
082:             */
083:            public void add(ToolItem item) {
084:                insert(item, getItemCount());
085:            }
086:
087:            /**
088:             * Returns the item at the specified index.
089:             * 
090:             * @param index the item index
091:             * @return the item at the index
092:             */
093:            public ToolItem getItem(int index) {
094:                if ((index < 0) || (index >= items.size()))
095:                    return null;
096:                return (ToolItem) items.get(index);
097:            }
098:
099:            /**
100:             * Returns the number of tool item's.
101:             * 
102:             * @return the item count
103:             */
104:            public int getItemCount() {
105:                return items.size();
106:            }
107:
108:            /**
109:             * Returns the index of the item.
110:             * 
111:             * @param item the item
112:             * @return the index
113:             */
114:            public int indexOf(ToolItem item) {
115:                return items.indexOf(item);
116:            }
117:
118:            /**
119:             * Inserts a item into the tool bar.
120:             * 
121:             * @param item the item to add
122:             * @param index the insert location
123:             */
124:            public void insert(ToolItem item, int index) {
125:                if (fireEvent(Events.BeforeAdd, this , item, index)) {
126:                    items.add(index, item);
127:                    if (rendered) {
128:                        renderItem(item, index);
129:                    }
130:                    fireEvent(Events.Add, this , item, index);
131:                }
132:            }
133:
134:            /**
135:             * Removes a tool item.
136:             * 
137:             * @param item the item to be removed
138:             */
139:            public void remove(ToolItem item) {
140:                if (fireEvent(Events.BeforeRemove, this , item)) {
141:                    items.remove(item);
142:                    if (rendered) {
143:                        panel.remove(item);
144:                    }
145:                    fireEvent(Events.Remove, this , item);
146:                }
147:            }
148:
149:            /**
150:             * Removes all tool items.
151:             */
152:            public void removeAll() {
153:                int size = getItemCount();
154:                for (int i = 0; i < size; i++) {
155:                    ToolItem item = getItem(0);
156:                    remove(item);
157:                }
158:            }
159:
160:            protected void doAttachChildren() {
161:                WidgetHelper.doAttach(panel);
162:            }
163:
164:            protected void doDetachChildren() {
165:                WidgetHelper.doDetach(panel);
166:            }
167:
168:            protected void onRender() {
169:                setElement(DOM.createDiv());
170:                setStyleName(baseStyle);
171:
172:                panel = new HorizontalPanel();
173:                panel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
174:                panel.setSpacing(2);
175:
176:                DOM.appendChild(getElement(), panel.getElement());
177:
178:                renderAll();
179:            }
180:
181:            private void renderAll() {
182:                int count = getItemCount();
183:                for (int i = 0; i < count; i++) {
184:                    ToolItem item = getItem(i);
185:                    renderItem(item, i);
186:                }
187:            }
188:
189:            private void renderItem(ToolItem item, int index) {
190:                panel.insert(item, index);
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.