Search in sources :

Example 1 with ProjectViewToolWindowFactory

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());
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) DataContext(com.intellij.openapi.actionSystem.DataContext) ProjectView(com.intellij.ide.projectView.ProjectView) ProjectViewImpl(com.intellij.ide.projectView.impl.ProjectViewImpl) ProjectViewToolWindowFactory(com.intellij.ide.projectView.impl.ProjectViewToolWindowFactory)

Aggregations

ProjectView (com.intellij.ide.projectView.ProjectView)1 ProjectViewImpl (com.intellij.ide.projectView.impl.ProjectViewImpl)1 ProjectViewToolWindowFactory (com.intellij.ide.projectView.impl.ProjectViewToolWindowFactory)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1