*
*
* @author $author$
- * @version $Revision$
+ * @version $Revision: 1.155 $
*/
public class Desktop extends jalview.jbgui.GDesktop implements
- DropTargetListener, ClipboardOwner, IProgressIndicator
+ DropTargetListener, ClipboardOwner, IProgressIndicator, jalview.api.StructureSelectionManagerProvider
{
private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
+ // alternate config - have scrollbars - see notes in JAL-153
+ //JScrollPane sp = new JScrollPane();
+ //sp.getViewport().setView(desktop);
+ //getContentPane().add(sp, BorderLayout.CENTER);
getContentPane().add(desktop, BorderLayout.CENTER);
- desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
-
+ desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
+
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktop.setDesktopManager(new MyDesktopManager(
} catch (java.beans.PropertyVetoException ve)
{
}
+ catch (java.lang.ClassCastException cex)
+ {
+ Cache.log.warn("Squashed a possible GUI implementation error. If you can recreate this, please look at http://issues.jalview.org/browse/JAL-869",cex);
+ }
}
public void lostOwnership(Clipboard clipboard, Transferable contents)
{
message.append("\n\n!! Jalview version "
+ jalview.bin.Cache.getProperty("LATEST_VERSION")
- + " is available for download from http://www.jalview.org !!\n");
+ + " is available for download from "+jalview.bin.Cache.getDefault("www.jalview.org","http://www.jalview.org")+" !!\n");
}
// TODO: update this text for each release or centrally store it for lite
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- java.io.File choice = chooser.getSelectedFile();
+ final Desktop me = this;
+ final java.io.File choice = chooser.getSelectedFile();
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+
setProgressBar("Saving jalview project " + choice.getName(),
choice.hashCode());
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
// TODO catch and handle errors for savestate
+ // TODO prevent user from messing with the Desktop whilst we're saving
try
{
new Jalview2XML().SaveState(choice);
Cache.log
.error("Problems whilst trying to save to "
+ choice.getName(), ex);
- JOptionPane.showMessageDialog(this,
+ JOptionPane.showMessageDialog(me,
"Error whilst saving current state to " + choice.getName(),
"Couldn't save project", JOptionPane.WARNING_MESSAGE);
}
setProgressBar(null, choice.hashCode());
-
+ }
+ }).start();
}
}
}
JPanel progressPanel;
-
+ ArrayList<JPanel> fileLoadingPanels=new ArrayList<JPanel>();
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);
+ thisprogress.add(new JLabel(string), BorderLayout.WEST);
- progressPanel.add(progressBar, BorderLayout.CENTER);
-
- 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);
fileLoadingCount--;
if (fileLoadingCount < 1)
{
- if (progressPanel != null)
+ for (JPanel flp : fileLoadingPanels)
{
- this.getContentPane().remove(progressPanel);
- progressPanel = null;
+ removeProgressPanel(flp);
}
+ fileLoadingPanels.clear();
fileLoadingCount = 0;
}
validate();
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;
}
}
- JProgressBar vamUpdate = null;
+ JPanel vamUpdate = null;
/**
* hide vamsas user gui bits when a vamsas document event is being handled.
/**
* Progress bars managed by the IProgressIndicator method.
*/
- private Hashtable progressBars, progressBarHandlers;
+ private Hashtable<Long,JPanel> progressBars;
+ private Hashtable<Long,IProgressIndicatorHandler> progressBarHandlers;
/*
* (non-Javadoc)
{
if (progressBars == null)
{
- progressBars = new Hashtable();
- progressBarHandlers = new Hashtable();
+ progressBars = new Hashtable<Long,JPanel>();
+ progressBarHandlers = new Hashtable<Long,IProgressIndicatorHandler>();
}
if (progressBars.get(new Long(id)) != null)
{
- JProgressBar progressPanel = (JProgressBar) progressBars
+ JPanel progressPanel = progressBars
.remove(new Long(id));
if (progressBarHandlers.contains(new Long(id)))
{