Source Code Cross Referenced for SortedFolder.java in  » Content-Management-System » contelligent » de » finix » contelligent » 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 » Content Management System » contelligent » de.finix.contelligent.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.components;
019:
020:        import java.util.Collections;
021:        import java.util.Iterator;
022:        import java.util.LinkedList;
023:        import java.util.List;
024:
025:        import de.finix.contelligent.CallData;
026:        import de.finix.contelligent.Component;
027:        import de.finix.contelligent.ModificationVetoException;
028:        import de.finix.contelligent.ObservingContainer;
029:        import de.finix.contelligent.logging.LoggingService;
030:        import de.finix.contelligent.util.StringUtils;
031:
032:        /**
033:         * A <code>SortedFolder</code> holds a comma separated list of names.
034:         */
035:        public class SortedFolder extends Folder implements  ObservingContainer {
036:            final static org.apache.log4j.Logger log = LoggingService
037:                    .getLogger(SortedFolder.class);
038:
039:            // if property 'nameList' equals this token (which should be the types
040:            // default value)
041:            // the name-list gets build up from scratch in postCreate().
042:            final static public String CREATE_NAMELIST_TOKEN = "[RECREATE-NAMELIST]";
043:
044:            // holds the sorted names of the subcomponents: the top element is at index
045:            // 0
046:            private List sortedNameList = null;
047:
048:            /** contains a comma separated list of names */
049:            private String nameList = "";
050:
051:            public void setNameList(String nameList) {
052:                this .nameList = nameList;
053:            }
054:
055:            public String getNameList() {
056:                return nameList;
057:            }
058:
059:            public void postCreate() throws Exception {
060:                super .postCreate();
061:                if (CREATE_NAMELIST_TOKEN.equals(nameList)) {
062:                    if (log.isDebugEnabled()) {
063:                        log
064:                                .debug("'"
065:                                        + this 
066:                                        + "':postCreate() - initially filling nameList ...");
067:                    }
068:                    boolean isFirst = true;
069:                    StringBuffer nameBuf = new StringBuffer();
070:                    for (Iterator it = super .getSubcomponentNames(); it
071:                            .hasNext();) {
072:                        String name = (String) it.next();
073:                        if (!isFirst)
074:                            nameBuf.append(',');
075:                        if (log.isDebugEnabled()) {
076:                            log.debug("'" + this  + "':postCreate() - adding"
077:                                    + name);
078:                        }
079:                        nameBuf.append(name);
080:                        isFirst = false;
081:                    }
082:                    nameList = nameBuf.toString();
083:                }
084:                if (nameList == null || nameList.trim().length() == 0) {
085:                    sortedNameList = new LinkedList();
086:                } else {
087:                    sortedNameList = StringUtils.tokenizeCSV(nameList.trim(),
088:                            ',');
089:                    // tokenizeCSV() returns list with one empty string if string is " "
090:                }
091:            }
092:
093:            public boolean moveUp(String toMove) {
094:                int oldIndex = sortedNameList.indexOf(toMove);
095:                if (oldIndex > 0) {
096:                    Object o = sortedNameList.remove(oldIndex);
097:                    sortedNameList.add(oldIndex - 1, o);
098:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
099:                    return true;
100:                }
101:                return false;
102:            }
103:
104:            public boolean moveDown(String toMove) {
105:                int oldIndex = sortedNameList.indexOf(toMove);
106:                if (oldIndex != -1 && (oldIndex < sortedNameList.size() - 1)) {
107:                    Object o = sortedNameList.remove(oldIndex);
108:                    sortedNameList.add(oldIndex + 1, o);
109:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
110:                    return true;
111:                }
112:                return false;
113:            }
114:
115:            public boolean moveToTop(String toMove) {
116:                int oldIndex = sortedNameList.indexOf(toMove);
117:                if (oldIndex > 0) {
118:                    Object o = sortedNameList.remove(oldIndex);
119:                    sortedNameList.add(0, o);
120:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
121:                    return true;
122:                }
123:                return false;
124:            }
125:
126:            public boolean moveToBottom(String toMove) {
127:                int oldIndex = sortedNameList.indexOf(toMove);
128:                if (oldIndex != -1 && (oldIndex < sortedNameList.size() - 1)) {
129:                    Object o = sortedNameList.remove(oldIndex);
130:                    sortedNameList.add(sortedNameList.size(), o);
131:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
132:                    return true;
133:                }
134:                return false;
135:            }
136:
137:            public int getPosition(String element) {
138:                return sortedNameList.indexOf(element);
139:            }
140:
141:            public boolean setPosition(String toMove, int index) {
142:                int oldIndex = sortedNameList.indexOf(toMove);
143:                if (index < sortedNameList.size()) {
144:                    Object o = sortedNameList.remove(oldIndex);
145:                    sortedNameList.add(index, o);
146:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
147:                    return true;
148:                }
149:                return false;
150:            }
151:
152:            public Iterator getSortedNames() {
153:                return sortedNameList.iterator();
154:            }
155:
156:            public Iterator getSubcomponentNames() {
157:                return sortedNameList.listIterator(0);
158:            }
159:
160:            /**
161:             * overwrites the method of the Folder to allow sorted eval
162:             */
163:            public Iterator getSubcomponentNames(int start, int amount) {
164:                if (amount <= -1) {
165:                    if (start < sortedNameList.size()) {
166:                        return sortedNameList.listIterator(start);
167:                    } else {
168:
169:                    }
170:                } else if (start < sortedNameList.size()) {
171:                    if (start + amount <= sortedNameList.size()) {
172:                        return sortedNameList.subList(start, start + amount)
173:                                .listIterator();
174:                    } else {
175:                        return sortedNameList.listIterator(start);
176:                    }
177:                }
178:                return Collections.EMPTY_LIST.iterator();
179:            }
180:
181:            /** appends the name of the given child to the name-list */
182:            public boolean subcomponentAdded(CallData callData, Component child) {
183:                String childName = child.getComponentContext().getPath()
184:                        .getName();
185:                if (log.isDebugEnabled()) {
186:                    log.debug("subcomponentAdded()- invoked with child '"
187:                            + childName + "' in callManager='"
188:                            + ctx.getCallManager() + "', persistenceManager='"
189:                            + ctx.getPersistenceManager() + "'");
190:                }
191:                if (!sortedNameList.contains(childName)) {
192:                    sortedNameList.add(childName);
193:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
194:                    return true;
195:                }
196:                return false;
197:            }
198:
199:            public boolean subcomponentRemoved(CallData callData,
200:                    String childName) {
201:                if (log.isDebugEnabled())
202:                    log
203:                            .debug("'"
204:                                    + this 
205:                                    + "':subcomponentRemoved()- invoked with childName '"
206:                                    + childName + "' ...");
207:
208:                if (sortedNameList.remove(childName)) {
209:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
210:                    if (log.isDebugEnabled())
211:                        log
212:                                .debug("'"
213:                                        + this 
214:                                        + "':subcomponentRemoved()- removed childName '"
215:                                        + childName + "'.");
216:                    return true;
217:                }
218:                return false;
219:            }
220:
221:            public boolean subcomponentRemoved(CallData callData,
222:                    Component child) {
223:                String childName = child.getComponentContext().getPath()
224:                        .getName();
225:
226:                if (log.isDebugEnabled())
227:                    log
228:                            .debug("'"
229:                                    + this 
230:                                    + "':subcomponentRemoved()- invoked with childName '"
231:                                    + childName + "' ...");
232:
233:                if (sortedNameList.remove(childName)) {
234:                    setNameList(StringUtils.createCSV(sortedNameList, ','));
235:                    if (log.isDebugEnabled())
236:                        log
237:                                .debug("'"
238:                                        + this 
239:                                        + "':subcomponentRemoved()- removed childName '"
240:                                        + childName + "'.");
241:                    return true;
242:                }
243:                return false;
244:            }
245:
246:            public boolean subcomponentChanged(CallData callData,
247:                    Component subComponent) throws ModificationVetoException {
248:                return false;
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.