Search in sources :

Example 1 with ClassesTreeStructureProvider

use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.

the class ProjectViewUpdatingTest method testShowClassMembers.

public void testShowClassMembers() throws Exception {
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    final JTree tree = pane.getTree();
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: showClassMembers\n" + getRootFiles() + " +External Libraries\n");
    myStructure.setShowMembers(true);
    PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
    PsiClass aClass = classFile.getClasses()[0];
    PsiFile containingFile = aClass.getContainingFile();
    pane.select(aClass, containingFile.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     -[Class1]\n" + "      +InnerClass\n" + "      getValue():int\n" + "      myField1:boolean\n" + "      myField2:boolean\n" + "     +Class2\n" + getRootFiles() + " +External Libraries\n", true);
    final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile());
    final int caretPosition = document.getText().indexOf("public class InnerClass") - 1;
    ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(myProject, () -> document.insertString(caretPosition, "\n"), "typing", null));
    PsiDocumentManager.getInstance(myProject).commitDocument(document);
    PlatformTestUtil.waitForAlarm(600);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     -[Class1]\n" + "      +InnerClass\n" + "      getValue():int\n" + "      myField1:boolean\n" + "      myField2:boolean\n" + "     +Class2\n" + getRootFiles() + " +External Libraries\n", true);
    classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
    aClass = classFile.getClasses()[0];
    final PsiField lastField = aClass.getFields()[1];
    pane.select(lastField, containingFile.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     -Class1\n" + "      +InnerClass\n" + "      getValue():int\n" + "      myField1:boolean\n" + "      [myField2:boolean]\n" + "     +Class2\n" + getRootFiles() + " +External Libraries\n", true);
    CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
        try {
            assertEquals("myField2", lastField.getName());
            lastField.setName("_firstField");
        } catch (IncorrectOperationException e) {
            fail(e.getMessage());
        }
    }), null, null);
    PlatformTestUtil.waitForAlarm(600);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     -Class1\n" + "      +InnerClass\n" + "      getValue():int\n" + "      [_firstField:boolean]\n" + "      myField1:boolean\n" + "     +Class2\n" + getRootFiles() + " +External Libraries\n", true);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider) IncorrectOperationException(com.intellij.util.IncorrectOperationException) FormMergerTreeStructureProvider(com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider) Document(com.intellij.openapi.editor.Document)

Example 2 with ClassesTreeStructureProvider

use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.

the class ProjectViewUpdatingTest method testAnnoyingScrolling.

public void testAnnoyingScrolling() throws Exception {
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject));
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    final JTree tree = pane.getTree();
    myStructure.setShowMembers(true);
    PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
    PsiClass aClass = classFile.getClasses()[0];
    PsiFile containingFile = aClass.getContainingFile();
    PsiDirectory directory = containingFile.getContainingDirectory();
    pane.select(aClass, containingFile.getVirtualFile(), true);
    Point viewPosition = ((JViewport) tree.getParent()).getViewPosition();
    for (int i = 0; i < 100; i++) {
        JavaDirectoryService.getInstance().createClass(directory, "A" + i);
    }
    PlatformTestUtil.waitForAlarm(600);
    Point viewPositionAfter = ((JViewport) tree.getParent()).getViewPosition();
    assertEquals(viewPosition, viewPositionAfter);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider)

Example 3 with ClassesTreeStructureProvider

use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.

the class ProjectViewUpdatingTest method testUpdateProjectView.

public void testUpdateProjectView() throws Exception {
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    final JTree tree = pane.getTree();
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
    final PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Form1.java");
    final PsiClass aClass = classFile.getClasses()[0];
    final PsiFile containingFile = aClass.getContainingFile();
    pane.select(aClass, containingFile.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     Form2.form\n" + "     -Form:Form1\n" + "      [Form1]\n" + "      Form1.form\n" + getRootFiles() + " +External Libraries\n", true);
    CommandProcessor.getInstance().executeCommand(myProject, () -> new RenameProcessor(myProject, aClass, "Form1_renamed", false, false).run(), null, null);
    PlatformTestUtil.waitForAlarm(600);
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     Form2.form\n" + "     -Form:Form1_renamed\n" + "      Form1.form\n" + "      [Form1_renamed]\n" + getRootFiles() + " +External Libraries\n", true);
    TreeUtil.collapseAll(pane.getTree(), -1);
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
    final PsiClass aClass2 = JavaDirectoryService.getInstance().createClass(getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1"), "Class6");
    PlatformTestUtil.waitForAlarm(600);
    final PsiFile containingFile2 = aClass2.getContainingFile();
    pane.select(aClass2, containingFile2.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     [Class6]\n" + "     Form2.form\n" + "     +Form:Form1_renamed\n" + getRootFiles() + " +External Libraries\n", true);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) FormMergerTreeStructureProvider(com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider)

Example 4 with ClassesTreeStructureProvider

use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.

the class FormMergerTreeStructureProviderTest method testStandardProvidersForm1.

public void testStandardProvidersForm1() {
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" + " PsiClass:Class1\n" + " PsiJavaFile:Class2.java\n" + "  PsiClass:Class2\n" + "  PsiClass:Class3\n" + " PsiJavaFile:Class4.java\n" + " PsiFile(plain text):Form2.form\n" + " Form:Form1\n" + "  PsiClass:Form1\n" + "  PsiFile(plain text):Form1.form\n");
    PsiFile psiFile = getPackageDirectory().findFile("Form1.form");
    VirtualFile virtualFile = psiFile.getContainingFile().getVirtualFile();
    myStructure.checkNavigateFromSourceBehaviour(psiFile, virtualFile, pane);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider) PsiFile(com.intellij.psi.PsiFile)

Example 5 with ClassesTreeStructureProvider

use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.

the class FormMergerTreeStructureProviderTest method testStandardProviders.

public void testStandardProviders() {
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" + " PsiClass:Class1\n" + " PsiJavaFile:Class2.java\n" + "  PsiClass:Class2\n" + "  PsiClass:Class3\n" + " PsiJavaFile:Class4.java\n" + " PsiFile(plain text):Form2.form\n" + " Form:Form1\n" + "  PsiClass:Form1\n" + "  PsiFile(plain text):Form1.form\n");
    PsiClass psiClass = ((PsiJavaFile) getPackageDirectory().findFile("Form1.java")).getClasses()[0];
    myStructure.checkNavigateFromSourceBehaviour(psiClass, psiClass.getContainingFile().getVirtualFile(), pane);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider) PsiClass(com.intellij.psi.PsiClass)

Aggregations

AbstractProjectViewPSIPane (com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane)5 ClassesTreeStructureProvider (com.intellij.ide.projectView.impl.ClassesTreeStructureProvider)5 FormMergerTreeStructureProvider (com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider)2 Document (com.intellij.openapi.editor.Document)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 PsiFile (com.intellij.psi.PsiFile)1 RenameProcessor (com.intellij.refactoring.rename.RenameProcessor)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1