Source Code Cross Referenced for TableItem.java in  » Ajax » MyGWT » net » mygwt » ui » client » widget » table » 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.table 
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.table;
009:
010:        import net.mygwt.ui.client.Events;
011:        import net.mygwt.ui.client.Style;
012:        import net.mygwt.ui.client.event.BaseEvent;
013:        import net.mygwt.ui.client.widget.Component;
014:        import net.mygwt.ui.client.widget.ToolTip;
015:
016:        import com.google.gwt.user.client.DOM;
017:        import com.google.gwt.user.client.Element;
018:        import com.google.gwt.user.client.ui.Widget;
019:
020:        /**
021:         * A row in a <code>Table</code>.
022:         */
023:        public class TableItem extends Component {
024:
025:            String[] toolTips;
026:            ToolTip cellToolTip;
027:            boolean hasWidgets;
028:            String[] cellStyles;
029:            boolean cellsRendered;
030:            private Table table;
031:            private Object[] values;
032:
033:            /**
034:             * Creates a new table item.
035:             * 
036:             * @param values the cell values
037:             */
038:            public TableItem(Object[] values) {
039:                this .values = values;
040:            }
041:
042:            /**
043:             * Returns the item's cell tooltip.
044:             * 
045:             * @return the tooltip
046:             */
047:            public ToolTip getCellToolTip() {
048:                return cellToolTip;
049:            }
050:
051:            /**
052:             * Returns the item's parent table.
053:             * 
054:             * @return the table
055:             */
056:            public Table getTable() {
057:                return table;
058:            }
059:
060:            /**
061:             * Returns a cell value.
062:             * 
063:             * @param index the cell index
064:             * @return the value
065:             */
066:            public Object getValue(int index) {
067:                return values[index];
068:            }
069:
070:            /**
071:             * Returns the item's values.
072:             * 
073:             * @return the values
074:             */
075:            public Object[] getValues() {
076:                return values;
077:            }
078:
079:            public void onBaseEvent(BaseEvent be) {
080:                // Pass along the event to the related cell tooltip if it exists
081:                // so that we don't consume the event before the tooltip processes it
082:                if (cellToolTip != null) {
083:                    cellToolTip.handleEvent(be);
084:                }
085:
086:                switch (be.type) {
087:                case Events.Click:
088:                    onClick(be);
089:                    break;
090:                case Events.DoubleClick:
091:                    onDoubleClick(be);
092:                    break;
093:                case Events.MouseOver:
094:                    onMouseOver(be);
095:                    break;
096:                case Events.MouseOut:
097:                    onMouseOut(be);
098:                    break;
099:                }
100:            }
101:
102:            /**
103:             * Sets the style for a cell.
104:             * 
105:             * @param index the column index
106:             * @param style the new style
107:             */
108:            public void setCellStyle(int index, String style) {
109:                if (cellStyles == null)
110:                    cellStyles = new String[values.length];
111:                cellStyles[index] = style;
112:                if (isRendered()) {
113:                    table.getView().setCellStyle(this , index, style);
114:                }
115:            }
116:
117:            /**
118:             * Sets a cell tooltip.
119:             * 
120:             * @param index the column index
121:             * @param text the text of the tool tip
122:             */
123:            public void setCellToolTip(int index, String text) {
124:                if (toolTips == null)
125:                    toolTips = new String[values.length];
126:                toolTips[index] = text;
127:                initCellToolTips();
128:            }
129:
130:            /**
131:             * Sets all of the cell tooltips
132:             * 
133:             * @param toolTips the tool tips to use
134:             */
135:            public void setCellToolTips(String[] toolTips) {
136:                this .toolTips = toolTips;
137:                initCellToolTips();
138:            }
139:
140:            /**
141:             * Sets a cell value.
142:             * 
143:             * @param index the column index
144:             * @param text the text
145:             */
146:            public void setText(int index, String text) {
147:                setValue(index, text);
148:            }
149:
150:            /**
151:             * Sets a cell value.
152:             * 
153:             * @param index the column index
154:             * @param value the value
155:             */
156:            public void setValue(int index, Object value) {
157:                values[index] = value;
158:                if (rendered) {
159:                    table.getView().renderItemValue(this , index, value);
160:                }
161:            }
162:
163:            /**
164:             * Sets a widget as a cell value.
165:             * 
166:             * @param index the column index
167:             * @param widget the widget
168:             */
169:            public void setWidget(int index, Widget widget) {
170:                hasWidgets = true;
171:                setValue(index, widget);
172:            }
173:
174:            protected void init(Table table) {
175:                this .table = table;
176:            }
177:
178:            protected void initCellToolTips() {
179:                if (cellToolTip == null && isRendered()) {
180:                    cellToolTip = new ToolTip(this );
181:                    cellToolTip.setTrackMouse(true);
182:                }
183:            }
184:
185:            protected void onCellMouseOver(BaseEvent be) {
186:                Element target = be.getTarget();
187:
188:                int index = table.getView().getCellIndex(target);
189:                if (index == Style.DEFAULT) {
190:                    return;
191:                }
192:
193:                if (cellToolTip != null) {
194:                    if (toolTips != null && toolTips[index] != null
195:                            && toolTips[index].length() > 0) {
196:                        cellToolTip.setText(null, toolTips[index]);
197:                        cellToolTip.setVisible(true);
198:                    } else {
199:                        cellToolTip.setVisible(false);
200:                    }
201:                }
202:            }
203:
204:            protected void onClick(BaseEvent be) {
205:                Element target = be.getTarget();
206:
207:                int index = table.getView().getCellIndex(target);
208:                if (index == Style.DEFAULT) {
209:                    return;
210:                }
211:
212:                be.widget = table;
213:                be.item = this ;
214:                be.rowIndex = table.indexOf(this );
215:                be.index = index;
216:
217:                table.fireEvent(Events.CellClick, be);
218:                table.fireEvent(Events.RowClick, be);
219:            }
220:
221:            protected void onDoubleClick(BaseEvent be) {
222:                Element target = be.getTarget();
223:
224:                int index = table.getView().getCellIndex(target);
225:                if (index == Style.DEFAULT) {
226:                    return;
227:                }
228:                BaseEvent evt = new BaseEvent();
229:                evt.widget = table;
230:                evt.item = this ;
231:                evt.rowIndex = table.indexOf(this );
232:                evt.index = index;
233:
234:                table.fireEvent(Events.CellDoubleClick, evt);
235:                table.fireEvent(Events.RowDoubleClick, evt);
236:            }
237:
238:            protected void onMouseOut(BaseEvent be) {
239:                table.getView().onHighlightRow(this , false);
240:            }
241:
242:            protected void onMouseOver(BaseEvent be) {
243:                table.getView().onHighlightRow(this , true);
244:                onCellMouseOver(be);
245:            }
246:
247:            protected void onRender() {
248:                setElement(DOM.createDiv());
249:            }
250:
251:            protected void setSelected(boolean select) {
252:                table.getView().onSelectItem(this, select);
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.