Search in sources :

Example 6 with CreateBranchWizard

use of org.eclipse.egit.ui.internal.repository.CreateBranchWizard in project egit by eclipse.

the class CreateBranchCommand method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final RepositoryTreeNode node = getSelectedNodes(event).get(0);
    if (node.getType() == RepositoryTreeNodeType.ADDITIONALREF) {
        Ref ref = (Ref) node.getObject();
        try (RevWalk rw = new RevWalk(node.getRepository())) {
            RevCommit baseCommit = rw.parseCommit(ref.getLeaf().getObjectId());
            WizardDialog dlg = new WizardDialog(getShell(event), new CreateBranchWizard(node.getRepository(), baseCommit.name()));
            dlg.setHelpAvailable(false);
            dlg.open();
        } catch (IOException e) {
            Activator.handleError(e.getMessage(), e, true);
        }
        return null;
    }
    String base = null;
    if (node.getObject() instanceof Ref)
        base = ((Ref) node.getObject()).getName();
    new WizardDialog(getShell(event), new CreateBranchWizard(node.getRepository(), base)).open();
    return null;
}
Also used : Ref(org.eclipse.jgit.lib.Ref) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) WizardDialog(org.eclipse.jface.wizard.WizardDialog) RevCommit(org.eclipse.jgit.revwalk.RevCommit) CreateBranchWizard(org.eclipse.egit.ui.internal.repository.CreateBranchWizard)

Aggregations

CreateBranchWizard (org.eclipse.egit.ui.internal.repository.CreateBranchWizard)6 WizardDialog (org.eclipse.jface.wizard.WizardDialog)6 Ref (org.eclipse.jgit.lib.Ref)4 IOException (java.io.IOException)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 TreeMap (java.util.TreeMap)1 RepositoryCommit (org.eclipse.egit.ui.internal.commit.RepositoryCommit)1 CheckoutDialog (org.eclipse.egit.ui.internal.dialogs.CheckoutDialog)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IWizard (org.eclipse.jface.wizard.IWizard)1 CheckoutEntry (org.eclipse.jgit.lib.CheckoutEntry)1 ReflogEntry (org.eclipse.jgit.lib.ReflogEntry)1 ReflogReader (org.eclipse.jgit.lib.ReflogReader)1 Repository (org.eclipse.jgit.lib.Repository)1 PlotCommit (org.eclipse.jgit.revplot.PlotCommit)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1