JAL-1700 made PDB service error mechanism more user friendly
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 28 May 2015 15:47:25 +0000 (16:47 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 28 May 2015 15:47:25 +0000 (16:47 +0100)
resources/images/warning.gif [new file with mode: 0644]
src/jalview/gui/PDBSearchPanel.java
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GPDBSearchPanel.java
src/jalview/jbgui/GStructureChooser.java
src/jalview/ws/dbsources/PDBRestClient.java

diff --git a/resources/images/warning.gif b/resources/images/warning.gif
new file mode 100644 (file)
index 0000000..3d57c8c
Binary files /dev/null and b/resources/images/warning.gif differ
index 950c6b7..4bd6f7c 100644 (file)
@@ -36,7 +36,6 @@ import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 
-import javax.swing.JOptionPane;
 import javax.swing.table.DefaultTableModel;
 
 @SuppressWarnings("serial")
@@ -62,6 +61,8 @@ public class PDBSearchPanel extends GPDBSearchPanel
   @Override
   public void txt_search_ActionPerformed()
   {
+    errorWarning.setLength(0);
+    lbl_warning.setVisible(false);
     btn_ok.setEnabled(false);
     boolean allowEmptySequence = false;
     mainFrame.setTitle(MessageManager
@@ -95,8 +96,10 @@ public class PDBSearchPanel extends GPDBSearchPanel
       } catch (Exception e)
       {
         // System.out.println(">>>>>>>>>>>>>>>" + e.getMessage());
-        JOptionPane.showMessageDialog(this, e.getMessage(),
-                "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
+        // JOptionPane.showMessageDialog(this, e.getMessage(),
+        // "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
+        errorWarning.append(e.getMessage());
+        checkForErrors();
         return;
       }
 
@@ -258,4 +261,14 @@ public class PDBSearchPanel extends GPDBSearchPanel
     }
   }
 
+  public void checkForErrors()
+  {
+    lbl_warning.setVisible(false);
+    if (errorWarning.length() > 0)
+    {
+      lbl_warning.setToolTipText(JvSwingUtils.wrapTooltip(true,
+              errorWarning.toString()));
+      lbl_warning.setVisible(true);
+    }
+  }
 }
index 2944cd8..015cd8e 100644 (file)
@@ -188,8 +188,8 @@ public class StructureChooser extends GStructureChooser
 .setTitle("Structure Chooser - Manual association");
       if (errors.size() > 0)
       {
-        StringBuilder errorMsg = new StringBuilder(
-                "Operation was unsucessful due to the following: \n");
+        StringBuilder errorMsg = new StringBuilder();
+        // "Operation was unsucessful due to the following: \n");
         for (String error : errors)
         {
           errorMsg.append(error).append("\n");
@@ -561,6 +561,21 @@ public class StructureChooser extends GStructureChooser
     AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
             .getCmb_assSeq().getSelectedItem();
     lbl_pdbManualFetchStatus.setIcon(errorImage);
+    lbl_pdbManualFetchStatus.setToolTipText("");
+    if (txt_search.getText().length() > 0)
+    {
+      lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
+              true, "No PDB entry found for \'" + txt_search.getText()
+                      + "\'"));
+    }
+
+    if (errorWarning.length() > 0)
+    {
+      lbl_pdbManualFetchStatus.setIcon(warningImage);
+      lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
+              true, errorWarning.toString()));
+    }
+
     if (selectedSequences.length == 1
             || !assSeqOpt.getName().equalsIgnoreCase(
                     "-Select Associated Seq-"))
@@ -569,6 +584,7 @@ public class StructureChooser extends GStructureChooser
       if (isValidPBDEntry)
       {
         btn_view.setEnabled(true);
+        lbl_pdbManualFetchStatus.setToolTipText("");
         lbl_pdbManualFetchStatus.setIcon(goodImage);
       }
     }
