Source Code Cross Referenced for FolderMenuDefinitionList.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » om » folder » impl » 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 » jetspeed 2.1.3 » org.apache.jetspeed.om.folder.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.om.folder.impl;
018:
019:        import java.util.AbstractList;
020:        import java.util.List;
021:
022:        import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
023:
024:        /**
025:         * FolderMenuDefinitionList
026:         *
027:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
028:         * @version $Id$
029:         */
030:        class FolderMenuDefinitionList extends AbstractList {
031:            private FolderImpl folder;
032:
033:            private List removedMenuDefinitions;
034:
035:            FolderMenuDefinitionList(FolderImpl folder) {
036:                super ();
037:                this .folder = folder;
038:            }
039:
040:            /**
041:             * validateDefinitionForAdd
042:             *
043:             * Validates menu definition to be added to this list.
044:             *
045:             * @param definition menu definition to add
046:             * @return list element to add
047:             */
048:            private FolderMenuDefinitionImpl validateDefinitionForAdd(
049:                    FolderMenuDefinitionImpl definition) {
050:                // only non-null definitions supported
051:                if (definition == null) {
052:                    throw new NullPointerException(
053:                            "Unable to add null to list.");
054:                }
055:                // make sure element is unique
056:                if (folder.accessMenus().contains(definition)) {
057:                    throw new IllegalArgumentException(
058:                            "Unable to add duplicate entry to list: "
059:                                    + (definition).getName());
060:                }
061:                // retrieve from removed list to reuse
062:                // previously removed element copying
063:                // menu definition data
064:                if (removedMenuDefinitions != null) {
065:                    int removedIndex = removedMenuDefinitions
066:                            .indexOf(definition);
067:                    if (removedIndex >= 0) {
068:                        // reuse menu definition with matching name
069:                        FolderMenuDefinitionImpl addDefinition = definition;
070:                        definition = (FolderMenuDefinitionImpl) removedMenuDefinitions
071:                                .remove(removedIndex);
072:                        // TODO: move this logic to copy methods on implementations
073:                        // copy menu definition members
074:                        definition.setOptions(addDefinition.getOptions());
075:                        definition.setDepth(addDefinition.getDepth());
076:                        definition.setPaths(addDefinition.isPaths());
077:                        definition.setRegexp(addDefinition.isRegexp());
078:                        definition.setProfile(addDefinition.getProfile());
079:                        definition.setOrder(addDefinition.getOrder());
080:                        definition.setSkin(addDefinition.getSkin());
081:                        definition.setTitle(addDefinition.getTitle());
082:                        definition.setShortTitle(addDefinition.getShortTitle());
083:                        definition.setMenuElements(addDefinition
084:                                .getMenuElements());
085:                        // copy menu definition metadata members
086:                        // TODO: strengthen... this code is not robust
087:                        // and may fail if multiple edits without a db
088:                        // update occur and duplicate metadata members
089:                        // are removed in one operation and reinserted
090:                        // in a subsequent operation because the
091:                        // metadata members are required to be unique
092:                        // and a removal list is not maintained for the
093:                        // metadata fields collections yet
094:                        definition.getMetadata().copyFields(
095:                                addDefinition.getMetadata().getFields());
096:                    }
097:                }
098:                return definition;
099:            }
100:
101:            /**
102:             * getRemovedMenuDefinitions
103:             *
104:             * @return removed menu definitions tracking collection
105:             */
106:            private List getRemovedMenuDefinitions() {
107:                if (removedMenuDefinitions == null) {
108:                    removedMenuDefinitions = DatabasePageManagerUtils
109:                            .createList();
110:                }
111:                return removedMenuDefinitions;
112:            }
113:
114:            /* (non-Javadoc)
115:             * @see java.util.List#add(int,java.lang.Object)
116:             */
117:            public void add(int index, Object element) {
118:                // implement for modifiable AbstractList:
119:                // validate index
120:                if ((index < 0) || (index > folder.accessMenus().size())) {
121:                    throw new IndexOutOfBoundsException(
122:                            "Unable to add to list at index: " + index);
123:                }
124:                // verify menu definition
125:                FolderMenuDefinitionImpl definition = validateDefinitionForAdd((FolderMenuDefinitionImpl) element);
126:                // add to underlying ordered list
127:                folder.accessMenus().add(index, definition);
128:            }
129:
130:            /* (non-Javadoc)
131:             * @see java.util.List#get(int)
132:             */
133:            public Object get(int index) {
134:                // implement for modifiable AbstractList
135:                return folder.accessMenus().get(index);
136:            }
137:
138:            /* (non-Javadoc)
139:             * @see java.util.List#remove(int)
140:             */
141:            public Object remove(int index) {
142:                // implement for modifiable AbstractList:
143:                // save removed element 
144:                FolderMenuDefinitionImpl removed = (FolderMenuDefinitionImpl) folder
145:                        .accessMenus().remove(index);
146:                if (removed != null) {
147:                    getRemovedMenuDefinitions().add(removed);
148:                }
149:                return removed;
150:            }
151:
152:            /* (non-Javadoc)
153:             * @see java.util.List#set(int,java.lang.Object)
154:             */
155:            public Object set(int index, Object element) {
156:                // implement for modifiable AbstractList:
157:                // verify menu definition
158:                FolderMenuDefinitionImpl newDefinition = validateDefinitionForAdd((FolderMenuDefinitionImpl) element);
159:                // set in underlying ordered list
160:                FolderMenuDefinitionImpl definition = (FolderMenuDefinitionImpl) folder
161:                        .accessMenus().set(index, newDefinition);
162:                // save replaced element
163:                getRemovedMenuDefinitions().add(definition);
164:                // return menu definition
165:                return definition;
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see java.util.List#size()
170:             */
171:            public int size() {
172:                // implement for modifiable AbstractList
173:                return folder.accessMenus().size();
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.