[hg] main-silver: #211047: Confirm deletion (of database or conn...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #211047: Confirm deletion (of database or conn...
  • Date: Mon, 28 Jan 2013 14:36:37 -0800

changeset 5333863cb88b in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5333863cb88b
description:
        #211047: Confirm deletion (of database or connection) in 
Services/Databases

diffstat:

 db.mysql/src/org/netbeans/modules/db/mysql/nodes/DatabaseNode.java |  16 
++++++++++
 db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java   |  15 
+++++++++
 derby/src/org/netbeans/modules/derby/DerbyDatabaseNode.java        |  14 
++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)

diffs (107 lines):

diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/nodes/DatabaseNode.java 
b/db.mysql/src/org/netbeans/modules/db/mysql/nodes/DatabaseNode.java
--- a/db.mysql/src/org/netbeans/modules/db/mysql/nodes/DatabaseNode.java
+++ b/db.mysql/src/org/netbeans/modules/db/mysql/nodes/DatabaseNode.java
@@ -46,10 +46,13 @@
 import org.netbeans.modules.db.mysql.actions.ConnectAction;
 import org.netbeans.modules.db.mysql.DatabaseServer;
 import javax.swing.Action;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
 import org.openide.actions.DeleteAction;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
 import org.openide.nodes.Node;
+import org.openide.util.NbBundle;
 import org.openide.util.actions.SystemAction;
 
 /**
@@ -90,8 +93,21 @@
         return true;
     }
     
+    @NbBundle.Messages({
+        "# {0} - Database name",
+        "MSG_Confirm_DB_Delete=Really delete database {0}?",
+        "MSG_Confirm_DB_Delete_Title=Delete Database"})
     @Override
     public void destroy() {
+        NotifyDescriptor d =
+                new NotifyDescriptor.Confirmation(
+                Bundle.MSG_Confirm_DB_Delete(model.getDbName()),
+                Bundle.MSG_Confirm_DB_Delete_Title(),
+                NotifyDescriptor.YES_NO_OPTION);
+        Object result = DialogDisplayer.getDefault().notify(d);
+        if (!NotifyDescriptor.OK_OPTION.equals(result)) {
+            return;
+        }
         DatabaseServer server = model.getServer();
         String dbname = model.getDbName();
 
diff --git a/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java 
b/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java
--- a/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java
+++ b/db/src/org/netbeans/modules/db/explorer/node/ConnectionNode.java
@@ -64,6 +64,8 @@
 import org.netbeans.modules.db.explorer.metadata.MetadataModelManager;
 import org.netbeans.modules.db.metadata.model.api.MetadataModel;
 import org.netbeans.modules.db.metadata.model.api.MetadataModels;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
 import org.openide.util.Exceptions;
 import org.openide.util.HelpCtx;
 import org.openide.util.NbBundle;
@@ -344,8 +346,21 @@
         return result;
     }
     
+    @NbBundle.Messages({
+        "# {0} - Connection name",
+        "MSG_Confirm_Connection_Delete=Really delete connection {0}?",
+        "MSG_Confirm_Connection_Delete_Title=Delete Connection"})
     @Override
     public void destroy() {
+        NotifyDescriptor d =
+                new NotifyDescriptor.Confirmation(
+                Bundle.MSG_Confirm_Connection_Delete(connection.getName()),
+                Bundle.MSG_Confirm_Connection_Delete_Title(),
+                NotifyDescriptor.YES_NO_OPTION);
+        Object result = DialogDisplayer.getDefault().notify(d);
+        if (!NotifyDescriptor.OK_OPTION.equals(result)) {
+            return;
+        }
         RP.post(
             new Runnable() {
                 @Override
diff --git a/derby/src/org/netbeans/modules/derby/DerbyDatabaseNode.java 
b/derby/src/org/netbeans/modules/derby/DerbyDatabaseNode.java
--- a/derby/src/org/netbeans/modules/derby/DerbyDatabaseNode.java
+++ b/derby/src/org/netbeans/modules/derby/DerbyDatabaseNode.java
@@ -43,6 +43,8 @@
 package org.netbeans.modules.derby;
 
 import javax.swing.Action;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
 import org.openide.actions.DeleteAction;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
@@ -91,9 +93,21 @@
     }
     
     @Override
+    @NbBundle.Messages({
+        "# {0} - Database name",
+        "MSG_Confirm_DB_Delete=Really delete database {0}?",
+        "MSG_Confirm_DB_Delete_Title=Delete Database"})
     public void destroy() {
+        NotifyDescriptor d =
+                new NotifyDescriptor.Confirmation(
+                Bundle.MSG_Confirm_DB_Delete(database),
+                Bundle.MSG_Confirm_DB_Delete_Title(),
+                NotifyDescriptor.YES_NO_OPTION);
+        Object result = DialogDisplayer.getDefault().notify(d);
+        if (NotifyDescriptor.OK_OPTION.equals(result)) {
         server.dropDatabase(database);
     }
+    }
     
     @Override
     public int compareTo(Object other) {

[hg] main-silver: #211047: Confirm deletion (of database or conn...

Jaroslav Havlin 01/28/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close