use of org.eclipse.egit.ui.internal.dialogs.RebaseTargetSelectionDialog in project egit by eclipse.
the class RebaseCurrentRefCommand method setRef.
private void setRef(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = getCurrentSelectionChecked(event);
if (currentSelection instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) currentSelection;
Object selected = selection.getFirstElement();
ref = getRef(selected);
} else
ref = null;
Object context = event.getApplicationContext();
if (!(context instanceof IEvaluationContext))
return;
final Repository repository = SelectionUtils.getRepository((IEvaluationContext) context);
if (repository == null)
return;
BasicConfigurationDialog.show(repository);
String currentFullBranch = getFullBranch(repository);
if (ref != null && ref.getName().equals(currentFullBranch))
ref = null;
if (ref == null) {
RebaseTargetSelectionDialog rebaseTargetSelectionDialog = new RebaseTargetSelectionDialog(getShell(event), repository);
if (rebaseTargetSelectionDialog.open() == IDialogConstants.OK_ID) {
String refName = rebaseTargetSelectionDialog.getRefName();
try {
ref = repository.findRef(refName);
} catch (IOException e) {
throw new ExecutionException(e.getMessage(), e);
}
interactive = rebaseTargetSelectionDialog.isInteractive();
preserveMerges = rebaseTargetSelectionDialog.isPreserveMerges();
} else {
return;
}
} else {
String branchName = Repository.shortenRefName(currentFullBranch);
Config cfg = repository.getConfig();
BranchRebaseMode rebase = cfg.getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
preserveMerges = rebase == BranchRebaseMode.PRESERVE;
interactive = rebase == BranchRebaseMode.INTERACTIVE;
}
jobname = NLS.bind(UIText.RebaseCurrentRefCommand_RebasingCurrentJobName, Repository.shortenRefName(currentFullBranch), ref.getName());
}
Aggregations