public class PerformChangeOperation extends Object implements IWorkspaceRunnable
Change
object. The operation
can be created in two different ways: with a given change or with a
CreateChangeOperation
. 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()
returns
true
) then the operation has called Change.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
IWorkspace
to achieve proper delta batching.
Note: this class is not intended to be extended outside of the refactoring framework.
Constructor and Description |
---|
PerformChangeOperation(Change change)
Creates a new perform change operation instance for the given change.
|
PerformChangeOperation(CreateChangeOperation op)
Creates a new
PerformChangeOperation for the given CreateChangeOperation . |
Modifier and Type | Method and Description |
---|---|
boolean |
changeExecuted()
Returns
true if the change has been executed. |
boolean |
changeExecutionFailed()
Returns
true if the change execution failed. |
protected void |
executeChange(IProgressMonitor pm)
Actually executes the change.
|
Change |
getChange()
Returns the change used by this operation.
|
RefactoringStatus |
getConditionCheckingStatus()
Returns the status of the condition checking.
|
Change |
getUndoChange()
Returns the undo change of the change performed by this operation.
|
RefactoringStatus |
getValidationStatus()
Returns the refactoring status returned from the call
IChange#isValid() . |
void |
run(IProgressMonitor pm)
Executes this runnable.
|
void |
setSchedulingRule(ISchedulingRule rule)
Sets the scheduling rule used to execute this operation.
|
void |
setUndoManager(IUndoManager manager,
String undoName)
Sets the undo manager.
|
public PerformChangeOperation(Change change)
change
- the change to be applied to the workbenchpublic PerformChangeOperation(CreateChangeOperation op)
PerformChangeOperation
for the given CreateChangeOperation
. The create change operation is used to create
the actual change to execute.op
- the CreateChangeOperation
used to create the
actual change objectpublic boolean changeExecutionFailed()
true
if the change execution failed.true
if the change execution failed;
false
otherwisepublic boolean changeExecuted()
true
if the change has been executed. Otherwise
false
is returned.true
if the change has been executed, otherwise
false
public RefactoringStatus getConditionCheckingStatus()
null
if
no condition checking has been requested.public Change getChange()
CreateChangeOperation
.
Method returns null
if the create operation did not create
a corresponding change or hasn't been executed yet.null
if no change
has been createdpublic Change getUndoChange()
null
if the change hasn't been performed yet or if the change
doesn't provide a undo.null
public RefactoringStatus getValidationStatus()
IChange#isValid()
.
Returns null
if the change has not been executed.public void setUndoManager(IUndoManager manager, String undoName)
manager
- the undo manager to use or null
if 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 be null
if manager is unequal null
public void setSchedulingRule(ISchedulingRule rule)
rule
- the rule to use, or null
to use no scheduling rulepublic void run(IProgressMonitor pm) throws CoreException
ICoreRunnable
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
. A CoreException
with a status
of severity IStatus.CANCEL
has the same effect as
an OperationCanceledException
.
run
in interface IWorkspaceRunnable
run
in interface ICoreRunnable
pm
- a progress monitor, or null
if progress reporting and
cancellation are not desired. The monitor is only valid for the duration
of the invocation of this method. Callers may call IProgressMonitor.done()
after this method returns or throws an exception, but this is not strictly
required.CoreException
- if this operation failsprotected void executeChange(IProgressMonitor pm) throws CoreException
pm
- a progress monitor to report progressCoreException
- if an unexpected error occurs during
change execution
Copyright (c) 2000, 2017 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.