Search in sources :

Example 1 with BranchOperationUI

use of org.eclipse.egit.ui.internal.branch.BranchOperationUI in project egit by eclipse.

the class CheckoutCommand method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final RepositoryTreeNode node = getSelectedNodes(event).get(0);
    if (!(node.getObject() instanceof Ref))
        return null;
    final Ref ref = (Ref) node.getObject();
    Repository repo = node.getRepository();
    BranchOperationUI op = BranchOperationUI.checkout(repo, ref.getName());
    op.start();
    return null;
}
Also used : Ref(org.eclipse.jgit.lib.Ref) Repository(org.eclipse.jgit.lib.Repository) BranchOperationUI(org.eclipse.egit.ui.internal.branch.BranchOperationUI) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)

Example 2 with BranchOperationUI

use of org.eclipse.egit.ui.internal.branch.BranchOperationUI in project egit by eclipse.

the class CheckoutHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Repository repo = getRepository(event);
    RevCommit commit = getSelectedCommit(event, repo);
    if (commit != null) {
        final BranchOperationUI op = BranchOperationUI.checkout(repo, commit.name());
        if (op != null)
            op.start();
    }
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) BranchOperationUI(org.eclipse.egit.ui.internal.branch.BranchOperationUI) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 3 with BranchOperationUI

use of org.eclipse.egit.ui.internal.branch.BranchOperationUI in project egit by eclipse.

the class CheckoutCommitHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ObjectId commitId = getSelectedCommitId(event);
    Repository repo = getRepository(event);
    final BranchOperationUI op;
    List<Ref> nodes;
    try {
        nodes = getBranchesOfCommit(getSelection(event), repo, true);
    } catch (IOException e) {
        throw new ExecutionException(UIText.AbstractHistoryCommitHandler_cantGetBranches, e);
    }
    if (nodes.isEmpty()) {
        op = BranchOperationUI.checkout(repo, commitId.name());
    } else if (nodes.size() == 1) {
        op = BranchOperationUI.checkout(repo, nodes.get(0).getName());
    } else {
        BranchSelectionDialog<Ref> dlg = new BranchSelectionDialog<>(HandlerUtil.getActiveShellChecked(event), nodes, UIText.CheckoutHandler_SelectBranchTitle, UIText.CheckoutHandler_SelectBranchMessage, SWT.SINGLE);
        if (dlg.open() == Window.OK) {
            op = BranchOperationUI.checkout(repo, dlg.getSelectedNode().getName());
        } else {
            op = null;
        }
    }
    if (op == null)
        return null;
    op.start();
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) BranchOperationUI(org.eclipse.egit.ui.internal.branch.BranchOperationUI) Ref(org.eclipse.jgit.lib.Ref) ObjectId(org.eclipse.jgit.lib.ObjectId) BranchSelectionDialog(org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

BranchOperationUI (org.eclipse.egit.ui.internal.branch.BranchOperationUI)3 Repository (org.eclipse.jgit.lib.Repository)3 Ref (org.eclipse.jgit.lib.Ref)2 IOException (java.io.IOException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 BranchSelectionDialog (org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1