Source Code Cross Referenced for FxSelectListEdit.java in  » J2EE » fleXive » com » flexive » shared » structure » 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.shared.structure 
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-2008
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.shared.structure;
034:
035:        import com.flexive.shared.CacheAdmin;
036:        import com.flexive.shared.SelectableObjectWithName;
037:        import com.flexive.shared.SelectableObjectWithLabel;
038:        import com.flexive.shared.security.ACL;
039:        import com.flexive.shared.value.FxString;
040:
041:        import java.io.Serializable;
042:        import java.util.ArrayList;
043:        import java.util.List;
044:
045:        /**
046:         * Editable select list
047:         *
048:         * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
049:         */
050:        public class FxSelectListEdit extends FxSelectList implements 
051:                Serializable {
052:
053:            private static final long serialVersionUID = 8842659204852529463L;
054:
055:            /**
056:             * is this a new list?
057:             */
058:            private boolean isNew;
059:            private FxSelectList original;
060:
061:            /**
062:             * Constructor
063:             *
064:             * @param list the list to make editable
065:             */
066:            public FxSelectListEdit(FxSelectList list) {
067:                super (list.id, list.parentListId, "" + list.name, list.label
068:                        .copy(), list.description.copy(),
069:                        list.allowDynamicItemCreation, list.createItemACL,
070:                        list.newItemACL, list.hasDefaultItem() ? list
071:                                .getDefaultItem().getId() : 0);
072:                this .isNew = false;
073:                this .original = list;
074:                this .parentList = list.parentList;
075:                for (FxSelectListItem i : list.getItems()) {
076:                    new FxSelectListItemEdit(i, this );
077:                }
078:            }
079:
080:            /**
081:             * Constructor for creating a new list
082:             *
083:             * @param parent                   parent list if not null
084:             * @param name                     name - has to be unique!
085:             * @param label                    label
086:             * @param description              description
087:             * @param allowDynamicItemCreation is dynamic item creation allowed?
088:             * @param createItemACL            ACL whose create flag is checked against for creating new list items
089:             * @param newItemACL               ACL assigned to new items
090:             * @param defaultItem              the default selected item, optional, can be <code>null</code>
091:             */
092:            public FxSelectListEdit(FxSelectList parent, String name,
093:                    FxString label, FxString description,
094:                    boolean allowDynamicItemCreation, ACL createItemACL,
095:                    ACL newItemACL, FxSelectListItem defaultItem) {
096:                super (-1, parent != null ? parent.getId() : -1, name, label,
097:                        description, allowDynamicItemCreation, createItemACL,
098:                        newItemACL, defaultItem != null ? defaultItem.getId()
099:                                : 0);
100:                if (parent != null || defaultItem != null)
101:                    super ._synchronize(CacheAdmin.getEnvironment());
102:                this .isNew = true;
103:            }
104:
105:            /**
106:             * Is this a new list?
107:             *
108:             * @return is a new list?
109:             */
110:            public boolean isNew() {
111:                return isNew;
112:            }
113:
114:            /**
115:             * Have any changes been made?
116:             *
117:             * @return changes made?
118:             */
119:            public boolean changes() {
120:                return isNew || original == null
121:                        || !original.name.equals(this .name)
122:                        || original.parentListId != this .parentListId
123:                        || !original.label.equals(this .label)
124:                        || !original.description.equals(this .description);
125:            }
126:
127:            /**
128:             * Set the name - has to be unique!
129:             *
130:             * @param name name
131:             */
132:            public void setName(String name) {
133:                this .name = name;
134:                if (this .name == null)
135:                    this .name = "";
136:            }
137:
138:            /**
139:             * Set the label
140:             *
141:             * @param label label
142:             */
143:            public void setLabel(FxString label) {
144:                this .label = label;
145:                if (this .label == null)
146:                    this .label = new FxString("");
147:            }
148:
149:            /**
150:             * Set the description
151:             *
152:             * @param description description
153:             */
154:            public void setDescription(FxString description) {
155:                this .description = description;
156:                if (this .description == null)
157:                    this .description = new FxString("");
158:            }
159:
160:            /**
161:             * Set a new default item, setting <code>null</code> will clear the default item
162:             *
163:             * @param defaultItem a new default item, setting <code>null</code> will clear the default item
164:             * @return this
165:             */
166:            public FxSelectListEdit setDefaultItem(FxSelectListItem defaultItem) {
167:                _setDefaultItem(defaultItem);
168:                return this ;
169:            }
170:
171:            /**
172:             * returns all list items as editable list items.
173:             *
174:             * @return  a list of editable list items.
175:             */
176:            public List<FxSelectListItemEdit> getEditableItems() {
177:                List<FxSelectListItemEdit> editableItems = new ArrayList<FxSelectListItemEdit>();
178:                for (Long l : items.keySet()) {
179:                    FxSelectListItem i = items.get(l);
180:                    if (i instanceof  FxSelectListItemEdit)
181:                        editableItems.add((FxSelectListItemEdit) i);
182:                    else
183:                        editableItems.add(new FxSelectListItemEdit(i));
184:                }
185:                return editableItems;
186:            }
187:
188:            /**
189:             * adds a new item to the select list.
190:             *
191:             * @param item    the item to add to the select list
192:             */
193:
194:            public void addItem(FxSelectListItem item) {
195:                new FxSelectListItemEdit(item.acl, this , item.label, item.data,
196:                        item.color);
197:            }
198:
199:            /**
200:             * Removes the item with Id from the items map.
201:             *
202:             * @param id    id of the item to remove
203:             */
204:
205:            public void removeItem(Long id) {
206:                this .items.remove(id);
207:            }
208:
209:            /**
210:             * Adds all given objects to this select list.
211:             *
212:             * @param items the objects to be added
213:             */
214:            public void addAll(List<? extends SelectableObjectWithLabel> items) {
215:                for (SelectableObjectWithLabel item : items) {
216:                    new FxSelectListItem(item.getId(), this , -1, item
217:                            .getLabel());
218:                }
219:            }
220:
221:            /**
222:             * Adds all given objects to this select list.
223:             *
224:             * @param items the objects to be added
225:             */
226:            public void addAllWithName(
227:                    List<? extends SelectableObjectWithName> items) {
228:                for (SelectableObjectWithName item : items) {
229:                    new FxSelectListItem(item.getId(), this , -1, new FxString(
230:                            false, item.getName()));
231:                }
232:            }
233:
234:            /**
235:             * Assign an id for a new created list to be synchronized with items
236:             *
237:             * @param newId new list id
238:             */
239:            public void _synchronizeId(long newId) {
240:                if (!isNew)
241:                    return;
242:                this .id = newId;
243:                for (FxSelectListItem item : this .getItems())
244:                    item._updateList(this );
245:            }
246:
247:            /**
248:             * Helper method to create a new FxSelectListEdit instance
249:             *
250:             * @param name                     name - has to be unique!
251:             * @param label                    label
252:             * @param description              description
253:             * @param allowDynamicItemCreation is dynamic item creation allowed?
254:             * @param createItemACL            ACL whose create flag is checked against for creating new list items
255:             * @param defaultItemACL           ACL assigned to new items
256:             * @return FxSelectListEdit
257:             */
258:            public static FxSelectListEdit createNew(String name,
259:                    FxString label, FxString description,
260:                    boolean allowDynamicItemCreation, ACL createItemACL,
261:                    ACL defaultItemACL) {
262:                return new FxSelectListEdit(null, name, label, description,
263:                        allowDynamicItemCreation, createItemACL,
264:                        defaultItemACL, null);
265:            }
266:
267:            /**
268:             * Helper method to create a new FxSelectListEdit instance
269:             *
270:             * @param parent                   parent list if not null
271:             * @param name                     name - has to be unique!
272:             * @param label                    label
273:             * @param description              description
274:             * @param allowDynamicItemCreation is dynamic item creation allowed?
275:             * @param createItemACL            ACL whose create flag is checked against for creating new list items
276:             * @param defaultItemACL           ACL assigned to new items
277:             * @return FxSelectListEdit
278:             */
279:            public static FxSelectListEdit createNew(FxSelectList parent,
280:                    String name, FxString label, FxString description,
281:                    boolean allowDynamicItemCreation, ACL createItemACL,
282:                    ACL defaultItemACL) {
283:                return new FxSelectListEdit(parent, name, label, description,
284:                        allowDynamicItemCreation, createItemACL,
285:                        defaultItemACL, null);
286:            }
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.