This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 129633
Collapse All | Expand All

(-)a/db/apichanges.xml (+14 lines)
Lines 105-110 Link Here
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
106
107
    <changes>
107
    <changes>
108
        <change>
109
            <api name="database_explorer_api"/>
110
            <summary>Add ability to show the Add JDBC Driver dialog synchronously</summary>
111
            <version major="1" minor="27"/>
112
            <date day="27" month="6" year="2008"/>
113
            <author login="davidvc"/>
114
            <compatibility addition="yes"/>
115
            <description>
116
                Add the ability to show the Add Driver dialog synchronously.  This
117
                must be run on the AWT event thread, but it gives you the ability to
118
                immediately get the resulting JDBCDriver that was added.
119
            </description>
120
            <issue number="129633"/>
121
        </change>
108
        <change>
122
        <change>
109
            <api name="database_explorer_api"/>
123
            <api name="database_explorer_api"/>
110
            <summary>Add ability to connect a database connection directly with no UI</summary>
124
            <summary>Add ability to connect a database connection directly with no UI</summary>
(-)a/db/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.db/1
2
OpenIDE-Module: org.netbeans.modules.db/1
3
OpenIDE-Module-Install: org/netbeans/modules/db/DatabaseModule.class
3
OpenIDE-Module-Install: org/netbeans/modules/db/DatabaseModule.class
4
OpenIDE-Module-Implementation-Version: 26
4
OpenIDE-Module-Implementation-Version: 27
5
OpenIDE-Module-Layer: org/netbeans/modules/db/resources/mf-layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/db/resources/mf-layer.xml
6
OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
6
OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
7
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/db/resources/Bundle.properties
7
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/db/resources/Bundle.properties
(-)a/db/src/org/netbeans/api/db/explorer/JDBCDriverManager.java (+17 lines)
Lines 184-189 Link Here
184
            new AddDriverAction.AddDriverDialogDisplayer().showDialog();
184
            new AddDriverAction.AddDriverDialogDisplayer().showDialog();
185
        }
185
        }
186
    }
186
    }
187
188
    /**
189
     * Shows the Add Driver dialog synchronously.  Must be run from the
190
     * AWT event thread; an IllegalStateException will be thrown if this
191
     * method is called from any other thread.
192
     *
193
     * @return the new driver that was added, or null if the driver was
194
     *   not successfully created
195
     *
196
     * @since 1.27
197
     */
198
    public JDBCDriver showAddDriverDialogFromEventThread() {
199
        if (!SwingUtilities.isEventDispatchThread()) {
200
            throw new IllegalStateException("The current thread is not the event dispatching thread."); // NOI18N
201
        }
202
        return new AddDriverAction.AddDriverDialogDisplayer().showDialog();        
203
    }
187
    
204
    
188
    /**
205
    /**
189
     * Registers a JDBCDriverListener.
206
     * Registers a JDBCDriverListener.
(-)a/db/src/org/netbeans/modules/db/explorer/actions/AddDriverAction.java (-5 / +9 lines)
Lines 57-66 Link Here
57
import org.netbeans.modules.db.explorer.dlg.AddDriverDialog;
57
import org.netbeans.modules.db.explorer.dlg.AddDriverDialog;
58
import org.netbeans.api.db.explorer.JDBCDriver;
58
import org.netbeans.api.db.explorer.JDBCDriver;
59
import org.netbeans.api.db.explorer.JDBCDriverManager;
59
import org.netbeans.api.db.explorer.JDBCDriverManager;
60
import org.openide.util.Exceptions;
60
61
61
public class AddDriverAction extends DatabaseAction {
62
public class AddDriverAction extends DatabaseAction {
62
    static final long serialVersionUID =-109193000951395612L;
63
    static final long serialVersionUID =-109193000951395612L;
63
    
64
65
    @Override
64
    public void performAction(Node[] activatedNodes) {
66
    public void performAction(Node[] activatedNodes) {
65
        new AddDriverDialogDisplayer().showDialog();
67
        new AddDriverDialogDisplayer().showDialog();
66
    }
68
    }
Lines 68-76 Link Here
68
    public static final class AddDriverDialogDisplayer {
70
    public static final class AddDriverDialogDisplayer {
69
        
71
        
70
        private Dialog dialog;
72
        private Dialog dialog;
71
        private JDBCDriver driver;
73
        private JDBCDriver driver = null;
72
        
74
        
73
        public void showDialog() {
75
        public JDBCDriver showDialog() {
74
            final AddDriverDialog dlgPanel = new AddDriverDialog();
76
            final AddDriverDialog dlgPanel = new AddDriverDialog();
75
77
76
            ActionListener actionListener = new ActionListener() {
78
            ActionListener actionListener = new ActionListener() {
Lines 90-96 Link Here
90
                            err.append(bundle().getString("AddDriverDialog_MissingClass")); //NOI18N
92
                            err.append(bundle().getString("AddDriverDialog_MissingClass")); //NOI18N
91
                        }
93
                        }
92
                        if (err.length() > 0) {
94
                        if (err.length() > 0) {
93
                            String message = MessageFormat.format(bundle().getString("AddDriverDialog_ErrorMessage"), new String[] {err.toString()}); //NOI18N
95
                            String message = MessageFormat.format(bundle().getString("AddDriverDialog_ErrorMessage"),
96
                                    err.toString()); //NOI18N
94
                            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE));
97
                            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE));
95
98
96
                            return;
99
                            return;
Lines 107-113 Link Here
107
                            driver = JDBCDriver.create(name, name, drvClass, (URL[]) drvLoc.toArray(new URL[drvLoc.size()]));
110
                            driver = JDBCDriver.create(name, name, drvClass, (URL[]) drvLoc.toArray(new URL[drvLoc.size()]));
108
                            JDBCDriverManager.getDefault().addDriver(driver);
111
                            JDBCDriverManager.getDefault().addDriver(driver);
109
                        } catch (DatabaseException exc) {
112
                        } catch (DatabaseException exc) {
110
                            //PENDING
113
                            Exceptions.printStackTrace(exc);
111
                        }                    
114
                        }                    
112
                    }
115
                    }
113
                }
116
                }
Lines 118-123 Link Here
118
            descriptor.setClosingOptions(closingOptions);
121
            descriptor.setClosingOptions(closingOptions);
119
            dialog = DialogDisplayer.getDefault().createDialog(descriptor);
122
            dialog = DialogDisplayer.getDefault().createDialog(descriptor);
120
            dialog.setVisible(true);
123
            dialog.setVisible(true);
124
            return driver;
121
        }
125
        }
122
    }
126
    }
123
}
127
}

Return to bug 129633