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


001:        package net.sourceforge.squirrel_sql.client.gui.session;
002:
003:        /*
004:         * Copyright (C) 2001-2004 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * Copyright (C) 2003-2004 Jason Height
008:         * jmheight@users.sourceforge.net
009:         *
010:         * This library is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public
012:         * License as published by the Free Software Foundation; either
013:         * version 2.1 of the License, or (at your option) any later version.
014:         *
015:         * This library is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
018:         * Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public
021:         * License along with this library; if not, write to the Free Software
022:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
023:         */
024:        import java.awt.BorderLayout;
025:        import java.awt.Component;
026:        import java.awt.Window;
027:        import java.awt.event.ActionEvent;
028:        import java.awt.event.ActionListener;
029:        import java.awt.event.FocusEvent;
030:        import java.sql.SQLException;
031:
032:        import javax.swing.Icon;
033:        import javax.swing.JPanel;
034:        import javax.swing.SwingUtilities;
035:        import javax.swing.event.InternalFrameAdapter;
036:        import javax.swing.event.InternalFrameEvent;
037:        import javax.swing.event.TreeSelectionEvent;
038:        import javax.swing.event.TreeSelectionListener;
039:        import javax.swing.tree.TreePath;
040:
041:        import net.sourceforge.squirrel_sql.client.IApplication;
042:        import net.sourceforge.squirrel_sql.client.action.ActionCollection;
043:        import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
044:        import net.sourceforge.squirrel_sql.client.session.IObjectTreeInternalFrame;
045:        import net.sourceforge.squirrel_sql.client.session.ISession;
046:        import net.sourceforge.squirrel_sql.client.session.action.RefreshSchemaInfoAction;
047:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
048:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreePanel;
049:        import net.sourceforge.squirrel_sql.fw.gui.SQLCatalogsComboBox;
050:        import net.sourceforge.squirrel_sql.fw.gui.ToolBar;
051:        import net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter;
052:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
053:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
054:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
055:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
056:
057:        /* Object Tree frame class*/
058:        public class ObjectTreeInternalFrame extends BaseSessionInternalFrame
059:                implements  IObjectTreeInternalFrame {
060:            /** Application API. */
061:            private final IApplication _app;
062:
063:            private ObjectTreePanel _objTreePanel;
064:
065:            /** Toolbar for window. */
066:            private ObjectTreeToolBar _toolBar;
067:
068:            private boolean _hasBeenVisible = false;
069:
070:            /** Internationalized strings for this class. */
071:            private static final StringManager s_stringMgr = StringManagerFactory
072:                    .getStringManager(ObjectTreeInternalFrame.class);
073:
074:            public ObjectTreeInternalFrame(ISession session) {
075:                super (session, session.getTitle(), true, true, true, true);
076:                _app = session.getApplication();
077:                setVisible(false);
078:                createGUI(session);
079:            }
080:
081:            public void addNotify() {
082:                super .addNotify();
083:                if (!_hasBeenVisible) {
084:                    _hasBeenVisible = true;
085:                    // Done this late so that plugins have time to register expanders
086:                    // with the object tree prior to it being built.
087:                    _objTreePanel.refreshTree();
088:                }
089:            }
090:
091:            public ObjectTreePanel getObjectTreePanel() {
092:                return _objTreePanel;
093:            }
094:
095:            public IObjectTreeAPI getObjectTreeAPI() {
096:                return _objTreePanel;
097:            }
098:
099:            private void createGUI(ISession session) {
100:                setVisible(false);
101:                final IApplication app = session.getApplication();
102:                Icon icon = app.getResources().getIcon(getClass(), "frameIcon"); //i18n
103:                if (icon != null) {
104:                    setFrameIcon(icon);
105:                }
106:
107:                // This is to fix a problem with the JDK (up to version 1.3)
108:                // where focus events were not generated correctly. The sympton
109:                // is being unable to key into the text entry field unless you click
110:                // elsewhere after focus is gained by the internal frame.
111:                // See bug ID 4309079 on the JavaSoft bug parade (plus others).
112:                addInternalFrameListener(new InternalFrameAdapter() {
113:                    public void internalFrameActivated(InternalFrameEvent evt) {
114:                        Window window = SwingUtilities
115:                                .windowForComponent(ObjectTreeInternalFrame.this 
116:                                        .getObjectTreePanel());
117:                        Component focusOwner = (window != null) ? window
118:                                .getFocusOwner() : null;
119:                        if (focusOwner != null) {
120:                            FocusEvent lost = new FocusEvent(focusOwner,
121:                                    FocusEvent.FOCUS_LOST);
122:                            FocusEvent gained = new FocusEvent(focusOwner,
123:                                    FocusEvent.FOCUS_GAINED);
124:                            window.dispatchEvent(lost);
125:                            window.dispatchEvent(gained);
126:                            window.dispatchEvent(lost);
127:                            focusOwner.requestFocus();
128:                        }
129:                    }
130:                });
131:
132:                _objTreePanel = new ObjectTreePanel(getSession());
133:                _objTreePanel
134:                        .addTreeSelectionListener(new ObjectTreeSelectionListener());
135:                _toolBar = new ObjectTreeToolBar(getSession(), _objTreePanel);
136:                JPanel contentPanel = new JPanel(new BorderLayout());
137:                contentPanel.add(_toolBar, BorderLayout.NORTH);
138:                contentPanel.add(_objTreePanel, BorderLayout.CENTER);
139:                setContentPane(contentPanel);
140:                validate();
141:            }
142:
143:            /** The class representing the toolbar at the top of a sql internal frame*/
144:            private class ObjectTreeToolBar extends ToolBar {
145:                /** Internationalized strings for this class. */
146:                private final StringManager s_stringMgr = StringManagerFactory
147:                        .getStringManager(ObjectTreeToolBar.class);
148:                private ILogger s_log = LoggerController
149:                        .createLogger(ObjectTreeToolBar.class);
150:                private CatalogsPanel _catalogsPanel;
151:
152:                ObjectTreeToolBar(ISession session, ObjectTreePanel panel) {
153:                    super ();
154:                    createGUI(session, panel);
155:                }
156:
157:                private void createGUI(ISession session, ObjectTreePanel panel) {
158:                    _catalogsPanel = new CatalogsPanel(session, this );
159:                    _catalogsPanel
160:                            .addActionListener(new CatalogsComboListener());
161:                    add(_catalogsPanel);
162:
163:                    ActionCollection actions = session.getApplication()
164:                            .getActionCollection();
165:                    setUseRolloverButtons(true);
166:                    setFloatable(false);
167:                    add(actions.get(RefreshSchemaInfoAction.class));
168:                }
169:            }
170:
171:            private final class CatalogsComboListener implements  ActionListener {
172:                public void actionPerformed(ActionEvent evt) {
173:                    Object src = evt.getSource();
174:                    if (src instanceof  SQLCatalogsComboBox) {
175:                        SQLCatalogsComboBox cmb = (SQLCatalogsComboBox) src;
176:                        String catalog = cmb.getSelectedCatalog();
177:                        if (catalog != null) {
178:                            try {
179:                                getSession().getSQLConnection().setCatalog(
180:                                        catalog);
181:                            } catch (SQLException ex) {
182:                                getSession().showErrorMessage(ex);
183:                            }
184:                        }
185:                    }
186:                }
187:            }
188:
189:            /** JASON: this could be added to the objecttreepanel if the status bar was attached
190:             *  to the application
191:             */
192:            private final class ObjectTreeSelectionListener implements 
193:                    TreeSelectionListener {
194:                public void valueChanged(TreeSelectionEvent evt) {
195:                    final TreePath selPath = evt.getNewLeadSelectionPath();
196:                    if (selPath != null) {
197:                        StringBuffer buf = new StringBuffer();
198:                        Object[] fullPath = selPath.getPath();
199:                        for (int i = 0; i < fullPath.length; ++i) {
200:                            if (fullPath[i] instanceof  ObjectTreeNode) {
201:                                ObjectTreeNode node = (ObjectTreeNode) fullPath[i];
202:                                buf.append('/').append(node.toString());
203:                            }
204:                        }
205:                        //JASON: have a main application status bar setStatusBarMessage(buf.toString());
206:                    }
207:                }
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.