Search in sources :

Example 1 with IHistoryView

use of org.eclipse.team.ui.history.IHistoryView in project egit by eclipse.

the class SelectionForViewsTest method before.

@Before
public void before() throws Exception {
    localRepositoryDir = createProjectAndCommitToRepository();
    remoteRepositoryDir = createRemoteRepository(localRepositoryDir);
    URIish uri = new URIish("file:///" + remoteRepositoryDir.getPath());
    File workdir = new File(getTestDirectory(), "ClonedRepo");
    CloneOperation op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0);
    op.run(null);
    clonedRepositoryDir = new File(workdir, Constants.DOT_GIT);
    RepositoryUtil repoUtil = Activator.getDefault().getRepositoryUtil();
    repoUtil.addConfiguredRepository(localRepositoryDir);
    repoUtil.addConfiguredRepository(clonedRepositoryDir);
    // it's bare
    repoUtil.addConfiguredRepository(remoteRepositoryDir);
    stagingView = TestUtil.showView(StagingView.VIEW_ID);
    reflogView = TestUtil.showView(ReflogView.VIEW_ID);
    rebaseInteractiveView = TestUtil.showView(RebaseInteractiveView.VIEW_ID);
    repoView = TestUtil.showView(RepositoriesView.VIEW_ID);
    RepositoriesView repos = (RepositoriesView) repoView.getViewReference().getView(false);
    repos.setReactOnSelection(true);
    historyView = TestUtil.showHistoryView();
    IHistoryView history = (IHistoryView) historyView.getViewReference().getView(false);
    ((GenericHistoryView) history).setLinkingEnabled(true);
    // Ensure that the git history page is active
    Exception[] exception = { null };
    PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
        try {
            history.showHistoryFor(new RepositoryNode(null, lookupRepository(localRepositoryDir)), true);
        } catch (Exception e) {
            exception[0] = e;
        }
    });
    if (exception[0] != null) {
        throw exception[0];
    }
    waitForRefreshes();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) File(java.io.File) IHistoryView(org.eclipse.team.ui.history.IHistoryView) CloneOperation(org.eclipse.egit.core.op.CloneOperation) RepositoryUtil(org.eclipse.egit.core.RepositoryUtil) Before(org.junit.Before)

Example 2 with IHistoryView

use of org.eclipse.team.ui.history.IHistoryView in project egit by eclipse.

the class ShowInHistoryHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    List<RepositoryCommit> commits = getCommits(event);
    if (commits.size() == 1) {
        RepositoryCommit repoCommit = commits.get(0);
        try {
            IHistoryView view = (IHistoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IHistoryView.VIEW_ID);
            view.showHistoryFor(repoCommit);
        } catch (PartInitException e) {
            throw new ExecutionException(e.getMessage(), e);
        }
    }
    return null;
}
Also used : PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) IHistoryView(org.eclipse.team.ui.history.IHistoryView)

Example 3 with IHistoryView

use of org.eclipse.team.ui.history.IHistoryView in project egit by eclipse.

the class GitAdapterFactory method getAdapter.

@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adapterType.isAssignableFrom(IHistoryPageSource.class)) {
        return GitHistoryPageSource.INSTANCE;
    }
    if (IWorkbenchAdapter.class == adapterType) {
        // property page names for git repository tree nodes
        if (adaptableObject instanceof RepositoryTreeNode) {
            return getRepositoryTreeNodeWorkbenchAdapter((RepositoryTreeNode) adaptableObject);
        }
        if (gitModelWorkbenchAdapter == null) {
            gitModelWorkbenchAdapter = new GitModelWorkbenchAdapter();
        }
        return gitModelWorkbenchAdapter;
    }
    if (adaptableObject instanceof IHistoryView && IShowInSource.class == adapterType) {
        IHistoryView historyView = (IHistoryView) adaptableObject;
        IHistoryPage historyPage = historyView.getHistoryPage();
        if (historyPage instanceof GitHistoryPage) {
            return historyPage;
        }
    }
    if (adaptableObject instanceof IURIEditorInput && adapterType == Repository.class) {
        return getRepository((IURIEditorInput) adaptableObject);
    }
    if (adaptableObject instanceof IURIEditorInput && adapterType == File.class) {
        return getFile((IURIEditorInput) adaptableObject);
    }
    if (adaptableObject instanceof GitModelObject && adapterType == ResourceMapping.class) {
        return GitObjectMapping.create((GitModelObject) adaptableObject);
    }
    if (adaptableObject instanceof GitModelObject && adapterType == IResource.class) {
        GitModelObject obj = (GitModelObject) adaptableObject;
        if (obj instanceof GitModelBlob) {
            IResource res = ResourceUtil.getFileForLocation(obj.getLocation(), false);
            if (res == null) {
                // Deleted resource?
                res = getWorkspaceResourceFromGitPath(obj.getLocation());
            }
            return res;
        }
        if (obj instanceof GitModelTree) {
            IResource res = root.getContainerForLocation(obj.getLocation());
            if (res == null) {
                res = root.getFolder(obj.getLocation());
            }
            return res;
        }
    }
    if (adapterType == Repository.class) {
        ResourceMapping m = AdapterUtils.adapt(adaptableObject, ResourceMapping.class);
        if (m != null) {
            return SelectionUtils.getRepository(new StructuredSelection(m));
        }
    }
    return null;
}
Also used : IURIEditorInput(org.eclipse.ui.IURIEditorInput) GitModelTree(org.eclipse.egit.ui.internal.synchronize.model.GitModelTree) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject) IHistoryPage(org.eclipse.team.ui.history.IHistoryPage) Repository(org.eclipse.jgit.lib.Repository) GitHistoryPage(org.eclipse.egit.ui.internal.history.GitHistoryPage) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) GitModelWorkbenchAdapter(org.eclipse.egit.ui.internal.synchronize.mapping.GitModelWorkbenchAdapter) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) IShowInSource(org.eclipse.ui.part.IShowInSource) IHistoryView(org.eclipse.team.ui.history.IHistoryView) File(java.io.File) IResource(org.eclipse.core.resources.IResource) GitModelBlob(org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob)

