Source Code Cross Referenced for CatalogWebTreeModel.java in  » Content-Management-System » openedit » org » openedit » store » links » 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 » Content Management System » openedit » org.openedit.store.links 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.openedit.store.links;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collections;
005:        import java.util.HashSet;
006:        import java.util.Iterator;
007:        import java.util.List;
008:        import java.util.Set;
009:
010:        import org.openedit.store.CatalogArchive;
011:        import org.openedit.store.Category;
012:        import org.openedit.store.SearchFilter;
013:
014:        import com.openedit.users.User;
015:        import com.openedit.webui.tree.WebTreeModel;
016:
017:        public class CatalogWebTreeModel implements  WebTreeModel {
018:            protected Category fieldRootCatalog;
019:            protected User fieldUser;
020:            protected Set fieldHiddenCatalogs;
021:            protected Set fieldLimitToCatalogs;
022:            protected CatalogArchive fieldCatalogArchive;
023:            protected SearchFilter fieldSearchFilter;
024:
025:            public CatalogWebTreeModel() {
026:            }
027:
028:            public CatalogWebTreeModel(Category inRootCatalog) {
029:                fieldRootCatalog = inRootCatalog;
030:            }
031:
032:            /**
033:             * @deprecated Use the list children method since it is faster
034:             */
035:            public Object getChild(Object inParent, int index) {
036:                return listChildren(inParent).get(index);
037:            }
038:
039:            public List listChildren(Object inParent) {
040:                if (inParent == null) {
041:                    return Collections.EMPTY_LIST;
042:                }
043:                Category parent = (Category) inParent;
044:                List ok = new ArrayList(parent.getChildren().size());
045:                for (Iterator iter = parent.getChildren().iterator(); iter
046:                        .hasNext();) {
047:                    //If this is slow then we might consider only checking the top level catalogs
048:                    Category cat = (Category) iter.next();
049:                    if (okToAdd(cat)) {
050:                        ok.add(cat);
051:                    }
052:                }
053:                return ok;
054:            }
055:
056:            protected boolean okToAdd(Category inCat) {
057:                if (inCat.getParentCatalog() == null) {
058:                    return true;
059:                }
060:                if (getHiddenCatalogs().contains(inCat.getId())) {
061:                    return false;
062:                }
063:                if (getLimitToCatalogs().size() > 0) {
064:                    //Only worry about including these catalogs
065:                    for (Iterator iterator = getLimitToCatalogs().iterator(); iterator
066:                            .hasNext();) {
067:                        Category okid = (Category) iterator.next();
068:                        if (inCat.getId().equals(okid.getId())
069:                                || okid.hasParent(inCat.getId())) {
070:                            return true;
071:                        }
072:                    }
073:                    //This could be slow
074:                    for (Iterator iterator = getLimitToCatalogs().iterator(); iterator
075:                            .hasNext();) {
076:                        Category okid = (Category) iterator.next();
077:                        if (inCat.hasParent(okid.getId())) {
078:                            return true;
079:                        }
080:                    }
081:
082:                    //None found so cancel if at same level as included one
083:                    for (Iterator iterator = getLimitToCatalogs().iterator(); iterator
084:                            .hasNext();) {
085:                        Category okid = (Category) iterator.next();
086:                        if (inCat.getLevel() == okid.getLevel()) {
087:                            return false;
088:                        }
089:                    }
090:                    //index/photo2/stuff1 nostuff
091:                    return true;
092:                }
093:
094:                return true;
095:            }
096:
097:            public Set getHiddenCatalogs() {
098:                if (fieldHiddenCatalogs == null) {
099:                    limitList();
100:                }
101:                return fieldHiddenCatalogs;
102:            }
103:
104:            public Set getLimitToCatalogs() {
105:                if (fieldLimitToCatalogs == null) {
106:                    limitList();
107:                }
108:                return fieldLimitToCatalogs;
109:            }
110:
111:            protected void limitList() {
112:                //look over this users permissions and see if there is a limit
113:                fieldHiddenCatalogs = new HashSet();
114:                fieldLimitToCatalogs = new HashSet();
115:                for (Iterator iterator = getSearchFilter().listAllFilters()
116:                        .iterator(); iterator.hasNext();) {
117:                    String perm = (String) iterator.next();
118:                    if (perm.startsWith("limittocategory:")) {
119:                        String catid = perm.substring("limittocategory:"
120:                                .length());
121:                        Category cat = getCatalogArchive().getCatalog(catid);
122:                        if (cat != null) {
123:                            fieldLimitToCatalogs.add(cat);
124:                        }
125:                        //				Category cat = getCatalogArchive().getCatalog(catid);
126:                        //				while( cat != null )
127:                        //				{
128:                        //					fieldExclusiveCatalogs.add(cat.getId());
129:                        //					cat = cat.getParentCatalog();
130:                        //				}
131:                    }
132:                    //This is old way to do it
133:                    else if (perm.startsWith("hidecategory:")) //Aways exclude it
134:                    {
135:                        String catid = perm.substring("hidecategory:".length());
136:                        fieldHiddenCatalogs.add(catid);
137:                    } else if (perm.startsWith("hidecatalog:")) //Aways exclude it
138:                    {
139:                        String catid = perm.substring("hidecatalog:".length());
140:                        fieldHiddenCatalogs.add(catid);
141:                    } else if (perm.startsWith("backgroundcatalog:")) //Aways exclude it
142:                    {
143:                        String catid = perm.substring("backgroundcatalog:"
144:                                .length());
145:                        fieldHiddenCatalogs.add(catid);
146:                    }
147:                }
148:            }
149:
150:            public List getChildren(Object inParent) {
151:                return listChildren(inParent);
152:            }
153:
154:            public List getChildrenInRows(Object inParent, int inColCount) {
155:                //Now break up the page into rows by dividing the count they wanted
156:                List children = getChildren(inParent);
157:                double rowscount = (double) children.size()
158:                        / (double) inColCount;
159:
160:                List rows = new ArrayList();
161:                for (int i = 0; i < rowscount; i++) {
162:                    int start = i * inColCount;
163:                    int end = i * inColCount + inColCount;
164:                    List sublist = children.subList(start, Math.min(children
165:                            .size(), end));
166:                    rows.add(sublist);
167:                }
168:                return rows;
169:            }
170:
171:            public int getChildCount(Object inParent) {
172:                return listChildren(inParent).size();
173:            }
174:
175:            public int getIndexOfChild(Object inParent, Object inChild) {
176:                return listChildren(inParent).indexOf(inChild);
177:            }
178:
179:            public boolean isLeaf(Object inNode) {
180:                return !((Category) inNode).hasChildren();
181:            }
182:
183:            public Object getRoot() {
184:                return fieldRootCatalog;
185:            }
186:
187:            public String getId(Object inNode) {
188:                if (inNode == null) {
189:                    return null;
190:                }
191:                return ((Category) inNode).getId();
192:            }
193:
194:            public Object getParent(Object inNode) {
195:                Category child = (Category) inNode;
196:                return child.getParentCatalog();
197:            }
198:
199:            public User getUser() {
200:                return fieldUser;
201:            }
202:
203:            public void setUser(User inUser) {
204:                fieldUser = inUser;
205:            }
206:
207:            public Category getRootCatalog() {
208:                return fieldRootCatalog;
209:            }
210:
211:            public void setRootCatalog(Category inRootCatalog) {
212:                fieldRootCatalog = inRootCatalog;
213:            }
214:
215:            public Object getChildById(String inId) {
216:                return findNodeById(getRoot(), inId);
217:            }
218:
219:            public Object findNodeById(Object inRoot, String inId) {
220:                String test = getId(inRoot);
221:                if (test.equals(inId)) {
222:                    return inRoot;
223:                }
224:                for (Iterator iterator = getChildren(inRoot).iterator(); iterator
225:                        .hasNext();) {
226:                    Object child = iterator.next();
227:                    child = findNodeById(child, inId);
228:                    if (child != null) {
229:                        return child;
230:                    }
231:                }
232:                return null;
233:            }
234:
235:            public CatalogArchive getCatalogArchive() {
236:                return fieldCatalogArchive;
237:            }
238:
239:            public void setCatalogArchive(CatalogArchive inCatalogArchive) {
240:                fieldCatalogArchive = inCatalogArchive;
241:            }
242:
243:            public SearchFilter getSearchFilter() {
244:                return fieldSearchFilter;
245:            }
246:
247:            public void setSearchFilter(SearchFilter inSearchFilter) {
248:                fieldSearchFilter = inSearchFilter;
249:            }
250:
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.