Search in sources :

Example 1 with BranchRenameDialog

use of org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog in project egit by eclipse.

the class RenameBranchOnCommitHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Repository repository = getRepository(event);
    if (repository == null)
        return null;
    List<Ref> branchesOfCommit = getBranchesOfCommit(getSelection(event));
    // this should have been checked by isEnabled()
    if (branchesOfCommit.isEmpty())
        return null;
    final Shell shell = getPart(event).getSite().getShell();
    final Ref branchToRename;
    if (branchesOfCommit.size() > 1) {
        BranchSelectionDialog<Ref> dlg = new BranchSelectionDialog<>(shell, branchesOfCommit, UIText.RenameBranchOnCommitHandler_SelectBranchDialogTitle, UIText.RenameBranchOnCommitHandler_SelectBranchDialogMessage, SWT.SINGLE);
        if (dlg.open() != Window.OK)
            return null;
        branchToRename = dlg.getSelectedNode();
    } else
        branchToRename = branchesOfCommit.get(0);
    new BranchRenameDialog(shell, repository, branchToRename).open();
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) Ref(org.eclipse.jgit.lib.Ref) Shell(org.eclipse.swt.widgets.Shell) BranchRenameDialog(org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog) BranchSelectionDialog(org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog)

Example 2 with BranchRenameDialog

use of org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog in project egit by eclipse.

the class RenameBranchCommand method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final List<RefNode> nodes = getSelectedNodes(event);
    RefNode refNode = nodes.get(0);
    Shell shell = getShell(event);
    new BranchRenameDialog(shell, refNode.getRepository(), refNode.getObject()).open();
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) BranchRenameDialog(org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode)

Aggregations

BranchRenameDialog (org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog)2 Shell (org.eclipse.swt.widgets.Shell)2 BranchSelectionDialog (org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog)1 RefNode (org.eclipse.egit.ui.internal.repository.tree.RefNode)1 Ref (org.eclipse.jgit.lib.Ref)1 Repository (org.eclipse.jgit.lib.Repository)1