use of com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider 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);
}
use of com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider 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);
}
Aggregations