Package org.eclipse.compare.patch
Class ApplyPatchOperation
java.lang.Object
org.eclipse.compare.patch.ApplyPatchOperation
- All Implemented Interfaces:
- Runnable
An operation that provides an interface to the Apply Patch Wizard. Users specify
 the input in terms of an 
IStorage (note: input must be in unified diff
 format), an IResource target to apply the patch to and can provide CompareConfiguration
 elements to supply the label and images used on the preview page and hunk merge page. Finally, the
 user can also supply a title and image to override the default ones provided by the Apply Patch Wizard.
 Note that the Apply Patch Wizard does not require any particular set of inputs, and in the absence of
 any user supplied values, it will work in default mode.- Since:
- 3.3
- 
Constructor SummaryConstructorsConstructorDescriptionApplyPatchOperation(IWorkbenchPart targetPart, IResource resource) Create an operation for the given part and resource.ApplyPatchOperation(IWorkbenchPart part, IStorage patch, IResource target, CompareConfiguration configuration) Creates a new ApplyPatchOperation with the supplied compare configuration, patch and target.
- 
Method SummaryModifier and TypeMethodDescriptionprotected ShellgetShell()Return the parent shell to be used when the wizard is opened.static booleanReturn whether the given storage contains a patch.voidOpen the Apply Patch wizard using the values associated with this operation.static IFilePatch[]parsePatch(IStorage storage) Parse the given patch and return the set of file patches that it contains.voidrun()protected voidThis method will save all dirty editors.voidsetPatchWizardImageDescriptor(ImageDescriptor descriptor) Sets the image descriptor to use in the patch wizard.voidsetPatchWizardTitle(String title) Sets the title of the patch wizard.
- 
Constructor Details- 
ApplyPatchOperationpublic ApplyPatchOperation(IWorkbenchPart part, IStorage patch, IResource target, CompareConfiguration configuration) Creates a new ApplyPatchOperation with the supplied compare configuration, patch and target. The behaviour of the Apply Patch wizard is controlled by the number of parameters supplied:- If a patch is supplied, the initial input page is skipped. If a patch is not supplied the wizard will open on the input page.
- If the patch is a workspace patch, the target selection page is skipped and the preview page is displayed.
- If the patch is not a workspace patch and the target is specified, the target page is still shown with the target selected.
 - Parameters:
- part- an IWorkbenchPart or- null
- patch- an IStorage containing a patch in unified diff format or- null
- target- an IResource which the patch is to be applied to or- null
- configuration- a CompareConfiguration supplying the labels and images for the preview patch page
 
- 
ApplyPatchOperationCreate an operation for the given part and resource. This method is a convenience method that callsApplyPatchOperation(IWorkbenchPart, IStorage, IResource, CompareConfiguration)with appropriate defaults for the other parameters.- Parameters:
- targetPart- an IResource which the patch is to be applied to or- null
- resource- an IResource which the patch is to be applied to or- null
- See Also:
 
 
- 
- 
Method Details- 
isPatchReturn whether the given storage contains a patch.- Parameters:
- storage- the storage
- Returns:
- whether the given storage contains a patch
- Throws:
- CoreException- if an error occurs reading the contents from the storage
 
- 
parsePatchParse the given patch and return the set of file patches that it contains.- Parameters:
- storage- the storage that contains the patch
- Returns:
- the set of file patches that the storage contains
- Throws:
- CoreException- if an error occurs reading the contents from the storage
 
- 
openWizardpublic void openWizard()Open the Apply Patch wizard using the values associated with this operation. This method must be called from the UI thread.
- 
getShellReturn the parent shell to be used when the wizard is opened. By default, the site of the part is used to get the shell. Subclasses may override.- Returns:
- the parent shell to be used when the wizard is opened
 
- 
saveAllEditorsprotected void saveAllEditors()This method will save all dirty editors. It will prompt the user if the Compare preference to save dirty editors before viewing a patch isfalse. Clients can use this or provide their own implementation.
- 
setPatchWizardTitleSets the title of the patch wizard. Needs to be set beforeopenWizard()is called.- Parameters:
- title- a string to display in the title bar
 
- 
setPatchWizardImageDescriptorSets the image descriptor to use in the patch wizard. Needs to be set beforeopenWizard()is called.- Parameters:
- descriptor- an image descriptor
 
- 
runpublic void run()
 
-