org.eclipse.ecf.docshare
Class DocShare

java.lang.Object
  extended by org.eclipse.ecf.datashare.AbstractShare
      extended by org.eclipse.ecf.docshare.DocShare

public class DocShare
extends AbstractShare

Represents a document sharing session between two participants.

Since:
2.1

Nested Class Summary
static class DocShare.SelectionReceiver
           
 
Field Summary
 
Fields inherited from class org.eclipse.ecf.datashare.AbstractShare
adapter, channel
 
Constructor Summary
DocShare(IChannelContainerAdapter adapter)
          Create a document sharing session instance.
 
Method Summary
 void dispose()
           
 ID getInitiatorID()
           
 ID getOtherID()
           
 ID getOurID()
           
 ID getReceiverID()
           
 org.eclipse.ui.texteditor.ITextEditor getTextEditor()
           
protected  void handleDisconnectEvent(IChannelDisconnectEvent cde)
           
protected  void handleMessage(ID fromContainerID, byte[] data)
          Receive message for this channel.
protected  void handleStartMessage(StartMessage message)
          This method called by the handleMessage(ID, byte[]) method if the type of the message received is a start message (sent by remote party via startShare(ID, String, ID, String, ITextEditor).
protected  void handleStopMessage(StopMessage message)
           
protected  void handleUpdateMessage(DocumentChangeMessage documentChangeMessage)
          This method called by the handleMessage(ID, byte[]) method if the type of the message received is an update message.
 boolean isInitiator()
           
 boolean isSharing()
           
 void startShare(ID our, java.lang.String fromName, ID toID, java.lang.String fileName, org.eclipse.ui.texteditor.ITextEditor editorPart)
          Start sharing an editor's contents between two participants.
 void stopShare()
          Stop editor sharing.
 java.lang.String toString()
           
 
Methods inherited from class org.eclipse.ecf.datashare.AbstractShare
getChannel, handleChannelEvent, handleConnectEvent, isDisposed, sendMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DocShare

public DocShare(IChannelContainerAdapter adapter)
         throws ECFException
Create a document sharing session instance.

Parameters:
adapter - the IChannelContainerAdapter to use to create this document sharing session.
Throws:
ECFException - if the channel cannot be created.
Method Detail

startShare

public void startShare(ID our,
                       java.lang.String fromName,
                       ID toID,
                       java.lang.String fileName,
                       org.eclipse.ui.texteditor.ITextEditor editorPart)
Start sharing an editor's contents between two participants. This will send a request to start sharing with the target identified by the toID parameter. The remote receiver will be displayed a message dialog, and given the option to start editor sharing, or not.

Parameters:
our - the ID associated with the initiator. Must not be null.
fromName - a name to present to the receiver. If null, our.getName() will be used.
toID - the ID of the intended receiver. Must not be null.
fileName - the file name of the file to be shared (with suffix type extension). Must not be null.
editorPart - the text editor currently showing the contents of this editor. Must not be null.

stopShare

public void stopShare()
Stop editor sharing. Message only sent if we are currently engaged in an editor sharing session (isSharing() returns true.


handleMessage

protected void handleMessage(ID fromContainerID,
                             byte[] data)
Description copied from class: AbstractShare
Receive message for this channel. This method will be called asynchronously by an arbitrary thread when data to the associated channel is received.

Specified by:
handleMessage in class AbstractShare
Parameters:
fromContainerID - the ID of the sender container. Will not be null.
data - the data received on the channel. Will not be null.

handleStartMessage

protected void handleStartMessage(StartMessage message)
                           throws IDCreateException
This method called by the handleMessage(ID, byte[]) method if the type of the message received is a start message (sent by remote party via startShare(ID, String, ID, String, ITextEditor).

Parameters:
message - the UpdateMessage received.
Throws:
IDCreateException

handleUpdateMessage

protected void handleUpdateMessage(DocumentChangeMessage documentChangeMessage)
This method called by the handleMessage(ID, byte[]) method if the type of the message received is an update message.

Parameters:
documentChangeMessage - the UpdateMessage received.

handleStopMessage

protected void handleStopMessage(StopMessage message)
Parameters:
message -

handleDisconnectEvent

protected void handleDisconnectEvent(IChannelDisconnectEvent cde)
Overrides:
handleDisconnectEvent in class AbstractShare

dispose

public void dispose()
Overrides:
dispose in class AbstractShare

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInitiatorID

public ID getInitiatorID()

getReceiverID

public ID getReceiverID()

getOurID

public ID getOurID()

getTextEditor

public org.eclipse.ui.texteditor.ITextEditor getTextEditor()

isSharing

public boolean isSharing()

getOtherID

public ID getOtherID()

isInitiator

public boolean isInitiator()