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


001:        package net.sourceforge.squirrel_sql.client.session.properties;
002:
003:        /**
004:         * Copyright (C) 2003-2004 Glenn Griffin
005:         *
006:         * Modifications Copyright (C) 2003-2004 Jason Height
007:         *
008:         * Adapted from SQLFilterSheet.java by Maury Hammel.
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.Dimension;
025:        import java.awt.GridBagConstraints;
026:        import java.awt.GridBagLayout;
027:        import java.awt.event.ActionEvent;
028:        import java.awt.event.ActionListener;
029:        import java.sql.SQLException;
030:        import java.util.SortedSet;
031:        import java.util.TreeSet;
032:
033:        import javax.swing.BorderFactory;
034:        import javax.swing.JButton;
035:        import javax.swing.JLabel;
036:        import javax.swing.JPanel;
037:        import javax.swing.JScrollPane;
038:
039:        import net.sourceforge.squirrel_sql.client.gui.session.BaseSessionInternalFrame;
040:        import net.sourceforge.squirrel_sql.client.session.ISession;
041:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.ContentsTab;
042:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
043:        import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
044:        import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
045:        import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
046:        import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
047:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
048:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
049:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
050:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
051:
052:        /**
053:         * Edit Where Cols dialog gui.
054:         * JASON: Rename to EditWhereColsInternalFrame 
055:         */
056:        @SuppressWarnings("serial")
057:        public class EditWhereColsSheet extends BaseSessionInternalFrame {
058:
059:            private static final StringManager s_stringMgr = StringManagerFactory
060:                    .getStringManager(EditWhereColsSheet.class);
061:
062:            /**
063:             * This interface defines locale specific strings. This should be
064:             * replaced with a property file.
065:             */
066:            private interface i18n {
067:                /** Title  */
068:                // i18n[editWhereColsSheet.editWhereColumns=Edit 'WHERE' columns]
069:                String TITLE = s_stringMgr
070:                        .getString("editWhereColsSheet.editWhereColumns");
071:            }
072:
073:            /** Logger for this class. */
074:            private static final ILogger s_log = LoggerController
075:                    .createLogger(EditWhereColsSheet.class);
076:
077:            /** A reference to a class containing information about the database metadata. */
078:            private IDatabaseObjectInfo _objectInfo;
079:
080:            /** Frame title. */
081:            private JLabel _titleLbl = new JLabel();
082:
083:            /** A reference to a panel for the EditWhereCols list. */
084:            private EditWhereColsPanel _editWhereColsPanel = null;
085:
086:            /**
087:             * Creates a new instance of SQLFilterSheet
088:             *
089:             * @param	session		A reference to the current SQuirreL session
090:             * @param	objectInfo	An instance of a class containing database metadata
091:             * 						information.
092:             */
093:            public EditWhereColsSheet(ISession session,
094:                    IDatabaseObjectInfo objectInfo) {
095:                super (session, i18n.TITLE, true);
096:                if (objectInfo == null) {
097:                    throw new IllegalArgumentException(
098:                            "Null IDatabaseObjectInfo passed");
099:                }
100:
101:                _objectInfo = objectInfo;
102:                createGUI();
103:            }
104:
105:            /**
106:             * Position and display the sheet.
107:             *
108:             * @param	show	A boolean that determines whether the sheet is shown
109:             * 					or hidden.
110:             */
111:            public synchronized void setVisible(boolean show) {
112:                if (show) {
113:                    if (!isVisible()) {
114:                        final boolean isDebug = s_log.isDebugEnabled();
115:                        long start = 0;
116:
117:                        if (isDebug) {
118:                            start = System.currentTimeMillis();
119:                        }
120:
121:                        if (isDebug) {
122:                            s_log.debug("Panel "
123:                                    + _editWhereColsPanel.getTitle()
124:                                    + " initialized in "
125:                                    + (System.currentTimeMillis() - start)
126:                                    + "ms");
127:                        }
128:
129:                        pack();
130:                        /*
131:                         * TODO: Work out why
132:                         * KLUDGE: For some reason, I am not able to get the sheet to
133:                         * size correctly. It always displays with a size that causes
134:                         * the sub-panels to have their scrollbars showing. Add a bit
135:                         * of an increase in the size of the panel so the scrollbars
136:                         * are not displayed.
137:                         */
138:                        Dimension d = getSize();
139:                        d.width += 5;
140:                        d.height += 5;
141:                        setSize(d);
142:                        /*
143:                         * END-KLUDGE
144:                         */
145:                        GUIUtils.centerWithinDesktop(this );
146:                    }
147:                    moveToFront();
148:                }
149:                super .setVisible(show);
150:            }
151:
152:            //	/**
153:            //	 * Set title of this frame. Ensure that the title label matches the frame title.
154:            //	 *
155:            //	 * @param	title	New title text.
156:            //	 */
157:            //	public void setTitle(String title)
158:            //	{
159:            //      super
160:            //	}
161:
162:            /**
163:             * Dispose of the sheet.
164:             */
165:            private void performClose() {
166:                dispose();
167:            }
168:
169:            public IDatabaseObjectInfo getDatabaseObjectInfo() {
170:                return _objectInfo;
171:            }
172:
173:            /**
174:             * Reset button pressed.  Reset the data to the way it was when we started
175:             * this round of editing.
176:             *
177:             */
178:            private void performReset() {
179:                _editWhereColsPanel.reset();
180:            }
181:
182:            /**
183:             * OK button pressed. Save data to EditWhereCols repository
184:             * then close dialog.
185:             */
186:            private void performOk() {
187:                // try to save the selection.
188:                // do not dispose of this panel if there is a problem
189:                if (_editWhereColsPanel.ok())
190:                    dispose();
191:            }
192:
193:            /**
194:             * Create the GUI elements for the sheet and pass in the setup data to the panel.
195:             */
196:            private void createGUI() {
197:                SortedSet<String> columnNames = new TreeSet<String>();
198:
199:                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
200:
201:                // This is a tool window.
202:                GUIUtils.makeToolWindow(this , true);
203:
204:                final ISession session = getSession();
205:
206:                try {
207:                    final ISQLConnection conn = session.getSQLConnection();
208:                    TableColumnInfo[] infos = conn.getSQLMetaData()
209:                            .getColumnInfo((ITableInfo) _objectInfo);
210:                    for (int i = 0; i < infos.length; i++) {
211:                        TableColumnInfo info = infos[i];
212:                        columnNames.add(info.getColumnName());
213:                    }
214:                } catch (SQLException ex) {
215:                    session.getApplication().showErrorDialog(
216:                    // i18n[editWhereColsSheet.unableToEdit=Unable to get list of columns, {0}]
217:                            s_stringMgr.getString(
218:                                    "editWhereColsSheet.unableToEdit", ex));
219:                }
220:                String unambiguousname = ContentsTab.getUnambiguousTableName(
221:                        session, _objectInfo.getQualifiedName());
222:                _editWhereColsPanel = new EditWhereColsPanel(session,
223:                        (ITableInfo) _objectInfo, columnNames, unambiguousname);
224:
225:                final JScrollPane sp = new JScrollPane(_editWhereColsPanel);
226:                sp.setBorder(BorderFactory.createEmptyBorder());
227:
228:                _titleLbl.setText(getTitle() + ": "
229:                        + _objectInfo.getSimpleName());
230:
231:                final JPanel contentPane = new JPanel(new GridBagLayout());
232:                contentPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5,
233:                        10));
234:                setContentPane(contentPane);
235:
236:                GridBagConstraints gbc = new GridBagConstraints();
237:
238:                gbc.gridwidth = 1;
239:
240:                gbc.gridx = 0;
241:                gbc.gridy = 0;
242:
243:                gbc.fill = GridBagConstraints.BOTH;
244:                gbc.weightx = 1;
245:                contentPane.add(_titleLbl, gbc);
246:
247:                gbc.fill = GridBagConstraints.NONE;
248:                gbc.gridx = GridBagConstraints.REMAINDER;
249:
250:                // leave a blank line just to make it look a bit nicer
251:                gbc.gridx = 0;
252:                ++gbc.gridy;
253:                contentPane.add(new JLabel(" "), gbc);
254:
255:                gbc.gridx = 0;
256:                ++gbc.gridy;
257:                contentPane
258:                        .add(
259:                                // i18n[editWhereColsSheet.limitSizeOfWhereClause=Limit the size of the WHERE clause used behind the scenes when editing cell contents.]
260:                                new JLabel(
261:                                        s_stringMgr
262:                                                .getString("editWhereColsSheet.limitSizeOfWhereClause")),
263:                                gbc);
264:                gbc.gridx = 0;
265:                ++gbc.gridy;
266:                contentPane
267:                        .add(
268:                                // i18n[editWhereColsSheet.shouldIncludePKs=The 'use' window should include at least the primary keys for the table.]
269:                                new JLabel(
270:                                        s_stringMgr
271:                                                .getString("editWhereColsSheet.shouldIncludePKs")),
272:                                gbc);
273:
274:                // leave a blank line just to make it look a bit nicer
275:                gbc.gridx = 0;
276:                ++gbc.gridy;
277:                contentPane.add(new JLabel(" "), gbc);
278:
279:                gbc.fill = GridBagConstraints.BOTH;
280:                gbc.gridwidth = 2;
281:                gbc.gridx = 0;
282:                ++gbc.gridy;
283:                gbc.weighty = 1;
284:                contentPane.add(_editWhereColsPanel, gbc);
285:
286:                ++gbc.gridy;
287:                gbc.gridwidth = 2;
288:                gbc.weighty = 0;
289:                contentPane.add(createButtonsPanel(), gbc);
290:            }
291:
292:            /**
293:             * Create a panel that contains the buttons that control the closing
294:             * of the sheet.
295:             *
296:             * @return An instance of a JPanel.
297:             */
298:            private JPanel createButtonsPanel() {
299:                JPanel pnl = new JPanel();
300:
301:                // i18n[editWherColsSheet.ok=OK]
302:                JButton okBtn = new JButton(s_stringMgr
303:                        .getString("editWherColsSheet.ok"));
304:                okBtn.addActionListener(new ActionListener() {
305:                    public void actionPerformed(ActionEvent evt) {
306:                        performOk();
307:                    }
308:                });
309:                // i18n[editWherColsSheet.reset=Reset]
310:                JButton resetBtn = new JButton(s_stringMgr
311:                        .getString("editWherColsSheet.reset"));
312:                resetBtn.addActionListener(new ActionListener() {
313:                    public void actionPerformed(ActionEvent evt) {
314:                        performReset();
315:                    }
316:                });
317:                // i18n[editWherColsSheet.close=Close]
318:                JButton closeBtn = new JButton(s_stringMgr
319:                        .getString("editWherColsSheet.close"));
320:                closeBtn.addActionListener(new ActionListener() {
321:                    public void actionPerformed(ActionEvent evt) {
322:                        performClose();
323:                    }
324:                });
325:
326:                pnl.add(okBtn);
327:                pnl.add(resetBtn);
328:                pnl.add(closeBtn);
329:
330:                GUIUtils.setJButtonSizesTheSame(new JButton[] { okBtn,
331:                        resetBtn, closeBtn });
332:                getRootPane().setDefaultButton(okBtn);
333:
334:                return pnl;
335:            }
336:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.