8d635a39ed144c4b26f01b632ab83bf05e57e79f
[jalview.git] / src / jalview / gui / VamsasClient.java
1 /**
2  * 
3  */
4 package jalview.gui;
5
6 import java.io.File;
7 import java.io.FileOutputStream;
8 import java.io.OutputStreamWriter;
9 import java.io.PrintWriter;
10 import java.util.Hashtable;
11 import java.util.Vector;
12 import java.util.jar.JarOutputStream;
13
14 import javax.swing.JInternalFrame;
15
16 import jalview.bin.Cache;
17
18 import org.vamsas.client.UserHandle;
19 import org.vamsas.client.simpleclient.FileWatcher;
20 import org.vamsas.client.simpleclient.VamsasArchive;
21 import org.vamsas.client.simpleclient.VamsasFile;
22 import org.vamsas.objects.core.VamsasDocument;
23 import org.vamsas.test.simpleclient.ArchiveClient;
24 import org.vamsas.test.simpleclient.ClientDoc;
25
26 /**
27  * @author jimp
28  *
29  */
30 public class VamsasClient extends ArchiveClient {
31         Desktop us;
32         // Cache.preferences for vamsas client session arena
33         // preferences for check for default session at startup.
34         // user and organisation stuff.
35         public VamsasClient(Desktop jdesktop,
36                         File sessionPath) {
37                 super(System.getProperty("user.name"),System.getProperty("host.name"), "jalview","2.7",
38                                 sessionPath);
39                 us=jdesktop;
40         }
41         public void initial_update() {
42                 Cache.log.info("Jalview loading the Vamsas Session.");
43                 // load in the vamsas archive for the first time
44                 ClientDoc cdoc = this.getUpdateable();
45                 
46         }
47         public void get_update(VamsasArchive doc) {
48                 Cache.log.info("Jalview updating from Vamsas Session.");
49         }
50         public void push_update() {
51                 // collect all uncached alignments and put them into the vamsas dataset.
52                 // store them.
53                 Cache.log.info("Jalview updating the Vamsas Session.");
54         }
55         public void end_session() {
56                 // stop any update/watcher thread.
57                 Cache.log.info("Jalview disconnecting from the Vamsas Session.");
58         }
59         java.util.Hashtable jv2vobj = null;
60         public void updateVamsasDocument(ClientDoc doc) {
61                 if (jv2vobj==null)
62                         jv2vobj = new Hashtable();
63                 // wander through frames 
64                 JInternalFrame[] frames = Desktop.desktop.getAllFrames();
65
66         if (frames == null)
67         {
68             return;
69         }
70
71         try
72         {       
73                 // Mapping
74                 // Alignframe.alignment (non-null dataset)==alignment
75                 // alignframe .alignment (dataset==null) = VAMAS[]
76                 // Tree.alignment = vamsas[].tree (vamsas[] given by dataset, alignment given by local ref]
77                 
78                 Vector shortNames = new Vector();
79                 
80                 //REVERSE ORDER
81             for (int i = frames.length - 1; i > -1; i--)
82             {
83                 if (frames[i] instanceof AlignFrame)
84                 {
85                         AlignFrame af = (AlignFrame) frames[i];
86                         // check if this frame has an associated alignment object ?
87                         // update alignment and root from frame.
88
89                 }
90             }
91         }
92         catch (Exception e) {
93                 Cache.log.error("Vamsas Document store exception",e);
94         }
95         }
96         protected class VamsasClientWatcher extends Thread implements Runnable {
97                 /* (non-Javadoc)
98                  * @see java.lang.Thread#run()
99                  */
100                 VamsasClient client=null;
101                 VamsasClientWatcher(VamsasClient client) {
102                         this.client = client;
103                 }
104                 public void run() {
105                         ClientDoc docio = client.watch(0);
106                         
107                 }
108                 
109         }
110         /**
111          * @param args
112          */
113         public static void main(String[] args) {
114                 // TODO Auto-generated method stub
115
116         }
117
118 }