Search in sources :

Example 1 with ApplyPatchOperation

use of org.eclipse.compare.patch.ApplyPatchOperation in project egit by eclipse.

the class ApplyPatchActionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResource[] resources = getSelectedResources(event);
    IResource resource = null;
    if (resources.length > 0) {
        resource = resources[0];
    }
    boolean isPatch = false;
    if (resource instanceof IFile) {
        try {
            isPatch = ApplyPatchOperation.isPatch((IFile) resource);
        } catch (CoreException e) {
            Activator.handleError(e.getMessage(), e, false);
        }
    }
    final ApplyPatchOperation op;
    if (isPatch) {
        op = new ApplyPatchOperation(HandlerUtil.getActivePart(event), (IFile) resource, null, new CompareConfiguration());
    } else {
        op = new ApplyPatchOperation(HandlerUtil.getActivePart(event), resource);
    }
    BusyIndicator.showWhile(Display.getDefault(), op);
    return null;
}
Also used : ApplyPatchOperation(org.eclipse.compare.patch.ApplyPatchOperation) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) CompareConfiguration(org.eclipse.compare.CompareConfiguration) IResource(org.eclipse.core.resources.IResource)

Aggregations

CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 ApplyPatchOperation (org.eclipse.compare.patch.ApplyPatchOperation)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1