@@ -789,6 +805,7 @@ public class StructureChooser extends GStructureChooser
   @Override
   protected void txt_search_ActionPerformed()
   {
+    errorWarning.setLength(0);
     isValidPBDEntry = false;
     if (txt_search.getText().length() > 0)
     {
@@ -808,12 +825,13 @@ public class StructureChooser extends GStructureChooser
         resultList = pdbRestCleint.executeRequest(pdbRequest);
       } catch (Exception e)
       {
-        JOptionPane.showMessageDialog(this, e.getMessage(),
-                "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
+        // JOptionPane.showMessageDialog(this, e.getMessage(),
+        // "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
+        errorWarning.append(e.getMessage());
         return;
       } finally
       {
-        System.out.println(">>>>> executing finally block");
+        // System.out.println(">>>>> executing finally block");
         validateSelections();
       }
       if (resultList.getSearchSummary() != null
@@ -844,5 +862,4 @@ public class StructureChooser extends GStructureChooser
     }
   }
 
-
 }
index e74f0ef..ec7d0f8 100644 (file)
@@ -33,10 +33,12 @@ import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 
+import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
 import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
@@ -73,9 +75,16 @@ public abstract class GPDBSearchPanel extends JPanel
   
   protected JTable tbl_summary = new JTable();
 
+  protected StringBuilder errorWarning = new StringBuilder();
+
   protected JScrollPane scrl_searchResult = new JScrollPane(
 tbl_summary);
 
+  protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
+          "/images/warning.gif"));
+
+  protected JLabel lbl_warning = new JLabel(warningImage);
+
   private JTabbedPane tabbedPane = new JTabbedPane();
 
   private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
@@ -109,6 +118,9 @@ tbl_summary);
    */
   private void jbInit() throws Exception
   {
+    lbl_warning.setVisible(false);
+    lbl_warning.setFont(new java.awt.Font("Verdana", 0, 12));
+
     tbl_summary.setAutoCreateRowSorter(true);
     tbl_summary.addMouseListener(new MouseAdapter()
     {
@@ -171,7 +183,8 @@ tbl_summary);
     });
 
     populateCmbSearchTargetOptions();
-
+    txt_search.setToolTipText(MessageManager
+            .getString("label.separate_multiple_accession_ids"));
     txt_search.setFont(new java.awt.Font("Verdana", 0, 12));
     txt_search.getDocument().addDocumentListener(new DocumentListener()
     {
@@ -223,6 +236,7 @@ tbl_summary);
     pnl_results.add(tabbedPane);
     pnl_inputs.add(cmb_searchTarget);
     pnl_inputs.add(txt_search);
+    pnl_inputs.add(lbl_warning);
 
     this.setLayout(mainLayout);
     this.add(pnl_inputs, java.awt.BorderLayout.NORTH);
index fc035b6..235c499 100644 (file)
@@ -71,6 +71,8 @@ public abstract class GStructureChooser extends JPanel implements
   protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<FilterOption>();
 
   protected AlignmentPanel ap;
+  
+  protected StringBuilder errorWarning = new StringBuilder();
 
   protected JLabel lbl_result = new JLabel(
           MessageManager.getString("label.select"));
@@ -119,6 +121,11 @@ public abstract class GStructureChooser extends JPanel implements
   protected ImageIcon errorImage = new ImageIcon(getClass().getResource(
           "/images/error.png"));
 
+  protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
+          "/images/warning.gif"));
+
+  protected JLabel lbl_warning = new JLabel(warningImage);
+
   protected JLabel lbl_loading = new JLabel(loadingImage);
 
   protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
index da50606..f40b302 100644 (file)
@@ -112,8 +112,8 @@ public class PDBRestClient
       else if (exceptionMsg.contains("UnknownHostException"))
       {
         throw new Exception(
-                "Jalview couldn't reach the host server @ www.ebi.ac.uk"
-                        + "\nPlease ensure that you are connected to the internet.");
+                "Jalview is unable to reach the host server \'www.ebi.ac.uk\'. "
+                        + "\nPlease ensure that you are connected to the internet and try again.");
         // The server 'www.ebi.ac.uk' is unreachable
       }
       else