com.ephox.editlive.java2.editor.operation
Interface OperationManager


public interface OperationManager


Field Summary
static String TRACK_CHANGES_ELEMENT_NAME
           
static String TRACK_CHANGES_NAMESPACE
          The namespace used for elements in the serialized XML.
static String XML_VERSION_ATTRIBUTE
           
static String XML_VERSION_ATTRIBUTE_VALUE
           
 
Method Summary
 void accept(Operation operation, HTMLDocument document)
          Accept an operation.
 void addOperationChangeListener(OperationListener listener)
          Add an operation change listener to the manager, listening for when the state of operations changes.
 String excludeRemovedWords(int offset, String text)
          Retrieves text with track changes hidden regardless of the current state
 Color getColorForUser(Operation operation)
          Get the color to use to render changes by an operation.
 Color getColorForUser(String author)
          Get the color to use to render changes by author.
 int getOperationCount()
          Get the number of operations that are currently being tracked.
 Collection<Operation> getOperations()
          Get the operations currently being tracked by this operation manager.
 Collection<Operation> getOperationsInRange(int start, int end)
          Get the list of operations that affect the specified range.
 Collection<Operation> getOperationsToRenderInRange(int start, int end)
          Get the list of operations that affect the rendering in the specified range.
 String getUsername()
          Returns the current user name.
 boolean isRemoved(int startOffset, int endOffset)
          Determine if all content in the specified range is marked as removed.
 boolean isTrackChangesEnabled()
          Returns whether or not changes are currently being tracked.
 Operation nextOperation(int afterOffset)
          Get the operation whose affected range starts closest to, but after afterOffset.
 Operation nextOperation(Operation currentOperation)
          Get the next operation after currentOperation, ordered by the start of the affected range.
 Operation previousOperation(int beforeOffset)
          Get the operation whose affected range starts closest to, but before or equal to beforeOffset.
 Operation previousOperation(Operation currentOperation)
          Get the operation before currentOperation, ordered by the start of the affected range.
 void reject(Operation operation, HTMLDocument document)
          Reject an operation.
 void removeOperation(Operation operation)
          Remove an operation from the manager without doing anything else.
 void removeOperationChangeListener(OperationListener listener)
          Remove an operation change listener from the manager.
 

Field Detail

TRACK_CHANGES_NAMESPACE

static final String TRACK_CHANGES_NAMESPACE
The namespace used for elements in the serialized XML.

See Also:
Constant Field Values

TRACK_CHANGES_ELEMENT_NAME

static final String TRACK_CHANGES_ELEMENT_NAME
See Also:
Constant Field Values

XML_VERSION_ATTRIBUTE_VALUE

static final String XML_VERSION_ATTRIBUTE_VALUE
See Also:
Constant Field Values

XML_VERSION_ATTRIBUTE

static final String XML_VERSION_ATTRIBUTE
See Also:
Constant Field Values
Method Detail

isTrackChangesEnabled

boolean isTrackChangesEnabled()
Returns whether or not changes are currently being tracked.

Returns:
true if track changes is enabled, otherwise false.

getOperationCount

int getOperationCount()
Get the number of operations that are currently being tracked.

Returns:
the number of operations being tracked.

getOperations

Collection<Operation> getOperations()
Get the operations currently being tracked by this operation manager. The returned collection is backed by the operation manager and updates as operations are performed, accepted, rejected and merged.

The operations are ordered by the start of the range in the document they affect.

Returns:
the collection of operations currently being tracked by the operation manager.

getOperationsToRenderInRange

Collection<Operation> getOperationsToRenderInRange(int start,
                                                   int end)
Get the list of operations that affect the rendering in the specified range.

Note that if track changes rendering is off, this method will always return an empty collection.

The operations are ordered by the start of the range in the document they affect.

Parameters:
start - the start of the range to check for operations in.
end - the end of the range to check for operations in.
Returns:
the operations that affect the specified range.

