use of com.intellij.ide.projectView.impl.ProjectViewToolWindowFactory in project intellij-community by JetBrains.
the class NavigateFromSourceTest method testAutoscrollFromSourceOnOpening.
public void testAutoscrollFromSourceOnOpening() throws Exception {
final PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(getPackageDirectory());
PsiClass psiClass = classes[0];
FileEditorManager.getInstance(getProject()).openFile(psiClass.getContainingFile().getVirtualFile(), true);
ProjectView projectView = ProjectView.getInstance(getProject());
((ProjectViewImpl) projectView).setAutoscrollFromSource(true, ProjectViewPane.ID);
ToolWindow toolWindow = ToolWindowManager.getInstance(getProject()).getToolWindow(ToolWindowId.PROJECT_VIEW);
new ProjectViewToolWindowFactory().createToolWindowContent(getProject(), toolWindow);
projectView.changeView(ProjectViewPane.ID);
UIUtil.dispatchAllInvocationEvents();
JComponent component = ((ProjectViewImpl) projectView).getComponent();
DataContext context = DataManager.getInstance().getDataContext(component);
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
assertEquals("Class1.java", ((PsiJavaFile) element).getName());
}
Aggregations