From 1fea862e99e1fdd5eb85d5feaec2d28de58828b4 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 16 Jun 2016 09:48:13 +0100 Subject: [PATCH] JAL-1993 hide sequence fetcher dialogue until database selection made --- src/jalview/gui/JDatabaseTree.java | 13 ++++++++----- src/jalview/gui/SequenceFetcher.java | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/jalview/gui/JDatabaseTree.java b/src/jalview/gui/JDatabaseTree.java index 6f602ad..6d8c4e0 100644 --- a/src/jalview/gui/JDatabaseTree.java +++ b/src/jalview/gui/JDatabaseTree.java @@ -188,6 +188,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener jc.validate(); // j.setPreferredSize(new Dimension(300,50)); add(jc, BorderLayout.CENTER); + ok.setEnabled(false); j.add(ok); j.add(cancel); add(j, BorderLayout.SOUTH); @@ -349,10 +350,12 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener { return; } + ok.setEnabled(false); if (dbviews.getSelectionCount() == 0) { selection = null; } + tsel = dbviews.getSelectionPaths(); boolean forcedFirstChild = false; List srcs = new ArrayList(); @@ -364,6 +367,10 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener .getLastPathComponent(); if (dmt.getUserObject() != null) { + /* + * enable OK button once a selection has been made + */ + ok.setEnabled(true); if (dmt.getUserObject() instanceof DbSourceProxy) { srcs.add((DbSourceProxy) dmt.getUserObject()); @@ -419,6 +426,7 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener } } + dbstatex.setText(" "); if (allowMultiSelections) { dbstatus.setText(MessageManager.formatMessage( @@ -427,7 +435,6 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener (srcs.size() == 1 ? "" : "s"), (srcs.size() > 0 ? " with " + x + " test quer" + (x == 1 ? "y" : "ies") : ".") })); - dbstatex.setText(" "); } else { @@ -440,10 +447,6 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener dbstatex.setText(MessageManager.formatMessage( "label.example_param", new String[] { qr })); } - else - { - dbstatex.setText(" "); - } } else { diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 71c8a39..cc8c46e 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -31,6 +31,7 @@ import jalview.fts.service.uniprot.UniprotFTSPanel; import jalview.io.gff.SequenceOntologyI; import jalview.util.DBRefUtils; import jalview.util.MessageManager; +import jalview.util.Platform; import jalview.ws.dbsources.das.api.DasSourceRegistryI; import jalview.ws.seqfetcher.DbSourceProxy; @@ -274,13 +275,13 @@ public class SequenceFetcher extends JPanel implements Runnable frame = new JInternalFrame(); frame.setContentPane(this); - if (new jalview.util.Platform().isAMac()) + if (Platform.isAMac()) { - Desktop.addInternalFrame(frame, getFrameTitle(), 400, 240); + Desktop.addInternalFrame(frame, getFrameTitle(), false, 400, 240); } else { - Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180); + Desktop.addInternalFrame(frame, getFrameTitle(), false, 400, 180); } } @@ -374,6 +375,12 @@ public class SequenceFetcher extends JPanel implements Runnable { debounceTrap++; String currentSelection = database.getSelectedItem(); + if (currentSelection == null) + { + close_actionPerformed(null); + } + + showPanel(); if (currentSelection.equalsIgnoreCase("pdb") && (database.action == KeyEvent.VK_ENTER || ((debounceTrap % 2) == 0))) @@ -972,4 +979,13 @@ public class SequenceFetcher extends JPanel implements Runnable { this.progressIndicator = progressIndicator; } + + /** + * Make this panel visible (after a selection has been made in the database + * chooser) + */ + void showPanel() + { + frame.setVisible(true); + } } -- 1.7.10.2