X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FVamsasApplication.java;h=bfe54875056853670c3d6a33d3f274f25bba8fbd;hb=e42d3ebcc571ec3fd765de7ceccd8d125e70002f;hp=d0dbf161c6f7956735a8491b32b3f406522f2fa7;hpb=b54ce2faedac908f831d8165c4903ef37949796b;p=jalview.git diff --git a/src/jalview/gui/VamsasApplication.java b/src/jalview/gui/VamsasApplication.java index d0dbf16..bfe5487 100644 --- a/src/jalview/gui/VamsasApplication.java +++ b/src/jalview/gui/VamsasApplication.java @@ -218,6 +218,7 @@ public class VamsasApplication "Impementation error! Vamsas Operations when client not initialised and connected."); } addDocumentUpdateHandler(); + addStoreDocumentHandler(); startSession(); Cache.log .debug("Jalview loading the Vamsas Session for the first time."); @@ -262,17 +263,27 @@ public class VamsasApplication public void push_update() { - Cache.log.info("Jalview updating to the Vamsas Session."); - dealWithDocumentUpdate(true); - /* - * IClientDocument cdoc=null; try { cdoc = vclient.getClientDocument(); } - * catch (Exception e) { Cache.log.error("Failed to get client document for - * update."); // RAISE A WARNING DIALOG disableGui(false); return; } - * updateVamsasDocument(cdoc); updateJalviewGui(); - * cdoc.setVamsasRoots(cdoc.getVamsasRoots()); // propagate update flags - * back vclient.updateDocument(cdoc); - */ - Cache.log.info("Jalview finished updating to the Vamsas Session."); + Thread udthread = new Thread(new Runnable() { + + public void run() + { + Cache.log.info("Jalview updating to the Vamsas Session."); + + dealWithDocumentUpdate(true); + /* + * IClientDocument cdoc=null; try { cdoc = vclient.getClientDocument(); } + * catch (Exception e) { Cache.log.error("Failed to get client document for + * update."); // RAISE A WARNING DIALOG disableGui(false); return; } + * updateVamsasDocument(cdoc); updateJalviewGui(); + * cdoc.setVamsasRoots(cdoc.getVamsasRoots()); // propagate update flags + * back vclient.updateDocument(cdoc); + */ + Cache.log.info("Jalview finished updating to the Vamsas Session."); + // TODO Auto-generated method stub + } + + }); + udthread.start(); } public void end_session() @@ -468,6 +479,30 @@ public class VamsasApplication Cache.log.debug("Added Jalview handler for vamsas document updates."); } + private void addStoreDocumentHandler() + { + final VamsasApplication client = this; + vclient.addVorbaEventHandler(uk.ac.vamsas.client.Events.DOCUMENT_REQUESTTOCLOSE, new PropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent evt) + { + Cache.log.debug("Asking user if the vamsas session should be stored."); + int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + "The current VAMSAS session has unsaved data - do you want to save it ?", + "VAMSAS Session Shutdown", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if(reply==JOptionPane.YES_OPTION) + { + Cache.log.debug("Prompting for vamsas store filename."); + Desktop.instance.vamsasSave_actionPerformed(null); + Cache.log.debug("Finished attempt at storing document."); + } + Cache.log.debug("finished dealing with REQUESTTOCLOSE event."); + } + }); + Cache.log.debug("Added Jalview handler for vamsas document updates."); + } public void disableGui(boolean b) { Desktop.instance.setVamsasUpdate(b);