From ec94f7012292e38963070fd5c0fa6dea244e6b3d Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 28 May 2015 16:47:25 +0100 Subject: [PATCH] JAL-1700 made PDB service error mechanism more user friendly --- resources/images/warning.gif | Bin 0 -> 239 bytes src/jalview/gui/PDBSearchPanel.java | 19 +++++++++++++++--- src/jalview/gui/StructureChooser.java | 29 +++++++++++++++++++++------ src/jalview/jbgui/GPDBSearchPanel.java | 16 ++++++++++++++- src/jalview/jbgui/GStructureChooser.java | 7 +++++++ src/jalview/ws/dbsources/PDBRestClient.java | 4 ++-- 6 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 resources/images/warning.gif diff --git a/resources/images/warning.gif b/resources/images/warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..3d57c8cb8947158533cc8f7747850a58ed5ff675 GIT binary patch literal 239 zcmZ?wbhEHb6k!ly_{`4m|33pWGqawaUPT3ikB?7Bhw!3BUaw>n{?DAbW5*5#450X* z+s`#5*x50_)kx2PnGvW!@h1zbIRiU`4oES`SO(_Aid|WLI;WUc2^z@Cl`lGfSn+9=I8ODd^jTki zTU4DtQD;Mp*5Q;#jn&(Qq%S>t@A&S;@BeJ_oKRaC8FV-pSb&g^fq_L>U{3RsEyu5A SGdf%quS)UsyWQ%>U=09Z*-0h< literal 0 HcmV?d00001 diff --git a/src/jalview/gui/PDBSearchPanel.java b/src/jalview/gui/PDBSearchPanel.java index 950c6b7..4bd6f7c 100644 --- a/src/jalview/gui/PDBSearchPanel.java +++ b/src/jalview/gui/PDBSearchPanel.java @@ -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); + } + } } diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 2944cd8..015cd8e 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -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 } } - } diff --git a/src/jalview/jbgui/GPDBSearchPanel.java b/src/jalview/jbgui/GPDBSearchPanel.java index e74f0ef..ec7d0f8 100644 --- a/src/jalview/jbgui/GPDBSearchPanel.java +++ b/src/jalview/jbgui/GPDBSearchPanel.java @@ -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); diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index fc035b6..235c499 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -71,6 +71,8 @@ public abstract class GStructureChooser extends JPanel implements protected JComboBox cmb_filterOption = new JComboBox(); 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); diff --git a/src/jalview/ws/dbsources/PDBRestClient.java b/src/jalview/ws/dbsources/PDBRestClient.java index da50606..f40b302 100644 --- a/src/jalview/ws/dbsources/PDBRestClient.java +++ b/src/jalview/ws/dbsources/PDBRestClient.java @@ -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 -- 1.7.10.2