JAL-2446 merged to spike branch
[jalview.git] / src / jalview / gui / JDatabaseTree.java
index 8294d2b..d92f6c0 100644 (file)
@@ -33,6 +33,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -86,9 +88,12 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
 
   private JLabel dbstatus, dbstatex;
 
+  private JPanel mainPanel = new JPanel(new BorderLayout());
+
   public JDatabaseTree(jalview.ws.SequenceFetcher sfetch)
   {
-    initDialogFrame(this, true, false,
+    mainPanel.add(this);
+    initDialogFrame(mainPanel, true, false,
             MessageManager
                     .getString("label.select_database_retrieval_source"),
             650, 490);
@@ -146,19 +151,19 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
     }
     // and sort the tree
     sortTreeNodes(root);
-    svp = new JScrollPane();
-    // svp.setAutoscrolls(true);
     dbviews = new JTree(new DefaultTreeModel(root, false));
     dbviews.setCellRenderer(new DbTreeRenderer(this));
 
     dbviews.getSelectionModel().setSelectionMode(
             TreeSelectionModel.SINGLE_TREE_SELECTION);
-    svp.getViewport().setView(dbviews);
-    // svp.getViewport().setMinimumSize(new Dimension(300,200));
-    // svp.setSize(300,250);
-    // JPanel panel=new JPanel();
-    // panel.setSize(new Dimension(350,220));
-    // panel.add(svp);
+    svp = new JScrollPane(dbviews);
+    svp.setMinimumSize(new Dimension(100, 200));
+    svp.setPreferredSize(new Dimension(200, 400));
+    svp.setMaximumSize(new Dimension(300, 600));
+
+    JPanel panel = new JPanel(new BorderLayout());
+    panel.setSize(new Dimension(350, 220));
+    panel.add(svp);
     dbviews.addTreeSelectionListener(new TreeSelectionListener()
     {
 
@@ -168,6 +173,19 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
         _setSelectionState();
       }
     });
+    dbviews.addMouseListener(new MouseAdapter()
+    {
+
+      @Override
+      public void mousePressed(MouseEvent e)
+      {
+        if (e.getClickCount() == 2)
+        {
+          okPressed();
+          closeDialog();
+        }
+      }
+    });
     JPanel jc = new JPanel(new BorderLayout()), j = new JPanel(
             new FlowLayout());
     jc.add(svp, BorderLayout.CENTER);
@@ -185,7 +203,6 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
     dbstat.add(dbstatex);
     jc.add(dbstat, BorderLayout.SOUTH);
     jc.validate();
-    // j.setPreferredSize(new Dimension(300,50));
     add(jc, BorderLayout.CENTER);
     ok.setEnabled(false);
     j.add(ok);
@@ -308,7 +325,6 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
   protected void okPressed()
   {
     _setSelectionState();
-    closeDialog();
   }
 
   @Override
@@ -557,6 +573,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener
     {
       action = arg0.getKeyCode();
       okPressed();
+      closeDialog();
     }
     if (!arg0.isConsumed() && arg0.getKeyChar() == KeyEvent.VK_ESCAPE)
     {