use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.
the class SquashHandler method isEnabled.
@Override
public boolean isEnabled() {
GitHistoryPage page = getPage();
if (page == null)
return false;
IStructuredSelection selection = getSelection(page);
if (selection.isEmpty())
return false;
Repository repository = getRepository(page);
if (repository.getRepositoryState() != RepositoryState.SAFE)
return false;
List elements = selection.toList();
int parentsNotSelected = 0;
for (Object element : elements) {
RevCommit commit = (RevCommit) element;
// one parent (this includes the root commit)
if (commit.getParentCount() != 1)
return false;
RevCommit parentCommit = commit.getParent(0);
if (!elements.contains(parentCommit))
parentsNotSelected++;
// contiguous selection of commits
if (parentsNotSelected > 1)
return false;
}
// has not been selected
if (parentsNotSelected != 1)
return false;
return true;
}
use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.
the class AbstractHistoryCommandHandler method getPageFromPart.
private GitHistoryPage getPageFromPart(IWorkbenchPart part) {
if (!(part instanceof IHistoryView))
return null;
IHistoryView view = (IHistoryView) part;
IHistoryPage page = view.getHistoryPage();
if (page instanceof GitHistoryPage)
return (GitHistoryPage) page;
return null;
}
Aggregations