Class RefactoringHistoryWizard
- java.lang.Object
-
- org.eclipse.jface.wizard.Wizard
-
- org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryWizard
-
- All Implemented Interfaces:
IShellProvider,IWizard
public class RefactoringHistoryWizard extends Wizard
A default implementation of a refactoring history wizard. Refactoring history wizards are used to execute the refactorings described by a refactoring history. A refactoring history wizard differs from a normal wizard in the following characteristics:- A refactoring history wizard consists of a sequence of one error page to present the outcome of a refactoring's condition checking and one preview page to present a preview of the workspace changes.
- Refactorings are applied to the workspace as soon as a preview has been accepted. Additionally, refactoring history wizards support the headless execution of refactorings. The user guided execution of a refactoring history triggers a series of error pages and preview pages. Within this sequence of pages, going back is not supported anymore. However, canceling the refactoring history wizard will undo the already performed refactorings.
A refactoring history wizard is usually opened using the
WizardDialog. Clients must ensure that the calling thread holds the workspace lock.Note: this class is intended to be extended by clients.
- Since:
- 3.2
- See Also:
Refactoring,RefactoringHistory
-
-
Field Summary
Fields Modifier and Type Field Description static intSTATUS_CODE_INTERRUPTEDThe status code representing an interrupted operation.-
Fields inherited from class org.eclipse.jface.wizard.Wizard
DEFAULT_IMAGE
-
-
Constructor Summary
Constructors Constructor Description RefactoringHistoryWizard(boolean overview, String caption, String title, String description)Creates a new refactoring history wizard.RefactoringHistoryWizard(String caption, String title, String description)Creates a new refactoring history wizard.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected RefactoringStatusaboutToPerformHistory(IProgressMonitor monitor)Hook method which is called before the first refactoring of the history is executed.protected RefactoringStatusaboutToPerformRefactoring(Refactoring refactoring, RefactoringDescriptor descriptor, IProgressMonitor monitor)Hook method which is called before the a refactoring of the history is executed.voidaddPage(IWizardPage page)Adds a new page to this wizard.voidaddPages()TheWizardimplementation of thisIWizardmethod does nothing.protected voidaddUserDefinedPages()Adds user defined wizard pages in front of the wizard.booleancanFinish()Returns whether this wizard could be finished without further user interaction.protected RefactoringcreateRefactoring(RefactoringDescriptor descriptor, RefactoringStatus status)Deprecated.since 3.6.protected RefactoringcreateRefactoring(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor)Deprecated.since 3.7.protected RefactoringContextcreateRefactoringContext(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor)Creates a refactoring context from the specified refactoring descriptor.voiddispose()TheWizardimplementation of thisIWizardmethod disposes all the pages controls usingDialogPage.dispose.org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPagegetErrorPage()Returns the error wizard page.IWizardPagegetNextPage(IWizardPage page)Returns the successor of the given page.org.eclipse.ltk.internal.ui.refactoring.IPreviewWizardPagegetPreviewPage()Returns the preview wizard page.IWizardPagegetPreviousPage(IWizardPage page)Returns the predecessor of the given page.protected RefactoringStatushistoryPerformed(IProgressMonitor monitor)Hook method which is called when all refactorings of the history have been executed.booleanperformCancel()TheWizardimplementation of thisIWizardmethod does nothing and returnstrue.booleanperformFinish()Subclasses must implement thisIWizardmethod to perform any special finish processing for their wizard.RefactoringStatusperformPreviewChange(Change change, Refactoring refactoring)Performs the change previously displayed in the preview.protected RefactoringStatusrefactoringPerformed(Refactoring refactoring, IProgressMonitor monitor)Hook method which is called when the specified refactoring has been performed, e.g. its change object has been successfully applied to the workspace.protected booleanselectPreviewChange(Change change)Hook method which is called for each change before it is displayed in a preview page.protected booleanselectStatusEntry(RefactoringStatusEntry entry)Hook method which is called for each status entry before it is displayed in a wizard page.voidsetConfiguration(RefactoringHistoryControlConfiguration configuration)Sets the refactoring history control configuration.voidsetInput(RefactoringHistory history)Sets the refactoring history.-
Methods inherited from class org.eclipse.jface.wizard.Wizard
createPageControls, getContainer, getDefaultPageImage, getDialogSettings, getPage, getPageCount, getPages, getShell, getStartingPage, getTitleBarColor, getWindowTitle, isHelpAvailable, needsPreviousAndNextButtons, needsProgressMonitor, setContainer, setDefaultPageImageDescriptor, setDialogSettings, setForcePreviousAndNextButtons, setHelpAvailable, setNeedsProgressMonitor, setTitleBarColor, setWindowTitle
-
-
-
-
Field Detail
-
STATUS_CODE_INTERRUPTED
public static final int STATUS_CODE_INTERRUPTED
The status code representing an interrupted operation.Note: This API must not be used from outside the refactoring framework.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RefactoringHistoryWizard
public RefactoringHistoryWizard(boolean overview, String caption, String title, String description)Creates a new refactoring history wizard.Clients must ensure that the refactoring history and the refactoring history control configuration are set before opening the wizard in a dialog.
- Parameters:
overview-trueto show an overview of the refactorings,falseotherwisecaption- the caption of the wizard windowtitle- the title of the overview pagedescription- the description of the overview page- See Also:
setConfiguration(RefactoringHistoryControlConfiguration),setInput(RefactoringHistory)
-
RefactoringHistoryWizard
public RefactoringHistoryWizard(String caption, String title, String description)
Creates a new refactoring history wizard.Clients must ensure that the refactoring history and the refactoring history control configuration are set before opening the wizard in a dialog.
Calling his constructor is equivalent to
RefactoringHistoryWizard(boolean, String, String, String)with the first argument equal totrue.- Parameters:
caption- the caption of the wizard windowtitle- the title of the overview pagedescription- the description of the overview page- See Also:
setConfiguration(RefactoringHistoryControlConfiguration),setInput(RefactoringHistory)
-
-
Method Detail
-
aboutToPerformHistory
protected RefactoringStatus aboutToPerformHistory(IProgressMonitor monitor)
Hook method which is called before the first refactoring of the history is executed. This method may be called from non-UI threads.This method is guaranteed to be called exactly once during the lifetime of a refactoring history wizard. The default implementation does nothing and returns a refactoring status of severity
RefactoringStatus.OK.Subclasses may reimplement this method to perform any special processing.
Returning a status of severity
RefactoringStatus.FATALwill terminate the execution of the refactorings.- Parameters:
monitor- the progress monitor to use- Returns:
- a status describing the outcome of the operation
-
aboutToPerformRefactoring
protected RefactoringStatus aboutToPerformRefactoring(Refactoring refactoring, RefactoringDescriptor descriptor, IProgressMonitor monitor)
Hook method which is called before the a refactoring of the history is executed. The refactoring itself is in an initialized state at the time of the method call. The default implementation does nothing and returns a status of severityRefactoringStatus.OK. This method may be called from non-UI threads.Subclasses may extend this method to perform any special processing.
Returning a status of severity
RefactoringStatus.FATALwill terminate the execution of the current refactoring.- Parameters:
refactoring- the refactoring about to be executeddescriptor- the refactoring descriptormonitor- the progress monitor to use- Returns:
- a status describing the outcome of the initialization
-
addPage
public final void addPage(IWizardPage page)
Adds a new page to this wizard. The page is inserted at the end of the page list. Clients must contribute their wizard pages by re-implementingaddUserDefinedPages().
-
addPages
public final void addPages()
Description copied from class:WizardTheWizardimplementation of thisIWizardmethod does nothing. Subclasses should extend if extra pages need to be added before the wizard opens. New pages should be added by callingaddPage.
-
addUserDefinedPages
protected void addUserDefinedPages()
Adds user defined wizard pages in front of the wizard.Clients may extend this method to add custom wizard pages in front of the wizard.
-
canFinish
public boolean canFinish()
Description copied from interface:IWizardReturns whether this wizard could be finished without further user interaction.The result of this method is typically used by the wizard container to enable or disable the Finish button.
-
createRefactoring
@Deprecated protected Refactoring createRefactoring(RefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException
Deprecated.since 3.6. OverridecreateRefactoringContext(RefactoringDescriptor, RefactoringStatus, IProgressMonitor)insteadMethod which is called to create a refactoring instance from a refactoring descriptor. The refactoring must be in an initialized state after the return of the method call. The default implementation delegates the task to the refactoring descriptor. This method may be called from non-UI threads.Subclasses may reimplement this method to customize the initialization of a refactoring.
- Parameters:
descriptor- the refactoring descriptorstatus- a refactoring status describing the outcome of the initialization- Returns:
- the refactoring, or
nullif this refactoring descriptor represents the unknown refactoring, or if no refactoring contribution is available for this refactoring descriptor - Throws:
CoreException- if an error occurs while creating the refactoring instance
-
createRefactoring
@Deprecated protected Refactoring createRefactoring(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor) throws CoreException
Deprecated.since 3.7. OverridecreateRefactoringContext(RefactoringDescriptor, RefactoringStatus, IProgressMonitor)insteadCreates a refactoring from the specified refactoring descriptor.The default implementation calls
createRefactoring(RefactoringDescriptor, RefactoringStatus)followed byaboutToPerformRefactoring(Refactoring, RefactoringDescriptor, IProgressMonitor). Implementors can replace this implementation.- Parameters:
descriptor- the refactoring descriptorstatus- the refactoring statusmonitor- the progress monitor to use- Returns:
- the refactoring, or
nullif this refactoring descriptor represents the unknown refactoring, or if no refactoring contribution is available for this refactoring descriptor - Throws:
CoreException- if an error occurs while creating the refactoring instance- Since:
- 3.4
-
createRefactoringContext
protected RefactoringContext createRefactoringContext(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor) throws CoreException
Creates a refactoring context from the specified refactoring descriptor.The default implementation calls
RefactoringDescriptor.createRefactoringContext(RefactoringStatus)followed byaboutToPerformRefactoring(Refactoring, RefactoringDescriptor, IProgressMonitor). Implementors can replace this implementation.- Parameters:
descriptor- the refactoring descriptorstatus- the refactoring statusmonitor- the progress monitor to use- Returns:
- the refactoring context, or
nullif this refactoring descriptor represents the unknown refactoring, or if no refactoring contribution is available for this refactoring descriptor - Throws:
CoreException- if an error occurs while creating the refactoring context- Since:
- 3.7
-
dispose
public void dispose()
Description copied from class:WizardTheWizardimplementation of thisIWizardmethod disposes all the pages controls usingDialogPage.dispose. Subclasses should extend this method if the wizard instance maintains addition SWT resource that need to be disposed.
-
getErrorPage
public final org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPage getErrorPage()
Returns the error wizard page.Note: This API must not be called from outside the refactoring framework.
- Returns:
- the error wizard page
- Restriction:
- This method is not intended to be referenced by clients.
-
getNextPage
public IWizardPage getNextPage(IWizardPage page)
Description copied from interface:IWizardReturns the successor of the given page.This method is typically called by a wizard page
- Specified by:
getNextPagein interfaceIWizard- Overrides:
getNextPagein classWizard- Parameters:
page- the page- Returns:
- the next page, or
nullif none
-
getPreviewPage
public final org.eclipse.ltk.internal.ui.refactoring.IPreviewWizardPage getPreviewPage()
Returns the preview wizard page.Note: This API must not be called from outside the refactoring framework.
- Returns:
- the preview wizard page
- Restriction:
- This method is not intended to be referenced by clients.
-
getPreviousPage
public IWizardPage getPreviousPage(IWizardPage page)
Description copied from interface:IWizardReturns the predecessor of the given page.This method is typically called by a wizard page
- Specified by:
getPreviousPagein interfaceIWizard- Overrides:
getPreviousPagein classWizard- Parameters:
page- the page- Returns:
- the previous page, or
nullif none
-
historyPerformed
protected RefactoringStatus historyPerformed(IProgressMonitor monitor)
Hook method which is called when all refactorings of the history have been executed. This method may be called from non-UI threads.This method is guaranteed to be called exactly once during the lifetime of a refactoring history wizard. It is not guaranteed that the user interface has not already been disposed of. The default implementation does nothing and returns a refactoring status of severity
RefactoringStatus.OK.Subclasses may reimplement this method to perform any special processing.
- Parameters:
monitor- the progress monitor to use- Returns:
- a status describing the outcome of the operation
-
performCancel
public boolean performCancel()
Description copied from class:WizardTheWizardimplementation of thisIWizardmethod does nothing and returnstrue. Subclasses should reimplement this method if they need to perform any special cancel processing for their wizard.- Specified by:
performCancelin interfaceIWizard- Overrides:
performCancelin classWizard- Returns:
trueto indicate the cancel request was accepted, andfalseto indicate that the cancel request was refused
-
performFinish
public boolean performFinish()
Description copied from class:WizardSubclasses must implement thisIWizardmethod to perform any special finish processing for their wizard.- Specified by:
performFinishin interfaceIWizard- Specified by:
performFinishin classWizard- Returns:
trueto indicate the finish request was accepted, andfalseto indicate that the finish request was refused
-
performPreviewChange
public final RefactoringStatus performPreviewChange(Change change, Refactoring refactoring)
Performs the change previously displayed in the preview.Note: This API must not be called from outside the refactoring framework.
- Parameters:
change- the change displayed in the previewrefactoring- the associated refactoring- Returns:
- the status of the operation, already handled by the user
-
refactoringPerformed
protected RefactoringStatus refactoringPerformed(Refactoring refactoring, IProgressMonitor monitor)
Hook method which is called when the specified refactoring has been performed, e.g. its change object has been successfully applied to the workspace. The default implementation does nothing and returns a refactoring status of severityRefactoringStatus.OK. This method may be called from non-UI threads.Subclasses may reimplement this method to perform any special processing.
Returning a status of severity
RefactoringStatus.FATALwill terminate the execution of the refactorings.- Parameters:
refactoring- the refactoring which has been performedmonitor- the progress monitor to use- Returns:
- a status describing the outcome of the operation
-
selectPreviewChange
protected boolean selectPreviewChange(Change change)
Hook method which is called for each change before it is displayed in a preview page. The default implementation returnstrue.Subclasses may reimplement this method to perform any special filtering of preview changes.
- Parameters:
change- the change to select- Returns:
trueif the change passes the filter,falseotherwise
-
selectStatusEntry
protected boolean selectStatusEntry(RefactoringStatusEntry entry)
Hook method which is called for each status entry before it is displayed in a wizard page. The default implementation returnstrue.Subclasses may reimplement this method to perform any special filtering of status entries on error pages.
- Parameters:
entry- the status entry to select- Returns:
trueif the status entry passes the filter,falseotherwise
-
setConfiguration
public final void setConfiguration(RefactoringHistoryControlConfiguration configuration)
Sets the refactoring history control configuration.This method must be called before opening the wizard in a dialog.
- Parameters:
configuration- the configuration to set
-
setInput
public final void setInput(RefactoringHistory history)
Sets the refactoring history.This method must be called before opening the wizard in a dialog.
- Parameters:
history- the refactoring history
-
-