org.electrocodeogram.cpc.core.api.hub.event
Class EclipseCutCopyPasteEvent

java.lang.Object
  extended by org.electrocodeogram.cpc.core.api.hub.event.CPCEvent
      extended by org.electrocodeogram.cpc.core.api.hub.event.EclipseEvent
          extended by org.electrocodeogram.cpc.core.api.hub.event.EclipseCutCopyPasteEvent
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<CPCEvent>

public class EclipseCutCopyPasteEvent
extends EclipseEvent

This event is generated by the CPC Sensor module, whenever the programmer executes a cut, copy or paste operation.
Besides the type and position, the event provides information about the current selection, the clipboard and the content of the editor.

Author:
vw

Nested Class Summary
static class EclipseCutCopyPasteEvent.Type
          The possible types of EclipseCutCopyPasteEvents.
 
Field Summary
protected  java.lang.String clipboard
           
protected  java.lang.String editorContent
           
protected  int offset
           
protected  java.lang.String selection
           
protected  EclipseCutCopyPasteEvent.Type type
           
 
Fields inherited from class org.electrocodeogram.cpc.core.api.hub.event.EclipseEvent
fileLocatedInWorkspace, fileLocatedInWorkspaceCached, filePath, project, supportedFile, supportedFileCached, user
 
Constructor Summary
EclipseCutCopyPasteEvent(java.lang.String user, java.lang.String project)
          Creates a new EclipseCutCopyPasteEvent for the given user and project.
 
Method Summary
 java.lang.String getClipboard()
          Retrieves the current clipboard content.
 java.lang.String getEditorContent()
          Retrieves the current content of the file/editor which was affected by this operation.
 int getOffset()
          Retrieves the offset in the document at which the operation occurred.
 java.lang.String getSelection()
          Retrieves the current selection in the editor.
 EclipseCutCopyPasteEvent.Type getType()
          Retrieves the EclipseCutCopyPasteEvent.Type of this event.
 boolean isValid()
          Checks if this event has been fully initialised.
 void setClipboard(java.lang.String clipboard)
          Sets the current clipboard content.
 void setEditorContent(java.lang.String editorContent)
          Sets the current content of the file/editor which was affected by this operation.
 void setOffset(int offset)
          Sets the offset within the document at which the operation occurred.
 void setSelection(java.lang.String selection)
          Sets the current selection in the editor.
 void setType(EclipseCutCopyPasteEvent.Type type)
          Sets the EclipseCutCopyPasteEvent.Type for this event.
 java.lang.String toString()
          Every event should implement a sensible toString method for use in debugging log messages.
 
Methods inherited from class org.electrocodeogram.cpc.core.api.hub.event.EclipseEvent
getFilePath, getProject, getUser, isFileLocatedInWorkspace, isSupportedFile, setFilePath, subToString
 
Methods inherited from class org.electrocodeogram.cpc.core.api.hub.event.CPCEvent
checkSeal, clone, compareTo, getCreationTime, seal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected EclipseCutCopyPasteEvent.Type type

selection

protected java.lang.String selection

clipboard

protected java.lang.String clipboard

editorContent

protected java.lang.String editorContent

offset

protected int offset
Constructor Detail

EclipseCutCopyPasteEvent

public EclipseCutCopyPasteEvent(java.lang.String user,
                                java.lang.String project)
Creates a new EclipseCutCopyPasteEvent for the given user and project.

Parameters:
user - the current user, never null.
project - the project for the file affected by this operation, never null.
Method Detail

getType

public EclipseCutCopyPasteEvent.Type getType()
Retrieves the EclipseCutCopyPasteEvent.Type of this event.

Returns:
type of this event, never null.

setType

public void setType(EclipseCutCopyPasteEvent.Type type)
Sets the EclipseCutCopyPasteEvent.Type for this event.
The value may not be EclipseCutCopyPasteEvent.Type.NULL.

This is a required value.

Parameters:
type - the type for this event, never null.

getSelection

public java.lang.String getSelection()
Retrieves the current selection in the editor.

Returns:
the current selection in the editor, never null.

setSelection

public void setSelection(java.lang.String selection)
Sets the current selection in the editor.

This is a required value.

Parameters:
selection - the current selection, never null.

getClipboard

public java.lang.String getClipboard()
Retrieves the current clipboard content.

Returns:
current clipboard content, never null.

setClipboard

public void setClipboard(java.lang.String clipboard)
Sets the current clipboard content.

This is a required value.

Parameters:
clipboard - the current clipboard content, never null.

getEditorContent

public java.lang.String getEditorContent()
Retrieves the current content of the file/editor which was affected by this operation.

Returns:
current editor content, never null.

setEditorContent

public void setEditorContent(java.lang.String editorContent)
Sets the current content of the file/editor which was affected by this operation.

This is a required value.

Parameters:
editorContent - current editor content, never null.

getOffset

public int getOffset()
Retrieves the offset in the document at which the operation occurred.
If the current selection is not empty, this is also the start offset of the selection. For a paste operation, the clipboard is inserted at this position.
The offset is the zero-based position character position within the file.

Returns:
offset of this event, always >=0.

setOffset

public void setOffset(int offset)
Sets the offset within the document at which the operation occurred.

This is a required value.

Parameters:
offset - the offset of this event, always >=0.

isValid

public boolean isValid()
Description copied from class: CPCEvent
Checks if this event has been fully initialised.
Will return false if one of the mandatory fields of the event has not yet been filled out.

Subclasses should override this method but should never return true. Instead they should delegate to the super class implementation once all validity checks on their level have passed.

The CPCEvent.isValid() implementation always returns true.

Overrides:
isValid in class EclipseEvent
Returns:
true if this event is valid, false otherwise.
See Also:
IEventHubRegistry.dispatch(CPCEvent)

toString

public java.lang.String toString()
Description copied from class: CPCEvent
Every event should implement a sensible toString method for use in debugging log messages.

Specified by:
toString in class CPCEvent
Returns:
debug string representation, never null.