Source Code Cross Referenced for RDPropertyGridView.java in  » Portal » Open-Portal » components » 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 » Portal » Open Portal » components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *  NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *  Copyright (c) 1996 Netscape Communications Corporation.
006:         *  All Rights Reserved.
007:         *  Use of this Source Code is subject to the terms of the applicable
008:         *  license agreement from Netscape Communications Corporation.
009:         *
010:         *                                      ==> MCW 07/97 <==
011:         */
012:
013:        package components;
014:
015:        import netscape.application.Bitmap;
016:        import netscape.application.Button;
017:        import netscape.application.Color;
018:        import netscape.application.DragDestination;
019:        import netscape.application.DragSession;
020:        import netscape.application.Graphics;
021:        import netscape.application.Image;
022:        import netscape.application.ListItem;
023:        import netscape.application.Popup;
024:        import netscape.application.Point;
025:        import netscape.application.Rect;
026:
027:        import graphical.MouseOverGridView;
028:        import graphical.PopupCellEditor;
029:
030:        import soif.Taxonomy;
031:        import soif.TaxonomyNode;
032:
033:        import util.BTreeNode;
034:
035:        import com.indius.grid.IGridCellEditor;
036:        import com.indius.grid.IGridRowEditView;
037:        import com.indius.grid.NullValue;
038:
039:        /**
040:         * RDPropertyGridView extends IGridEditView. Implements support for
041:         * popup and checkbox cells. (MCW)
042:         */
043:
044:        public class RDPropertyGridView extends MouseOverGridView implements 
045:                DragDestination {
046:            private boolean m_editable;
047:            private Image m_editableImage;
048:            private Image m_noneditableImage;
049:            private Image m_selectedImage;
050:            private boolean m_updated = false;
051:
052:            private String m_editableFields = null; // Editable field names
053:
054:            private Taxonomy m_taxonomy;
055:
056:            public RDPropertyGridView(int x, int y, int w, int h,
057:                    Taxonomy taxonomy) {
058:                super (x, y, w, h);
059:
060:                m_taxonomy = taxonomy;
061:                initPropertyGridView();
062:            }
063:
064:            public void initPropertyGridView() {
065:                m_editableImage = new Bitmap(Header.piece,
066:                        Header.pieceImageSize.width,
067:                        Header.pieceImageSize.height);
068:
069:                m_noneditableImage = new Bitmap(Header.piecelocked,
070:                        Header.pieceImageSize.width,
071:                        Header.pieceImageSize.height);
072:
073:                m_selectedImage = new Bitmap(Header.pieceselected,
074:                        Header.pieceImageSize.width,
075:                        Header.pieceImageSize.height);
076:            }
077:
078:            /**
079:             * editableView - returns the editable stat of a view. (MCW)
080:             */
081:            public boolean editableView() {
082:                return m_editable;
083:            }
084:
085:            /**
086:             * setEditableView - Sets the editable state of a view. (MCW)
087:             */
088:            public void setEditableView(boolean flag) {
089:                m_editable = flag;
090:            }
091:
092:            /**
093:             * updatedView - returns the update status of a view. (MCW)
094:             */
095:            public boolean updatedView() {
096:                return m_updated;
097:            }
098:
099:            /**
100:             * setUpdatedView - Sets the updated status of a view. (MCW)
101:             */
102:            public void setUpdatedView(boolean flag) {
103:                m_updated = flag;
104:            }
105:
106:            /**
107:             * setEditableFields - list of editable field names
108:             */
109:            public void setEditableFields(String fieldNames) {
110:                m_editableFields = fieldNames;
111:            }
112:
113:            public boolean isEditable(int r) {
114:                while (grid().getValue(r, 1).toString().length() == 0) {
115:                    r--;
116:                }
117:
118:                String fieldName = grid().getValue(r, 1).toString();
119:
120:                if ((m_editableFields.indexOf("," + fieldName) == -1)
121:                        && (m_editableFields.indexOf(fieldName + ",") == -1)) {
122:                    return false;
123:                }
124:
125:                return true;
126:            }
127:
128:            /**
129:             * onPressCell override. Used to change the state of a checkbox
130:             * cell on a mouse click. (MCW)
131:             */
132:            public void onPressCell(int r, int c) {
133:                super .onPressCell(r, c);
134:                createGridCellEditor(r, 2);
135:            }
136:
137:            /**
138:             * editable override. Returns the editable state of a cell.  (MCW)
139:             */
140:            public boolean editable(int r, int c) {
141:                return isEditable(r);
142:            }
143:
144:            /**
145:             * setEditableRow - Set up row as editable/non-editable.  (MCW)
146:             */
147:            public void setEditableRow(int r, boolean flag) {
148:                if (flag == true) {
149:                    grid().setValue(r, 0, m_editableImage);
150:                } else {
151:                    grid().setValue(r, 0, m_noneditableImage);
152:                }
153:
154:                return;
155:            }
156:
157:            /**
158:             * createGridCellEditor - Create editor at specified location. (MCW)
159:             */
160:            public void createGridCellEditor(int r, int c) {
161:                deleteGridCellEditor(true); // destroy any existing cell editor
162:                m_editRow = r;
163:                m_editColumn = c;
164:                createGridCellEditor();
165:            }
166:
167:            /**
168:             * paintCellForeground override - Display selected image
169:             */
170:            public void paintCellForeground(Graphics g, int r, int c, Rect rect) {
171:                if (c == 0) {
172:                    // Draw selected image or let Indius draw default image.
173:                    if (isSelected(r) == true) {
174:                        m_selectedImage.drawCentered(g, rect);
175:                        return;
176:                    }
177:                }
178:
179:                super .paintCellForeground(g, r, c, rect);
180:            }
181:
182:            /*******************/
183:            /* DragDestination */
184:            /*******************/
185:
186:            public boolean dragEntered(DragSession ds) {
187:                return m_editable;
188:            }
189:
190:            public boolean dragMoved(DragSession ds) {
191:                return true;
192:            }
193:
194:            public void dragExited(DragSession ds) {
195:                return;
196:            }
197:
198:            public boolean dragDropped(DragSession ds) {
199:                if (m_editable == false) {
200:                    return false;
201:                }
202:
203:                Point destPoint = ds.destinationMousePoint();
204:                int r = locateRow(destPoint.y, 0);
205:                int i = r;
206:
207:                // Label is blank when the field has multiple values, so backup
208:                // to last non-blank entry for field name.
209:                while (grid().getValue(i, 1).toString().length() == 0) {
210:                    i--;
211:                }
212:
213:                if (grid().getValue(i, 1).toString().equalsIgnoreCase(
214:                        "classification") == false) {
215:                    return false; // Can only drag into classification
216:                }
217:
218:                ListItem li = (ListItem) ds.data(); // Get dropped item
219:                BTreeNode btn = (BTreeNode) li.data();
220:                Object o = btn.getValue();
221:
222:                if (o instanceof  TaxonomyNode) {
223:                    grid().setValue(r, 2, ((TaxonomyNode) o).getId());
224:                    addDirtyRect(cellRect(r, 2)); // Refresh classification cell
225:                    deleteGridCellEditor(false); // Destroy existing editor, dump changes
226:                }
227:
228:                m_updated = true;
229:                return true;
230:            }
231:
232:            public DragDestination acceptsDrag(DragSession ds, int x, int y) {
233:                return this ;
234:            }
235:
236:            public IGridCellEditor newGridCellEditor(int r, int c) {
237:
238:                if (c != 2) { // Not interested unless it is value column
239:                    return super .newGridCellEditor(r, c);
240:                }
241:
242:                // Label is blank when the field has multiple values, so backup
243:                // to last non-blank entry for field name.
244:                int i = r;
245:
246:                while (grid().getValue(i, 1).toString().length() == 0) {
247:                    i--;
248:                }
249:
250:                if (grid().getValue(i, 1).toString().equalsIgnoreCase(
251:                        "classification") == true) {
252:                    String selected = grid().getValue(r, 2).toString();
253:                    PopupCellEditor e = new PopupCellEditor();
254:                    m_taxonomy.binaryTree.resetEnumeration();
255:
256:                    for (i = 0; m_taxonomy.binaryTree.hasMoreElements(true); i++) {
257:                        m_taxonomy.binaryTree.nextElement(true);
258:                        Object o = m_taxonomy.binaryTree.getValue();
259:
260:                        if (o instanceof  TaxonomyNode) {
261:                            String item = ((TaxonomyNode) o).getId();
262:                            e.addItem(item, item);
263:
264:                            if (selected.compareTo(item) == 0) {
265:                                e.selectItemAt(i);
266:                            }
267:                        }
268:                    }
269:
270:                    return e;
271:                }
272:
273:                return super.newGridCellEditor(r, c);
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.