From: jprocter Date: Fri, 5 Aug 2011 15:47:56 +0000 (+0100) Subject: allow several progress bars on the desktop window (JAL-898) X-Git-Tag: Release_2_7~114 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9d67f04acb1c0ae097b918b09a997c5561592880;p=jalview.git allow several progress bars on the desktop window (JAL-898) --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 8a96ec4..56bd82f 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1270,44 +1270,47 @@ public class Desktop extends jalview.jbgui.GDesktop implements } JPanel progressPanel; - + ArrayList fileLoadingPanels=new ArrayList(); public void startLoading(final String fileName) { if (fileLoadingCount == 0) { - addProgressPanel("Loading File: " + fileName + " "); - + fileLoadingPanels.add(addProgressPanel("Loading File: " + fileName + " ")); } fileLoadingCount++; } - private JProgressBar addProgressPanel(String string) + private JPanel addProgressPanel(String string) { if (progressPanel == null) { - progressPanel = new JPanel(new BorderLayout()); + progressPanel = new JPanel(new GridLayout(1,1)); totalProgressCount = 0; + instance.getContentPane().add(progressPanel, BorderLayout.SOUTH); } + JPanel thisprogress=new JPanel(new BorderLayout(10,5)); JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); - progressPanel.add(new JLabel(string), BorderLayout.WEST); - - progressPanel.add(progressBar, BorderLayout.CENTER); + thisprogress.add(new JLabel(string), BorderLayout.WEST); - instance.getContentPane().add(progressPanel, BorderLayout.SOUTH); - totalProgressCount++; - validate(); - return progressBar; + thisprogress.add(progressBar, BorderLayout.CENTER); + progressPanel.add(thisprogress); + ((GridLayout)progressPanel.getLayout()).setRows(((GridLayout)progressPanel.getLayout()).getRows()+1); + ++totalProgressCount; + instance.validate(); + return thisprogress; } int totalProgressCount = 0; - private void removeProgressPanel(JProgressBar progbar) + private void removeProgressPanel(JPanel progbar) { if (progressPanel != null) { progressPanel.remove(progbar); + GridLayout gl = (GridLayout) progressPanel.getLayout(); + gl.setRows(gl.getRows()-1); if (--totalProgressCount < 1) { this.getContentPane().remove(progressPanel); @@ -1322,11 +1325,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements fileLoadingCount--; if (fileLoadingCount < 1) { - if (progressPanel != null) + for (JPanel flp : fileLoadingPanels) { - this.getContentPane().remove(progressPanel); - progressPanel = null; + removeProgressPanel(flp); } + fileLoadingPanels.clear(); fileLoadingCount = 0; } validate(); @@ -1773,7 +1776,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { java.io.File choice = chooser.getSelectedFile(); - JProgressBar progpanel = addProgressPanel("Saving VAMSAS Document to " + JPanel progpanel = addProgressPanel("Saving VAMSAS Document to " + choice.getName()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); String warnmsg = null; @@ -1807,7 +1810,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } - JProgressBar vamUpdate = null; + JPanel vamUpdate = null; /** * hide vamsas user gui bits when a vamsas document event is being handled. @@ -2079,7 +2082,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements /** * Progress bars managed by the IProgressIndicator method. */ - private Hashtable progressBars, progressBarHandlers; + private Hashtable progressBars; + private Hashtable progressBarHandlers; /* * (non-Javadoc) @@ -2090,13 +2094,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements { if (progressBars == null) { - progressBars = new Hashtable(); - progressBarHandlers = new Hashtable(); + progressBars = new Hashtable(); + progressBarHandlers = new Hashtable(); } if (progressBars.get(new Long(id)) != null) { - JProgressBar progressPanel = (JProgressBar) progressBars + JPanel progressPanel = progressBars .remove(new Long(id)); if (progressBarHandlers.contains(new Long(id))) {