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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/taggable/tool/DecoratedTaggingProvider.java $
003:         * $Id: DecoratedTaggingProvider.java 22575 2007-03-13 23:10:19Z jmpease@syr.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2007 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.matrix.taggable.tool;
021:
022:        import java.util.ArrayList;
023:        import java.util.List;
024:
025:        import org.sakaiproject.assignment.taggable.api.Tag;
026:        import org.sakaiproject.assignment.taggable.api.TagColumn;
027:        import org.sakaiproject.assignment.taggable.api.TagList;
028:        import org.sakaiproject.assignment.taggable.api.TaggableActivity;
029:        import org.sakaiproject.assignment.taggable.api.TaggingProvider;
030:
031:        /**
032:         * Wrapper around {@link TaggingProvider} for displaying a pageable/sortable
033:         * list of tags for an activity or item. Since there may be multiple providers
034:         * each with a list of tags displayed on a single page, this class enables each
035:         * provider to maintain the page/sort state of its list separate from others.
036:         * 
037:         * @author The Sakai Foundation.
038:         */
039:        public class DecoratedTaggingProvider {
040:
041:            private Sort sort;
042:
043:            private Pager pager;
044:
045:            private TaggableActivity activity;
046:
047:            private TaggingProvider provider;
048:
049:            private TagList tagList;
050:
051:            protected final static int[] PAGESIZES = { 5, 10, 20, 50, 100, 200 };
052:
053:            public DecoratedTaggingProvider(TaggableActivity activity,
054:                    TaggingProvider provider) {
055:                this .activity = activity;
056:                this .provider = provider;
057:                sort = new Sort("", true);
058:                tagList = provider.getTags(activity);
059:                pager = new Pager(tagList.size(), 0, 20);
060:            }
061:
062:            public Sort getSort() {
063:                return sort;
064:            }
065:
066:            public Pager getPager() {
067:                return pager;
068:            }
069:
070:            public boolean getAllowViewTags() {
071:                return provider.allowViewTags(activity.getContext());
072:            }
073:
074:            public TaggingProvider getProvider() {
075:                return provider;
076:            }
077:
078:            public List<Tag> getTags() {
079:                List<Tag> tags = new ArrayList<Tag>();
080:                if (tagList != null) {
081:                    tagList.sort(tagList.getColumn(sort.getSort()), sort
082:                            .isAscending());
083:                    tags = tagList.subList(pager.getFirstItem(), pager
084:                            .getLastItemNumber());
085:                }
086:                return tags;
087:            }
088:
089:            public List<TagColumn> getColumns() {
090:                return provider.getTags(activity).getColumns();
091:            }
092:
093:            public class Sort {
094:
095:                protected String sortString = "";
096:
097:                protected boolean ascending = true;
098:
099:                public Sort(String sort, boolean ascending) {
100:                    sortString = sort;
101:                    this .ascending = ascending;
102:                }
103:
104:                public boolean isAscending() {
105:                    return ascending;
106:                }
107:
108:                public void setAscending(boolean ascending) {
109:                    this .ascending = ascending;
110:                }
111:
112:                public String getSort() {
113:                    return sortString;
114:                }
115:
116:                public void setSort(String sort) {
117:                    sortString = sort;
118:                }
119:            }
120:
121:            public class Pager {
122:
123:                protected int totalItems;
124:
125:                protected int firstItem;
126:
127:                protected int pageSize;
128:
129:                public static final String FIRST = "|<", PREVIOUS = "<",
130:                        NEXT = ">", LAST = ">|";
131:
132:                public Pager(int totalItems, int firstItem, int pageSize) {
133:                    this .totalItems = totalItems;
134:                    this .firstItem = firstItem;
135:                    this .pageSize = pageSize;
136:                }
137:
138:                public int getFirstItemNumber() {
139:                    return firstItem + 1;
140:                }
141:
142:                public int getLastItemNumber() {
143:                    int n = firstItem + pageSize;
144:                    return (totalItems < n ? totalItems : n);
145:                }
146:
147:                public boolean getCanFirst() {
148:                    return firstItem > 0;
149:                }
150:
151:                public boolean getCanPrevious() {
152:                    return getCanFirst();
153:                }
154:
155:                public boolean getCanNext() {
156:                    return getLastItemNumber() < totalItems;
157:                }
158:
159:                public boolean getCanLast() {
160:                    return getCanNext();
161:                }
162:
163:                public int[] getPageSizes() {
164:                    return PAGESIZES;
165:                }
166:
167:                public int getFirstItem() {
168:                    return firstItem;
169:                }
170:
171:                public void setFirstItem(int firstItem) {
172:                    this .firstItem = firstItem;
173:                }
174:
175:                public int getPageSize() {
176:                    return pageSize;
177:                }
178:
179:                public void setPageSize(int pageSize) {
180:                    this .pageSize = pageSize;
181:                }
182:
183:                public int getTotalItems() {
184:                    return totalItems;
185:                }
186:
187:                public void setTotalItems(int totalItems) {
188:                    this.totalItems = totalItems;
189:                }
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.