Source Code Cross Referenced for FormMemento.java in  » Swing-Library » abeille-forms-designer » com » jeta » forms » store » memento » 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 » Swing Library » abeille forms designer » com.jeta.forms.store.memento 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2004 JETA Software, Inc.  All rights reserved.
003:         * 
004:         * Redistribution and use in source and binary forms, with or without modification, 
005:         * are permitted provided that the following conditions are met:
006:         *
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer.
009:         *
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution.
013:         *
014:         *  o Neither the name of JETA Software nor the names of its contributors may 
015:         *    be used to endorse or promote products derived from this software without 
016:         *    specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
021:         * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022:         * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
023:         * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
026:         * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         */
029:
030:        package com.jeta.forms.store.memento;
031:
032:        import java.io.IOException;
033:        import java.util.HashMap;
034:        import java.util.Iterator;
035:        import java.util.LinkedList;
036:
037:        import com.jeta.forms.gui.common.FormUtils;
038:        import com.jeta.forms.store.JETAObjectInput;
039:        import com.jeta.forms.store.JETAObjectOutput;
040:        import com.jeta.forms.store.support.Matrix;
041:
042:        /**
043:         * This class represents the state of a FormComponent including all of its Java
044:         * bean components and nested forms. A FormMemento can be safely serialized to
045:         * an i/o stream. You can get the state of a FormComponent by calling:
046:         * {@link com.jeta.forms.gui.form.FormComponent#getState} Likewise, you can set
047:         * the state of a FormComponent by calling:
048:         * {@link com.jeta.forms.gui.form.FormComponent#setState} Once you have a
049:         * FormMemento object, you can create and initialize multiple FormComponents
050:         * from the memento.
051:         * 
052:         * <pre>
053:         * 
054:         *     // assume you have a given form component
055:         *     FormComponent fc1 = ...;
056:         * 
057:         *     FormMemento memento = fc1.getState();
058:         *     FormComponent fc2 = new FormComponent();
059:         *     fc2.setState( memento );
060:         * 
061:         *     FormComponent fc3 = new FormComponent();
062:         *     fc3.setState( memento );
063:         *    
064:         *     //  fc2 and fc3 are copies of fc1 
065:         *  
066:         * </pre>
067:         * 
068:         * @author Jeff Tassin
069:         */
070:        public class FormMemento extends ComponentMemento {
071:            static final long serialVersionUID = -7808404997780438089L;
072:
073:            /**
074:             * The version of this class.
075:             */
076:            public static final int VERSION = 5;
077:
078:            /**
079:             * The encoded row specifications used in the FormLayout for this form.
080:             */
081:            private String m_row_specs;
082:
083:            /**
084:             * The encoded column specifications used in the FormLayout for this form.
085:             */
086:            private String m_column_specs;
087:
088:            /**
089:             * A list of child component states (ComponentMemento)
090:             */
091:            private LinkedList m_components = new LinkedList();
092:
093:            /**
094:             * The bean properties for the form such as background color, opaque, fill,
095:             * etc. This variable will be null for class versions less than 5.
096:             */
097:            private PropertiesMemento m_properties_memento;
098:
099:            /**
100:             * The relative path that contains this form if it is linked form.
101:             */
102:            private String m_path;
103:
104:            /**
105:             * A unique id for this form.
106:             */
107:            private String m_id;
108:
109:            /**
110:             * The cell painters for this form. These are responsible for fill effects
111:             * for an individual cell.
112:             */
113:            private Matrix m_cell_painters;
114:
115:            /**
116:             * The row group assignments for the form.
117:             * 
118:             * @see com.jgoodies.forms.layout.FormLayout#setRowGroups(int[][])
119:             */
120:            private FormGroupSet m_row_groups;
121:
122:            /**
123:             * The column group assignments for the form.
124:             * 
125:             * @see com.jgoodies.forms.layout.FormLayout#setColumnGroups(int[][])
126:             */
127:            private FormGroupSet m_column_groups;
128:
129:            /**
130:             * The focus policy for this form. Can be null. (Not currently used).
131:             */
132:            private FocusPolicyMemento m_focus_policy;
133:
134:            /**
135:             * Properties for the form. These are properties such as background color
136:             * and border that are applied to the form as a whole. m_properties<String,Object>
137:             * where: String: property name Object: property value (must be
138:             * serializable)
139:             * 
140:             * @deprecated As of version 5 of this class. PropertiesMemento is used
141:             *             instead.
142:             */
143:            private HashMap m_properties = new HashMap();
144:
145:            /**
146:             * Adds a child component's state to the list of states owned by this
147:             * memento.
148:             * 
149:             * @param memento
150:             *            the state of a Java Bean (BeanComponent) or nested form that
151:             *            is contained by this form.
152:             */
153:            public void addComponent(ComponentMemento memento) {
154:                m_components.add(memento);
155:            }
156:
157:            /**
158:             * Returns a matrix that defines the painters for individual cells in the
159:             * form.
160:             * 
161:             * @return A matrix of cell painters
162:             */
163:            public Matrix getCellPainters() {
164:                return m_cell_painters;
165:            }
166:
167:            /**
168:             * Return the column groups for the form.
169:             * 
170:             * @return the column groups for the form
171:             */
172:            public FormGroupSet getColumnGroups() {
173:                return m_column_groups;
174:            }
175:
176:            /**
177:             * Return an encoded string of column specs for this form. Each column spec
178:             * is separated by a comma.
179:             * 
180:             * @return the encoded ColumnSpecs used by the FormLayout for this form.
181:             */
182:            public String getColumnSpecs() {
183:                return m_column_specs;
184:            }
185:
186:            /**
187:             * Returns the focus policy for the form.
188:             * 
189:             * @return the focus policy for this form
190:             * @deprecated no longer supporting focus in the designer.
191:             */
192:            public FocusPolicyMemento getFocusPolicy() {
193:                return m_focus_policy;
194:            }
195:
196:            /**
197:             * Returns a unique id for this form. The id is used primarily in the
198:             * designer and has no effect during runtime.
199:             * 
200:             * @return the unique id for this form
201:             */
202:            public String getId() {
203:                return m_id;
204:            }
205:
206:            /**
207:             * Returns properties memento for this form. The PropertiesMemento stores
208:             * the Java Bean properties and custom properties for a component.
209:             * 
210:             * @return the properties memento to associated with this form.
211:             */
212:            public PropertiesMemento getPropertiesMemento() {
213:                return m_properties_memento;
214:            }
215:
216:            /**
217:             * @return the form properties
218:             * @deprecated replaced by getPropertiesMemento. see
219:             *             #getPropertiesMemento().
220:             */
221:            public HashMap getProperties() {
222:                return m_properties;
223:            }
224:
225:            /**
226:             * Returns the relative path where this form is located. This is the same as
227:             * the package that contains the form.
228:             * 
229:             * @return the relative path where this form is located.
230:             */
231:            public String getRelativePath() {
232:                return m_path;
233:            }
234:
235:            /**
236:             * Return the row groups for this form.
237:             * 
238:             * @return the row groups for the form
239:             */
240:            public FormGroupSet getRowGroups() {
241:                return m_row_groups;
242:            }
243:
244:            /**
245:             * Return an encoded string of row specs for this form. Each row spec is
246:             * separated by a comma.
247:             * 
248:             * @return the encoded RowSpecs used by the FormLayout for this form.
249:             */
250:            public String getRowSpecs() {
251:                return m_row_specs;
252:            }
253:
254:            /**
255:             * Returns an iterator to a set of ComponentMemento objects which are
256:             * contained by this form.
257:             * 
258:             * @returns an iterator that can be used to iterate over all child
259:             *          ComponentMemento objects currently contained in this mememnto
260:             */
261:            public Iterator iterator() {
262:                return m_components.iterator();
263:            }
264:
265:            /**
266:             * Used for testing
267:             */
268:            public void print() {
269:                System.out
270:                        .println(" >>>>>>>>>>>>>>>>>  FormMemento state >>>>>>>>>>>>>> ");
271:                System.out.println("rowSpecs: " + m_row_specs);
272:                System.out.println("colSpecs: " + m_column_specs);
273:                System.out.println(" ----------- comp mementos --------- ");
274:                Iterator iter = m_components.iterator();
275:                while (iter.hasNext()) {
276:                    ComponentMemento cm = (ComponentMemento) iter.next();
277:                    cm.print();
278:                }
279:            }
280:
281:            /**
282:             * Sets the cell painters defined in the form.
283:             * 
284:             * @param painters
285:             *            A matrix of cell painters
286:             */
287:            public void setCellPainters(Matrix painters) {
288:                m_cell_painters = painters;
289:            }
290:
291:            /**
292:             * Set the column groups for the form
293:             * 
294:             * @param colgrps
295:             *            the column groups
296:             * @see com.jgoodies.forms.layout.FormLayout#setColumnGroups(int[][])
297:             */
298:            public void setColumnGroups(FormGroupSet colgrps) {
299:                m_column_groups = colgrps;
300:            }
301:
302:            /**
303:             * Sets the encoded ColumnSpecs used by the FormLayout for this form.
304:             * 
305:             * @param colSpecs
306:             *            a comma separated list of column specs.
307:             */
308:            public void setColumnSpecs(String colSpecs) {
309:                m_column_specs = colSpecs;
310:            }
311:
312:            /**
313:             * Sets the focus policy for this form
314:             * 
315:             * @param memento
316:             *            the focus policy state
317:             * @deprecated focus is no longer supported in the designer.
318:             */
319:            public void setFocusPolicy(FocusPolicyMemento memento) {
320:                m_focus_policy = memento;
321:            }
322:
323:            /**
324:             * Sets the unique id for this form. Ids are only used by the designer and
325:             * have no effect during runtime.
326:             * 
327:             * @param id
328:             *            the id to assign to the form.
329:             */
330:            public void setId(String id) {
331:                m_id = id;
332:            }
333:
334:            /**
335:             * Sets the relative path where this form is located. This is the same as
336:             * the package that contains the form.
337:             * 
338:             * @param path
339:             *            the relative path to set for the form.
340:             */
341:            public void setRelativePath(String path) {
342:                m_path = path;
343:            }
344:
345:            /**
346:             * Set the row groups for the form
347:             * 
348:             * @param rowgrps
349:             *            the row groups to set
350:             * @see com.jgoodies.forms.layout.FormLayout#setRowGroups(int[][])
351:             */
352:            public void setRowGroups(FormGroupSet rowgrps) {
353:                m_row_groups = rowgrps;
354:            }
355:
356:            /**
357:             * Sets the form properties
358:             * 
359:             * @deprecated As of version 5 of this class.
360:             * @see #setPropertiesMemento(PropertiesMemento)
361:             */
362:            public void setProperties(HashMap props) {
363:                m_properties = props;
364:            }
365:
366:            /**
367:             * Sets the properties memento for this form. The PropertiesMemento stores
368:             * standard Java bean properties and custom properties.
369:             * 
370:             * @param pm
371:             *            the properties memento to associated with this form.
372:             */
373:            public void setPropertiesMemento(PropertiesMemento pm) {
374:                m_properties_memento = pm;
375:            }
376:
377:            /**
378:             * Sets the RowSpecs used by the FormLayout for this form.
379:             * 
380:             * @param rowSpecs
381:             *            a comma separated list of row specs for the form.
382:             */
383:            public void setRowSpecs(String rowSpecs) {
384:                m_row_specs = rowSpecs;
385:            }
386:
387:            /**
388:             * Returns the number of child components in this form.
389:             */
390:            public int size() {
391:                return m_components.size();
392:            }
393:
394:            /**
395:             * JETAPersistable Implementation
396:             */
397:            public void read(JETAObjectInput in) throws ClassNotFoundException,
398:                    IOException {
399:                super .read(in.getSuperClassInput());
400:                int version = in.readVersion();
401:                m_id = (String) in.readObject("id");
402:                m_path = (String) in.readObject("path");
403:                if (FormUtils.isDesignMode()) {
404:                    m_path = FormUtils.fixPath(m_path);
405:                }
406:
407:                m_row_specs = (String) in.readObject("rowspecs");
408:                m_column_specs = (String) in.readObject("colspecs");
409:                m_components = (LinkedList) in.readObject("components");
410:
411:                if (version >= 5) {
412:                    m_properties_memento = (PropertiesMemento) in
413:                            .readObject("properties");
414:                } else {
415:                    m_properties = (HashMap) in.readObject("properties");
416:                }
417:
418:                if (version >= 2)
419:                    m_cell_painters = (Matrix) in.readObject("cellpainters");
420:
421:                if (version >= 3) {
422:                    m_focus_policy = (FocusPolicyMemento) in
423:                            .readObject("focuspolicy");
424:                    // not doing focus anymore
425:                    m_focus_policy = null;
426:                }
427:
428:                if (version >= 4) {
429:                    m_row_groups = (FormGroupSet) in.readObject("rowgroups");
430:                    m_column_groups = (FormGroupSet) in.readObject("colgroups");
431:                }
432:            }
433:
434:            /**
435:             * JETAPersistable Implementation
436:             */
437:            public void write(JETAObjectOutput out) throws IOException {
438:                super .write(out.getSuperClassOutput(ComponentMemento.class));
439:                out.writeVersion(VERSION);
440:                out.writeObject("id", m_id);
441:                out.writeObject("path", m_path);
442:                out.writeObject("rowspecs", m_row_specs);
443:                out.writeObject("colspecs", m_column_specs);
444:                out.writeObject("components", m_components);
445:                out.writeObject("properties", m_properties_memento);
446:                out.writeObject("cellpainters", m_cell_painters);
447:                out.writeObject("focuspolicy", m_focus_policy);
448:                out.writeObject("rowgroups", m_row_groups);
449:                out.writeObject("colgroups", m_column_groups);
450:            }
451:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.