This is an automated email from the ASF dual-hosted git repository.
ebakke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new cadff49dc7 Fix a 'Cannot call invokeAndWait from the event dispatcher
thread' exception when calling DatabaseConnection.showConnectionDialog from the
EDT.
cadff49dc7 is described below
commit cadff49dc7447058ca164a9b3d05107c5e02c8cd
Author: Eirik Bakke <[email protected]>
AuthorDate: Mon Jun 5 19:14:39 2023 -0400
Fix a 'Cannot call invokeAndWait from the event dispatcher thread'
exception when calling DatabaseConnection.showConnectionDialog from the EDT.
---
.../modules/db/explorer/action/ConnectAction.java | 37 ++++++++++------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git
a/ide/db/src/org/netbeans/modules/db/explorer/action/ConnectAction.java
b/ide/db/src/org/netbeans/modules/db/explorer/action/ConnectAction.java
index bbe0f41327..ffe4ca8c53 100644
--- a/ide/db/src/org/netbeans/modules/db/explorer/action/ConnectAction.java
+++ b/ide/db/src/org/netbeans/modules/db/explorer/action/ConnectAction.java
@@ -223,27 +223,24 @@ public class ConnectAction extends AbstractAction
implements ContextAwareAction,
dbcon.addPropertyChangeListener(connectionListener);
- try {
- if (headless) {
- connectWithNewInfo(dbcon, input);
- } else {
- ActionListener actionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (event.getSource() ==
DialogDescriptor.OK_OPTION) {
- connectWithNewInfo(dbcon, input);
- }
+ if (headless) {
+ connectWithNewInfo(dbcon, input);
+ } else {
+ ActionListener actionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ if (event.getSource() ==
DialogDescriptor.OK_OPTION) {
+ connectWithNewInfo(dbcon, input);
}
- };
-
- SwingUtilities.invokeAndWait(() -> {
- ConnectPanel basePanel = input.getConnectPanel();
- dlg = new ConnectionDialog(this, basePanel,
basePanel.getTitle(), CONNECT_ACTION_HELPCTX, actionListener);
- dlg.setVisible(true);
- });
- }
- } catch (InterruptedException | InvocationTargetException ex) {
- Exceptions.printStackTrace(ex);
+ }
+ };
+
+ Mutex.EVENT.writeAccess((Mutex.Action<Void>) () -> {
+ ConnectPanel basePanel = input.getConnectPanel();
+ dlg = new ConnectionDialog(this, basePanel,
basePanel.getTitle(), CONNECT_ACTION_HELPCTX, actionListener);
+ dlg.setVisible(true);
+ return null;
+ });
}
dbcon.removeExceptionListener(excListener);
} else { // without dialog with connection data (username,
password), just with progress dlg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists