Source Code Cross Referenced for DesktopManager.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfpshare » beans » 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 » ERP CRM Financial » Personal Finance Manager » br.com.gfpshare.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 11/10/2004
003:         * 
004:         * ============================================================================
005:         * GNU Lesser General Public License
006:         * ============================================================================
007:         *
008:         * Swing Components - visit http://sf.net/projects/gfd
009:         * 
010:         * Copyright (C) 2004  Igor Regis da Silva Simões
011:         * 
012:         * This library is free software; you can redistribute it and/or
013:         * modify it under the terms of the GNU Lesser General Public
014:         * License as published by the Free Software Foundation; either
015:         * version 2.1 of the License, or (at your option) any later version.
016:         * 
017:         * This library is distributed in the hope that it will be useful,
018:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
020:         * Lesser General Public License for more details.
021:         * 
022:         * You should have received a copy of the GNU Lesser General Public
023:         * License along with this library; if not, write to the Free Software
024:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
025:         */
026:
027:        package br.com.gfpshare.beans;
028:
029:        import java.awt.Container;
030:        import java.beans.PropertyVetoException;
031:
032:        import javax.swing.DefaultDesktopManager;
033:        import javax.swing.JDesktopPane;
034:        import javax.swing.JFrame;
035:        import javax.swing.JInternalFrame;
036:        import javax.swing.UIManager;
037:        import javax.swing.plaf.basic.BasicInternalFrameUI;
038:
039:        /**
040:         * @author Igor Regis da Silva Simoes
041:         */
042:        public class DesktopManager extends DefaultDesktopManager {
043:            private JDesktopPane desktop = null;
044:
045:            private Container principal = null;
046:
047:            /**
048:             * @param desktop
049:             */
050:            public DesktopManager(JDesktopPane desktop) {
051:                super ();
052:                this .desktop = desktop;
053:            }
054:
055:            /**
056:             * @see javax.swing.DesktopManager#maximizeFrame(javax.swing.JInternalFrame)
057:             */
058:            @Override
059:            public void maximizeFrame(JInternalFrame f) {
060:                super .maximizeFrame(f);
061:                f.setBorder(null);
062:                setBoundsForFrame(f, 0, -f.getInsets().top, f.getParent()
063:                        .getBounds().width, f.getParent().getBounds().height
064:                        + f.getInsets().top);
065:
066:                /* TODO REMOVER
067:                Component[] c = f.getComponents();
068:                for (int i = 0; i < c.length; i++)
069:                {
070:                	if (c[i].getClass().getName().indexOf("TitlePane") != -1)
071:                	{
072:                		((JComponent) c[i]).setVisible(false);
073:                	}
074:                }*/// O código abaixo parece ser mais eficiente
075:                if (f.isVisible()) {
076:                    setNorthPaneVisible(f, false);
077:                    maximizadoAtivo(f);
078:                }
079:            }
080:
081:            /**
082:             * Seta a visibilidade do painel norte do internal frame.
083:             * @param f
084:             * @param visible
085:             */
086:            private void setNorthPaneVisible(JInternalFrame f, boolean visible) {
087:                try {
088:                    ((BasicInternalFrameUI) f.getUI()).getNorthPane()
089:                            .setVisible(visible);
090:                } catch (Exception e) {
091:                    e.printStackTrace();
092:                }
093:            }
094:
095:            /**
096:             * @see javax.swing.DesktopManager#activateFrame(javax.swing.JInternalFrame)
097:             */
098:            @Override
099:            public void activateFrame(JInternalFrame f) {
100:                super .activateFrame(f);
101:                if (f.isVisible() && f.isMaximum()) {
102:                    f.setBorder(null);
103:                    setBoundsForFrame(f, 0, -f.getInsets().top, f.getParent()
104:                            .getBounds().width,
105:                            f.getParent().getBounds().height
106:                                    + f.getInsets().top);
107:
108:                    /* TODO REMOVER
109:                    Component[] c = f.getComponents();
110:                    for (int i = 0; i < c.length; i++)
111:                    {
112:                    	if (c[i].getClass().getName().indexOf("TitlePane") != -1)
113:                    	{
114:                    		((JComponent) c[i]).setVisible(false);
115:                    	}
116:                    }*/
117:                    setNorthPaneVisible(f, false);
118:                    maximizadoAtivo(f);
119:                } else {
120:                    minimizadoAtivo();
121:                }
122:            }
123:
124:            /**
125:             * @see javax.swing.DesktopManager#closeFrame(javax.swing.JInternalFrame)
126:             */
127:            @Override
128:            public void closeFrame(JInternalFrame f) {
129:                super .closeFrame(f);
130:            }
131:
132:            /**
133:             * @see javax.swing.DesktopManager#deiconifyFrame(javax.swing.JInternalFrame)
134:             */
135:            @Override
136:            public void deiconifyFrame(JInternalFrame f) {
137:                f.setClosable(true);
138:                super .deiconifyFrame(f);
139:                if (f.isVisible() && f.isMaximum()) {
140:                    maximizadoAtivo(f);
141:                }
142:            }
143:
144:            /**
145:             * @see javax.swing.DesktopManager#iconifyFrame(javax.swing.JInternalFrame)
146:             */
147:            @Override
148:            public void iconifyFrame(JInternalFrame f) {
149:                f.setClosable(false);
150:                super .iconifyFrame(f);
151:                minimizadoAtivo();
152:            }
153:
154:            /**
155:             * @see javax.swing.DesktopManager#minimizeFrame(javax.swing.JInternalFrame)
156:             */
157:            @Override
158:            public void minimizeFrame(JInternalFrame f) {
159:                super .minimizeFrame(f);
160:                /* TODO REMOVER
161:                Component[] c = f.getComponents();
162:                for (int i = 0; i < c.length; i++)
163:                {
164:                	if (c[i].getClass().getName().indexOf("TitlePane") != -1)
165:                	{
166:                		((JComponent) c[i]).setVisible(true);
167:                	}
168:                }
169:                 */
170:                setNorthPaneVisible(f, true);
171:                f.setBorder(UIManager.getBorder("InternalFrame.border"));
172:                if (f.isVisible()) {
173:                    minimizadoAtivo();
174:                }
175:            }
176:
177:            /**
178:             * @return Retorna o frame principal da aplicacao
179:             */
180:            private JFrame getPrincipal() {
181:                if (principal == null) {
182:                    principal = desktop.getParent();
183:                    while (!(principal instanceof  JFrame)) {
184:                        principal = principal.getParent();
185:                    }
186:                }
187:                return (JFrame) principal;
188:
189:            }
190:
191:            /**
192:             * @see javax.swing.DesktopManager#deactivateFrame(javax.swing.JInternalFrame)
193:             */
194:            @Override
195:            public void deactivateFrame(JInternalFrame f) {
196:                minimizadoAtivo();
197:                if (!f.isVisible()) {
198:                    myActivateNextFrame(desktop);
199:                }
200:            }
201:
202:            private void maximizadoAtivo(JInternalFrame f) {
203:                ((IMenuBar) getPrincipal().getJMenuBar())
204:                        .setBotoesFrameVisible(true);
205:                ((IMenuBar) getPrincipal().getJMenuBar()).setFrame(f);
206:                getPrincipal().setTitle(
207:                        getPrincipal().getTitle() + " -- " + f.getTitle());
208:            }
209:
210:            private void minimizadoAtivo() {
211:                ((IMenuBar) getPrincipal().getJMenuBar())
212:                        .setBotoesFrameVisible(false);
213:                ((IMenuBar) getPrincipal().getJMenuBar()).setFrame(null);
214:                if (getPrincipal().getTitle().indexOf(" --") > -1)
215:                    getPrincipal().setTitle(
216:                            getPrincipal().getTitle().substring(0,
217:                                    getPrincipal().getTitle().indexOf(" --")));
218:            }
219:
220:            private void myActivateNextFrame(Container c) {
221:                JInternalFrame nextFrame = null;
222:                if (c == null)
223:                    return;
224:                for (int i = 0; i < c.getComponentCount(); i++) {
225:                    if (c.getComponent(i) instanceof  JInternalFrame
226:                            && ((JInternalFrame) c.getComponent(i)).isVisible()) {
227:                        nextFrame = (JInternalFrame) c.getComponent(i);
228:                        break;
229:                    }
230:                }
231:                if (nextFrame != null) {
232:                    try {
233:                        nextFrame.setSelected(true);
234:                    } catch (PropertyVetoException e2) {
235:                        //Nao fazemos nada
236:                    }
237:                    nextFrame.moveToFront();
238:                }
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.