JAL-1700 made PDB service error mechanism more user friendly
[jalview.git] / src / jalview / gui / StructureChooser.java
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
     }
   }
 
-
 }