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.
Summary: | DatabaseExplorerUIs.connect feature problems | ||
---|---|---|---|
Product: | db | Reporter: | ndev69 <ndev69> |
Component: | MySQL | Assignee: | Jaroslav Havlin <jhavlin> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | romanmostyka |
Priority: | P3 | Keywords: | NETFIX |
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | proposed patch v1 |
Description
ndev69
2008-12-02 17:07:04 UTC
This is the routine I am using to connect the combobox. When connections are removed the combo box is not updated. Below is the fix I am using to accomplish this task. public void populateForm() { ConnectionManager manager = ConnectionManager.getDefault(); DatabaseExplorerUIs.connect(connectionsCombo, manager); DatabaseConnection current = SQLConnectionManager.getDefault().getActiveConnection(); if (current != null) { connectionsCombo.setSelectedItem(current); } } private void removeActiveConnection(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Object selItem = connectionsCombo.getSelectedItem(); if (selItem instanceof DatabaseConnection) { SQLConnectionManager.getDefault().setActiveConnection(null); try { **** issue# 135003 fixed this call it now works.. however the combo is not updated. ConnectionManager.getDefault().removeConnection((DatabaseConnection) selItem); } catch (DatabaseException ex) { ex.printStackTrace(IOProvider.getDefault().getStdOut()); } ***** This is needed to get the call to re-register the combo box model without generating a class cast exception. I am assuming that the DatabaseExplorerUIs.connect method adds a property change listener and listens for model changes and removes itself. If not may want to either fix by adding the remove support or add a DatabaseExplorerUIs.remove method to handle this type of work around. Personally I think the DatabaseExplorerUIs.connect method should handle adding and removing items properly as connections become available and are lost. connectionsCombo.setModel(new DefaultComboBoxModel()); populateForm(); } } Reassigned to new owner. Created attachment 125545 [details]
proposed patch v1
Fixed by useing a connection listener to directly tie the comboboxmodel to the connection list.
A weaklistener is constructed to prevent a memoryleak, unittest is attached.
It has been 4 years since I initially reported this bug. In the beginnig there were several exchanges to even convince whoever is at the other end of this system that this problem even existed. I have long since given up on this product and moved to .NET. Cudos to your persiverance, but 4 years, and this is just a proposed patch. I know it is a free product but I assume you actually want people to use it. Integrated as http://hg.netbeans.org/core-main/rev/3e8d6e8df597 Thank you, Matthias! Integrated into 'main-golden', will be available in build *201210250921* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/3e8d6e8df597 User: Jaroslav Havlin <jhavlin@netbeans.org> Log: #154383: DatabaseExplorerUIs.connect feature problems |