Source Code Cross Referenced for TileInternalFramesAction.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » fw » gui » action » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.fw.gui.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.fw.gui.action;
002:
003:        /*
004:         * Copyright (C) 2001-2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.awt.Dimension;
022:        import java.awt.event.ActionEvent;
023:        import java.beans.PropertyVetoException;
024:
025:        import javax.swing.JDesktopPane;
026:        import javax.swing.JInternalFrame;
027:
028:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
029:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
030:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
031:
032:        /**
033:         * This class will tile all internal frames owned by a
034:         * <CODE>JDesktopPane</CODE>.
035:         *
036:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
037:         */
038:        public abstract class TileInternalFramesAction extends BaseAction
039:                implements  IHasJDesktopPane {
040:            /** Internationalized strings for this class. */
041:            private static final StringManager s_stringMgr = StringManagerFactory
042:                    .getStringManager(TileInternalFramesAction.class);
043:
044:            /**
045:             * The <CODE>JDesktopPane</CODE> that owns the internal frames to be
046:             * tiled.
047:             */
048:            private JDesktopPane _desktop;
049:
050:            /**
051:             * Default constructor.
052:             */
053:            public TileInternalFramesAction() {
054:                this (null);
055:            }
056:
057:            /**
058:             * Constructor specifying the <CODE>JDesktopPane</CODE> that owns the
059:             * internal frames to be tiled.
060:             *
061:             * @param	desktop		the <CODE>JDesktopPane</CODE> that owns the
062:             *						internal frames to be cascaded.
063:             */
064:            public TileInternalFramesAction(JDesktopPane desktop) {
065:                super (s_stringMgr.getString("TileInternalFramesAction.title"));
066:                setJDesktopPane(desktop);
067:            }
068:
069:            /**
070:             * Set the <CODE>JDesktopPane</CODE> that owns the internal frames to be
071:             * cascaded.
072:             *
073:             * @param	desktop		the <CODE>JDesktopPane</CODE> that owns the
074:             *						internal frames to be cascaded.
075:             */
076:            public void setJDesktopPane(JDesktopPane value) {
077:                _desktop = value;
078:            }
079:
080:            /**
081:             * Tile the internal frames.
082:             *
083:             * @param	evt	 Specifies the event being proceessed.
084:             */
085:            public void actionPerformed(ActionEvent evt) {
086:                if (_desktop != null) {
087:                    JInternalFrame[] children = GUIUtils
088:                            .getNonMinimizedNonToolWindows(_desktop
089:                                    .getAllFrames());
090:                    final int cells = children.length;
091:                    if (cells > 0) {
092:                        final RowColumnCount rcc = getRowColumnCount(cells);
093:                        final int rows = rcc._rowCount;
094:                        final int cols = rcc._columnCount;
095:                        //?? Extract this out into a class like CascadeInternalFramePositioner.
096:
097:                        final Dimension desktopSize = _desktop.getSize();
098:                        final int width = desktopSize.width / cols;
099:                        final int height = desktopSize.height / rows;
100:                        int xPos = 0;
101:                        int yPos = 0;
102:
103:                        for (int y = 0; y < rows; ++y) {
104:                            for (int x = 0; x < cols; ++x) {
105:                                final int idx = y + (x * rows);
106:                                if (idx >= cells) {
107:                                    break;
108:                                }
109:                                JInternalFrame frame = children[idx];
110:                                if (!frame.isClosed()) {
111:                                    if (frame.isIcon()) {
112:                                        try {
113:                                            frame.setIcon(false);
114:                                        } catch (PropertyVetoException ignore) {
115:                                            // Ignore.
116:                                        }
117:                                    } else if (frame.isMaximum()) {
118:                                        try {
119:                                            frame.setMaximum(false);
120:                                        } catch (PropertyVetoException ignore) {
121:                                            // Ignore.
122:                                        }
123:                                    }
124:
125:                                    frame.reshape(xPos, yPos, width, height);
126:                                    xPos += width;
127:                                }
128:                            }
129:                            xPos = 0;
130:                            yPos += height;
131:                        }
132:                    }
133:                }
134:            }
135:
136:            /**
137:             * Retrieve the number of rows and columns that the internal frames
138:             * should be rearranged into.
139:             *
140:             * @param	internalFrameCount	Number of internal frames to be rearranged.
141:             */
142:            protected abstract RowColumnCount getRowColumnCount(
143:                    int internalFrameCount);
144:
145:            public final static class RowColumnCount {
146:                protected final int _rowCount;
147:                protected final int _columnCount;
148:
149:                public RowColumnCount(int rowCount, int columnCount) {
150:                    _rowCount = rowCount;
151:                    _columnCount = columnCount;
152:                }
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.