JAL-1060 - prototype GUI with traffic light coding for JABAWS urls that were fine...
[jalview.git] / src / jalview / jbgui / GWsPreferences.java
index da9322c..4e855af 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
  * 
@@ -35,8 +35,9 @@ import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JProgressBar;
 import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
-import javax.swing.SwingConstants;
 import javax.swing.border.TitledBorder;
 
 /**
@@ -46,8 +47,20 @@ import javax.swing.border.TitledBorder;
  */
 public class GWsPreferences extends JPanel
 {
-  protected JList wsList = new JList();
+  protected JList sbrsList = new JList();
 
+  protected TitledBorder sbrsListTitleBorder = new TitledBorder(
+          "Simple Bioinformatics Rest Services");
+
+  protected JButton newSbrsUrl = new JButton();
+
+  protected JButton editSbrsUrl = new JButton();
+
+  protected JButton deleteSbrsUrl = new JButton();
+
+  // Web service status and url table
+  protected JTable wsList=new JTable();
+  
   protected TitledBorder wsListTitleBorder = new TitledBorder(
           "Web Service Discovery URLS");
 
@@ -65,8 +78,6 @@ public class GWsPreferences extends JPanel
 
   protected JCheckBox indexByType = new JCheckBox();
 
-  protected JCheckBox enableJws1Services = new JCheckBox();
-
   protected JCheckBox enableJws2Services = new JCheckBox();
 
   protected JCheckBox enableEnfinServices = new JCheckBox();
@@ -89,14 +100,28 @@ public class GWsPreferences extends JPanel
 
   JPanel wsListNavButs = new JPanel();
 
+  JScrollPane srbsListPane = new JScrollPane();
+
+  JPanel srbsListUrlPanel = new JPanel();
+
+  JPanel srbsListPanel = new JPanel();
+
+  JPanel srbsListButtons = new JPanel();
+
+  JPanel srbsListNavButs = new JPanel();
+
   BorderLayout myBorderlayout = new BorderLayout();
 
   BorderLayout wsListBorderlayout = new BorderLayout();
+  
+  BorderLayout srbsListBorderlayout = new BorderLayout();
 
   GridBagLayout wsPrefLayout = new GridBagLayout();
 
   GridBagLayout wsListLayout = new GridBagLayout();
 
+  GridBagLayout srbsListLayout = new GridBagLayout();
+
   GridBagLayout wsMenuLayout = new GridBagLayout();
 
   JPanel wsMenuButtons = new JPanel();
@@ -170,16 +195,6 @@ public class GWsPreferences extends JPanel
         enableJws2Services_actionPerformed(e);
       }
     });
-    enableJws1Services
-            .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
-    enableJws1Services.setText("Enable Legacy Services");
-    enableJws1Services.addActionListener(new ActionListener()
-    {
-      public void actionPerformed(ActionEvent e)
-      {
-        enableJws1Services_actionPerformed(e);
-      }
-    });
     displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
     displayWsWarning.setText("Display warnings");
     displayWsWarning
@@ -239,6 +254,34 @@ public class GWsPreferences extends JPanel
         moveWsUrlDown_actionPerformed(e);
       }
     });
+    newSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
+    newSbrsUrl.setText("Add a SBRS definition");
+    newSbrsUrl.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        newSbrsUrl_actionPerformed(e);
+      }
+    });
+    editSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
+    editSbrsUrl.setText("Edit SBRS definition");
+    editSbrsUrl.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        editSbrsUrl_actionPerformed(e);
+      }
+    });
+
+    deleteSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
+    deleteSbrsUrl.setText("Delete SBRS definition");
+    deleteSbrsUrl.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        deleteSbrsUrl_actionPerformed(e);
+      }
+    });
 
     setLayout(myBorderlayout);
     setPreferredSize(new Dimension(500, 400));
@@ -246,11 +289,12 @@ public class GWsPreferences extends JPanel
     progressBar.setString("");
     wsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
     wsListUrlPanel.setLayout(new BorderLayout());
-    // wsListUrlPanel.setPreferredSize(new Dimension(482,202));
     wsListPane.setBorder(BorderFactory.createEtchedBorder());
     wsListPane.getViewport().add(wsList);
-    wsListPane.setPreferredSize(new Dimension(380, 200));
+    wsList.setPreferredSize(new Dimension(482,202));
+    wsListPane.setPreferredSize(new Dimension(380, 80));
     wsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+    wsList.setColumnSelectionAllowed(false);
     wsList.addMouseListener(new MouseListener()
     {
 
@@ -283,28 +327,73 @@ public class GWsPreferences extends JPanel
       }
 
     });
