Source Code Cross Referenced for ViewerCell.java in  » IDE-Eclipse » jface » org » eclipse » jface » viewers » 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 » IDE Eclipse » jface » org.eclipse.jface.viewers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 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:         *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
011:         *     											 - fix in bug: 195908,198035
012:         *******************************************************************************/package org.eclipse.jface.viewers;
013:
014:        import org.eclipse.swt.graphics.Color;
015:        import org.eclipse.swt.graphics.Font;
016:        import org.eclipse.swt.graphics.Image;
017:        import org.eclipse.swt.graphics.Rectangle;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.swt.widgets.Item;
020:        import org.eclipse.swt.widgets.Widget;
021:
022:        /**
023:         * The ViewerCell is the JFace representation of a cell entry in a ViewerRow.
024:         *
025:         * @since 3.3
026:         *
027:         */
028:        public class ViewerCell {
029:            private int columnIndex;
030:
031:            private ViewerRow row;
032:
033:            private Object element;
034:
035:            /**
036:             * Constant denoting the cell above current one (value is 1).
037:             */
038:            public static int ABOVE = 1;
039:
040:            /**
041:             * Constant denoting the cell below current one (value is 2).
042:             */
043:            public static int BELOW = 1 << 1;
044:
045:            /**
046:             * Constant denoting the cell to the left of the current one (value is 4).
047:             */
048:            public static int LEFT = 1 << 2;
049:
050:            /**
051:             * Constant denoting the cell to the right of the current one (value is 8).
052:             */
053:            public static int RIGHT = 1 << 3;
054:
055:            /**
056:             * Create a new instance of the receiver on the row.
057:             *
058:             * @param row
059:             * @param columnIndex
060:             */
061:            ViewerCell(ViewerRow row, int columnIndex, Object element) {
062:                this .row = row;
063:                this .columnIndex = columnIndex;
064:                this .element = element;
065:            }
066:
067:            /**
068:             * Get the index of the cell.
069:             *
070:             * @return the index
071:             */
072:            public int getColumnIndex() {
073:                return columnIndex;
074:            }
075:
076:            /**
077:             * Get the bounds of the cell.
078:             *
079:             * @return {@link Rectangle}
080:             */
081:            public Rectangle getBounds() {
082:                return row.getBounds(columnIndex);
083:            }
084:
085:            /**
086:             * Get the element this row represents.
087:             *
088:             * @return {@link Object}
089:             */
090:            public Object getElement() {
091:                if (element != null) {
092:                    return element;
093:                }
094:                return row.getElement();
095:            }
096:
097:            /**
098:             * Return the text for the cell.
099:             *
100:             * @return {@link String}
101:             */
102:            public String getText() {
103:                return row.getText(columnIndex);
104:            }
105:
106:            /**
107:             * Return the Image for the cell.
108:             *
109:             * @return {@link Image} or <code>null</code>
110:             */
111:            public Image getImage() {
112:                return row.getImage(columnIndex);
113:            }
114:
115:            /**
116:             * Set the background color of the cell.
117:             *
118:             * @param background
119:             */
120:            public void setBackground(Color background) {
121:                row.setBackground(columnIndex, background);
122:
123:            }
124:
125:            /**
126:             * Set the foreground color of the cell.
127:             *
128:             * @param foreground
129:             */
130:            public void setForeground(Color foreground) {
131:                row.setForeground(columnIndex, foreground);
132:
133:            }
134:
135:            /**
136:             * Set the font of the cell.
137:             *
138:             * @param font
139:             */
140:            public void setFont(Font font) {
141:                row.setFont(columnIndex, font);
142:
143:            }
144:
145:            /**
146:             * Set the text for the cell.
147:             *
148:             * @param text
149:             */
150:            public void setText(String text) {
151:                row.setText(columnIndex, text);
152:
153:            }
154:
155:            /**
156:             * Set the Image for the cell.
157:             *
158:             * @param image
159:             */
160:            public void setImage(Image image) {
161:                row.setImage(columnIndex, image);
162:
163:            }
164:
165:            /**
166:             * Set the columnIndex.
167:             *
168:             * @param column
169:             */
170:            void setColumn(int column) {
171:                columnIndex = column;
172:
173:            }
174:
175:            /**
176:             * Set the row to rowItem and the columnIndex to column.
177:             *
178:             * @param rowItem
179:             * @param column
180:             */
181:            void update(ViewerRow rowItem, int column, Object element) {
182:                row = rowItem;
183:                columnIndex = column;
184:                this .element = element;
185:            }
186:
187:            /**
188:             * Return the item for the receiver.
189:             *
190:             * @return {@link Item}
191:             */
192:            public Widget getItem() {
193:                return row.getItem();
194:            }
195:
196:            /**
197:             * Get the control for this cell.
198:             *
199:             * @return {@link Control}
200:             */
201:            public Control getControl() {
202:                return row.getControl();
203:            }
204:
205:            /**
206:             * Get the current index. This can be different from the original index when
207:             * columns are reordered
208:             *
209:             * @return the current index (as shown in the UI)
210:             * @since 3.4
211:             */
212:            public int getVisualIndex() {
213:                return row.getVisualIndex(getColumnIndex());
214:            }
215:
216:            /**
217:             * Returns the specified neighbor of this cell, or <code>null</code> if no
218:             * neighbor exists in the given direction. Direction constants can be
219:             * combined by bitwise OR; for example, this method will return the cell to
220:             * the upper-left of the current cell by passing {@link #ABOVE} |
221:             * {@link #LEFT}. If <code>sameLevel</code> is <code>true</code>, only
222:             * cells in sibling rows (under the same parent) will be considered.
223:             *
224:             * @param directionMask
225:             *            the direction mask used to identify the requested neighbor
226:             *            cell
227:             * @param sameLevel
228:             *            if <code>true</code>, only consider cells from sibling rows
229:             * @return the requested neighbor cell, or <code>null</code> if not found
230:             */
231:            public ViewerCell getNeighbor(int directionMask, boolean sameLevel) {
232:                ViewerRow row;
233:
234:                if ((directionMask & ABOVE) == ABOVE) {
235:                    row = this .row.getNeighbor(ViewerRow.ABOVE, sameLevel);
236:                } else if ((directionMask & BELOW) == BELOW) {
237:                    row = this .row.getNeighbor(ViewerRow.BELOW, sameLevel);
238:                } else {
239:                    row = this .row;
240:                }
241:
242:                if (row != null) {
243:                    int columnIndex;
244:                    columnIndex = getVisualIndex();
245:
246:                    if ((directionMask & LEFT) == LEFT) {
247:                        columnIndex -= 1;
248:                    } else if ((directionMask & RIGHT) == RIGHT) {
249:                        columnIndex += 1;
250:                    }
251:
252:                    if (columnIndex >= 0 && columnIndex < row.getColumnCount()) {
253:                        return row.getCellAtVisualIndex(columnIndex);
254:                    }
255:                }
256:
257:                return null;
258:            }
259:
260:            /**
261:             * @return the row
262:             */
263:            public ViewerRow getViewerRow() {
264:                return row;
265:            }
266:
267:            /*
268:             * (non-Javadoc)
269:             *
270:             * @see java.lang.Object#hashCode()
271:             */
272:            public int hashCode() {
273:                final int prime = 31;
274:                int result = 1;
275:                result = prime * result + columnIndex;
276:                result = prime * result + ((row == null) ? 0 : row.hashCode());
277:                return result;
278:            }
279:
280:            /*
281:             * (non-Javadoc)
282:             *
283:             * @see java.lang.Object#equals(java.lang.Object)
284:             */
285:            public boolean equals(Object obj) {
286:                if (this  == obj)
287:                    return true;
288:                if (obj == null)
289:                    return false;
290:                if (getClass() != obj.getClass())
291:                    return false;
292:                final ViewerCell other = (ViewerCell) obj;
293:                if (columnIndex != other.columnIndex)
294:                    return false;
295:                if (row == null) {
296:                    if (other.row != null)
297:                        return false;
298:                } else if (!row.equals(other.row))
299:                    return false;
300:                return true;
301:            }
302:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.