Search in sources :

Example 6 with HistoryPageInput

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

the class RepositoriesView method getShowInContext.

@Override
public ShowInContext getShowInContext() {
    IStructuredSelection selection = (IStructuredSelection) getCommonViewer().getSelection();
    List<Object> elements = getShowInElements(selection);
    // GenericHistoryView only shows a selection of a single resource (see
    // bug 392949), so prepare our own history page input which can contain
    // multiple files to support showing more than one file in history.
    // It's also necessary for a single file that is outside of the
    // workspace (and as such is not an IResource).
    HistoryPageInput historyPageInput = getHistoryPageInput(selection);
    return new ShowInContext(historyPageInput, new StructuredSelection(elements));
}
Also used : HistoryPageInput(org.eclipse.egit.ui.internal.history.HistoryPageInput) ShowInContext(org.eclipse.ui.part.ShowInContext) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with HistoryPageInput

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

the class BlameInformationControl method showCommitInHistory.

private void showCommitInHistory() {
    getShell().dispose();
    IHistoryView part;
    try {
        part = (IHistoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IHistoryView.VIEW_ID);
    } catch (PartInitException e) {
        Activator.logError(e.getLocalizedMessage(), e);
        return;
    }
    if (part == null)
        return;
    Repository repository = revision.getRepository();
    if (!repository.isBare()) {
        String sourcePath = revision.getSourcePath();
        File file = new File(repository.getWorkTree(), sourcePath);
        BlameHistoryPageInput input = new BlameHistoryPageInput(repository, revision.getCommit(), file);
        part.showHistoryFor(input);
    } else {
        HistoryPageInput input = new BlameHistoryPageInput(repository, revision.getCommit());
        part.showHistoryFor(input);
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) BlameHistoryPageInput(org.eclipse.egit.ui.internal.blame.BlameOperation.BlameHistoryPageInput) HistoryPageInput(org.eclipse.egit.ui.internal.history.HistoryPageInput) PartInitException(org.eclipse.ui.PartInitException) IHistoryView(org.eclipse.team.ui.history.IHistoryView) File(java.io.File) BlameHistoryPageInput(org.eclipse.egit.ui.internal.blame.BlameOperation.BlameHistoryPageInput)

Example 8 with HistoryPageInput

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

the class ShowHistoryActionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Repository repo = getRepository(true, event);
    // assert all resources map to the same repository
    if (repo == null) {
        return null;
    }
    try {
        IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
        if (activeWorkbenchWindow != null) {
            IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
            if (page != null) {
                IResource[] resources = getSelectedResources(event);
                IHistoryView view = (IHistoryView) page.showView(IHistoryView.VIEW_ID);
                if (resources.length == 1) {
                    view.showHistoryFor(resources[0]);
                    return null;
                }
                HistoryPageInput list = new HistoryPageInput(repo, resources);
                view.showHistoryFor(list);
            }
        }
    } catch (PartInitException e) {
        throw new ExecutionException(e.getMessage(), e);
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Repository(org.eclipse.jgit.lib.Repository) HistoryPageInput(org.eclipse.egit.ui.internal.history.HistoryPageInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException) IHistoryView(org.eclipse.team.ui.history.IHistoryView) IResource(org.eclipse.core.resources.IResource)

Aggregations

HistoryPageInput (org.eclipse.egit.ui.internal.history.HistoryPageInput)8 Repository (org.eclipse.jgit.lib.Repository)7 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 PartInitException (org.eclipse.ui.PartInitException)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IHistoryView (org.eclipse.team.ui.history.IHistoryView)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IRepositoryCommit (org.eclipse.egit.core.internal.IRepositoryCommit)1 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)1 BlameHistoryPageInput (org.eclipse.egit.ui.internal.blame.BlameOperation.BlameHistoryPageInput)1 CompareTreeView (org.eclipse.egit.ui.internal.dialogs.CompareTreeView)1 FileNode (org.eclipse.egit.ui.internal.repository.tree.FileNode)1 FolderNode (org.eclipse.egit.ui.internal.repository.tree.FolderNode)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Nullable (org.eclipse.jgit.annotations.Nullable)1