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

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.EclipseResourcePersistenceEvent
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<CPCEvent>

public class EclipseResourcePersistenceEvent
extends EclipseEvent

This event is generated by the CPC Sensor module, whenever a documents persistence state changes, i.e. when a file is saved or reverted.
This event provides information about the type of persistence event as well as whether the document and whether it is currently open in an editor window.

Author:
vw

Nested Class Summary
static class EclipseResourcePersistenceEvent.Type
          The type of the EclipseResourcePersistenceEvent.
 
Field Summary
protected  org.eclipse.jface.text.IDocument document
           
protected  boolean openInEditor
           
protected  EclipseResourcePersistenceEvent.Type type
           
 
Fields inherited from class org.electrocodeogram.cpc.core.api.hub.event.EclipseEvent
fileLocatedInWorkspace, fileLocatedInWorkspaceCached, filePath, project, supportedFile, supportedFileCached, user
 
Constructor Summary
EclipseResourcePersistenceEvent(java.lang.String user, java.lang.String project)
          Creates a new EclipseResourcePersistenceEvent for the given user and project.
 
Method Summary
 org.eclipse.jface.text.IDocument getDocument()
          Retrieves the IDocument instance which corresponds to this event.
 EclipseResourcePersistenceEvent.Type getType()
          Retrieves the type of this event.
 boolean isOpenInEditor()
          Indicates whether the file corresponding to this event is currently open in an editor window.
 boolean isValid()
          Checks if this event has been fully initialised.
 void setDocument(org.eclipse.jface.text.IDocument document)
          Sets the IDocument instance which corresponds to this event.
 void setOpenInEditor(boolean openInEditor)
          Specifies whether the file corresponding to this event is currently open in an editor window.
 void setType(EclipseResourcePersistenceEvent.Type type)
          Sets the type of 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 EclipseResourcePersistenceEvent.Type type

openInEditor

protected boolean openInEditor

document

protected org.eclipse.jface.text.IDocument document
Constructor Detail

EclipseResourcePersistenceEvent

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

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

getType

public EclipseResourcePersistenceEvent.Type getType()
Retrieves the type of this event.

Returns:
the type of this event, never null.

setType

public void setType(EclipseResourcePersistenceEvent.Type type)
Sets the type of this event.

This is a required value.

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

isOpenInEditor

public boolean isOpenInEditor()
Indicates whether the file corresponding to this event is currently open in an editor window.
This can be used to distinguish between automatic background actions and user initiated operations.

Returns:
true if the file is currently open in an editor, false otherwise.

setOpenInEditor

public void setOpenInEditor(boolean openInEditor)
Specifies whether the file corresponding to this event is currently open in an editor window.

This is a required value.

Parameters:
openInEditor - true if the file is currently open in an editor, false otherwise.

getDocument

public org.eclipse.jface.text.IDocument getDocument()
Retrieves the IDocument instance which corresponds to this event.

Returns:
the document underlying this event, never null.

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document)
Sets the IDocument instance which corresponds to this event.

This is a required value.

Parameters:
document - the document underlying this event, never null.

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.