Class CollabManager

All Implemented Interfaces:
ActionListener, EventListener, SharableListener, IdvConstants

public class CollabManager extends IdvManager implements SharableListener
This class manages the IDV collaboration mechanism
Author:
IDV development team
  • Field Details

    • 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:
    • 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 Details

    • CollabManager

      public CollabManager(IntegratedDataViewer idv)
      Create the CollabManager
      Parameters:
      idv - Reference to the IDV
  • Method Details

    • 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 - the 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 - the 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