ucar.unidata.idv.collab
Class CollabManager

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.collab.CollabManager
All Implemented Interfaces:
ActionListener, EventListener, SharableListener, IdvConstants

public class CollabManager
extends IdvManager
implements SharableListener

This class manages the IDV collaboration mechanism

Version:
$Revision: 1.30 $Date: 2006/04/04 21:19:06 $
Author:
IDV development team

Field Summary
static CollabMsgType MSG_ACKNEWUSER
          Message type to acknowledge the acceptance or rejection of a new user
static CollabMsgType MSG_ACTION
          Message type for some ui action (not used now)
static CollabMsgType MSG_BUNDLE
          Message type for xml idv bundles
static CollabMsgType MSG_CLOSE
          Message type to tell others we are closing
static CollabMsgType MSG_DATASOURCE
          Message type for announcing new data sources
static String MSG_DELIMITER
          The de,limiter between the msg id and the body of the message
static CollabMsgType MSG_DISPLAY
          Message type for announcing new displays
static CollabMsgType MSG_MESSAGE
          Message type for chat text message
static CollabMsgType MSG_NEWUSER
          Message type for new users
static CollabMsgType MSG_NEWWINDOW
          Message type for when a new window is created
static CollabMsgType MSG_REMOVEDATASOURCE
          Message type for when a datasource is removed
static CollabMsgType MSG_REMOVEDISPLAYCONTROL
          Message type for when a display is removed
static CollabMsgType MSG_STATE
          Message type for when an objects state changes
static String PREF_ACCEPTALL
          Will identify the accept all.
static String PREF_HOSTNAME
          Will identify the hostname preference.
static String PREF_PORT
          Will identify the port preference.
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_B64ISL, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOERRORSINGUI, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_MAX_PERMGENSIZE, DEFAULT_TIMEZONE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_NCIDV_VERSION, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, NULL_STRING, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_GEOMETRY_BY_REF, PREF_HISTORY, PREF_IMAGE_BY_REF, PREF_LARGE_REMOTE_DATA_WARN, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LEGEND_SHOWICONS, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAX_PERMGENSIZE, PREF_MAXIMAGESIZE, PREF_MEMORY, PREF_NPOT_IMAGE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_THREADS_DATA, PREF_THREADS_RENDER, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_WINDOW_SHOWTOOLBAR, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_DISPLAYLIST_GROUP, PROP_FIXFILELOCKUP, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_MAP_GLOBE_LEVEL, PROP_MAP_MAP_LEVEL, PROP_MINIMUMFRAMECYCLETIME, PROP_MONITORPORT, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWCLOCK, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_USE_TIMEDRIVER, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Constructor Summary
CollabManager(IntegratedDataViewer idv)
          Create the CollabManager
 
Method Summary
 void checkShareData(Sharable from, Object dataId, Object[] data)
          The implementation of the SharableListener interface.
protected  void clientAdded(CollabClient client)
          We have a new client
protected  void clientRemoved(CollabClient client)
          Client is goen
 void connect()
          Try to connect to the class member hostname.
protected  boolean connectTo(String collabHostName)
          Try to connect to the given host
 void controlHasBeenInitialized(DisplayControl control)
          This gets called when the given DisplayControl has been initialized.
 void disconnectAll()
          Close down all connections
protected  JComponent doMakeContents()
          Make the GUI
protected  Sharable findSharable(String id)
          Find the Sharable object identified by the given id.
protected  Sharable findSharable(String id, List sharables)
          Find the Sharable object identified by the given id in the list of sharables
 boolean getOkToRelay()
          Is it ok for the server to relay messages that have been sent by another client to any other clients we may be connected to.
protected  String getUserName()
          Get our user's name
 String getWindowTitle()
          Get the window title to use
protected  void handleMessage(CollabClient from, String msg)
          Process the given message from the given client.
protected  void handleMessage(CollabClient from, String msg, boolean checkIfMessageHasBeenSeen)
          Process the given message from the given client.
protected  void handleMessageInner(CollabClient fromClient, String msg, boolean checkIfMessageHasBeenSeen)
          Handle the incoming message.
protected  void handleMessageInnerInner(CollabClient fromClient, CollabMsgType msgType, String from, String contents)
          Really handle the incoming message
protected  boolean haveClients()
          Are there any clients we are connected to
 boolean haveDisplayControl(DisplayControl displayControl)
          Is this an existing DisplayControl
protected  boolean isEnabled()
          Are we doing an event capture and/or do we have any connected clients
protected  String makeMsg(CollabMsgType type, String body1)
          Construct the message.
 void newWindow(ViewManager vm)
          Send the MSG_NEWWINDOW message.
 void runCaptureFile(String filename)
          Execute the events in the given capture file
 void sendText(String msg)
          Send the MSG_MESSAGE text message (the chat text)