-    // wsListButtons.setPreferredSize(new Dimension(480, 60));
     wsListButtons.setLayout(new FlowLayout());
-    // wsListButtons.add(moveWsUrlUp);
-    // wsListButtons.add(moveWsUrlDown);
     wsListButtons.add(newWsUrl);
     wsListButtons.add(editWsUrl);
     wsListButtons.add(deleteWsUrl);
+    wsListButtons.setMinimumSize(new Dimension(350,80));
     wsListNavButs.setSize(new Dimension(80, 80));
     wsListNavButs.setPreferredSize(new Dimension(80, 80));
     wsListNavButs.setLayout(new FlowLayout());
     wsListNavButs.add(moveWsUrlUp);
     wsListNavButs.add(moveWsUrlDown);
-    wsListUrlPanel.add(wsListPane, BorderLayout.EAST);
+    wsListUrlPanel.add(wsListPane, BorderLayout.CENTER);
     wsListUrlPanel.add(wsListNavButs, BorderLayout.WEST);
     wsListPanel.setBorder(wsListTitleBorder);
     wsListPanel.setLayout(new BorderLayout());
     wsListPanel.add(wsListUrlPanel, BorderLayout.NORTH);
     wsListPanel.add(wsListButtons, BorderLayout.SOUTH);
+
+    srbsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
+    srbsListUrlPanel.setLayout(new BorderLayout());
+    srbsListPane.setBorder(BorderFactory.createEtchedBorder());
+    srbsListPane.getViewport().add(sbrsList);
+    sbrsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+    sbrsList.addMouseListener(new MouseListener()
+    {
+
+      public void mouseClicked(MouseEvent e)
+      {
+        if (e.getClickCount() > 1)
+        {
+          editSbrsUrl_actionPerformed(null);
+        }
+
+      }
+
+      public void mouseEntered(MouseEvent e)
+      {
+
+      }
+
+      public void mouseExited(MouseEvent e)
+      {
+      }
+
+      public void mousePressed(MouseEvent e)
+      {
+
+      }
+
+      public void mouseReleased(MouseEvent e)
+      {
+
+      }
+
+    });
+    srbsListButtons.setLayout(new FlowLayout());
+    srbsListButtons.add(newSbrsUrl);
+    srbsListButtons.add(editSbrsUrl);
+    srbsListButtons.add(deleteSbrsUrl);
+    srbsListUrlPanel.add(srbsListPane, BorderLayout.CENTER);
+    srbsListPanel.setBorder(sbrsListTitleBorder);
+    srbsListPanel.setLayout(new BorderLayout());
+    srbsListPanel.add(srbsListUrlPanel, BorderLayout.NORTH);
+    srbsListPanel.add(srbsListButtons, BorderLayout.CENTER);
+
     wsMenuButtons.setLayout(new GridLayout(2, 3));
     wsMenuButtons.add(indexByHost);
     wsMenuButtons.add(indexByType);
-    wsMenuButtons.add(enableJws1Services);
     wsMenuButtons.add(enableJws2Services);
     wsMenuButtons.add(enableEnfinServices);
     wsMenuButtons.add(displayWsWarning);
@@ -315,11 +404,36 @@ public class GWsPreferences extends JPanel
     wsMenuRefreshButs.add(resetWs, null);
     wsMenuRefreshButs.add(progressBar, null);
     myBorderlayout.setHgap(3);
-    add(wsListPanel, BorderLayout.NORTH);
+    if (jalview.bin.Cache.getDefault("ENABLE_RSBS_EDITOR",false)) {
+       JTabbedPane listPanels=new JTabbedPane();
+       listPanels.addTab("JABAWS Servers",wsListPanel);
+       listPanels.addTab("RSB Services", srbsListPanel);
+       add(listPanels,  BorderLayout.NORTH);
+    } else {
+       add(wsListPanel, BorderLayout.NORTH);
+    }
     add(wsMenuButtons, BorderLayout.CENTER);
     add(wsMenuRefreshButs, BorderLayout.SOUTH);
   }
 
+  protected void deleteSbrsUrl_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
+  protected void editSbrsUrl_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
+  protected void newSbrsUrl_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
   protected void displayWsWarning_actionPerformed(ActionEvent e)
   {
     // TODO Auto-generated method stub
@@ -376,11 +490,6 @@ public class GWsPreferences extends JPanel
 
   }
 
-  protected void enableJws1Services_actionPerformed(ActionEvent e)
-  {
-
-  }
-
   protected void refreshWs_actionPerformed(ActionEvent e)
   {