Source Code Cross Referenced for SelectListBean.java in  » J2EE » fleXive » com » flexive » war » beans » admin » main » 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 » J2EE » fleXive » com.flexive.war.beans.admin.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2007
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.war.beans.admin.main;
034:
035:        import com.flexive.faces.messages.FxFacesMsgErr;
036:        import com.flexive.shared.CacheAdmin;
037:        import com.flexive.shared.EJBLookup;
038:        import com.flexive.shared.FxSharedUtils;
039:        import com.flexive.shared.security.ACL;
040:        import com.flexive.shared.structure.FxSelectList;
041:        import com.flexive.shared.structure.FxSelectListEdit;
042:        import com.flexive.shared.structure.FxSelectListItemEdit;
043:        import com.flexive.shared.value.FxString;
044:
045:        import java.util.ArrayList;
046:        import java.util.List;
047:        import java.util.Map;
048:
049:        /**
050:         * Bean to display and edit FxSelectList objects and FxSelectListItem objects
051:         *
052:         * @author Gerhard Glos (gerhard.glos@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
053:         */
054:
055:        public class SelectListBean {
056:            //used to filter out the select lists with id's 0 up to DELIMITER and prevent them from being edited
057:            private static final long SYSTEM_INTERNAL_LISTS_DELIMITER = 0;
058:            private FxSelectListEdit selectList = null;
059:            private long selectListId = -1;
060:            private String selectListName = "";
061:            private FxString selectListLabel = new FxString("");
062:            private FxString selectListDescription = new FxString("");
063:            private boolean selectListAllowDynamicCreation = true;
064:            private long selectListCreateItemACLId = ACL.Category.SELECTLIST
065:                    .getDefaultId();
066:            private long selectListDefaultItemACLId = ACL.Category.SELECTLISTITEM
067:                    .getDefaultId();
068:
069:            private long listItemId = -1;
070:            private FxString itemLabel = new FxString("");
071:            private ACL itemACL = null;
072:            private String itemData = "";
073:            private String itemColor = "";
074:
075:            /**
076:             * hack to generate unique id for the UI delete button, which can be used in java script
077:             *
078:             * @return unique id string for delete button
079:             */
080:            public Map<Long, String> getIdMap() {
081:                return FxSharedUtils
082:                        .getMappedFunction(new FxSharedUtils.ParameterMapper<Long, String>() {
083:                            public String get(Object key) {
084:                                long id = (Long) key;
085:                                if (id >= 0)
086:                                    return String.valueOf(id);
087:                                else
088:                                    return "_" + String.valueOf(id * -1);
089:                            }
090:                        });
091:            }
092:
093:            public FxString getItemLabel() {
094:                return itemLabel;
095:            }
096:
097:            public void setItemLabel(FxString itemLabel) {
098:                this .itemLabel = itemLabel;
099:            }
100:
101:            public ACL getItemACL() {
102:                return itemACL;
103:            }
104:
105:            public void setItemACL(ACL itemACL) {
106:                this .itemACL = itemACL;
107:            }
108:
109:            public String getItemData() {
110:                return itemData;
111:            }
112:
113:            public void setItemData(String itemData) {
114:                this .itemData = itemData;
115:            }
116:
117:            public String getItemColor() {
118:                return itemColor;
119:            }
120:
121:            public void setItemColor(String itemColor) {
122:                this .itemColor = itemColor;
123:            }
124:
125:            public long getListItemId() {
126:                return listItemId;
127:            }
128:
129:            public void setListItemId(long listItemId) {
130:                this .listItemId = listItemId;
131:            }
132:
133:            public long getSelectListId() {
134:                return selectListId;
135:            }
136:
137:            public void setSelectListId(long selectListId) {
138:                this .selectListId = selectListId;
139:            }
140:
141:            public String getSelectListName() {
142:                return selectListName;
143:            }
144:
145:            public void setSelectListName(String selectListName) {
146:                this .selectListName = selectListName;
147:            }
148:
149:            public FxString getSelectListLabel() {
150:                return selectListLabel;
151:            }
152:
153:            public void setSelectListLabel(FxString selectListLabel) {
154:                this .selectListLabel = selectListLabel;
155:            }
156:
157:            public FxString getSelectListDescription() {
158:                return selectListDescription;
159:            }
160:
161:            public void setSelectListDescription(FxString selectListDescription) {
162:                this .selectListDescription = selectListDescription;
163:            }
164:
165:            public boolean isSelectListAllowDynamicCreation() {
166:                return selectListAllowDynamicCreation;
167:            }
168:
169:            public void setSelectListAllowDynamicCreation(
170:                    boolean selectListAllowDynamicCreation) {
171:                this .selectListAllowDynamicCreation = selectListAllowDynamicCreation;
172:            }
173:
174:            public long getSelectListCreateItemACLId() {
175:                return selectListCreateItemACLId;
176:            }
177:
178:            public void setSelectListCreateItemACLId(
179:                    long selectListCreateItemACL) {
180:                this .selectListCreateItemACLId = selectListCreateItemACL;
181:            }
182:
183:            public ACL getSelectListDefaultItemACL() {
184:                return CacheAdmin.getEnvironment().getACL(
185:                        selectListDefaultItemACLId);
186:            }
187:
188:            public void setSelectListDefaultItemACL(ACL selectListDefaultItemACL) {
189:                this .selectListDefaultItemACLId = selectListDefaultItemACL
190:                        .getId();
191:                setItemACL(selectListDefaultItemACL);
192:            }
193:
194:            public FxSelectListEdit getSelectList() {
195:                return selectList;
196:            }
197:
198:            public List<FxSelectList> getSelectLists() {
199:                return doFilter(CacheAdmin.getEnvironment().getSelectLists());
200:            }
201:
202:            private List<FxSelectList> doFilter(List<FxSelectList> selectLists) {
203:                List<FxSelectList> filtered = new ArrayList<FxSelectList>();
204:                for (FxSelectList s : selectLists) {
205:                    if (s.getId() < 0
206:                            || s.getId() > SYSTEM_INTERNAL_LISTS_DELIMITER)
207:                        filtered.add(s);
208:                }
209:                return filtered;
210:            }
211:
212:            public String showSelectListOverview() {
213:                return "selectListOverview";
214:            }
215:
216:            public String showCreateSelectList() {
217:                reset();
218:                return "createSelectList";
219:            }
220:
221:            public String showEditSelectList() {
222:                return "editSelectList";
223:            }
224:
225:            public void reset() {
226:                selectListName = "";
227:                selectListLabel = new FxString("");
228:                selectListDescription = new FxString("");
229:                selectListAllowDynamicCreation = true;
230:                selectListCreateItemACLId = ACL.Category.SELECTLIST
231:                        .getDefaultId();
232:                selectListDefaultItemACLId = ACL.Category.SELECTLISTITEM
233:                        .getDefaultId();
234:            }
235:
236:            public String createSelectList() {
237:                try {
238:                    selectListId = EJBLookup.getSelectListEngine().save(
239:                            FxSelectListEdit.createNew(selectListName,
240:                                    selectListLabel, selectListDescription,
241:                                    selectListAllowDynamicCreation, CacheAdmin
242:                                            .getEnvironment().getACL(
243:                                                    selectListCreateItemACLId),
244:                                    CacheAdmin.getEnvironment().getACL(
245:                                            selectListDefaultItemACLId)));
246:                    reset();
247:                    return initEditing();
248:                } catch (Throwable t) {
249:                    new FxFacesMsgErr(t).addToContext();
250:                    return null;
251:                }
252:            }
253:
254:            public String initEditing() {
255:                selectList = CacheAdmin.getEnvironment().getSelectList(
256:                        selectListId).asEditable();
257:                setSelectListAllowDynamicCreation(selectList
258:                        .isAllowDynamicItemCreation());
259:                setSelectListDefaultItemACL(selectList.getNewItemACL());
260:                setSelectListCreateItemACLId(selectList.getCreateItemACL()
261:                        .getId());
262:                setSelectListDescription(selectList.getDescription());
263:                setSelectListLabel(selectList.getLabel());
264:                setSelectListName(selectList.getName());
265:                setItemACL(selectList.getNewItemACL());
266:
267:                return showEditSelectList();
268:            }
269:
270:            public void deleteSelectList() {
271:                try {
272:                    EJBLookup.getSelectListEngine().remove(
273:                            CacheAdmin.getEnvironment().getSelectList(
274:                                    selectListId));
275:                } catch (Throwable t) {
276:                    new FxFacesMsgErr(t).addToContext();
277:                }
278:            }
279:
280:            public void deleteListItem() {
281:                selectList.removeItem(listItemId);
282:            }
283:
284:            public void addListItem() {
285:                new FxSelectListItemEdit(itemACL, selectList, itemLabel,
286:                        itemData, itemColor);
287:                itemLabel = new FxString("");
288:                itemACL = selectList.getNewItemACL();
289:                itemData = "";
290:                itemColor = "";
291:            }
292:
293:            public String saveSelectList() {
294:                try {
295:                    EJBLookup.getSelectListEngine().save(selectList);
296:                    reset();
297:                    return showSelectListOverview();
298:                } catch (Throwable t) {
299:                    new FxFacesMsgErr(t).addToContext();
300:                    return null;
301:                }
302:            }
303:
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.