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,org.eclipse.core.commands.operations.IUndoableOperation
public class ComplexOperation extends org.eclipse.core.commands.operations.AbstractOperation implements IComplexOperation
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
Constructors Constructor Description ComplexOperation(java.lang.String descr, IComplexOperationSelection selectionImpl, IPropUndoRedo undoRedo)Constructor of Add Operation.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOperation(IComplexSubOperation oper)Adds a sub operation.voidaddProp(PropCnr pc, GProp<?> gp)Adds a property.voidaddPropError(GProp<?> gp, IPropErrorItem pei)Adds a property error.booleancanExecute()Returns whether the operation can be executed in its current state.booleancanRedo()Returns whether the operation can be redone in its current state.booleancanUndo()Returns whether the operation can be undone in its current state.org.eclipse.core.runtime.IStatusexecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)Executes the Paste.ContainerParticipantgetContainerParticipant(PropCnr pc)Gets a container participant or creates one.ComplexOperationgetGlobal()Gets the global complex operation in progress.booleanhasPerformedAnOperation()Checks if an operation has been performed successfully or if it's an empty operation for undo.voidinsertProp(PropCnr pc, GProp<?> gp, int index)Inserts a property.voidmoveProp(GProp<?> gp, PropCnr toContainer, Atom newName, int toIndex)Moves a property to another container.ContainerSelectionnewContainerSelection(GProp<?> prop)Creates a new ContainerSelection instance for a property container involved in the operation.ContainerSelectionnewContainerSelection(PropCnr parent, Atom childAtom)Creates a new ContainerSelection instance for a property container involved in the operation.org.eclipse.core.runtime.IStatusredo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)Redoes the Paste operation: same as Execute.voidremoveProp(GProp<?> gp)Removes a property.voidremovePropError(GProp<?> gp, java.lang.String errorID)Removes a property error.voidrenameProp(GProp<?> gp, Atom newName)Renames a property.voidreorderProps(PropCnr pc, Atom[] order)Reorder a property container.booleansetGlobal()Sets this operation as the current one for global operations.voidsetPropError(GProp<?> gp, PropError pe)Sets all errors in a property.voidsetPropValue(GProp<?> gp, java.lang.Object newValue)Sets a property value.voidsetSelectionAfter(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.voidsetSelectionBefore(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.org.eclipse.core.runtime.IStatusundo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)Performs the undo of a Paste operation.booleanunsetGlobal()Removes this operation as the current one for global operations.
Constructor Detail
ComplexOperation
public ComplexOperation(java.lang.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 Detail
getGlobal
public ComplexOperation getGlobal()
Gets the global complex operation in progress.- Returns:
- The global operation, or null for none.
setSelectionBefore
public 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.Use the method
newContainerSelection(GProp)to create the array elements.- Parameters:
selection- The selection.
setSelectionAfter
public 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.Use the method
newContainerSelection(GProp)to create the array elements.- Parameters:
selection- The selection.
setPropValue
public void setPropValue(GProp<?> gp, java.lang.Object newValue)
Sets a property value.- Specified by:
setPropValuein interfaceIComplexOperation
addProp
public void addProp(PropCnr pc, GProp<?> gp)
Adds a property.- Specified by:
addPropin interfaceIComplexOperation
insertProp
public void insertProp(PropCnr pc, GProp<?> gp, int index)
Inserts a property.- Specified by:
insertPropin interfaceIComplexOperation
removeProp
public void removeProp(GProp<?> gp)
Removes a property.- Specified by:
removePropin interfaceIComplexOperation
renameProp
public void renameProp(GProp<?> gp, Atom newName)
Renames a property.- Specified by:
renamePropin interfaceIComplexOperation
setPropError
public void setPropError(GProp<?> gp, PropError pe)
Sets all errors in a property.- Specified by:
setPropErrorin interfaceIComplexOperation
addPropError
public void addPropError(GProp<?> gp, IPropErrorItem pei)
Adds a property error.- Specified by:
addPropErrorin interfaceIComplexOperation
removePropError
public void removePropError(GProp<?> gp, java.lang.String errorID)
Removes a property error.- Specified by:
removePropErrorin interfaceIComplexOperation
moveProp
public void moveProp(GProp<?> gp, PropCnr toContainer, Atom newName, int toIndex)
Moves a property to another container.- Specified by:
movePropin interfaceIComplexOperation
reorderProps
public void reorderProps(PropCnr pc, Atom[] order)
Reorder a property container.- Specified by:
reorderPropsin interfaceIComplexOperation
hasPerformedAnOperation
public boolean hasPerformedAnOperation()
Checks if an operation has been performed successfully or if it's an empty operation for undo.- Specified by:
hasPerformedAnOperationin interfaceIComplexOperation
getContainerParticipant
public ContainerParticipant getContainerParticipant(PropCnr pc)
Gets a container participant or creates one.- Parameters:
pc- The property container.- Returns:
- The container participant.
newContainerSelection
public ContainerSelection newContainerSelection(GProp<?> prop)
Creates a new ContainerSelection instance for a property container involved in the operation.- Parameters:
prop- A selected property.- Returns:
- The ContainerSelection instance.
newContainerSelection
public ContainerSelection newContainerSelection(PropCnr parent, Atom childAtom)
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
public void addOperation(IComplexSubOperation oper)
Adds a sub operation.
canExecute
public boolean canExecute()
Returns whether the operation can be executed in its current state.- Specified by:
canExecutein interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Overrides:
canExecutein classorg.eclipse.core.commands.operations.AbstractOperation
execute
public org.eclipse.core.runtime.IStatus execute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionExceptionExecutes the Paste.- Specified by:
executein interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Specified by:
executein classorg.eclipse.core.commands.operations.AbstractOperation- Throws:
org.eclipse.core.commands.ExecutionException
canRedo
public boolean canRedo()
Returns whether the operation can be redone in its current state.- Specified by:
canRedoin interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Overrides:
canRedoin classorg.eclipse.core.commands.operations.AbstractOperation
redo
public org.eclipse.core.runtime.IStatus redo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionExceptionRedoes the Paste operation: same as Execute.- Specified by:
redoin interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Specified by:
redoin classorg.eclipse.core.commands.operations.AbstractOperation- Throws:
org.eclipse.core.commands.ExecutionException
canUndo
public boolean canUndo()
Returns whether the operation can be undone in its current state.- Specified by:
canUndoin interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Overrides:
canUndoin classorg.eclipse.core.commands.operations.AbstractOperation
undo
public org.eclipse.core.runtime.IStatus undo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionExceptionPerforms the undo of a Paste operation.- Specified by:
undoin interfaceorg.eclipse.core.commands.operations.IUndoableOperation- Specified by:
undoin classorg.eclipse.core.commands.operations.AbstractOperation- Throws:
org.eclipse.core.commands.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.