Class PerformChangeOperation
- java.lang.Object
-
- org.eclipse.ltk.core.refactoring.PerformChangeOperation
-
- All Implemented Interfaces:
IWorkspaceRunnable,ICoreRunnable
public class PerformChangeOperation extends Object implements IWorkspaceRunnable
Operation that, when run, performs aChangeobject. The operation can be created in two different ways: with a given change or with aCreateChangeOperation. If created the second way the given create change operation will be used to create the actual change to perform.If the change has been performed successfully (e.g.
changeExecuted()returnstrue) then the operation has calledChange.dispose()as well to clear-up internal state in the change object. If it hasn't been executed the change, the change is still intact and the client is responsible to dispose the change object.If an undo change has been provided by the change to execute then the operation calls
Change.initializeValidationData(IProgressMonitor)to initialize the undo change's validation data.If an undo manager has been set via the method
setUndoManager(IUndoManager, String)then the undo object, if any has been provided, will be pushed onto the manager's undo stack.The operation should be executed via the run method offered by
IWorkspaceto achieve proper delta batching.Note: this class is not intended to be extended outside of the refactoring framework.
- Since:
- 3.0
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Constructor Summary
Constructors Constructor Description PerformChangeOperation(Change change)Creates a new perform change operation instance for the given change.PerformChangeOperation(CreateChangeOperation op)Creates a newPerformChangeOperationfor the givenCreateChangeOperation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchangeExecuted()Returnstrueif the change has been executed.booleanchangeExecutionFailed()Returnstrueif the change execution failed.protected voidexecuteChange(IProgressMonitor pm)Actually executes the change.ChangegetChange()Returns the change used by this operation.RefactoringStatusgetConditionCheckingStatus()Returns the status of the condition checking.ChangegetUndoChange()Returns the undo change of the change performed by this operation.RefactoringStatusgetValidationStatus()Returns the refactoring status returned from the callIChange#isValid().voidrun(IProgressMonitor pm)Executes this runnable.voidsetSchedulingRule(ISchedulingRule rule)Sets the scheduling rule used to execute this operation.voidsetUndoManager(IUndoManager manager, String undoName)Sets the undo manager.
-
-
-
Constructor Detail
-
PerformChangeOperation
public PerformChangeOperation(Change change)
Creates a new perform change operation instance for the given change.- Parameters:
change- the change to be applied to the workbench
-
PerformChangeOperation
public PerformChangeOperation(CreateChangeOperation op)
Creates a newPerformChangeOperationfor the givenCreateChangeOperation. The create change operation is used to create the actual change to execute.- Parameters:
op- theCreateChangeOperationused to create the actual change object
-
-
Method Detail
-
changeExecutionFailed
public boolean changeExecutionFailed()
Returnstrueif the change execution failed.- Returns:
trueif the change execution failed;falseotherwise
-
changeExecuted
public boolean changeExecuted()
Returnstrueif the change has been executed. Otherwisefalseis returned.- Returns:
trueif the change has been executed, otherwisefalse
-
getConditionCheckingStatus
public RefactoringStatus getConditionCheckingStatus()
Returns the status of the condition checking. Returnsnullif no condition checking has been requested.- Returns:
- the status of the condition checking
-
getChange
public Change getChange()
Returns the change used by this operation. This is either the change passed to the constructor or the one create by theCreateChangeOperation. Method returnsnullif the create operation did not create a corresponding change or hasn't been executed yet.- Returns:
- the change used by this operation or
nullif no change has been created
-
getUndoChange
public Change getUndoChange()
Returns the undo change of the change performed by this operation. Returnsnullif the change hasn't been performed yet or if the change doesn't provide a undo.- Returns:
- the undo change of the performed change or
null
-
getValidationStatus
public RefactoringStatus getValidationStatus()
Returns the refactoring status returned from the callIChange#isValid(). Returnsnullif the change has not been executed.- Returns:
- the change's validation status
-
setUndoManager
public void setUndoManager(IUndoManager manager, String undoName)
Sets the undo manager. If the executed change provides an undo change, then the undo change is pushed onto this manager.- Parameters:
manager- the undo manager to use ornullif no undo recording is desiredundoName- the name used to present the undo change on the undo stack. Must be a human-readable string. Must not benullif manager is unequalnull
-
setSchedulingRule
public void setSchedulingRule(ISchedulingRule rule)
Sets the scheduling rule used to execute this operation. If not set then the workspace root is used. The supplied Change must be able to be performed in the provided scheduling rule.- Parameters:
rule- the rule to use, ornullto use no scheduling rule- Since:
- 3.3
-
run
public void run(IProgressMonitor pm) throws CoreException
Description copied from interface:ICoreRunnableExecutes this runnable.The provided monitor can be used to report progress and respond to cancellation. If the progress monitor has been canceled, the runnable should finish its execution at the earliest convenience and throw an
OperationCanceledException. ACoreExceptionwith a status of severityIStatus.CANCELhas the same effect as anOperationCanceledException.- Specified by:
runin interfaceICoreRunnable- Specified by:
runin interfaceIWorkspaceRunnable- Parameters:
pm- a progress monitor, ornullif progress reporting and cancellation are not desired. The monitor is only valid for the duration of the invocation of this method. Callers may callIProgressMonitor.done()after this method returns or throws an exception, but this is not strictly required.- Throws:
CoreException- if this operation fails
-
executeChange
protected void executeChange(IProgressMonitor pm) throws CoreException
Actually executes the change.- Parameters:
pm- a progress monitor to report progress- Throws:
CoreException- if an unexpected error occurs during change execution
-
-