applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / client / Events.java
1 /*
2  * This file is part of the Vamsas Client version 0.1. 
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
4  *  Andrew Waterhouse and Dominik Lindner.
5  * 
6  * Earlier versions have also been incorporated into Jalview version 2.4 
7  * since 2008, and TOPALi version 2 since 2007.
8  * 
9  * The Vamsas Client is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *  
14  * The Vamsas Client is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 package uk.ac.vamsas.client;
23
24 /**
25  * Enumerates the event types generated during the lifecycle of a Vamsas
26  * session. See the excel spreadsheet in
27  * VamsasClient/docs/VamsasSessionEventAnalysis.xls for some more information
28  * about when these are generated and how they should be handled.
29  * 
30  */
31
32 public class Events {
33   /**
34    * Generated when a client has finished updating the document. Client which
35    * has completed an update should not receive the event. NewValue:
36    * uk.ac.vamsas.client.IClient for session.
37    */
38   public static final String DOCUMENT_UPDATE = "uk.ac.vamsas.client.events.documentUpdateEvent";
39
40   /**
41    * Generated when a new vamsas document is created (perhaps from some existing
42    * Vamsas data) so an application may do its own data space initialization.
43    * Raised for a new application connecting to a vamsas document NewValue:
44    * uk.ac.vamsas.client.IClient for session. LATER: DOCUMENT_CREATE event may
45    * be redundant
46    */
47   public static final String DOCUMENT_CREATE = "uk.ac.vamsas.client.events.documentCreateEvent";
48
49   /**
50    * Generated when a new vamsas client is attached to a session (Handle is
51    * passed) Note: the newly created client does not receive the event.
52    */
53   public static final String CLIENT_CREATION = "uk.ac.vamsas.client.events.clientCreateEvent";
54
55   /**
56    * Generated when a vamsas client leaves a session (Handle is passed to all
57    * others).
58    */
59   public static final String CLIENT_FINALIZATION = "uk.ac.vamsas.client.events.clientFinalizationEvent";
60
61   /**
62    * Generated prior to session Shutdown, after the last participating vamsas
63    * client has finalized. Probably only useful to IClientFactory
64    * implementations. NewValue: <Vamsas-session URN>
65    */
66   public static final String SESSION_SHUTDOWN = "uk.ac.vamsas.client.events.SessionShutdownEvent";
67
68   /**
69    * Generated for all clients when any client calls IClient.storeDocument() to
70    * allow them to store any updates before an offline copy of the session is
71    * created. Any client that handles this should call the
72    * IClient.getDocument(), update and then IClient.updateDocument in the same
73    * handler thread (the lock on the document is held until the handler exits).
74    * EventName: <Vamsas-session URN> NewValue: uk.ac.vamsas.client.IClient for
75    * session.
76    */
77   public static final String DOCUMENT_FINALIZEAPPDATA = "uk.ac.vamsas.client.events.DocumentFinalizeAppData";
78
79   /**
80    * Generated by Vorba stub for the sole remaining client instance in a
81    * session, when it makes a call to finalizeClient(). It is only raised if the
82    * session has been modified since the last call to storeDocument() by any
83    * application. LATER: copies of a document should be on a per-user basis for
84    * multi-user sessions. Sequence is as follows : 1. All other vamsas clients
85    * have called finalizeClient() 2. Final living client monitors closures, and
86    * realises that it is last. 3. Final client generates event to prompt
87    * associated application to inquire if the user wishes to save the document
88    * for future reference. * Any call to finalizeClient in a thread other than
89    * the registered EventListener will block until the RequestToClose handler
90    * has exited. NewValue: uk.ac.vamsas.client.IClient for session.
91    */
92   public static final String DOCUMENT_REQUESTTOCLOSE = "uk.ac.vamas.client.DocumentRequestToCloseEvent";
93
94   public static java.util.Vector EventList = initList();
95
96   private static java.util.Vector initList() {
97     java.util.Vector vec = new java.util.Vector();
98     vec.add((Object) DOCUMENT_UPDATE);
99     vec.add((Object) DOCUMENT_CREATE);
100     vec.add((Object) CLIENT_CREATION);
101     vec.add((Object) CLIENT_FINALIZATION);
102     vec.add((Object) SESSION_SHUTDOWN);
103     vec.add((Object) DOCUMENT_REQUESTTOCLOSE);
104     vec.add((Object) DOCUMENT_FINALIZEAPPDATA);
105     return vec;
106   }
107 }