Source Code Cross Referenced for GlassPaneManager.java in  » Testing » jacareto » jacareto » comp » glasspanes » 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 » Testing » jacareto » jacareto.comp.glasspanes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.comp.glasspanes;
025:
026:        import jacareto.comp.Components;
027:        import jacareto.system.Environment;
028:        import jacareto.system.EnvironmentMember;
029:
030:        import java.awt.Component;
031:        import java.awt.Window;
032:
033:        import java.util.Hashtable;
034:        import java.util.Iterator;
035:        import java.util.Vector;
036:
037:        import javax.swing.JDialog;
038:        import javax.swing.JFrame;
039:
040:        /**
041:         * <p>
042:         * Manages the classpane of the components.
043:         * </p>
044:         *
045:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
046:         * @version 1.01
047:         */
048:        public class GlassPaneManager extends EnvironmentMember {
049:            /** The env. */
050:            private Environment env;
051:
052:            /** The instance which knows the components. */
053:            private Components components;
054:
055:            /** The stored glass pane compounds. */
056:            private Hashtable glassPaneCompounds;
057:
058:            /** A vector which stores all windows who have got a glass pane compound. */
059:            private Vector glassPaneWindows;
060:
061:            /**
062:             * Creates a new GlassPaneCompound.
063:             *
064:             * @param env the environment
065:             * @param components the instance which knows the components
066:             */
067:            public GlassPaneManager(Environment env, Components components) {
068:                super (env);
069:                this .components = components;
070:                glassPaneCompounds = new Hashtable();
071:                glassPaneWindows = new Vector(5, 5);
072:            }
073:
074:            /**
075:             * Returns a glass pane compound for windows based on swing. If the window does not have a
076:             * glasspane compound, <code>null</code> is returned.
077:             *
078:             * @param window the window
079:             *
080:             * @return the glasspane compound, or <code>null</code> if the window does not have a glasspane
081:             *         compound
082:             */
083:            public GlassPaneCompound getGlassPaneCompound(Window window) {
084:                GlassPaneCompound result = null;
085:
086:                if (glassPaneCompounds.containsKey(window)) {
087:                    result = (GlassPaneCompound) glassPaneCompounds.get(window);
088:                }
089:
090:                return result;
091:            }
092:
093:            /**
094:             * Returns all glasspane compounds.
095:             *
096:             * @return all glasspane compounds in an array.
097:             */
098:            public GlassPaneCompound[] getGlassPaneCompounds() {
099:                GlassPaneCompound[] result = new GlassPaneCompound[glassPaneCompounds
100:                        .size()];
101:                Iterator it = glassPaneCompounds.values().iterator();
102:                int index = 0;
103:
104:                while (it.hasNext()) {
105:                    result[index++] = (GlassPaneCompound) it.next();
106:                }
107:
108:                return result;
109:            }
110:
111:            /**
112:             * Creates a glasspane compound for the given window. The compound is integrated into the
113:             * window as glasspane.
114:             *
115:             * @param window window (must be a SWING window).
116:             *
117:             * @return the glasspane compound
118:             */
119:            public GlassPaneCompound createGlassPaneCompound(Window window) {
120:                // replace the window's glass pane with a new  glass pane compound
121:                // if it is not already one
122:                GlassPaneCompound compound = null;
123:
124:                if ((window != null) && window instanceof  JFrame) {
125:                    // The window is a subclass of javax.swing.JFrame
126:                    JFrame frame = (JFrame) window;
127:                    Component targetApplicationPane = frame.getGlassPane();
128:
129:                    if ((targetApplicationPane != null)
130:                            && targetApplicationPane instanceof  GlassPaneCompound) {
131:                        compound = (GlassPaneCompound) frame.getGlassPane();
132:                    } else {
133:                        compound = new GlassPaneCompound(getEnvironment(),
134:                                components, window);
135:                        frame.setGlassPane(compound);
136:                        glassPaneWindows.add(frame);
137:
138:                        frame.getGlassPane().setVisible(true);
139:                        frame.validate();
140:                        frame.repaint();
141:                    }
142:                } else if ((window != null) && window instanceof  JDialog) {
143:                    // The window is a subclass of javax.swing.JDialog
144:                    JDialog dialog = (JDialog) window;
145:                    Component targetApplicationPane = dialog.getGlassPane();
146:
147:                    if ((targetApplicationPane != null)
148:                            && targetApplicationPane instanceof  GlassPaneCompound) {
149:                        compound = (GlassPaneCompound) dialog.getGlassPane();
150:                    } else {
151:                        compound = new GlassPaneCompound(getEnvironment(),
152:                                components, window);
153:                        dialog.setGlassPane(compound);
154:                        glassPaneWindows.add(dialog);
155:
156:                        dialog.getGlassPane().setVisible(true);
157:                        dialog.validate();
158:                        dialog.repaint();
159:                    }
160:                }
161:
162:                if (compound != null) {
163:                    glassPaneCompounds.put(window, compound);
164:                }
165:
166:                return compound;
167:            }
168:
169:            /**
170:             * Removes all glass pane compounds.
171:             */
172:            public void removeAllGlassPaneCompounds() {
173:                Iterator it = glassPaneWindows.iterator();
174:
175:                while (it.hasNext()) {
176:                    Window window = (Window) it.next();
177:
178:                    if (window instanceof  JFrame) {
179:                        JFrame frame = (JFrame) window;
180:                        Component glasspane = frame.getGlassPane();
181:
182:                        if ((glasspane != null)
183:                                && glasspane instanceof  GlassPaneCompound) {
184:                            GlassPaneCompound compound = (GlassPaneCompound) glasspane;
185:
186:                            if (compound
187:                                    .hasGlassPane(GlassPaneCompound.TARGET_APPLICATION_PANE)) {
188:                                Component targetGlassPane = compound
189:                                        .getGlassPane(GlassPaneCompound.TARGET_APPLICATION_PANE);
190:                                boolean isVisible = targetGlassPane.isVisible();
191:                                frame.setGlassPane(targetGlassPane);
192:                                frame.getGlassPane().setVisible(isVisible);
193:                            } else {
194:                                frame.getGlassPane().setVisible(false);
195:                                frame.setGlassPane(null);
196:                            }
197:
198:                            frame.validate();
199:                            frame.repaint();
200:                        }
201:                    } else if (window instanceof  JDialog) {
202:                        JDialog dialog = (JDialog) window;
203:                        Component glasspane = dialog.getGlassPane();
204:
205:                        if ((glasspane != null)
206:                                && glasspane instanceof  GlassPaneCompound) {
207:                            GlassPaneCompound compound = (GlassPaneCompound) glasspane;
208:
209:                            if (compound
210:                                    .hasGlassPane(GlassPaneCompound.TARGET_APPLICATION_PANE)) {
211:                                Component targetGlassPane = compound
212:                                        .getGlassPane(GlassPaneCompound.TARGET_APPLICATION_PANE);
213:                                boolean isVisible = targetGlassPane.isVisible();
214:                                dialog.setGlassPane(targetGlassPane);
215:                                dialog.getGlassPane().setVisible(isVisible);
216:                            } else {
217:                                dialog.getGlassPane().setVisible(false);
218:                                dialog.setGlassPane(null);
219:                            }
220:
221:                            dialog.validate();
222:                            dialog.repaint();
223:                        }
224:                    }
225:                }
226:
227:                glassPaneWindows.clear();
228:                glassPaneCompounds.clear();
229:            }
230:
231:            /**
232:             * Sets the visibility state of all glass panes with the specified type in all contained
233:             * glasspane compounds
234:             *
235:             * @param type the glasspane type
236:             * @param isVisible whether or not those panes should be visible
237:             */
238:            public synchronized void setVisible(int type, boolean isVisible) {
239:                Vector compounds = new Vector(glassPaneCompounds.values());
240:
241:                for (int i = 0; i < compounds.size(); i++) {
242:                    ((GlassPaneCompound) compounds.get(i)).setVisible(type,
243:                            isVisible);
244:                }
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.