Example 4 with IHistoryView

use of org.eclipse.team.ui.history.IHistoryView in project egit by eclipse.

the class SelectionForViewsTest method after.

@After
public void after() {
    RepositoriesView repos = (RepositoriesView) repoView.getViewReference().getView(false);
    repos.setReactOnSelection(false);
    IHistoryView history = (IHistoryView) historyView.getViewReference().getView(false);
    ((GenericHistoryView) history).setLinkingEnabled(false);
    stagingView = null;
    reflogView = null;
    rebaseInteractiveView = null;
    historyView = null;
    repoView = null;
}
Also used : GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) IHistoryView(org.eclipse.team.ui.history.IHistoryView) After(org.junit.After)

Example 5 with IHistoryView

use of org.eclipse.team.ui.history.IHistoryView in project egit by eclipse.

the class GitFlowAdapterFactory method getAdapter.

@SuppressWarnings("unchecked")
@Override
public Repository getAdapter(Object adaptableObject, Class adapterType) {
    Repository repository = null;
    if (adaptableObject instanceof IResource) {
        IResource resource = (IResource) adaptableObject;
        repository = getRepository(resource);
    } else if (adaptableObject instanceof IHistoryView) {
        IHistoryView historyView = (IHistoryView) adaptableObject;
        IHistoryPage historyPage = historyView.getHistoryPage();
        Object input = historyPage.getInput();
        if (input instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) input;
            repository = node.getRepository();
        } else if (input instanceof IResource) {
            repository = getRepository((IResource) input);
        }
    } else if (adaptableObject instanceof ISelection) {
        IStructuredSelection structuredSelection = SelectionUtils.getStructuredSelection((ISelection) adaptableObject);
        repository = SelectionUtils.getRepository(structuredSelection);
    } else {
        throw new IllegalStateException();
    }
    return repository;
}
Also used : IHistoryPage(org.eclipse.team.ui.history.IHistoryPage) Repository(org.eclipse.jgit.lib.Repository) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) IHistoryView(org.eclipse.team.ui.history.IHistoryView) IResource(org.eclipse.core.resources.IResource)

Aggregations

IHistoryView (org.eclipse.team.ui.history.IHistoryView)8 Repository (org.eclipse.jgit.lib.Repository)4 File (java.io.File)3 IResource (org.eclipse.core.resources.IResource)3 IHistoryPage (org.eclipse.team.ui.history.IHistoryPage)3 PartInitException (org.eclipse.ui.PartInitException)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 GitHistoryPage (org.eclipse.egit.ui.internal.history.GitHistoryPage)2 HistoryPageInput (org.eclipse.egit.ui.internal.history.HistoryPageInput)2 RepositoriesView (org.eclipse.egit.ui.internal.repository.RepositoriesView)2 RepositoryNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryNode)2 GenericHistoryView (org.eclipse.team.internal.ui.history.GenericHistoryView)2 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)1 RepositoryUtil (org.eclipse.egit.core.RepositoryUtil)1 CloneOperation (org.eclipse.egit.core.op.CloneOperation)1 BlameHistoryPageInput (org.eclipse.egit.ui.internal.blame.BlameOperation.BlameHistoryPageInput)1 RepositoryCommit (org.eclipse.egit.ui.internal.commit.RepositoryCommit)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