Source Code Cross Referenced for RPTWizTreeTableCellEditor.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » ui » swing » treetable » 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 Netbeans » uml » org.netbeans.modules.uml.ui.swing.treetable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        /*
043:         * Created on Jun 9, 2003
044:         *
045:         */
046:        package org.netbeans.modules.uml.ui.swing.treetable;
047:
048:        import java.awt.Component;
049:        import java.awt.event.FocusEvent;
050:        import java.awt.event.FocusListener;
051:        import java.awt.event.MouseEvent;
052:        import java.util.EventObject;
053:        import java.util.StringTokenizer;
054:
055:        import javax.swing.AbstractCellEditor;
056:        import javax.swing.JComboBox;
057:        import javax.swing.JTable;
058:        import javax.swing.JTextField;
059:        import javax.swing.table.TableCellEditor;
060:        import javax.swing.tree.TreeModel;
061:        import javax.swing.tree.TreePath;
062:
063:        import org.netbeans.modules.uml.common.ETSystem;
064:        import org.netbeans.modules.uml.core.configstringframework.ConfigStringTranslator;
065:        import org.netbeans.modules.uml.core.support.umlutils.IPropertyDefinition;
066:        import org.netbeans.modules.uml.core.support.umlutils.IPropertyElement;
067:
068:        //import org.netbeans.modules.uml.ui.addins.webreport.WebRPTFormatDlg;
069:
070:        public class RPTWizTreeTableCellEditor extends AbstractCellEditor
071:                implements  TableCellEditor {
072:            private JTreeTable.TreeTableCellRenderer tree = null;
073:
074:            //private WebRPTFormatDlg m_Editor = null;
075:
076:            /**
077:             *
078:             */
079:            public RPTWizTreeTableCellEditor() {
080:                super ();
081:            }
082:
083:            public RPTWizTreeTableCellEditor(JTreeTable.TreeTableCellRenderer tr) {
084:                super ();
085:                tree = tr;
086:            }
087:
088:            //	public RPTWizTreeTableCellEditor(JTreeTable.TreeTableCellRenderer tr, PropertyEditor editor)
089:            //	{
090:            //		super();
091:            //		tree = tr;
092:            //		m_Editor = editor;
093:            //	}
094:
095:            public JTreeTable.TreeTableCellRenderer getTree() {
096:                return tree;
097:            }
098:
099:            /**
100:             * TreeTableCellEditor implementation. Component returned is the
101:             * JTree.
102:             */
103:            public Component getTableCellEditorComponent(JTable table,
104:                    Object value, boolean isSelected, int r, int c) {
105:                //PropertyEditor.instance().setCurrentRow(r);
106:
107:                Component retObj = null;
108:
109:                //set the current row on property editor
110:                //		m_Editor.setCurrentRow(r);
111:
112:                boolean isEditable = true;
113:
114:                if (c == 2) {
115:                    TreePath path = getTree().getPathForRow(r);
116:                    if (path != null) {
117:                        Object obj = path.getLastPathComponent();
118:                        if (obj instanceof  JDefaultMutableTreeNode) {
119:                            JDefaultMutableTreeNode node = (JDefaultMutableTreeNode) obj;
120:                            final IPropertyElement ele = (IPropertyElement) node
121:                                    .getUserObject();
122:                            IPropertyDefinition def = ele
123:                                    .getPropertyDefinition();
124:                            long mult = def.getMultiplicity();
125:                            String values = def.getValidValues();
126:                            ETSystem.out.println(values);
127:                            if (values != null) {
128:                                if (values.equals("FormatString")) {
129:                                    //This node is non-editable, I need to format string to show.
130:                                } else if (values.equals("#DataTypeList")) {
131:                                    String buffer = "buffer buffer"; //m_Editor.buildDataTypeList(ele);
132:                                    JDescribeComboBox temp = new JDescribeComboBox(/*m_Editor*/);
133:                                    temp.setBorder(null);
134:                                    StringTokenizer tokenizer = new StringTokenizer(
135:                                            buffer, "|");
136:                                    while (tokenizer.hasMoreTokens()) {
137:                                        String transVal = tokenizer.nextToken();
138:                                        temp.addItem(transVal);
139:                                    }
140:                                    temp.setSelectedItem(value);
141:                                    retObj = temp;
142:                                } else {
143:                                    String cType = def.getControlType();
144:                                    if (cType != null
145:                                            && cType.equals("read-only")) {
146:                                        JTextField temp = new JTextField();
147:                                        temp.setEditable(false);
148:                                        isEditable = false;
149:                                        temp.setBorder(null);
150:                                        if (value != null) {
151:                                            ConfigStringTranslator translator = new ConfigStringTranslator();
152:                                            temp.setText(translator.translate(
153:                                                    def, value.toString()));
154:                                        }
155:                                        retObj = temp;
156:                                    } else {
157:                                        ConfigStringTranslator translator = new ConfigStringTranslator();
158:                                        JComboBox temp = new JComboBox();
159:                                        temp.setBorder(null);
160:                                        //temp.addFocusListener(new EditorFocusListener());
161:                                        //cannot make is editable as the focus listener will stop working
162:                                        //temp.setEditable(true);
163:                                        temp.setPopupVisible(false);
164:                                        StringTokenizer tokenizer = new StringTokenizer(
165:                                                values, "|");
166:                                        while (tokenizer.hasMoreTokens()) {
167:                                            String transVal = translator
168:                                                    .translate(def, tokenizer
169:                                                            .nextToken());
170:                                            temp.addItem(transVal);
171:                                        }
172:                                        temp.setSelectedItem(value);
173:
174:                                        retObj = temp;
175:                                    }
176:                                }
177:                            } else {
178:                                String cType = def.getControlType();
179:                                if (mult > 1
180:                                        && (cType == null || !cType
181:                                                .equals("read-only"))) {
182:                                    if (table instanceof  JPropertyTreeTable) {
183:                                        //WebRPTFormatDlg editor = ((RPTWizPropertyTreeTable)table).getPropertyEditor();
184:                                        JDescribeButton btn = new JDescribeButton(
185:                                                r/*, editor*/);
186:                                        btn.setBorder(null);
187:                                        retObj = btn;
188:
189:                                        //retObj.addFocusListener(new EditorFocusListener());
190:                                        //mark the component as non-editable, so that
191:                                        //we do not add property listener to it.
192:                                        isEditable = false;
193:                                    }
194:                                } else {
195:                                    JTextField temp = new JTextField();
196:                                    temp.setBorder(null);
197:                                    if (value != null) {
198:                                        temp.setText(value.toString());
199:                                        //								temp.addActionListener(new ActionListener() {
200:                                        //
201:                                        //									public void actionPerformed(ActionEvent e)
202:                                        //									{
203:                                        //										ele.setModified(true);
204:                                        //									}
205:                                        //								});
206:                                    }
207:                                    if (cType == null
208:                                            || cType.equals("read-only")) {
209:                                        temp.setEditable(false);
210:
211:                                        //mark the component as non-editable, so that
212:                                        //we do not add property listener to it.
213:                                        isEditable = false;
214:                                    }
215:                                    retObj = temp;
216:                                }
217:                            }
218:                            //ETSystem.out.println("in getTableCellRen... = " + mult + values);
219:                        }
220:                    }
221:                } else if (c == 1) {
222:                    TreePath path = getTree().getPathForRow(r);
223:                    if (path != null) {
224:                        Object obj = path.getLastPathComponent();
225:                        if (obj instanceof  JDefaultMutableTreeNode) {
226:                            JDefaultMutableTreeNode node = (JDefaultMutableTreeNode) obj;
227:                            if (node.getChildCount() > 0) {
228:                                retObj = null;//tree;
229:                            } else {
230:                                return null;
231:                            }
232:                        }
233:                    }
234:                } else if (c == 0) {
235:                    //ETSystem.out.println("First column selected for images filter");
236:                    //	m_Editor.sortPropertyEditorElements(r);
237:                    return null;
238:                }
239:
240:                //I want to add property change listener only if the component is
241:                // in values column and is editable.
242:                if (retObj != null && c == 2 && isEditable) {
243:                    //			retObj.addPropertyChangeListener(new PropertyChangeListener()
244:                    //			{
245:                    //
246:                    //				public void propertyChange(PropertyChangeEvent arg0)
247:                    //				{
248:                    //					m_Editor.columnValueChanged(arg0);
249:                    //				}
250:                    //			}
251:                    //			);
252:                }
253:
254:                if (retObj != null && c == 2) {
255:                    retObj.addFocusListener(new FocusListener() {
256:
257:                        public void focusGained(FocusEvent e) {
258:                            if (!e.isTemporary()) {
259:                                //				m_Editor.handleFocusGainedOnCellEvent(e);
260:                            }
261:                            //ETSystem.out.println("Focus gained on " + obj.getClass());
262:                        }
263:
264:                        public void focusLost(FocusEvent e) {
265:                            if (!e.isTemporary()) {
266:                                //				m_Editor.handleFocusLostOnCellEvent(e);
267:                            }
268:                            //ETSystem.out.println("Focus lost on " + obj.getClass() + " new value = " + text);
269:                        }
270:                    });
271:                }
272:                return retObj;
273:            }
274:
275:            /**
276:             * Overridden to return false, and if the event is a mouse event
277:             * it is forwarded to the tree.<p>
278:             * The behavior for this is debatable, and should really be offered
279:             * as a property. By returning false, all keyboard actions are
280:             * implemented in terms of the table. By returning true, the
281:             * tree would get a chance to do something with the keyboard
282:             * events. For the most part this is ok. But for certain keys,
283:             * such as left/right, the tree will expand/collapse where as
284:             * the table focus should really move to a different column. Page
285:             * up/down should also be implemented in terms of the table.
286:             * By returning false this also has the added benefit that clicking
287:             * outside of the bounds of the tree node, but still in the tree
288:             * column will select the row, whereas if this returned true
289:             * that wouldn't be the case.
290:             * <p>By returning false we are also enforcing the policy that
291:             * the tree will never be editable (at least by a key sequence).
292:             */
293:            public boolean isCellEditable(EventObject e) {
294:                if (e instanceof  MouseEvent) {
295:                    TreeModel model = tree.getModel();
296:                    if (model instanceof  TreeTableModel) {
297:                        TreeTableModel tModel = (TreeTableModel) model;
298:                        for (int counter = tModel.getColumnCount() - 1; counter >= 0; counter--) {
299:                            if (tModel.getColumnClass(counter).equals(
300:                                    PropertyTreeTableModel.class))
301:                            //if (counter == 1)
302:                            {
303:                                MouseEvent me = (MouseEvent) e;
304:                                if (me.getClickCount() == 2) {
305:                                    //the element was double clicked, need to expand/collapse
306:                                    //					m_Editor.handleDoubleClick();
307:                                } else {
308:                                    //need to pass on this mouse event to the tree.
309:                                    MouseEvent newME = new MouseEvent(tree, me
310:                                            .getID(), me.getWhen(), me
311:                                            .getModifiers(), me.getX(), me
312:                                            .getY(), me.getClickCount(), me
313:                                            .isPopupTrigger());
314:                                    tree.dispatchEvent(newME);
315:                                    break;
316:                                }
317:                            }
318:                        }
319:                    }
320:                }
321:                return true;
322:            }
323:
324:            /* (non-Javadoc)
325:             * @see javax.swing.CellEditor#getCellEditorValue()
326:             */
327:            public Object getCellEditorValue() {
328:                // TODO Auto-generated method stub
329:                return tree;
330:            }
331:
332:            private class EditorFocusListener implements  FocusListener {
333:                public void focusGained(FocusEvent e) {
334:                    //m_Editor.handleFocusGainedOnCellEvent(e);
335:                    ETSystem.out.println("Focus gained on ");
336:                }
337:
338:                public void focusLost(FocusEvent e) {
339:                    //m_Editor.handleFocusLostOnCellEvent(e);
340:                    ETSystem.out.println("Focus lost on ");
341:                }
342:            }
343:        }
www___.j___a___v__a__2s___.__co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.