Search in sources :

Example 1 with RebaseTargetSelectionDialog

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());
}
Also used : RebaseTargetSelectionDialog(org.eclipse.egit.ui.internal.dialogs.RebaseTargetSelectionDialog) BranchRebaseMode(org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode) Repository(org.eclipse.jgit.lib.Repository) Config(org.eclipse.jgit.lib.Config) ISelection(org.eclipse.jface.viewers.ISelection) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

IOException (java.io.IOException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)1 RebaseTargetSelectionDialog (org.eclipse.egit.ui.internal.dialogs.RebaseTargetSelectionDialog)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 BranchRebaseMode (org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode)1 Config (org.eclipse.jgit.lib.Config)1 Repository (org.eclipse.jgit.lib.Repository)1