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


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.jeta.swingbuilder.gui.main;
020:
021:        import java.awt.Dimension;
022:        import java.awt.Point;
023:        import java.awt.Rectangle;
024:
025:        import javax.swing.JFrame;
026:        import javax.swing.JPanel;
027:        import javax.swing.JSplitPane;
028:        import javax.swing.SwingUtilities;
029:
030:        import com.jeta.forms.components.image.ImageComponent;
031:        import com.jeta.forms.components.panel.FormPanel;
032:        import com.jeta.forms.gui.common.FormUtils;
033:        import com.jeta.open.i18n.I18N;
034:        import com.jeta.open.registry.JETARegistry;
035:        import com.jeta.swingbuilder.common.ComponentNames;
036:        import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
037:        import com.jeta.swingbuilder.interfaces.app.ObjectStore;
038:        import com.jeta.swingbuilder.resources.Icons;
039:        import com.jeta.swingbuilder.store.FrameState;
040:
041:        /**
042:         * This class is responsible for handling the docking behavior of the properties
043:         * window.
044:         * 
045:         * @author Jeff Tassin
046:         */
047:        class FrameDocker {
048:            /**
049:             * The main container in the application frame that contains the tool
050:             * palette, form editor, and optionally the properties window
051:             */
052:            private JPanel m_main_panel;
053:
054:            /**
055:             * The main split pane in the application frame.
056:             */
057:            private JSplitPane m_split;
058:
059:            /**
060:             * The properties frame window. Null if docked.
061:             */
062:            private JFrame m_properties_frame;
063:
064:            /**
065:             * The properties view
066:             */
067:            private FormPanel m_properties_view;
068:
069:            /**
070:             * Panel that contains the form editor and component toolbar
071:             */
072:            private JPanel m_editor_panel;
073:
074:            /**
075:             * The last know split pane divider location
076:             */
077:            private int m_divider_location = 0;
078:
079:            public static final String ID_PROPERTIES_FRAME_STATE = "property.frame.bounds";
080:
081:            /**
082:             * ctor
083:             */
084:            FrameDocker(JPanel main_panel, JPanel editor_panel,
085:                    JSplitPane split, FormPanel properties_view) {
086:                m_main_panel = main_panel;
087:                m_editor_panel = editor_panel;
088:                m_split = split;
089:                m_properties_view = properties_view;
090:            }
091:
092:            /**
093:             * Docks or undocks properties window window
094:             */
095:            void dockPropertiesFrame(Rectangle bounds) {
096:                if (m_properties_frame == null) {
097:                    Point frame_org = new Point(0, 0);
098:                    SwingUtilities.convertPointToScreen(frame_org,
099:                            m_properties_view);
100:
101:                    togglePropertiesFrame();
102:
103:                    m_properties_frame = new JFrame();
104:                    m_properties_frame.setTitle(I18N
105:                            .getLocalizedMessage("Form Properties"));
106:                    javax.swing.ImageIcon icon = FormDesignerUtils
107:                            .loadImage(Icons.LINKED_FORM_16);
108:                    if (icon != null)
109:                        m_properties_frame.setIconImage(icon.getImage());
110:
111:                    ImageComponent btn = (ImageComponent) m_properties_view
112:                            .getComponentByName(FormPropertiesNames.ID_DOCK_FRAME);
113:                    btn.setIcon(FormDesignerUtils
114:                            .loadImage(Icons.SPLIT_WINDOWS_16));
115:
116:                    m_properties_frame.getContentPane().add(m_properties_view);
117:
118:                    if (bounds == null)
119:                        setPropertyPaneBounds(frame_org.x - 10,
120:                                frame_org.y - 10,
121:                                m_properties_view.getWidth() + 20,
122:                                m_properties_view.getHeight() + 20);
123:                    else
124:                        setPropertyPaneBounds(bounds.x, bounds.y, bounds.width,
125:                                bounds.height);
126:
127:                    m_properties_frame.setVisible(true);
128:                } else {
129:                    ImageComponent btn = (ImageComponent) m_properties_view
130:                            .getComponentByName(FormPropertiesNames.ID_DOCK_FRAME);
131:                    btn.setIcon(FormDesignerUtils.loadImage(Icons.WINDOWS_16));
132:
133:                    m_properties_frame.getContentPane().remove(
134:                            m_properties_view);
135:                    m_properties_frame.dispose();
136:                    m_properties_frame = null;
137:                    m_main_panel.remove(m_editor_panel);
138:                    m_split.add(m_editor_panel);
139:                    m_split.add(m_properties_view);
140:
141:                    if (m_divider_location > 0)
142:                        m_split.setDividerLocation(m_divider_location);
143:                    else
144:                        m_split.setDividerLocation(0.7);
145:
146:                    m_main_panel.add(m_split);
147:
148:                    m_main_panel.revalidate();
149:                    m_main_panel.repaint();
150:                }
151:            }
152:
153:            /**
154:             * Retrieves the last known frame bounds of the properties frame from the
155:             * property store and sets the frame size.
156:             */
157:            void initializeFrameBounds() {
158:                try {
159:                    ObjectStore os = (ObjectStore) JETARegistry
160:                            .lookup(ComponentNames.APPLICATION_STATE_STORE);
161:                    FrameState fstate = (FrameState) os
162:                            .load(ID_PROPERTIES_FRAME_STATE);
163:                    if (fstate != null) {
164:                        if (!fstate.isDocked()) {
165:                            dockPropertiesFrame(fstate.getBounds());
166:                        }
167:                    }
168:                } catch (Exception e) {
169:                    // ignore
170:                }
171:            }
172:
173:            private void setPropertyPaneBounds(int x, int y, int width,
174:                    int height) {
175:                Dimension screensz = java.awt.Toolkit.getDefaultToolkit()
176:                        .getScreenSize();
177:
178:                width = Math.min(width, screensz.width * 8 / 10);
179:                height = Math.min(height, screensz.height * 8 / 10);
180:
181:                width = Math.max(64, width);
182:                height = Math.max(64, height);
183:
184:                x = Math.min(screensz.width - width - 50, x);
185:                y = Math.min(screensz.height - height - 50, y);
186:
187:                x = Math.max(20, x);
188:                y = Math.max(20, y);
189:
190:                m_properties_frame.setBounds(x, y, width, height);
191:            }
192:
193:            /**
194:             * Saves the frame state to the object store and
195:             */
196:            void shutDown() {
197:                try {
198:                    ObjectStore os = (ObjectStore) JETARegistry
199:                            .lookup(ComponentNames.APPLICATION_STATE_STORE);
200:
201:                    FrameState fstate;
202:                    if (m_properties_frame == null)
203:                        fstate = new FrameState();
204:                    else
205:                        fstate = new FrameState(m_properties_frame.getBounds());
206:
207:                    os.store(ID_PROPERTIES_FRAME_STATE, fstate);
208:                } catch (Exception e) {
209:                    // ignore
210:                }
211:            }
212:
213:            /**
214:             * Hides or displays properties window window
215:             */
216:            void togglePropertiesFrame() {
217:                if (m_properties_frame == null) {
218:                    if (m_properties_view.getParent() == m_split) {
219:                        m_divider_location = m_split.getDividerLocation();
220:                        m_split.remove(m_properties_view);
221:                        m_split.remove(m_editor_panel);
222:                        m_main_panel.removeAll();
223:                        m_main_panel.add(m_editor_panel);
224:                    } else {
225:                        m_main_panel.removeAll();
226:                        m_split.add(m_editor_panel);
227:                        m_split.add(m_properties_view);
228:                        m_main_panel.add(m_split);
229:
230:                        if (m_divider_location > 0)
231:                            m_split.setDividerLocation(m_divider_location);
232:                        else
233:                            m_split.setDividerLocation(0.7);
234:                    }
235:
236:                    m_main_panel.revalidate();
237:                    m_main_panel.repaint();
238:                } else {
239:                    if (m_properties_frame.isActive()
240:                            && m_properties_frame.isVisible()) {
241:                        m_properties_frame.setVisible(false);
242:                    } else {
243:                        m_properties_frame.setVisible(true);
244:                        if (m_properties_frame.getExtendedState() == java.awt.Frame.ICONIFIED)
245:                            m_properties_frame
246:                                    .setExtendedState(java.awt.Frame.NORMAL);
247:                        m_properties_frame.toFront();
248:                    }
249:                }
250:            }
251:
252:            /**
253:             * Updates all child components when the look and feel has changed
254:             */
255:            public void updateUI() {
256:                if (m_properties_frame != null)
257:                    FormUtils.updateLookAndFeel(m_properties_frame);
258:            }
259:
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.