use of org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan in project egit by eclipse.
the class AbstractRebaseCommandHandler method startRebaseJob.
private void startRebaseJob(final RebaseOperation rebase, final Repository repository, final RebaseCommand.Operation operation) {
JobUtil.scheduleUserWorkspaceJob(rebase, jobname, JobFamilies.REBASE, new JobChangeAdapter() {
@Override
public void aboutToRun(IJobChangeEvent event) {
// that repository state is safe
if (operation == Operation.BEGIN && !repository.getRepositoryState().equals(RepositoryState.SAFE)) {
throw new IllegalStateException(// $NON-NLS-1$
"Can't start rebase if repository state isn't SAFE");
}
super.aboutToRun(event);
}
@Override
public void done(IJobChangeEvent cevent) {
finishRebaseInteractive();
IStatus result = cevent.getJob().getResult();
if (result == null) {
return;
}
// abort and show exception
if (operation == Operation.BEGIN && result.getSeverity() == IStatus.ERROR) {
handleBeginError(repository, result);
} else if (result.getSeverity() == IStatus.CANCEL)
Display.getDefault().asyncExec(new Runnable() {
@Override
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.AbstractRebaseCommand_DialogTitle, dialogMessage);
}
});
else if (result.isOK()) {
if (rebase.getResult().getStatus() == Status.UNCOMMITTED_CHANGES) {
handleUncommittedChanges(repository, rebase.getResult().getUncommittedChanges());
} else {
RebaseResultDialog.show(rebase.getResult(), repository);
if (operation == Operation.ABORT)
setAmending(false, false);
if (rebase.getResult().getStatus() == Status.EDIT)
setAmending(true, true);
}
}
}
private void setAmending(final boolean amending, final boolean openStagingView) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
IViewPart view;
if (openStagingView)
view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StagingView.VIEW_ID);
else
view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(StagingView.VIEW_ID);
if (view instanceof StagingView) {
final StagingView sv = (StagingView) view;
sv.reload(repository);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
sv.setAmending(amending);
}
});
}
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
}
});
}
private void finishRebaseInteractive() {
RebaseInteractivePlan plan = RebaseInteractivePlan.getPlan(repository);
if (plan != null && !plan.isRebasingInteractive())
plan.dispose();
}
});
}
Aggregations