use of org.eclipse.egit.ui.internal.repository.SelectResetTypePage in project egit by eclipse.
the class ResetCommand method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final RepositoryTreeNode<?> node = getSelectedNodes(event).get(0);
final String currentBranch;
try {
currentBranch = node.getRepository().getFullBranch();
} catch (IOException e1) {
throw new ExecutionException(e1.getMessage(), e1);
}
if (!(node.getObject() instanceof Ref)) {
// allowing reset to any commit
return new ResetActionHandler().execute(event);
}
// If a ref is selected in the repository view, only reset to
// that ref will be possible.
final Ref targetBranch = (Ref) node.getObject();
final String repoName = Activator.getDefault().getRepositoryUtil().getRepositoryName(node.getRepository());
Wizard wiz = new Wizard() {
@Override
public void addPages() {
addPage(new SelectResetTypePage(repoName, node.getRepository(), currentBranch, targetBranch.getName()));
setWindowTitle(UIText.ResetCommand_WizardTitle);
}
@Override
public boolean performFinish() {
final ResetType resetType = ((SelectResetTypePage) getPages()[0]).getResetType();
ResetMenu.performReset(getShell(), node.getRepository(), targetBranch.getObjectId(), resetType);
return true;
}
};
WizardDialog dlg = new WizardDialog(getShell(event), wiz);
dlg.setHelpAvailable(false);
dlg.open();
return null;
}
Aggregations