Source Code Cross Referenced for ItsNatTreeCellUIImpl.java in  » Ajax » ItsNat » org » itsnat » impl » comp » ui » 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 » ItsNat » org.itsnat.impl.comp.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          ItsNat Java Web Application Framework
003:          Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004:          Author: Jose Maria Arranz Santamaria
005:
006:          This program is free software: you can redistribute it and/or modify
007:          it under the terms of the GNU Affero General Public License as published by
008:          the Free Software Foundation, either version 3 of the License, or
009:          (at your option) any later version. See the GNU Affero General Public 
010:          License for more details. See the copy of the GNU Affero General Public License
011:          included in this program. If not, see <http://www.gnu.org/licenses/>.
012:         */
013:
014:        package org.itsnat.impl.comp.ui;
015:
016:        import javax.swing.tree.TreeModel;
017:        import javax.swing.tree.TreePath;
018:        import org.itsnat.comp.ui.ItsNatTreeCellUI;
019:        import org.itsnat.comp.ui.ItsNatTreeUI;
020:        import org.itsnat.impl.core.ItsNatUserDataImpl;
021:        import org.itsnat.impl.core.domutil.ElementTreeNodeImpl;
022:        import org.itsnat.impl.core.util.*;
023:        import org.w3c.dom.Element;
024:
025:        /**
026:         * En cierto modo el par ItsNatTreeCellUI/Impl es redundante pues se podría
027:         * usar ElementTreeNode directanemte sin embargo nos sirve
028:         * para sacar información del ElementTreeNode sin exponer 
029:         * métodos que puedan modificar el árbol, esto en los ItsNatTree es
030:         * fundamental pues ha de modificarse el árbol (nuevos items etc)
031:         * a través de los métodos normales de ItsNatTree, TreeModel etc,
032:         * en ese contexto ItsNatTreeCellUI nos ofrece info del nodo a modo de "sólo lectura" 
033:         * NO debe usarse el ItsNatTreeCellUI obtenido antes de un cambio en la estructura
034:         * 
035:         * 
036:         * 
037:         * 
038:         * 
039:         * 
040:         * @author jmarranz
041:         */
042:        public class ItsNatTreeCellUIImpl extends ItsNatUserDataImpl implements 
043:                ItsNatTreeCellUI {
044:            protected ElementTreeNodeImpl treeNode;
045:            protected ItsNatTreeUIImpl treeUI;
046:            protected boolean expandState = true;
047:
048:            /**
049:             * Creates a new instance of ItsNatTreeCellUIImpl
050:             */
051:            private ItsNatTreeCellUIImpl(ItsNatTreeUIImpl treeUI,
052:                    ElementTreeNodeImpl treeNode) {
053:                super (false);
054:
055:                this .treeUI = treeUI;
056:                this .treeNode = treeNode;
057:            }
058:
059:            public static ItsNatTreeCellUIImpl getItsNatTreeCellUI(
060:                    ItsNatTreeUIImpl treeUI, ElementTreeNodeImpl treeNode) {
061:                if (treeNode == null)
062:                    return null; // puede ser el root y modo rootless             
063:                ItsNatTreeCellUIImpl treeNodeUI = (ItsNatTreeCellUIImpl) treeNode
064:                        .getAuxObject();
065:                if (treeNodeUI == null) {
066:                    treeNodeUI = new ItsNatTreeCellUIImpl(treeUI, treeNode);
067:                    treeNode.setAuxObject(treeNodeUI);
068:                }
069:                return treeNodeUI;
070:            }
071:
072:            public ItsNatTreeUI getItsNatTreeUI() {
073:                return treeUI;
074:            }
075:
076:            public ElementTreeNodeImpl getElementTreeNode() {
077:                // No publicar
078:                return treeNode;
079:            }
080:
081:            public ItsNatTreeCellUI getTreeNodeUIParent() {
082:                ElementTreeNodeImpl treeNodeParent = (ElementTreeNodeImpl) treeNode
083:                        .getElementTreeNodeParent();
084:                return getItsNatTreeCellUI(treeUI, treeNodeParent);
085:            }
086:
087:            public Element getParentElement() {
088:                return treeNode.getParentElement();
089:            }
090:
091:            public Element getContentElement() {
092:                return treeUI.getContentElement(treeNode);
093:            }
094:
095:            public Element getHandleElement() {
096:                return treeUI.getHandleElement(treeNode);
097:            }
098:
099:            public Element getIconElement() {
100:                return treeUI.getIconElement(treeNode);
101:            }
102:
103:            public Element getLabelElement() {
104:                return treeUI.getLabelElement(treeNode);
105:            }
106:
107:            public int getIndex() {
108:                return treeNode.getIndex();
109:            }
110:
111:            public int getChildCount() {
112:                return treeUI.getChildCount(treeNode);
113:            }
114:
115:            public ItsNatTreeCellUI getChildItsNatTreeCellUIAt(int index) {
116:                return treeUI.getChildItsNatTreeCellUIAt(index, treeNode);
117:            }
118:
119:            public int getRow() {
120:                return treeUI.getRow(treeNode);
121:            }
122:
123:            public ItsNatTreeCellUI[] getTreeNodeUIPath() {
124:                ItsNatTreeCellUI nodeInfoCurr;
125:
126:                int count = 1;
127:                nodeInfoCurr = this ;
128:                while (nodeInfoCurr.getTreeNodeUIParent() != null) {
129:                    count++;
130:                    nodeInfoCurr = nodeInfoCurr.getTreeNodeUIParent();
131:                }
132:
133:                ItsNatTreeCellUI[] path = new ItsNatTreeCellUI[count];
134:                nodeInfoCurr = this ;
135:                for (int i = path.length - 1; i >= 0; i--) {
136:                    path[i] = nodeInfoCurr;
137:                    nodeInfoCurr = nodeInfoCurr.getTreeNodeUIParent();
138:                }
139:                return path;
140:            }
141:
142:            public int getDeepLevel() {
143:                return treeNode.getDeepLevel();
144:            }
145:
146:            public TreePath getTreePath() {
147:                // No memorizamos el path calculado porque puede cambiar en cualquier momento al cambiar el árbol
148:                return calcTreePath();
149:            }
150:
151:            public TreePath calcTreePath() {
152:                TreeModel dataModel = treeUI.getItsNatTree().getTreeModel();
153:                ItsNatTreeCellUI[] infoPath = getTreeNodeUIPath();
154:                int pathLen = infoPath.length;
155:                if (treeUI.isRootless())
156:                    pathLen++;
157:                Object[] path = new Object[pathLen];
158:                Object parentNode = dataModel.getRoot();
159:                path[0] = parentNode;
160:                int first, delta;
161:                if (treeUI.isRootless()) {
162:                    first = 0;
163:                    delta = 1;
164:                } else {
165:                    first = 1;
166:                    delta = 0;
167:                }
168:                for (int i = first; i < infoPath.length; i++) {
169:                    int index = infoPath[i].getIndex();
170:                    parentNode = dataModel.getChild(parentNode, index);
171:                    path[i + delta] = parentNode;
172:                }
173:                return new TreePath(path);
174:            }
175:
176:            public void expand(boolean expandState) {
177:                this .expandState = expandState;
178:            }
179:
180:            public boolean isExpanded() {
181:                return expandState;
182:            }
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.