getOperationsInRange

Collection<Operation> getOperationsInRange(int start,
                                           int end)
Get the list of operations that affect the specified range.

The operations are ordered by the start of the range in the document they affect.

Parameters:
start - the start of the range to check for operations in.
end - the end of the range to check for operations in.
Returns:
the operations that affect the specified range.

accept

void accept(Operation operation,
            HTMLDocument document)
            throws BadLocationException
Accept an operation. Once accepted, operations are no longer tracked by the manager and their effects are fully applied to the document.

Parameters:
operation - the operation to accept. Must have been retrieved from this operation manager.
document - the document being edited. This must be the document retrieved from the HTML editing pane.
Throws:
BadLocationException - if the operation attempts to access or modify an invalid location in the document.

reject

void reject(Operation operation,
            HTMLDocument document)
            throws BadLocationException
Reject an operation. The effects of the operation on the document are reversed as if the operation had never been performed. The operation will no longer be tracked.

Parameters:
operation - the operation to reject. Must have been retrieved from this operation manager.
document - the document to reverse changes in. This must be the document retrieved from the HTML editing pane.
Throws:
BadLocationException - if the operation attempts to access or modify an invalid location in the document.

nextOperation

Operation nextOperation(Operation currentOperation)
Get the next operation after currentOperation, ordered by the start of the affected range. Operations which both start at the same offset, are ordered by the order in which they occurred.

Parameters:
currentOperation - the operation to get the next operation after, or null to get the first operation in the document.
Returns:
the Operation after currentOperation.

previousOperation

Operation previousOperation(Operation currentOperation)
Get the operation before currentOperation, ordered by the start of the affected range. Operations which both start at the same offset, are ordered by the order in which they occurred.

Parameters:
currentOperation - the operation to get the operation before, or null to get the last operation in the document.
Returns:
the Operation before currentOperation.

nextOperation

Operation nextOperation(int afterOffset)
Get the operation whose affected range starts closest to, but after afterOffset.

Parameters:
afterOffset - the offset to find the closest operation after.
Returns:
the first tracked operation that starts after afterOffset.

previousOperation

Operation previousOperation(int beforeOffset)
Get the operation whose affected range starts closest to, but before or equal to beforeOffset.

Parameters:
beforeOffset - the offset to find the closest operation before.
Returns:
the first tracked operation that starts at or before beforeOffset.

getColorForUser

Color getColorForUser(String author)
Get the color to use to render changes by author.

Parameters:
author - the author to get the color for.
Returns:
the color associated with the author author.

getColorForUser

Color getColorForUser(Operation operation)
Get the color to use to render changes by an operation.

Parameters:
operation - the operation to get the color for.
Returns:
the color associated with the operation operation.

getUsername

String getUsername()
Returns the current user name.

Returns:
the current user name.

addOperationChangeListener

void addOperationChangeListener(OperationListener listener)
Add an operation change listener to the manager, listening for when the state of operations changes.

Parameters:
listener - the OperationListener to receive events

removeOperationChangeListener

void removeOperationChangeListener(OperationListener listener)
Remove an operation change listener from the manager. The listener will no longer receive event notifications.

Parameters:
listener - the OperationListener to remove.

removeOperation

void removeOperation(Operation operation)
Remove an operation from the manager without doing anything else.
WARNING: This will have different side effects depending on the operation, some will appear accepted and others rejected.


isRemoved

boolean isRemoved(int startOffset,
                  int endOffset)
Determine if all content in the specified range is marked as removed.

Parameters:
startOffset - the start of the range.
endOffset - the end of the range.
Returns:
true if all text in the range is marked as removed, otherwise false.

excludeRemovedWords

String excludeRemovedWords(int offset,
                           String text)
Retrieves text with track changes hidden regardless of the current state

Parameters:
offset - The offset of the text in the document
text - A piece of text from the document
Returns:
The text with any removed portions taken out

Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved.