Source Code Cross Referenced for WidgetState.java in  » Groupware » lucane » org » lucane » client » util » 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 » Groupware » lucane » org.lucane.client.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Lucane - a collaborative platform
003:         * Copyright (C) 2004  Vincent Fiack <vfiack@mail15.com>
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:
020:        package org.lucane.client.util;
021:
022:        import java.awt.*;
023:        import javax.swing.*;
024:
025:        import org.lucane.client.LocalConfig;
026:
027:        /**
028:         * Used to store a widget (JFrame, JScrollPane, ...) in a LocalConfig
029:         */
030:        public class WidgetState {
031:            /**
032:             * Create a key based on the widget name
033:             * 
034:             * @param component the widget
035:             * @param property the property to store
036:             * @return the key
037:             */
038:            private static String getKey(Component component, String property) {
039:                String name = (component != null) ? component.getName()
040:                        : "null";
041:                return "widget-" + name + "-" + property;
042:            }
043:
044:            /**
045:             * Save a component
046:             * 
047:             * @param config the LocalConfig
048:             * @param widget the component
049:             */
050:            public static void save(LocalConfig config, Object widget) {
051:                if (widget instanceof  JFrame)
052:                    save(config, (JFrame) widget);
053:                else if (widget instanceof  Window)
054:                    save(config, (Window) widget);
055:                else if (widget instanceof  JSlider)
056:                    save(config, (JSlider) widget);
057:                else if (widget instanceof  JSplitPane)
058:                    save(config, (JSplitPane) widget);
059:            }
060:
061:            /**
062:             * Restore a component
063:             * 
064:             * @param config the LocalConfig
065:             * @param widget the component
066:             */
067:            public static void restore(LocalConfig config, Object widget) {
068:                if (widget instanceof  JFrame)
069:                    restore(config, (JFrame) widget);
070:                else if (widget instanceof  Window)
071:                    restore(config, (Window) widget);
072:                else if (widget instanceof  JSlider)
073:                    restore(config, (JSlider) widget);
074:                else if (widget instanceof  JSplitPane)
075:                    restore(config, (JSplitPane) widget);
076:            }
077:
078:            /**
079:             * Save a window
080:             * 
081:             * @param config the LocalConfig
082:             * @param window the Window
083:             */
084:            public static void save(LocalConfig config, Window window) {
085:                config.set(getKey(window, "saved"), "true");
086:                config
087:                        .set(getKey(window, "location.x"),
088:                                window.getLocation().x);
089:                config
090:                        .set(getKey(window, "location.y"),
091:                                window.getLocation().y);
092:                config.set(getKey(window, "height"), window.getHeight());
093:                config.set(getKey(window, "width"), window.getWidth());
094:            }
095:
096:            /**
097:             * Restore a window
098:             * 
099:             * @param config the LocalConfig
100:             * @param window the Window
101:             */
102:            public static void restore(LocalConfig config, Window window) {
103:                String saved = config.get(getKey(window, "saved"));
104:                if (saved == null)
105:                    return;
106:
107:                int x = config.getInt(getKey(window, "location.x"));
108:                int y = config.getInt(getKey(window, "location.y"));
109:                window.setLocation(x, y);
110:
111:                int height = config.getInt(getKey(window, "height"));
112:                int width = config.getInt(getKey(window, "width"));
113:                window.setSize(width, height);
114:            }
115:
116:            /**
117:             * Save a frame
118:             * 
119:             * @param config the LocalConfig
120:             * @param frame the JFrame
121:             */
122:            public static void save(LocalConfig config, JFrame frame) {
123:                save(config, (Window) frame);
124:                config.set(getKey(frame, "extended"), frame.getExtendedState());
125:            }
126:
127:            /**
128:             * Restore a frame
129:             * 
130:             * @param config the LocalConfig
131:             * @param frame the JFrame
132:             */
133:            public static void restore(LocalConfig config, JFrame frame) {
134:                String saved = config.get(getKey(frame, "saved"));
135:                if (saved == null)
136:                    return;
137:
138:                restore(config, (Window) frame);
139:                frame
140:                        .setExtendedState(config.getInt(getKey(frame,
141:                                "extended")));
142:            }
143:
144:            /**
145:             * Save a slider
146:             * 
147:             * @param config the LocalConfig
148:             * @param slider the splider
149:             */
150:            public static void save(LocalConfig config, JSlider slider) {
151:                config.set(getKey(slider, "saved"), "true");
152:                config.set(getKey(slider, "value"), slider.getValue());
153:            }
154:
155:            /**
156:             * Restore a slider
157:             * 
158:             * @param config the LocalConfig
159:             * @param slider the JSlider
160:             */
161:            public static void restore(LocalConfig config, JSlider slider) {
162:                String saved = config.get(getKey(slider, "saved"));
163:                if (saved == null)
164:                    return;
165:
166:                slider.setValue(config.getInt(getKey(slider, "value")));
167:            }
168:
169:            /**
170:             * Save a JSplitPane
171:             * 
172:             * @param config the LocalConfig
173:             * @param split the JSplitPane
174:             */
175:            public static void save(LocalConfig config, JSplitPane split) {
176:                config.set(getKey(split, "saved"), "true");
177:                config.set(getKey(split, "dividerLocation"), split
178:                        .getDividerLocation());
179:            }
180:
181:            /**
182:             * Restore a JSplitPane
183:             * 
184:             * @param config the LocalConfig
185:             * @param split the JSplitPane
186:             */
187:            public static void restore(LocalConfig config, JSplitPane split) {
188:                String saved = config.get(getKey(split, "saved"));
189:                if (saved == null)
190:                    return;
191:
192:                split.setDividerLocation(config.getInt(getKey(split,
193:                        "dividerLocation")));
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.