From ca91ef118ff467dee590a67d8ea762c98451660a Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 14 Jun 2006 10:19:54 +0000 Subject: [PATCH] Fileloading progressbar --- src/jalview/gui/Desktop.java | 41 +++++++++++++++++++++++++++++++++++++++- src/jalview/io/FileLoader.java | 5 +++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 6ac9b76..0b88bca 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -48,6 +48,7 @@ public class Desktop extends jalview.jbgui.GDesktop public static Object [] jalviewClipboard; + static int fileLoadingCount= 0; /** * Creates a new Desktop object. @@ -80,7 +81,8 @@ public class Desktop extends jalview.jbgui.GDesktop setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); desktop = new JDesktopPane(); desktop.setBackground(Color.white); - setContentPane(desktop); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(desktop, BorderLayout.CENTER); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); // This line prevents Windows Look&Feel resizing all new windows to maximum @@ -626,5 +628,42 @@ public class Desktop extends jalview.jbgui.GDesktop { new SequenceFetcher(null); } + + JPanel progressPanel; + + public void startLoading(final String fileName) + { + if (fileLoadingCount == 0) + { + progressPanel = new JPanel(new BorderLayout()); + JProgressBar progressBar = new JProgressBar(); + progressBar.setIndeterminate(true); + + progressPanel.add(new JLabel("Loading File: " + fileName + " "), + BorderLayout.WEST); + + progressPanel.add(progressBar, BorderLayout.CENTER); + + instance.getContentPane().add(progressPanel, BorderLayout.SOUTH); + } + fileLoadingCount++; + validate(); + } + + public void stopLoading() + { + fileLoadingCount--; + if (fileLoadingCount < 1) + { + if(progressPanel!=null) + { + this.getContentPane().remove(progressPanel); + progressPanel = null; + } + fileLoadingCount = 0; + } + validate(); + } + } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index f720804..7db0b90 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -122,8 +122,11 @@ public class FileLoader AlignFrame af; + public void run() { + Desktop.instance.startLoading(file); + SequenceI[] sequences = null; if (format.equalsIgnoreCase("Jalview")) @@ -194,6 +197,8 @@ public class FileLoader { updateRecentlyOpened(); } + + Desktop.instance.stopLoading(); } } -- 1.7.10.2