Source Code Cross Referenced for SchemaPanel.java in  » IDE-Netbeans » db » org » netbeans » modules » db » explorer » dlg » 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 » IDE Netbeans » db » org.netbeans.modules.db.explorer.dlg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.db.explorer.dlg;
043:
044:        import java.awt.BorderLayout;
045:        import java.sql.Connection;
046:        import java.sql.SQLException;
047:        import java.util.Vector;
048:        import javax.swing.JComponent;
049:        import javax.swing.SwingUtilities;
050:        import org.netbeans.api.progress.ProgressHandle;
051:        import org.netbeans.api.progress.ProgressHandleFactory;
052:
053:        import org.openide.util.NbBundle;
054:
055:        import org.netbeans.modules.db.explorer.DatabaseConnection;
056:        import org.openide.util.RequestProcessor;
057:
058:        public class SchemaPanel extends javax.swing.JPanel {
059:
060:            private ConnectionDialogMediator mediator;
061:            private DatabaseConnection dbcon;
062:            private ProgressHandle progressHandle;
063:            private JComponent progressComponent;
064:
065:            /**
066:             * Creates a new form SchemaPanel
067:             * 
068:             * @param dbcon instance of DatabaseConnection object
069:             */
070:            public SchemaPanel(ConnectionDialogMediator mediator,
071:                    DatabaseConnection dbcon) {
072:                this .mediator = mediator;
073:                this .dbcon = dbcon;
074:                initComponents();
075:                initAccessibility();
076:
077:                ConnectionProgressListener progressListener = new ConnectionProgressListener() {
078:                    public void connectionStarted() {
079:                        startProgress();
080:                    }
081:
082:                    public void connectionStep(String step) {
083:                        setProgressMessage(step);
084:                    }
085:
086:                    public void connectionFinished() {
087:                        stopProgress(true);
088:                    }
089:
090:                    public void connectionFailed() {
091:                        stopProgress(false);
092:                    }
093:                };
094:                mediator.addConnectionProgressListener(progressListener);
095:            }
096:
097:            private void initAccessibility() {
098:                schemaLabel.getAccessibleContext().setAccessibleDescription(
099:                        NbBundle.getBundle(
100:                                "org.netbeans.modules.db.resources.Bundle")
101:                                .getString("ACS_SchemaDialogTextA11yDesc")); //NOI18N
102:                schemaComboBox
103:                        .getAccessibleContext()
104:                        .setAccessibleName(
105:                                NbBundle
106:                                        .getBundle(
107:                                                "org.netbeans.modules.db.resources.Bundle")
108:                                        .getString(
109:                                                "ACS_SchemaDialogTextComboBoxA11yName")); //NOI18N
110:                commentTextArea.getAccessibleContext().setAccessibleName(
111:                        NbBundle.getBundle(
112:                                "org.netbeans.modules.db.resources.Bundle")
113:                                .getString("ACS_SchemaPanelCommentA11yName")); //NOI18N
114:                commentTextArea
115:                        .getAccessibleContext()
116:                        .setAccessibleDescription(
117:                                NbBundle
118:                                        .getBundle(
119:                                                "org.netbeans.modules.db.resources.Bundle")
120:                                        .getString(
121:                                                "ACS_SchemaPanelCommentA11yDesc")); //NOI18N
122:                connectProgressPanel
123:                        .getAccessibleContext()
124:                        .setAccessibleName(
125:                                NbBundle
126:                                        .getBundle(
127:                                                "org.netbeans.modules.db.resources.Bundle")
128:                                        .getString(
129:                                                "ACS_ConnectionProgressBarA11yName")); //NOI18N
130:                connectProgressPanel
131:                        .getAccessibleContext()
132:                        .setAccessibleDescription(
133:                                NbBundle
134:                                        .getBundle(
135:                                                "org.netbeans.modules.db.resources.Bundle")
136:                                        .getString(
137:                                                "ACS_ConnectionProgressBarA11yDesc")); //NOI18N
138:                schemaButton.getAccessibleContext().setAccessibleName(
139:                        NbBundle.getBundle(
140:                                "org.netbeans.modules.db.resources.Bundle")
141:                                .getString("ACS_GetSchemasButtonA11yName")); //NOI18N
142:                schemaButton.getAccessibleContext().setAccessibleDescription(
143:                        NbBundle.getBundle(
144:                                "org.netbeans.modules.db.resources.Bundle")
145:                                .getString("ACS_GetSchemasButtonA11yDesc")); //NOI18N
146:                this .getAccessibleContext().setAccessibleName(
147:                        NbBundle.getBundle(
148:                                "org.netbeans.modules.db.resources.Bundle")
149:                                .getString("ACS_GetSchemasPanelA11yName")); //NOI18N
150:                this .getAccessibleContext().setAccessibleDescription(
151:                        NbBundle.getBundle(
152:                                "org.netbeans.modules.db.resources.Bundle")
153:                                .getString("ACS_GetSchemasPanelA11yDesc")); //NOI18N
154:            }
155:
156:            /** This method is called from within the constructor to
157:             * initialize the form.
158:             * WARNING: Do NOT modify this code. The content of this method is
159:             * always regenerated by the Form Editor.
160:             */
161:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
162:            private void initComponents() {
163:                java.awt.GridBagConstraints gridBagConstraints;
164:
165:                commentTextArea = new javax.swing.JTextArea();
166:                schemaLabel = new javax.swing.JLabel();
167:                schemaComboBox = new javax.swing.JComboBox();
168:                schemaButton = new javax.swing.JButton();
169:                connectProgressPanel = new javax.swing.JPanel();
170:                progressMessageLabel = new javax.swing.JLabel();
171:                progressContainerPanel = new javax.swing.JPanel();
172:
173:                FormListener formListener = new FormListener();
174:
175:                setLayout(new java.awt.GridBagLayout());
176:
177:                commentTextArea.setEditable(false);
178:                commentTextArea.setFont(javax.swing.UIManager
179:                        .getFont("Label.font"));
180:                commentTextArea.setLineWrap(true);
181:                commentTextArea.setText(NbBundle.getBundle(
182:                        "org.netbeans.modules.db.resources.Bundle").getString(
183:                        "MSG_SchemaPanelComment")); // NOI18N
184:                commentTextArea.setWrapStyleWord(true);
185:                commentTextArea.setDisabledTextColor(javax.swing.UIManager
186:                        .getColor("Label.foreground"));
187:                commentTextArea.setEnabled(false);
188:                commentTextArea.setOpaque(false);
189:                gridBagConstraints = new java.awt.GridBagConstraints();
190:                gridBagConstraints.gridwidth = 3;
191:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
192:                gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
193:                add(commentTextArea, gridBagConstraints);
194:
195:                schemaLabel.setLabelFor(schemaComboBox);
196:                org.openide.awt.Mnemonics.setLocalizedText(schemaLabel,
197:                        NbBundle.getBundle(
198:                                "org.netbeans.modules.db.resources.Bundle")
199:                                .getString("SchemaDialogText")); // NOI18N
200:                gridBagConstraints = new java.awt.GridBagConstraints();
201:                gridBagConstraints.gridx = 0;
202:                gridBagConstraints.gridy = 1;
203:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
204:                gridBagConstraints.weighty = 1.0;
205:                gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
206:                add(schemaLabel, gridBagConstraints);
207:
208:                schemaComboBox.setToolTipText(NbBundle.getBundle(
209:                        "org.netbeans.modules.db.resources.Bundle").getString(
210:                        "ACS_SchemaDialogTextComboBoxA11yDesc")); // NOI18N
211:                schemaComboBox.setEnabled(false);
212:                schemaComboBox.setPrototypeDisplayValue("wwwwwwwwww");
213:                gridBagConstraints = new java.awt.GridBagConstraints();
214:                gridBagConstraints.gridx = 1;
215:                gridBagConstraints.gridy = 1;
216:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
217:                gridBagConstraints.weightx = 1.0;
218:                gridBagConstraints.weighty = 1.0;
219:                gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
220:                add(schemaComboBox, gridBagConstraints);
221:
222:                org.openide.awt.Mnemonics.setLocalizedText(schemaButton,
223:                        NbBundle.getBundle(
224:                                "org.netbeans.modules.db.resources.Bundle")
225:                                .getString("SchemaDialogGetButton")); // NOI18N
226:                schemaButton.setToolTipText(NbBundle.getBundle(
227:                        "org.netbeans.modules.db.resources.Bundle").getString(
228:                        "ACS_GetSchemasButtonA11yDesc")); // NOI18N
229:                schemaButton.addActionListener(formListener);
230:                gridBagConstraints = new java.awt.GridBagConstraints();
231:                gridBagConstraints.gridx = 2;
232:                gridBagConstraints.gridy = 1;
233:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
234:                gridBagConstraints.weighty = 1.0;
235:                gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 11);
236:                add(schemaButton, gridBagConstraints);
237:
238:                connectProgressPanel.setToolTipText(NbBundle.getBundle(
239:                        "org.netbeans.modules.db.resources.Bundle").getString(
240:                        "ACS_ConnectionProgressBarA11yDesc")); // NOI18N
241:                connectProgressPanel.setLayout(new java.awt.BorderLayout(0, 5));
242:
243:                org.openide.awt.Mnemonics.setLocalizedText(
244:                        progressMessageLabel, " ");
245:                connectProgressPanel.add(progressMessageLabel,
246:                        java.awt.BorderLayout.NORTH);
247:
248:                progressContainerPanel.setMinimumSize(new java.awt.Dimension(
249:                        20, 20));
250:                progressContainerPanel.setPreferredSize(new java.awt.Dimension(
251:                        20, 20));
252:                progressContainerPanel.setLayout(new java.awt.BorderLayout());
253:                connectProgressPanel.add(progressContainerPanel,
254:                        java.awt.BorderLayout.CENTER);
255:
256:                gridBagConstraints = new java.awt.GridBagConstraints();
257:                gridBagConstraints.gridx = 0;
258:                gridBagConstraints.gridy = 2;
259:                gridBagConstraints.gridwidth = 3;
260:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
261:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
262:                gridBagConstraints.weightx = 1.0;
263:                gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 11);
264:                add(connectProgressPanel, gridBagConstraints);
265:            }
266:
267:            // Code for dispatching events from components to event handlers.
268:
269:            private class FormListener implements  java.awt.event.ActionListener {
270:                FormListener() {
271:                }
272:
273:                public void actionPerformed(java.awt.event.ActionEvent evt) {
274:                    if (evt.getSource() == schemaButton) {
275:                        SchemaPanel.this .schemaButtonActionPerformed(evt);
276:                    }
277:                }
278:            }// </editor-fold>//GEN-END:initComponents
279:
280:            private void schemaButtonActionPerformed(
281:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_schemaButtonActionPerformed
282:                schemaComboBox.setEnabled(false);
283:                schemaComboBox.removeAllItems();
284:
285:                Connection con = dbcon.getConnection();
286:                try {
287:                    if (con == null || con.isClosed())
288:                        dbcon.connect();
289:                    else {
290:                        RequestProcessor.getDefault().post(new Runnable() {
291:                            public void run() {
292:                                mediator.fireConnectionStarted();
293:                                mediator.retrieveSchemas(SchemaPanel.this ,
294:                                        dbcon, dbcon.getUser());
295:                                mediator.fireConnectionFinished();
296:                            }
297:                        });
298:                    }
299:                } catch (SQLException exc) {
300:                    //isClosed() method failed, try to connect
301:                    dbcon.connect();
302:                }
303:            }//GEN-LAST:event_schemaButtonActionPerformed
304:
305:            // Variables declaration - do not modify//GEN-BEGIN:variables
306:            private javax.swing.JTextArea commentTextArea;
307:            private javax.swing.JPanel connectProgressPanel;
308:            private javax.swing.JPanel progressContainerPanel;
309:            private javax.swing.JLabel progressMessageLabel;
310:            private javax.swing.JButton schemaButton;
311:            private javax.swing.JComboBox schemaComboBox;
312:            private javax.swing.JLabel schemaLabel;
313:
314:            // End of variables declaration//GEN-END:variables
315:
316:            public String getSchema() {
317:                Object schema = schemaComboBox.getSelectedItem();
318:                if (schema != null
319:                        && !schema
320:                                .toString()
321:                                .equals(
322:                                        NbBundle
323:                                                .getBundle(
324:                                                        "org.netbeans.modules.db.resources.Bundle")
325:                                                .getString("TXT_NoSchema"))) //NOI18N
326:                    return schema.toString();
327:                else
328:                    return null;
329:            }
330:
331:            public boolean setSchemas(Vector items, String schema) {
332:                schemaComboBox.removeAllItems();
333:                for (int i = 0; i < items.size(); i++)
334:                    schemaComboBox.addItem(items.elementAt(i));
335:
336:                if (items.size() == 0) {
337:                    schemaComboBox.addItem(NbBundle.getBundle(
338:                            "org.netbeans.modules.db.resources.Bundle")
339:                            .getString("TXT_NoSchema")); //NOI18N
340:                    schemaComboBox.setEnabled(false);
341:                } else
342:                    schemaComboBox.setEnabled(true);
343:
344:                if (items.size() == 1)
345:                    //no or only one schema in the items
346:                    return true;
347:
348:                int idx = items.indexOf(schema);
349:                if (idx == -1)
350:                    idx = items.indexOf(schema.toLowerCase());
351:                if (idx == -1)
352:                    idx = items.indexOf(schema.toUpperCase());
353:                if (idx != -1) {
354:                    schemaComboBox.setSelectedIndex(idx);
355:                    // schema has been found in the items
356:                    return true;
357:                }
358:
359:                // schema has not been found in the items; index is set to the first item
360:                return false;
361:            }
362:
363:            public void setComment(String msg) {
364:                commentTextArea.setText(msg);
365:            }
366:
367:            private void startProgress() {
368:                SwingUtilities.invokeLater(new Runnable() {
369:                    public void run() {
370:                        progressHandle = ProgressHandleFactory
371:                                .createHandle(null);
372:                        progressComponent = ProgressHandleFactory
373:                                .createProgressComponent(progressHandle);
374:                        progressContainerPanel.add(progressComponent,
375:                                BorderLayout.CENTER);
376:                        progressHandle.start();
377:                        progressMessageLabel.setText(NbBundle.getBundle(
378:                                "org.netbeans.modules.db.resources.Bundle")
379:                                .getString("ConnectionProgress_Connecting"));
380:                        schemaButton.setEnabled(false);
381:                    }
382:                });
383:            }
384:
385:            private void setProgressMessage(final String message) {
386:                SwingUtilities.invokeLater(new Runnable() {
387:                    public void run() {
388:                        progressMessageLabel.setText(message);
389:                        schemaButton.setEnabled(false);
390:                    }
391:                });
392:            }
393:
394:            private void stopProgress(final boolean connected) {
395:                SwingUtilities.invokeLater(new Runnable() {
396:                    public void run() {
397:                        progressHandle.finish();
398:                        progressContainerPanel.remove(progressComponent);
399:                        // without this, the removed progress component remains painted on its parent... why?
400:                        progressContainerPanel.repaint();
401:                        if (connected) {
402:                            progressMessageLabel
403:                                    .setText(NbBundle
404:                                            .getBundle(
405:                                                    "org.netbeans.modules.db.resources.Bundle")
406:                                            .getString(
407:                                                    "ConnectionProgress_Established"));
408:                        } else {
409:                            progressMessageLabel.setText(NbBundle.getBundle(
410:                                    "org.netbeans.modules.db.resources.Bundle")
411:                                    .getString("ConnectionProgress_Failed"));
412:                        }
413:                        schemaButton.setEnabled(true);
414:                    }
415:                });
416:            }
417:
418:            public void resetProgress() {
419:                progressMessageLabel.setText(" "); // NOI18N
420:            }
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.