package jalview.gui;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Hashtable;
* @author jimp
*
*/
-public class VamsasClient extends ArchiveClient {
+public class VamsasClient
+ extends ArchiveClient
+{
// Cache.preferences for vamsas client session arena
// preferences for check for default session at startup.
// user and organisation stuff.
public VamsasClient(Desktop jdesktop,
- File sessionPath) {
- super(System.getProperty("user.name"),System.getProperty("host.name"), "jalview","2.7",
- sessionPath);
+ File sessionPath)
+ {
+ super(System.getProperty("user.name"), System.getProperty("host.name"),
+ "jalview", "2.7",
+ sessionPath);
}
- public void initial_update() {
+
+ public void initial_update()
+ {
Cache.log.info("Jalview loading the Vamsas Session.");
// load in the vamsas archive for the first time
ClientDoc cdoc = this.getUpdateable();
af.alignPanel.alignmentChanged();
}
}
- } catch (Exception e) {
- Cache.log.warn("Exception whilst refreshing jalview windows after a vamsas document update.", e);
+ }
+ catch (Exception e)
+ {
+ Cache.log.warn(
+ "Exception whilst refreshing jalview windows after a vamsas document update.",
+ e);
}
doUpdate(cdoc);
cdoc.closeDoc();
}
+
/**
* this will close all windows currently in Jalview.
*
- protected void closeWindows() {
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ protected void closeWindows() {
+ JInternalFrame[] frames = Desktop.desktop.getAllFrames();
if (frames == null)
{
try
{
for (int i = frames.length - 1; i > -1; i--) {
- frames[i].dispose();
+ frames[i].dispose();
}
} catch (Exception e) {
- Cache.log.error("Whilst closing windows",e);
+ Cache.log.error("Whilst closing windows",e);
}
- }
+ }
- public void get_update(VamsasArchive doc) {
- // Close windows - load update.
- Cache.log.info("Jalview updating from Vamsas Session.");
- }
+ public void get_update(VamsasArchive doc) {
+ // Close windows - load update.
+ Cache.log.info("Jalview updating from Vamsas Session.");
+ }
*/
- VamsasClientWatcher watcher=null;
- public void push_update() {
- watchForChange=false;
- try {
+ VamsasClientWatcher watcher = null;
+ public void push_update()
+ {
+ watchForChange = false;
+ try
+ {
Thread.sleep(WATCH_SLEEP);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
- };
+ }
+ ;
ClientDoc cdoc = getUpdateable();
updateVamsasDocument(cdoc);
doUpdate(cdoc);
cdoc.closeDoc();
- cdoc=null;
- watchForChange=true;
- if (watcher!=null) {
+ cdoc = null;
+ watchForChange = true;
+ if (watcher != null)
+ {
watcher.start();
}
// collect all uncached alignments and put them into the vamsas dataset.
// store them.
Cache.log.info("Jalview updating the Vamsas Session.");
}
- public void end_session() {
+
+ public void end_session()
+ {
// stop any update/watcher thread.
- watchForChange=false; // this makes any watch(long) loops return.
+ watchForChange = false; // this makes any watch(long) loops return.
// we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped.
- try {
+ try
+ {
Thread.sleep(WATCH_SLEEP);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
- };
+ }
+ ;
Cache.log.info("Jalview disconnecting from the Vamsas Session.");
}
- public void updateJalview(ClientDoc cdoc) {
+
+ public void updateJalview(ClientDoc cdoc)
+ {
ensureJvVamsas();
- VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj, baseProvEntry());
+ VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj,
+ baseProvEntry());
vds.updateToJalview();
}
- private void ensureJvVamsas() {
- if (jv2vobj==null) {
+
+ private void ensureJvVamsas()
+ {
+ if (jv2vobj == null)
+ {
jv2vobj = new IdentityHashMap();
vobj2jv = new Hashtable();
}
}
+
/**
* jalview object binding to VorbaIds
*/
IdentityHashMap jv2vobj = null;
Hashtable vobj2jv = null;
- public void updateVamsasDocument(ClientDoc doc) {
+ public void updateVamsasDocument(ClientDoc doc)
+ {
ensureJvVamsas();
- VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj, baseProvEntry());
+ VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj,
+ baseProvEntry());
// wander through frames
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
}
}
}
- catch (Exception e) {
- Cache.log.error("Vamsas Document store exception",e);
+ catch (Exception e)
+ {
+ Cache.log.error("Vamsas Document store exception", e);
}
}
- private Entry baseProvEntry() {
+
+ private Entry baseProvEntry()
+ {
org.vamsas.objects.core.Entry pentry = new org.vamsas.objects.core.Entry();
pentry.setUser(this.getProvenanceUser());
pentry.setApp(this.getClientHandle().getClientName());
pentry.setAction("created");
return pentry;
}
- protected class VamsasClientWatcher extends Thread {
+
+ protected class VamsasClientWatcher
+ extends Thread
+ {
/* (non-Javadoc)
* @see java.lang.Thread#run()
*/
- VamsasClient client=null;
- VamsasClientWatcher(VamsasClient client) {
+ VamsasClient client = null;
+ VamsasClientWatcher(VamsasClient client)
+ {
this.client = client;
}
- boolean running=false;
- public void run() {
- running=true;
- while (client.watchForChange) {
+
+ boolean running = false;
+ public void run()
+ {
+ running = true;
+ while (client.watchForChange)
+ {
ClientDoc docio = client.watch(0);
- if (docio!=null) {
+ if (docio != null)
+ {
client.disableGui(true);
Cache.log.debug("Updating jalview from changed vamsas document.");
client.updateJalview(docio);
Cache.log.debug("Finished updating from document change.");
docio.closeDoc();
- docio=null;
+ docio = null;
client.disableGui(false);
}
}
- running=false;
+ running = false;
}
}
- public void disableGui(boolean b) {
+
+ public void disableGui(boolean b)
+ {
Desktop.instance.setVamsasUpdate(b);
}
- public void startWatcher() {
- if (watcher==null)
- watcher=new VamsasClientWatcher(this);
- Thread thr = new Thread() {
- public void run() {
+
+ public void startWatcher()
+ {
+ if (watcher == null)
+ {
+ watcher = new VamsasClientWatcher(this);
+ }
+ Thread thr = new Thread()
+ {
+ public void run()
+ {
watcher.start();
}
};