7 import java.io.FileOutputStream;
8 import java.io.OutputStreamWriter;
9 import java.io.PrintWriter;
10 import java.util.Hashtable;
11 import java.util.IdentityHashMap;
12 import java.util.Vector;
13 import java.util.jar.JarOutputStream;
15 import javax.swing.JInternalFrame;
17 import jalview.bin.Cache;
19 import org.vamsas.client.UserHandle;
20 import org.vamsas.client.simpleclient.FileWatcher;
21 import org.vamsas.client.simpleclient.VamsasArchive;
22 import org.vamsas.client.simpleclient.VamsasFile;
23 import org.vamsas.objects.core.VamsasDocument;
24 import org.vamsas.test.simpleclient.ArchiveClient;
25 import org.vamsas.test.simpleclient.ClientDoc;
31 public class VamsasClient extends ArchiveClient {
33 // Cache.preferences for vamsas client session arena
34 // preferences for check for default session at startup.
35 // user and organisation stuff.
36 public VamsasClient(Desktop jdesktop,
38 super(System.getProperty("user.name"),System.getProperty("host.name"), "jalview","2.7",
42 public void initial_update() {
43 Cache.log.info("Jalview loading the Vamsas Session.");
44 // load in the vamsas archive for the first time
45 ClientDoc cdoc = this.getUpdateable();
50 * this will close all windows currently in Jalview.
53 protected void closeWindows() {
54 JInternalFrame[] frames = Desktop.desktop.getAllFrames();
63 for (int i = frames.length - 1; i > -1; i--) {
66 } catch (Exception e) {
67 Cache.log.error("Whilst closing windows",e);
71 public void get_update(VamsasArchive doc) {
72 // Close windows - load update.
73 Cache.log.info("Jalview updating from Vamsas Session.");
75 public void push_update() {
76 // collect all uncached alignments and put them into the vamsas dataset.
78 Cache.log.info("Jalview updating the Vamsas Session.");
80 public void end_session() {
81 // stop any update/watcher thread.
82 Cache.log.info("Jalview disconnecting from the Vamsas Session.");
84 public void updateJalview(ClientDoc cdoc) {
87 protected void _updateAlignFrame(ClientDoc cdoc, AlignFrame av) {
91 * jalview object binding to VorbaIds
93 IdentityHashMap jv2vobj = null;
94 Hashtable vobj2jv = null;
95 public void updateVamsasDocument(ClientDoc doc) {
97 jv2vobj = new IdentityHashMap();
98 vobj2jv = new Hashtable();
100 // wander through frames
101 JInternalFrame[] frames = Desktop.desktop.getAllFrames();
111 // Alignframe.alignment (non-null dataset)==alignment
112 // alignframe .alignment (dataset==null) = VAMAS[]
113 // Tree.alignment = vamsas[].tree (vamsas[] given by dataset, alignment given by local ref]
115 Vector shortNames = new Vector();
118 for (int i = frames.length - 1; i > -1; i--)
120 if (frames[i] instanceof AlignFrame)
122 AlignFrame af = (AlignFrame) frames[i];
124 // check if this frame has an associated alignment object ?
126 // update alignment and root from frame.
131 catch (Exception e) {
132 Cache.log.error("Vamsas Document store exception",e);
135 protected class VamsasClientWatcher extends Thread implements Runnable {
137 * @see java.lang.Thread#run()
139 VamsasClient client=null;
140 VamsasClientWatcher(VamsasClient client) {
141 this.client = client;
144 ClientDoc docio = client.watch(0);
152 public static void main(String[] args) {
153 // TODO Auto-generated method stub