Search in sources :

Example 11 with GitHistoryPage

use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.

the class PushCommitHandler method isEnabled.

@Override
public boolean isEnabled() {
    GitHistoryPage page = getPage();
    if (page == null)
        return false;
    IStructuredSelection sel = getSelection(page);
    return sel.size() == 1 && sel.getFirstElement() instanceof RevCommit;
}
Also used : GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 12 with GitHistoryPage

use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.

the class RewordHandler method isEnabled.

@Override
public boolean isEnabled() {
    GitHistoryPage page = getPage();
    if (page == null)
        return false;
    IStructuredSelection selection = getSelection(page);
    if (selection.size() != 1)
        return false;
    Repository repository = getRepository(page);
    if (repository.getRepositoryState() != RepositoryState.SAFE)
        return false;
    RevCommit commit = (RevCommit) selection.getFirstElement();
    return (commit.getParentCount() == 1);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 13 with GitHistoryPage

use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.

the class SetQuickdiffBaselineHandler method isEnabled.

@Override
public boolean isEnabled() {
    GitHistoryPage page = getPage();
    if (page == null)
        return false;
    IStructuredSelection selection = getSelection(page);
    return selection.size() == 1;
}
Also used : GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 14 with GitHistoryPage

use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.

the class ShowBlameHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    GitHistoryPage page = getPage(event);
    if (page == null) {
        return null;
    }
    Object input = page.getInputInternal().getSingleItem();
    if (input == null) {
        return null;
    }
    Repository repo = getRepository(event);
    if (repo == null) {
        return null;
    }
    String path = getPath(repo, page);
    if (path == null) {
        return null;
    }
    RevCommit commit = getSelectedCommit(event);
    if (commit == null) {
        return null;
    }
    try {
        IFileRevision revision = CompareUtils.getFileRevision(path, commit, repo, null);
        if (revision instanceof CommitFileRevision) {
            BlameOperation op = new BlameOperation((CommitFileRevision) revision, HandlerUtil.getActiveShell(event), page.getSite().getPage());
            JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
        }
    } catch (IOException e) {
        Activator.showError(UIText.ShowBlameHandler_errorMessage, e);
    }
    return null;
}
Also used : CommitFileRevision(org.eclipse.egit.core.internal.storage.CommitFileRevision) Repository(org.eclipse.jgit.lib.Repository) GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage) BlameOperation(org.eclipse.egit.ui.internal.blame.BlameOperation) IFileRevision(org.eclipse.team.core.history.IFileRevision) IOException(java.io.IOException) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 15 with GitHistoryPage

use of org.eclipse.egit.ui.internal.history.GitHistoryPage in project egit by eclipse.

the class ShowVersionsHandler method isEnabled.

@Override
public boolean isEnabled() {
    GitHistoryPage page = getPage();
    if (page == null)
        return false;
    int size = getSelection(page).size();
    if (size == 0)
        return false;
    return page.getInputInternal().isSingleFile();
}
Also used : GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage)

Aggregations

GitHistoryPage (org.eclipse.egit.ui.internal.history.GitHistoryPage)17 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 RevCommit (org.eclipse.jgit.revwalk.RevCommit)9 Repository (org.eclipse.jgit.lib.Repository)6 IOException (java.io.IOException)2 Ref (org.eclipse.jgit.lib.Ref)2 IHistoryPage (org.eclipse.team.ui.history.IHistoryPage)2 IHistoryView (org.eclipse.team.ui.history.IHistoryView)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IResource (org.eclipse.core.resources.IResource)1 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)1 CommitFileRevision (org.eclipse.egit.core.internal.storage.CommitFileRevision)1 BlameOperation (org.eclipse.egit.ui.internal.blame.BlameOperation)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 GitModelWorkbenchAdapter (org.eclipse.egit.ui.internal.synchronize.mapping.GitModelWorkbenchAdapter)1 GitModelBlob (org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob)1 GitModelObject (org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)1 GitModelTree (org.eclipse.egit.ui.internal.synchronize.model.GitModelTree)1