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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations