use of com.intellij.ide.commander.CommanderPanel in project intellij-community by JetBrains.
the class FileStructureDialogTest method testFileStructureForClass.
public void testFileStructureForClass() throws Exception {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(getPackageDirectory());
assertNotNull(aPackage);
final PsiClass psiClass = aPackage.getClasses()[0];
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
assertNotNull(virtualFile);
final StructureViewBuilder structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
assertNotNull(structureViewBuilder);
final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder) structureViewBuilder).createStructureViewModel(null);
final EditorFactory factory = EditorFactory.getInstance();
assertNotNull(factory);
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
assertNotNull(document);
final Editor editor = factory.createEditor(document, myProject);
try {
final FileStructureDialog dialog = new FileStructureDialog(structureViewModel, editor, myProject, psiClass, new Disposable() {
@Override
public void dispose() {
structureViewModel.dispose();
}
}, true);
try {
final CommanderPanel panel = dialog.getPanel();
assertListsEqual((ListModel) panel.getModel(), "Inner1\n" + "Inner2\n" + "__method(): void\n" + "_myField1: int\n" + "_myField2: String\n");
} finally {
dialog.close(0);
}
} finally {
factory.releaseEditor(editor);
}
}
Aggregations