OSDN Git Service

Fix #32187: anyActionPerformed -> getActionMap().get(cmd).actionPerformed...
[stew/Stew4.git] / src / net / argius / stew / ui / window / DatabaseInfoTree.java
index 044113f..8d2f8a1 100644 (file)
@@ -12,7 +12,6 @@ import static net.argius.stew.ui.window.AnyActionKey.copy;
 import static net.argius.stew.ui.window.AnyActionKey.refresh;
 import static net.argius.stew.ui.window.DatabaseInfoTree.ActionKey.*;
 import static net.argius.stew.ui.window.WindowOutputProcessor.showInformationMessageDialog;
-
 import java.awt.*;
 import java.awt.event.*;
 import java.io.*;
@@ -20,11 +19,9 @@ import java.sql.*;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.List;
-
 import javax.swing.*;
 import javax.swing.event.*;
 import javax.swing.tree.*;
-
 import net.argius.stew.*;
 
 /**
@@ -79,7 +76,13 @@ final class DatabaseInfoTree extends JTree implements AnyActionListener, TextSea
     @Override
     public void anyActionPerformed(AnyActionEvent ev) {
         log.atEnter("anyActionPerformed", ev);
-        if (ev.isAnyOf(copySimpleName)) {
+        if (ev.isAnyOf(copy)) {
+            final String cmd = ev.getActionCommand();
+            Action action = getActionMap().get(cmd);
+            if (action != null) {
+                action.actionPerformed(new ActionEvent(this, 1001, cmd));
+            }
+        } else if (ev.isAnyOf(copySimpleName)) {
             copySimpleName();
         } else if (ev.isAnyOf(copyFullName)) {
             copyFullName();
@@ -215,8 +218,8 @@ final class DatabaseInfoTree extends JTree implements AnyActionListener, TextSea
                 ++c;
             }
         }
-        if (c >= 2) {
-            return String.format("%s;%s", phrase, join(",", nCopies(c, "")));
+        if (c >= 1) {
+            return String.format("%s;%s", phrase, join("", nCopies(c - 1, ",")));
         }
         return phrase;
     }
@@ -600,6 +603,12 @@ final class DatabaseInfoTree extends JTree implements AnyActionListener, TextSea
                         }
                     });
                 } catch (SQLException ex) {
+                    try {
+                        if (dbmeta.getConnection().isClosed())
+                            return;
+                    } catch (SQLException exx) {
+                        ex.setNextException(exx);
+                    }
                     throw new RuntimeException(ex);
                 }
             }