Source Code Cross Referenced for CleverPHLFrame.java in  » Testing » jacareto » jacareto » cleverphl » gui » 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.cleverphl.gui 
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.cleverphl.gui;
025:
026:        import jacareto.cleverphl.CleverPHL;
027:        import jacareto.cleverphl.menu.CleverPHLAction;
028:        import jacareto.system.Customization;
029:        import jacareto.toolkit.EnhancedHashtable;
030:        import jacareto.toolkit.HashtableException;
031:        import jacareto.toolkit.ResourceLoader;
032:
033:        import java.awt.Dimension;
034:        import java.awt.Insets;
035:        import java.awt.Point;
036:        import java.awt.Toolkit;
037:        import java.awt.event.ComponentEvent;
038:        import java.awt.event.ComponentListener;
039:
040:        import javax.swing.ImageIcon;
041:        import javax.swing.JCheckBoxMenuItem;
042:        import javax.swing.JFrame;
043:        import javax.swing.JToolBar;
044:
045:        /**
046:         * The main frame of CleverPHL.
047:         *
048:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
049:         * @version 1.01
050:         */
051:        public class CleverPHLFrame extends JFrame {
052:            /** The CleverPHL instance. */
053:            protected CleverPHL cleverPHL;
054:
055:            /** The menu state. */
056:            private MenuState menuState;
057:
058:            /** The customization key which contains information of this frame. */
059:            private String customizationKey;
060:
061:            /** The customization key which contains information of the related menu item. */
062:            private String menuCustomizationKey;
063:
064:            /** Adapts the customization when the frame changes. */
065:            private CustomizationAdaptation customizationAdaptation;
066:
067:            /**
068:             * Creates a new frame.
069:             *
070:             * @param cleverPHL the CleverPHL instance
071:             * @param customizationKey DOCUMENT ME!
072:             * @param menuCustomizationKey DOCUMENT ME!
073:             */
074:            public CleverPHLFrame(CleverPHL cleverPHL, String customizationKey,
075:                    String menuCustomizationKey) {
076:                super ();
077:                this .cleverPHL = cleverPHL;
078:                this .customizationKey = customizationKey;
079:                this .menuCustomizationKey = menuCustomizationKey;
080:
081:                /*File file = new File(cleverPHL.getEnvironment ().getFiles ().getDir ("IMAGES_DIR")
082:                                              .getAbsolutePath () + File.separator + "FrameIcon.gif");
083:
084:                if (file.exists ()) {
085:                    setIconImage ((new ImageIcon(file.getAbsolutePath ())).getImage ());
086:                }    */
087:                ImageIcon icon = ResourceLoader.getImageIcon("FrameIcon.gif");
088:
089:                if (icon != null) {
090:                    setIconImage(icon.getImage());
091:                }
092:
093:                applyCustomization();
094:                setName(cleverPHL.getCustomization().getString(
095:                        "Components.JacaretoComponent", "JACARETO_COMPONENT"));
096:
097:                customizationAdaptation = new CustomizationAdaptation(
098:                        cleverPHL, this );
099:
100:                addComponentListener(customizationAdaptation);
101:            }
102:
103:            /**
104:             * Returns the menu bar.
105:             *
106:             * @return CleverPHLMenuBar
107:             */
108:            public CleverPHLMenuBar getCleverPHLMenuBar() {
109:                return (CleverPHLMenuBar) getJMenuBar();
110:            }
111:
112:            /**
113:             * Creates the menu.
114:             *
115:             * @param customizationKey the customization key of the menu bar
116:             */
117:            protected void createMenu(String customizationKey) {
118:                // The menu bar
119:                CleverPHLMenuBar menuBar = new CleverPHLMenuBar(cleverPHL, this );
120:                menuBar.create(customizationKey);
121:                menuState = new MenuState(cleverPHL, menuBar,
122:                        MenuState.NO_SESSION);
123:                setJMenuBar(menuBar);
124:            }
125:
126:            /**
127:             * Returns the menu state.
128:             *
129:             * @return the menu state
130:             */
131:            public MenuState getMenuState() {
132:                return menuState;
133:            }
134:
135:            /**
136:             * Returns the cleverphl instance.
137:             *
138:             * @return the cleverphl instance
139:             */
140:            public CleverPHL getCleverPHL() {
141:                return cleverPHL;
142:            }
143:
144:            /**
145:             * Sets the window visible or not.
146:             *
147:             * @param isVisible whether or not the window is visible
148:             */
149:            public void setVisible(boolean isVisible) {
150:                try {
151:                    super .setVisible(isVisible);
152:
153:                    if ((menuCustomizationKey != null)
154:                            && !menuCustomizationKey.equals("")) {
155:                        ((JCheckBoxMenuItem) cleverPHL.getMainFrame()
156:                                .getCleverPHLMenuBar().getMenuItem(
157:                                        menuCustomizationKey))
158:                                .setSelected(isVisible);
159:                    }
160:                } catch (Exception e) {
161:                    cleverPHL.getLogger().debug(
162:                            cleverPHL.getLanguage().getString(
163:                                    "CleverPHL.Msg.ViewMenuInitFailed"));
164:                }
165:            }
166:
167:            /**
168:             * Adds all tool bar actions to the tool bar.
169:             *
170:             * @param toolBar the tool bar
171:             * @param key the customization key for the tool bar specification
172:             */
173:            protected void createToolBar(JToolBar toolBar, String key) {
174:                Customization customization = cleverPHL.getCustomization();
175:                EnhancedHashtable map = customization.getMap(key + ".Items",
176:                        new EnhancedHashtable());
177:                CleverPHLMenuBar menuBar = getCleverPHLMenuBar();
178:
179:                toolBar.setMargin(new Insets(1, 1, 1, 1));
180:
181:                for (int i = 0; i < map.size(); i++) {
182:                    try {
183:                        CleverPHLAction action = (CleverPHLAction) menuBar
184:                                .getAction(map.getString("" + i));
185:                        toolBar.add(new CleverPHLButton(action));
186:                    } catch (HashtableException h) {
187:                        cleverPHL
188:                                .getLogger()
189:                                .debug(
190:                                        cleverPHL
191:                                                .getLanguage()
192:                                                .getString(
193:                                                        "CleverPHL.Frame.Msg.ToolBarCreationProblem")
194:                                                + " " + i);
195:                    }
196:                }
197:            }
198:
199:            /**
200:             * Applies the customization
201:             */
202:            public void applyCustomization() {
203:                Customization customization = cleverPHL.getCustomization();
204:                int x = customization.getInt(customizationKey + ".Bounds.X", 0);
205:                int y = customization.getInt(customizationKey + ".Bounds.Y", 0);
206:                int width = customization.getInt(customizationKey
207:                        + ".Bounds.Width", 200);
208:                int height = customization.getInt(customizationKey
209:                        + ".Bounds.Height", 200);
210:
211:                Toolkit toolkit = Toolkit.getDefaultToolkit();
212:                Dimension screenSize = toolkit.getScreenSize();
213:                int screenWidth = (int) screenSize.getWidth();
214:                int screenHeight = (int) screenSize.getHeight();
215:
216:                if ((x + width) > screenWidth) {
217:                    x = screenWidth - width;
218:                }
219:
220:                if ((y + height) > screenHeight) {
221:                    y = screenHeight - height;
222:                }
223:
224:                if (x < 0) {
225:                    x = 0;
226:                }
227:
228:                if (y < 0) {
229:                    y = 0;
230:                }
231:
232:                if ((x + width) > screenWidth) {
233:                    width = screenWidth - x;
234:                }
235:
236:                if ((y + height) > screenHeight) {
237:                    height = screenHeight - y;
238:                }
239:
240:                setLocation(x, y);
241:                setSize(width, height);
242:            }
243:
244:            /**
245:             * Sets the frame to the visibility state stored in the customization.
246:             */
247:            public void restoreVisibilityFromCustomization() {
248:                Customization customization = cleverPHL.getCustomization();
249:                setVisible(customization.getBoolean(customizationKey
250:                        + ".Visible", false));
251:            }
252:
253:            // Changes the customization values
254:            class CustomizationAdaptation implements  ComponentListener {
255:                //~ Instance fields ------------------------------------------------------------------------
256:
257:                CleverPHL cleverPHL;
258:                CleverPHLFrame frame;
259:
260:                //~ Constructors ---------------------------------------------------------------------------
261:
262:                /**
263:                 * DOCUMENT ME!
264:                 *
265:                 * @param cleverPHL
266:                 * @param frame
267:                 */
268:                public CustomizationAdaptation(CleverPHL cleverPHL,
269:                        CleverPHLFrame frame) {
270:                    this .cleverPHL = cleverPHL;
271:                    this .frame = frame;
272:                }
273:
274:                //~ Methods --------------------------------------------------------------------------------
275:
276:                /**
277:                 * {@inheritDoc}
278:                 */
279:                public void componentMoved(ComponentEvent event) {
280:                    Point point = frame.getLocationOnScreen();
281:                    Customization customization = cleverPHL.getCustomization();
282:                    customization.put(customizationKey + ".Bounds.X", point.x);
283:                    customization.put(customizationKey + ".Bounds.Y", point.y);
284:                }
285:
286:                /**
287:                 * {@inheritDoc}
288:                 */
289:                public void componentResized(ComponentEvent event) {
290:                    Dimension dim = frame.getSize();
291:                    Customization customization = cleverPHL.getCustomization();
292:                    customization.put(customizationKey + ".Bounds.Width",
293:                            dim.width);
294:                    customization.put(customizationKey + ".Bounds.Height",
295:                            dim.height);
296:                }
297:
298:                /**
299:                 * {@inheritDoc}
300:                 */
301:                public void componentHidden(ComponentEvent event) {
302:                    Customization customization = cleverPHL.getCustomization();
303:                    customization.put(customizationKey + ".Visible", false);
304:                }
305:
306:                /**
307:                 * {@inheritDoc}
308:                 */
309:                public void componentShown(ComponentEvent event) {
310:                    Customization customization = cleverPHL.getCustomization();
311:                    customization.put(customizationKey + ".Visible", true);
312:                }
313:            }
314:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.