Source Code Cross Referenced for ListTool.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » list » tool » 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 » ERP CRM Financial » sakai » org.theospi.portfolio.list.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/common/tool-lib/src/java/org/theospi/portfolio/list/tool/ListTool.java $
003:         * $Id: ListTool.java 22946 2007-03-19 17:37:01Z john.ellis@rsmart.com $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.theospi.portfolio.list.tool;
021:
022:        import java.util.ArrayList;
023:        import java.util.Collections;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.sakaiproject.component.cover.ServerConfigurationService;
031:        import org.sakaiproject.tool.api.ToolSession;
032:        import org.sakaiproject.tool.cover.SessionManager;
033:        import org.theospi.portfolio.list.intf.DecoratedListItem;
034:        import org.theospi.portfolio.list.intf.ListItemUtils;
035:        import org.theospi.portfolio.list.intf.ListService;
036:        import org.theospi.portfolio.list.model.Column;
037:        import org.theospi.portfolio.list.model.ListConfig;
038:        import org.theospi.portfolio.shared.tool.ToolBase;
039:
040:        public class ListTool extends ToolBase implements  ListItemUtils {
041:            protected final transient Log logger = LogFactory
042:                    .getLog(getClass());
043:
044:            private ListService listService;
045:            private DecoratedEntry currentEntry;
046:
047:            private ListConfig currentConfig;
048:            private String sortCol;
049:            private int sortDir = SORT_ASC;
050:
051:            public static final int SORT_ASC = 1;
052:            public static final int SORT_DESC = -1;
053:            public static final String SORT_FIELD = "org.theospi.portfolio.list.sortField";
054:            public static final String SORT_DIR = "org.theospi.portfolio.list.sortDir";
055:            public static final int TOTAL_COLUMNS = 10;
056:
057:            public ListTool() {
058:                logger.debug("ListTool()");
059:            }
060:
061:            public String formatMessage(String key, Object[] args) {
062:                return getMessageFromBundle(key, args);
063:            }
064:
065:            public List getEntries() {
066:                List entries = getListService().getList();
067:                List returned = new ArrayList();
068:
069:                int count = 0;
070:                for (Iterator i = entries.iterator(); i.hasNext();) {
071:                    Object listItem = i.next();
072:                    if (listItem instanceof  DecoratedListItem) {
073:                        ((DecoratedListItem) listItem).setListItemUtils(this );
074:                    }
075:                    returned.add(new DecoratedEntry(listItem, getListService(),
076:                            this ));
077:                    count++;
078:                    if (getCurrentConfig().getRows() > 0
079:                            && count == getCurrentConfig().getRows()) {
080:                        //sort(returned);
081:                        break;
082:                        //return returned;
083:                    }
084:                }
085:
086:                sort(returned);
087:                return returned;
088:            }
089:
090:            protected void sort(List list) {
091:                ToolSession session = SessionManager.getCurrentToolSession();
092:                String sortField = getDefaultSortColumn();
093:                int sortDir = SORT_ASC;
094:                try {
095:                    if (session.getAttribute(SORT_FIELD) != null)
096:                        sortField = (String) session.getAttribute(SORT_FIELD);
097:
098:                    if (session.getAttribute(SORT_DIR) != null)
099:                        sortDir = ((Integer) session.getAttribute(SORT_DIR))
100:                                .intValue();
101:                } catch (Exception e) {
102:                    logger
103:                            .debug("Exception getting sorting details. Use the defaults instead.");
104:                }
105:
106:                if (sortField != null && !sortField.equals("")) {
107:                    Collections.sort(list, new DecoratedEntryComparator(
108:                            sortField, sortDir));
109:                }
110:            }
111:
112:            public boolean isCurrentSortField(String field) {
113:                ToolSession session = SessionManager.getCurrentToolSession();
114:                String sortField = getDefaultSortColumn();
115:                if (session.getAttribute(SORT_FIELD) != null)
116:                    sortField = (String) session.getAttribute(SORT_FIELD);
117:
118:                return field.equals(sortField);
119:            }
120:
121:            public boolean lookUpInBundle(String field) {
122:                return getBundleLookupColumns().contains(field);
123:            }
124:
125:            public int getCurrentSortDir() {
126:                ToolSession session = SessionManager.getCurrentToolSession();
127:                int sortDir = SORT_ASC;
128:                try {
129:                    sortDir = ((Integer) session.getAttribute(SORT_DIR))
130:                            .intValue();
131:                } catch (Exception e) {
132:                    logger
133:                            .debug("Exception getting sorting details. Use the defaults instead.");
134:                }
135:                return sortDir;
136:            }
137:
138:            public List getDisplayColumns() {
139:                List columns = getListService().getCurrentDisplayColumns();
140:                List decoratedColumns = new ArrayList(columns.size());
141:                for (Iterator i = columns.iterator(); i.hasNext();) {
142:                    Column column = (Column) i.next();
143:                    decoratedColumns.add(new DecoratedColumn(column, this ));
144:                }
145:                return decoratedColumns;
146:            }
147:
148:            public String getServerUrl() {
149:                return ServerConfigurationService.getServerUrl();
150:            }
151:
152:            public List getSelectedColumns() {
153:                Map selected = getCurrentConfig().getSelected();
154:                List decoratedColumns = new ArrayList(TOTAL_COLUMNS);
155:                for (int i = 0; i < TOTAL_COLUMNS; i++) {
156:                    Column column = (Column) selected.get(i);
157:                    decoratedColumns.add(new DecoratedColumn(column, this ));
158:                }
159:                return decoratedColumns;
160:            }
161:
162:            public List getSortableColumns() {
163:                return getListService().getSortableColumns();
164:            }
165:
166:            public List getBundleLookupColumns() {
167:                return getListService().getBundleLookupColumns();
168:            }
169:
170:            private String getDefaultSortColumn() {
171:                return getListService().getDefaultSortColumn();
172:            }
173:
174:            public ListService getListService() {
175:                return listService;
176:            }
177:
178:            public void setListService(ListService listService) {
179:                this .listService = listService;
180:                setCurrentConfig(getListService().getCurrentConfig());
181:            }
182:
183:            public String processActionOptions() {
184:                setCurrentConfig(getListService().getCurrentConfig());
185:
186:                return "options";
187:            }
188:
189:            public String processActionSort(DecoratedColumn column, int dir) {
190:                ToolSession session = SessionManager.getCurrentToolSession();
191:                session.setAttribute(SORT_FIELD, column.getBase().getName());
192:                session.setAttribute(SORT_DIR, dir);
193:
194:                return "main";
195:            }
196:
197:            public String processMain() {
198:                return "main";
199:            }
200:
201:            public String processActionOptionsSave() {
202:                getListService().saveOptions(getCurrentConfig());
203:                return "main";
204:            }
205:
206:            public DecoratedEntry getCurrentEntry() {
207:                return currentEntry;
208:            }
209:
210:            public void setCurrentEntry(DecoratedEntry currentEntry) {
211:                this .currentEntry = currentEntry;
212:            }
213:
214:            public ListConfig getCurrentConfig() {
215:                return currentConfig;
216:            }
217:
218:            public void setCurrentConfig(ListConfig currentConfig) {
219:                this .currentConfig = currentConfig;
220:            }
221:
222:            /**
223:             * @return the sortCol
224:             */
225:            public String getSortCol() {
226:                return sortCol;
227:            }
228:
229:            /**
230:             * @param sortCol the sortCol to set
231:             */
232:            public void setSortCol(String sortCol) {
233:                this .sortCol = sortCol;
234:            }
235:
236:            /**
237:             * @return the sortDir
238:             */
239:            public int getSortDir() {
240:                return sortDir;
241:            }
242:
243:            /**
244:             * @param sortDir the sortDir to set
245:             */
246:            public void setSortDir(int sortDir) {
247:                this.sortDir = sortDir;
248:            }
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.