Package com.iizigo.editor.complex
Class ComplexOperation
java.lang.Object
org.eclipse.core.commands.operations.AbstractOperation
com.iizigo.editor.complex.ComplexOperation
- All Implemented Interfaces:
IComplexOperation
,IUndoableOperation
The Complex operation can bundle advanced combination of operation between property containers. The operation is constructed with the property containers involved in the operation. Then the operation is executed. As it is executed, the undo/redo operations is built up.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorDescriptionComplexOperation
(String descr, IComplexOperationSelection selectionImpl, IPropUndoRedo undoRedo) Constructor of Add Operation.Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a sub operation.void
Adds a property.void
addPropError
(GProp<?> gp, IPropErrorItem pei) Adds a property error.boolean
Returns whether the operation can be executed in its current state.boolean
canRedo()
Returns whether the operation can be redone in its current state.boolean
canUndo()
Returns whether the operation can be undone in its current state.execute
(IProgressMonitor monitor, IAdaptable info) Executes the Paste.Gets a container participant or creates one.Gets the global complex operation in progress.boolean
Checks if an operation has been performed successfully or if it's an empty operation for undo.void
insertProp
(PropCnr pc, GProp<?> gp, int index) Inserts a property.void
Moves a property to another container.newContainerSelection
(GProp<?> prop) Creates a new ContainerSelection instance for a property container involved in the operation.newContainerSelection
(PropCnr parent, Atom childAtom) Creates a new ContainerSelection instance for a property container involved in the operation.redo
(IProgressMonitor monitor, IAdaptable info) Redoes the Paste operation: same as Execute.void
removeProp
(GProp<?> gp) Removes a property.void
removePropError
(GProp<?> gp, String errorID) Removes a property error.void
renameProp
(GProp<?> gp, Atom newName) Renames a property.void
reorderProps
(PropCnr pc, Atom[] order) Reorder a property container.boolean
Sets this operation as the current one for global operations.void
setPropError
(GProp<?> gp, PropError pe) Sets all errors in a property.void
setPropValue
(GProp<?> gp, Object newValue) Sets a property value.void
setSelectionAfter
(ContainerSelection[] selection) Sets the selection after the operation has been performed so that it can be restored at a redo operation, before or after it has been executed.void
setSelectionBefore
(ContainerSelection[] selection) Sets the selection before the operation has been performed so that it can be restored at a undo operation, before or after it has been executed.undo
(IProgressMonitor monitor, IAdaptable info) Performs the undo of a Paste operation.boolean
Removes this operation as the current one for global operations.Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, dispose, getContexts, getLabel, hasContext, removeContext, setLabel, toString
Constructor Details
ComplexOperation
public ComplexOperation(String descr, IComplexOperationSelection selectionImpl, IPropUndoRedo undoRedo) Constructor of Add Operation.- Parameters:
descr
- Description of the operation.selectionImpl
- Selection to set in the Viewer of "undoRedo" when operation completes (also for undo), null for none.undoRedo
- The undo/redo provider, null for no undo/redo support.
Method Details
getGlobal
Gets the global complex operation in progress.- Returns:
- The global operation, or null for none.
setSelectionBefore
Sets the selection before the operation has been performed so that it can be restored at a undo operation, before or after it has been executed.Use the method
newContainerSelection(GProp)
to create the array elements.- Parameters:
selection
- The selection.
setSelectionAfter
Sets the selection after the operation has been performed so that it can be restored at a redo operation, before or after it has been executed.Use the method
newContainerSelection(GProp)
to create the array elements.- Parameters:
selection
- The selection.
setPropValue
Sets a property value.- Specified by:
setPropValue
in interfaceIComplexOperation
addProp
Adds a property.- Specified by:
addProp
in interfaceIComplexOperation
insertProp
Inserts a property.- Specified by:
insertProp
in interfaceIComplexOperation
removeProp
Removes a property.- Specified by:
removeProp
in interfaceIComplexOperation
renameProp
Renames a property.- Specified by:
renameProp
in interfaceIComplexOperation
setPropError
Sets all errors in a property.- Specified by:
setPropError
in interfaceIComplexOperation
addPropError
Adds a property error.- Specified by:
addPropError
in interfaceIComplexOperation
removePropError
Removes a property error.- Specified by:
removePropError
in interfaceIComplexOperation
moveProp
Moves a property to another container.- Specified by:
moveProp
in interfaceIComplexOperation
reorderProps
Reorder a property container.- Specified by:
reorderProps
in interfaceIComplexOperation
hasPerformedAnOperation
public boolean hasPerformedAnOperation()Checks if an operation has been performed successfully or if it's an empty operation for undo.- Specified by:
hasPerformedAnOperation
in interfaceIComplexOperation
getContainerParticipant
Gets a container participant or creates one.- Parameters:
pc
- The property container.- Returns:
- The container participant.
newContainerSelection
Creates a new ContainerSelection instance for a property container involved in the operation.- Parameters:
prop
- A selected property.- Returns:
- The ContainerSelection instance.
newContainerSelection
Creates a new ContainerSelection instance for a property container involved in the operation.- Parameters:
parent
- The parent of the selected property.childAtom
- The atom of the selected property.- Returns:
- The ContainerSelection instance.
addOperation
Adds a sub operation.canExecute
public boolean canExecute()Returns whether the operation can be executed in its current state.- Specified by:
canExecute
in interfaceIUndoableOperation
- Overrides:
canExecute
in classAbstractOperation
execute
Executes the Paste.- Specified by:
execute
in interfaceIUndoableOperation
- Specified by:
execute
in classAbstractOperation
- Throws:
ExecutionException
canRedo
public boolean canRedo()Returns whether the operation can be redone in its current state.- Specified by:
canRedo
in interfaceIUndoableOperation
- Overrides:
canRedo
in classAbstractOperation
redo
Redoes the Paste operation: same as Execute.- Specified by:
redo
in interfaceIUndoableOperation
- Specified by:
redo
in classAbstractOperation
- Throws:
ExecutionException
canUndo
public boolean canUndo()Returns whether the operation can be undone in its current state.- Specified by:
canUndo
in interfaceIUndoableOperation
- Overrides:
canUndo
in classAbstractOperation
undo
Performs the undo of a Paste operation.- Specified by:
undo
in interfaceIUndoableOperation
- Specified by:
undo
in classAbstractOperation
- Throws:
ExecutionException
setGlobal
public boolean setGlobal()Sets this operation as the current one for global operations.- Returns:
- true for single global operation assigned, false if another one has been replaced.
unsetGlobal
public boolean unsetGlobal()Removes this operation as the current one for global operations. If this operation is not the global one, nothing happens.- Returns:
- true for success, false if this operation was not the global one.