protected  void serverStarted()
          The server has started.
protected  void serverStopped()
          The server has stopped.
 void showCapture()
          Bring up the event capture window
 void showChat()
          Show the chat pane
 void showClients()
          Show the clients pane
 void showConnect()
          Show the connect pane
 void showLog()
          Show the log pane
 void showWindow()
          Create the GUI if needed and popup the window.
 void write(CollabMsgType type, String message)
          Write to all clients the given message of the given message type.
protected  void writeChatText(String from, String msg)
          Add the given chat text to the text area
 void writeRemoveDataSource(DataSource dataSource)
          Send the MSG_REMOVEDATASOURCE message for the given data source
 void writeRemoveDisplayControl(DisplayControl display)
          Send the MSG_REMOVEDISPLAYCONTROL message for the given display control
 void writeState()
          Send the MSG_BUNDLE message.
protected  void writeState(CollabClient client)
          Write the current state of the application to the given client.
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getInstallManager, getJythonManager, getPersistenceManager, getPreferenceManager, getProperty, getProperty, getProperty, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getStore, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
actionPerformed, close, getContents, getDialog, getFrame, getWindow, isShowing, removeAll, setMenuBar, setWindowTitle, shouldMakeDialog, show, show, showModal, toFront, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_HOSTNAME

public static String PREF_HOSTNAME
Will identify the hostname preference. Not used at the moment


PREF_PORT

public static String PREF_PORT
Will identify the port preference. Not used at the moment


PREF_ACCEPTALL

public static String PREF_ACCEPTALL
Will identify the accept all. Not used at the moment


MSG_DELIMITER

public static final String MSG_DELIMITER
The de,limiter between the msg id and the body of the message

See Also:
Constant Field Values

MSG_NEWUSER

public static final CollabMsgType MSG_NEWUSER
Message type for new users


MSG_ACKNEWUSER

public static final CollabMsgType MSG_ACKNEWUSER
Message type to acknowledge the acceptance or rejection of a new user


MSG_CLOSE

public static final CollabMsgType MSG_CLOSE
Message type to tell others we are closing


MSG_BUNDLE

public static final CollabMsgType MSG_BUNDLE
Message type for xml idv bundles


MSG_DATASOURCE

public static final CollabMsgType MSG_DATASOURCE
Message type for announcing new data sources


MSG_DISPLAY

public static final CollabMsgType MSG_DISPLAY
Message type for announcing new displays


MSG_MESSAGE

public static final CollabMsgType MSG_MESSAGE
Message type for chat text message


MSG_STATE

public static final CollabMsgType MSG_STATE
Message type for when an objects state changes


MSG_NEWWINDOW

public static final CollabMsgType MSG_NEWWINDOW
Message type for when a new window is created


MSG_REMOVEDATASOURCE

public static final CollabMsgType MSG_REMOVEDATASOURCE
Message type for when a datasource is removed


MSG_REMOVEDISPLAYCONTROL

public static final CollabMsgType MSG_REMOVEDISPLAYCONTROL
Message type for when a display is removed


MSG_ACTION

public static final CollabMsgType MSG_ACTION
Message type for some ui action (not used now)

Constructor Detail

CollabManager

public CollabManager(IntegratedDataViewer idv)
Create the CollabManager

Parameters:
idv - Reference to the IDV
Method Detail

connect

public void connect()
Try to connect to the class member hostname.


writeState

protected void writeState(CollabClient client)
Write the current state of the application to the given client. This creates an application bundle which is sent to the given client.

Parameters:
client - The client to write to

connectTo

protected boolean connectTo(String collabHostName)
Try to connect to the given host

Parameters:
collabHostName - The host to connect to
Returns:
Was the connection successful

checkShareData

public void checkShareData(Sharable from,
                           Object dataId,
                           Object[] data)
The implementation of the SharableListener interface. This gets called when the state of a Sharable object (e.g., a DisplayControl, a ViewManager) is changed.

Specified by:
checkShareData in interface SharableListener
Parameters:
from - The object that changed
dataId - An identifier (typically a String name) of what changed
data - Array of things that changed

getOkToRelay

public boolean getOkToRelay()
Is it ok for the server to relay messages that have been sent by another client to any other clients we may be connected to.

Returns:
OK to relay messages

isEnabled

protected boolean isEnabled()
Are we doing an event capture and/or do we have any connected clients

Returns:
Are we enabled to handle events

haveClients

protected boolean haveClients()
Are there any clients we are connected to

Returns:
Have any clients

showConnect

public void showConnect()
Show the connect pane


showClients

public void showClients()
Show the clients pane


showChat

public void showChat()
Show the chat pane


showLog

public void showLog()
Show the log pane


showCapture

public void showCapture()
Bring up the event capture window


runCaptureFile

public void runCaptureFile(String filename)
Execute the events in the given capture file

Parameters:
filename - Filename of the capture file

disconnectAll

public void disconnectAll()
Close down all connections


clientAdded

protected void clientAdded(CollabClient client)
We have a new client

Parameters:
client - The new client

clientRemoved

protected void clientRemoved(CollabClient client)
Client is goen

Parameters:
client - The goner client

serverStopped

protected void serverStopped()
The server has stopped. Update the GUI labels, etc.


serverStarted

protected void serverStarted()
The server has started. Update the GUI labels, etc.


showWindow

public void showWindow()
Create the GUI if needed and popup the window.


doMakeContents

protected JComponent doMakeContents()
Make the GUI

Overrides:
doMakeContents in class WindowHolder
Returns:
The gui

getWindowTitle

public String getWindowTitle()
Get the window title to use

Overrides:
getWindowTitle in class WindowHolder
Returns:
The window title

sendText

public void sendText(String msg)
Send the MSG_MESSAGE text message (the chat text)

Parameters:
msg - The message to send

writeRemoveDataSource

public void writeRemoveDataSource(DataSource dataSource)
Send the MSG_REMOVEDATASOURCE message for the given data source

Parameters:
dataSource - The data source that was removed

writeRemoveDisplayControl

public void writeRemoveDisplayControl(DisplayControl display)
Send the MSG_REMOVEDISPLAYCONTROL message for the given display control

Parameters:
display - The display control that was removed

writeState

public void writeState()
Send the MSG_BUNDLE message. This creates the application state bundle and sends it out to all clients.


newWindow

public void newWindow(ViewManager vm)
Send the MSG_NEWWINDOW message.

Parameters:
vm - The new ViewManager

write

public void write(CollabMsgType type,
                  String message)
Write to all clients the given message of the given message type.

Parameters:
type - The message type
message - The message

getUserName

protected String getUserName()
Get our user's name

Returns:
User's name

makeMsg

protected String makeMsg(CollabMsgType type,
                         String body1)
Construct the message. The format is:
 UNIQUEID:MESSAGETYPE:USERNAME:MESSAGEBODY
 

Parameters:
type - The type of the message
body1 - The message text
Returns:
The constructed message

handleMessage

protected void handleMessage(CollabClient from,
                             String msg)
Process the given message from the given client.

Parameters:
from - The CollabClient this message is from . This may be the replayClient
msg - the message

handleMessage

protected void handleMessage(CollabClient from,
                             String msg,
                             boolean checkIfMessageHasBeenSeen)
Process the given message from the given client. If checkIfMessageHasBeenSeen is true then if we have seen this message before we ignore it.

Parameters:
from - The CollabClient this message is from . This may be the replayClient
msg - the message
checkIfMessageHasBeenSeen - Only process unique messages

handleMessageInner

protected void handleMessageInner(CollabClient fromClient,
                                  String msg,
                                  boolean checkIfMessageHasBeenSeen)
                           throws Exception
Handle the incoming message.

Parameters:
fromClient - Who sent it
msg - The message
checkIfMessageHasBeenSeen - Should we check if we have seen this. Normal collaboration message we always check. This flag is there so the CaptureManager can replay messages even though we may have already seen them.
Throws:
Exception

handleMessageInnerInner

protected void handleMessageInnerInner(CollabClient fromClient,
                                       CollabMsgType msgType,
                                       String from,
                                       String contents)
                                throws Exception
Really handle the incoming message

Parameters:
fromClient - From where
msgType - Type
from - From whom
contents - Message body
Throws:
Exception

writeChatText

protected void writeChatText(String from,
                             String msg)
Add the given chat text to the text area

Parameters:
from - From whom
msg - The text

haveDisplayControl

public boolean haveDisplayControl(DisplayControl displayControl)
Is this an existing DisplayControl

Parameters:
displayControl - The display control to check
Returns:
Does the display control exist in the app

findSharable

protected Sharable findSharable(String id,
                                List sharables)
Find the Sharable object identified by the given id in the list of sharables

Parameters:
id - Id to search for
sharables - The haystack
Returns:
The found Sharable or null if not found

findSharable

protected Sharable findSharable(String id)
Find the Sharable object identified by the given id. This looks in the list of display controls, the data sources, the view managers and the animation widgets. (Which are the different classes of of objects that we share state for.

Parameters:
id - Id to search for
Returns:
The found Sharable or null if not found

controlHasBeenInitialized

public void controlHasBeenInitialized(DisplayControl control)
This gets called when the given DisplayControl has been initialized. When we get this, if we are enabled, we send the MSG_DISPLAY message with the xml encoding of the display.

Parameters:
control - The display control that has been initialized