else
return null;
}
String jobname = NLS.bind(UIText.MergeAction_JobNameMerge, refName);
final MergeOperation op = new MergeOperation(repository, refName);
Job job = new WorkspaceJob(jobname) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
op.execute(monitor);
} catch (final CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setRule(op.getSchedulingRule());
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent cevent) {
IStatus result = cevent.getJob().getResult();
if (result.getSeverity() == IStatus.CANCEL)
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// don't use getShell(event) here since
// the active shell has changed since the
// execution has been triggered.
Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
MessageDialog
.openInformation(
shell,
UIText.MergeAction_MergeCanceledTitle,
UIText.MergeAction_MergeCanceledMessage);
}
});
else if (!result.isOK())
Activator.handleError(result.getMessage(), result
.getException(), true);
else
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
MergeResultDialog.getDialog(shell, repository, op
.getResult()).open();
}
});
}
});
job.schedule();
return null;
}