Source Code Cross Referenced for FxSelectListItemEdit.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.exceptions.FxInvalidParameterException;
036:        import com.flexive.shared.security.ACL;
037:        import com.flexive.shared.value.BinaryDescriptor;
038:        import com.flexive.shared.value.FxString;
039:
040:        import java.io.Serializable;
041:
042:        /**
043:         * Editable select list item
044:         *
045:         * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046:         */
047:        public class FxSelectListItemEdit extends FxSelectListItem implements 
048:                Serializable {
049:
050:            private static final long serialVersionUID = -4068691002679713796L;
051:
052:            /**
053:             * is this a new list item?
054:             */
055:            private boolean isNew;
056:            /**
057:             * The original item to compare for changes
058:             */
059:            private FxSelectListItem original;
060:
061:            /**
062:             * Constructor to make an existing list item editable
063:             *
064:             * @param item the item to make editable
065:             */
066:            public FxSelectListItemEdit(FxSelectListItem item) {
067:                super (item.id, item.acl, item.list, item.parentItemId,
068:                        item.label, item.data, item.color, item.iconId,
069:                        item.iconVer, item.iconQuality, item.lifeCycleInfo);
070:                this .isNew = false;
071:                this .original = item;
072:                this .parentItem = item.parentItem;
073:            }
074:
075:            /**
076:             * Internal constructor to make an existing list item editable and add it to an editable select list.
077:             *
078:             * @param item  the item to make editable
079:             * @param list  the new list to add the item to
080:             */
081:            FxSelectListItemEdit(FxSelectListItem item, FxSelectListEdit list) {
082:                super (item.id, item.acl, list, item.parentItemId, item.label,
083:                        item.data, item.color, item.iconId, item.iconVer,
084:                        item.iconQuality, item.lifeCycleInfo);
085:                this .isNew = false;
086:                this .original = item;
087:                this .parentItem = item.parentItem;
088:            }
089:
090:            /**
091:             * Constructor for creating a new list item
092:             *
093:             * @param acl   the items ACL
094:             * @param list  the list this item belongs to
095:             * @param label this items label
096:             * @param data  optional data
097:             * @param color color for display
098:             */
099:            public FxSelectListItemEdit(ACL acl, FxSelectList list,
100:                    FxString label, String data, String color) {
101:                super (calcId(list), acl, list, -1, label, data, color,
102:                        BinaryDescriptor.SYS_SELECTLIST_DEFAULT, 1, 1, null);
103:                this .isNew = true;
104:                this .original = null;
105:            }
106:
107:            /**
108:             * Calculate an unused id for the parent list to use for this item (for new items only)
109:             *
110:             * @param list parent list to check
111:             * @return calculated id
112:             */
113:            private static synchronized long calcId(FxSelectList list) {
114:                int curr = -1;
115:                while (list.containsItem(curr))
116:                    curr--;
117:                return curr;
118:            }
119:
120:            /**
121:             * Is this a new list item?
122:             *
123:             * @return is anew list item?
124:             */
125:            public boolean isNew() {
126:                return isNew;
127:            }
128:
129:            /**
130:             * Have any changes been made?
131:             *
132:             * @return changes made?
133:             */
134:            public boolean changes() {
135:                return isNew || original == null
136:                        || !this .data.equals(original.data)
137:                        || !this .color.equals(original.color)
138:                        || this .iconId != original.iconId
139:                        || this .iconVer != original.iconVer
140:                        || this .iconQuality != original.iconQuality
141:                        || !this .label.equals(original.label)
142:                        || this .parentItemId != original.parentItemId
143:                        || this .acl.getId() != original.acl.getId();
144:            }
145:
146:            /**
147:             * Set this items label
148:             *
149:             * @param label label of this item
150:             */
151:            public void setLabel(FxString label) {
152:                this .label = label;
153:                if (this .label == null)
154:                    this .label = new FxString("");
155:            }
156:
157:            /**
158:             * Set this items acl
159:             *
160:             * @param acl acl of this item
161:             */
162:            public void setAcl(ACL acl) {
163:                this .acl = acl;
164:            }
165:
166:            /**
167:             * Set optional item data
168:             *
169:             * @param data optional item data
170:             */
171:            public void setData(String data) {
172:                this .data = data;
173:                if (this .data == null)
174:                    this .data = "";
175:            }
176:
177:            /**
178:             * Set the items display color
179:             *
180:             * @param color display color
181:             */
182:            public void setColor(String color) {
183:                this .color = color;
184:                if (this .color == null)
185:                    this .color = "";
186:            }
187:
188:            /**
189:             * Set the id of icon used for user interfaces (reference to binaries, internal field!)
190:             *
191:             * @param iconId id of icon used for user interfaces (reference to binaries, internal field!)
192:             */
193:            public void setIconId(long iconId) {
194:                this .iconId = iconId;
195:            }
196:
197:            /**
198:             * Set the version of icon used for user interfaces (reference to binaries, internal field!)
199:             *
200:             * @param iconVer version of icon used for user interfaces (reference to binaries, internal field!)
201:             */
202:            public void setIconVer(int iconVer) {
203:                this .iconVer = iconVer;
204:            }
205:
206:            /**
207:             * Set the quality of icon used for user interfaces (reference to binaries, internal field!)
208:             *
209:             * @param iconQuality quality of icon used for user interfaces (reference to binaries, internal field!)
210:             */
211:            public void setIconQuality(int iconQuality) {
212:                this .iconQuality = iconQuality;
213:            }
214:
215:            public FxSelectListItemEdit setDefaultItem() {
216:                this .getList()._setDefaultItem(this );
217:                return this ;
218:            }
219:
220:            /**
221:             * Helper method to create a new FxSelectListItemEdit instance
222:             *
223:             * @param acl   the items ACL
224:             * @param list  the list this item belongs to
225:             * @param label this items label
226:             * @param data  optional data
227:             * @param color color for display
228:             * @return FxSelectListItemEdit
229:             */
230:            public static FxSelectListItemEdit createNew(ACL acl,
231:                    FxSelectList list, FxString label, String data, String color) {
232:                return new FxSelectListItemEdit(acl, list, label, data, color);
233:            }
234:
235:            /**
236:             * Set a parent item
237:             *
238:             * @param item item from the parent list to assign as parent item
239:             * @return FxSelectListItemEdit
240:             * @throws FxInvalidParameterException if the parent item is not valid for this item
241:             */
242:            public FxSelectListItemEdit setParentItem(FxSelectListItem item)
243:                    throws FxInvalidParameterException {
244:                if (item == null)
245:                    return this ;
246:                if (!this .getList().hasParentList())
247:                    throw new FxInvalidParameterException("item",
248:                            "ex.structure.list.item.noParentList", this 
249:                                    .getLabel().getBestTranslation());
250:                if (item.getList().getId() != this .getList().getId())
251:                    throw new FxInvalidParameterException("item",
252:                            "ex.structure.list.item.invalidParent", this
253:                                    .getList().getId(), item.getList().getId());
254:                this.parentItem = item;
255:                return this;
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.