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


001:        package net.sourceforge.squirrel_sql.client.gui.db;
002:
003:        /*
004:         * Copyright (C) 2001-2004 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.BorderLayout;
022:        import java.awt.event.MouseEvent;
023:        import java.beans.PropertyChangeEvent;
024:        import java.beans.PropertyChangeListener;
025:
026:        import javax.swing.JList;
027:        import javax.swing.ListSelectionModel;
028:        import javax.swing.SwingUtilities;
029:        import javax.swing.ToolTipManager;
030:
031:        import javax.swing.event.ListDataEvent;
032:        import javax.swing.event.ListDataListener;
033:        import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
034:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
035:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
036:
037:        import net.sourceforge.squirrel_sql.client.IApplication;
038:        import net.sourceforge.squirrel_sql.client.preferences.SquirrelPreferences;
039:        import net.sourceforge.squirrel_sql.client.resources.SquirrelResources;
040:
041:        /**
042:         * This is a <CODE>JList</CODE> that dispays all the <CODE>ISQLDriver</CODE>
043:         * objects.
044:         *
045:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
046:         */
047:        public class DriversList extends JList implements  IDriversList {
048:            /** Application API. */
049:            private IApplication _app;
050:
051:            /** Model for this component. */
052:            private DriversListModel _model;
053:
054:            /** Internationalized strings for this class. */
055:            private static final StringManager s_stringMgr = StringManagerFactory
056:                    .getStringManager(DriversList.class);
057:
058:            /**
059:             * Ctor specifying Application API object.
060:             *
061:             * @param	app		Application API.
062:             *
063:             * @throws	IllegalArgumentException
064:             * 			Thrown if <TT>null</TT> <TT>IApplication</TT> passed.
065:             */
066:            public DriversList(IApplication app)
067:                    throws IllegalArgumentException {
068:                super ();
069:                if (app == null) {
070:                    throw new IllegalArgumentException(
071:                            "Null IApplication passed");
072:                }
073:                _app = app;
074:                _model = new DriversListModel(_app);
075:                setModel(_model);
076:                setLayout(new BorderLayout());
077:                getSelectionModel().setSelectionMode(
078:                        ListSelectionModel.SINGLE_SELECTION);
079:
080:                SquirrelResources res = _app.getResources();
081:                setCellRenderer(new DriverListCellRenderer(res
082:                        .getIcon("list.driver.found"), res
083:                        .getIcon("list.driver.notfound")));
084:
085:                propertiesChanged(null);
086:
087:                final int selDriverIdx = app.getSquirrelPreferences()
088:                        .getDriversSelectedIndex();
089:                final int size = getModel().getSize();
090:                if (selDriverIdx > -1 && selDriverIdx < size) {
091:                    setSelectedIndex(selDriverIdx);
092:                } else {
093:                    setSelectedIndex(0);
094:                }
095:
096:                _app.getSquirrelPreferences().addPropertyChangeListener(
097:                        new PropertyChangeListener() {
098:                            public void propertyChange(PropertyChangeEvent evt) {
099:                                final String propName = evt != null ? evt
100:                                        .getPropertyName() : null;
101:                                propertiesChanged(propName);
102:                            }
103:                        });
104:
105:                _model.addListDataListener(new ListDataListener() {
106:                    public void contentsChanged(ListDataEvent evt) {
107:                        // Unused.
108:                    }
109:
110:                    public void intervalAdded(ListDataEvent evt) {
111:                        final int idx = evt.getIndex0();
112:                        SwingUtilities.invokeLater(new Runnable() {
113:                            public void run() {
114:                                clearSelection();
115:                                setSelectedIndex(idx);
116:                            }
117:                        });
118:                    }
119:
120:                    public void intervalRemoved(ListDataEvent evt) {
121:                        final int idx = evt.getIndex0();
122:                        SwingUtilities.invokeLater(new Runnable() {
123:                            public void run() {
124:                                clearSelection();
125:                                int modelSize = getModel().getSize();
126:                                if (idx < modelSize) {
127:                                    setSelectedIndex(idx);
128:                                } else if (modelSize > 0) {
129:                                    setSelectedIndex(modelSize - 1);
130:                                }
131:                            }
132:                        });
133:                    }
134:                });
135:            }
136:
137:            /**
138:             * Component has been added to its parent.
139:             */
140:            public void addNotify() {
141:                super .addNotify();
142:                // Register so that we can display different tooltips depending
143:                // which entry in list mouse is over.
144:                ToolTipManager.sharedInstance().registerComponent(this );
145:            }
146:
147:            /**
148:             * Component has been removed from its parent.
149:             */
150:            public void removeNotify() {
151:                super .removeNotify();
152:                // Don't need tooltips any more.
153:                ToolTipManager.sharedInstance().unregisterComponent(this );
154:            }
155:
156:            /**
157:             * Return the <CODE>DriversListModel</CODE> that controls this list.
158:             */
159:            public DriversListModel getTypedModel() {
160:                return _model;
161:            }
162:
163:            /**
164:             * Return the <CODE>ISQLDriver</CODE> that is currently selected.
165:             */
166:            public ISQLDriver getSelectedDriver() {
167:                return (ISQLDriver) getSelectedValue();
168:            }
169:
170:            /**
171:             * Return the description for the driver that the mouse is currently
172:             * over as the tooltip text.
173:             *
174:             * @param	event	Used to determine the current mouse position.
175:             */
176:            public String getToolTipText(MouseEvent evt) {
177:                String tip = null;
178:                final int idx = locationToIndex(evt.getPoint());
179:                if (idx != -1) {
180:                    tip = ((ISQLDriver) getModel().getElementAt(idx)).getName();
181:                } else {
182:                    tip = getToolTipText();
183:                }
184:                return tip;
185:            }
186:
187:            /**
188:             * Return the tooltip used for this component if the mouse isn't over
189:             * an entry in the list.
190:             */
191:            public String getToolTipText() {
192:                // i18n[DriversList.tooltiptext=List of database drivers that can be used to configure an alias]
193:                return s_stringMgr.getString("DriversList.tooltiptext");
194:            }
195:
196:            /**
197:             * Application properties have changed so update this object.
198:             *
199:             * @param	propName	Name of property that has changed or <TT>null</TT>
200:             * 						if multiple properties have changed.
201:             */
202:            private void propertiesChanged(String propName) {
203:                if (propName == null
204:                        || propName
205:                                .equals(SquirrelPreferences.IPropertyNames.SHOW_LOADED_DRIVERS_ONLY)) {
206:                    boolean show = _app.getSquirrelPreferences()
207:                            .getShowLoadedDriversOnly();
208:                    _model.setShowLoadedDriversOnly(show);
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.