Search in sources :

Example 11 with StructureViewModel

use of com.intellij.ide.structureView.StructureViewModel in project intellij-community by JetBrains.

the class StructureViewCompositeModel method getFilters.

@NotNull
@Override
public Filter[] getFilters() {
    final HashSet<Filter> filters = new HashSet<>();
    for (StructureViewComposite.StructureViewDescriptor view : myViews) {
        final StructureViewModel model = view.structureView.getTreeModel();
        filters.addAll(Arrays.asList(model.getFilters()));
    }
    return filters.toArray(new Filter[filters.size()]);
}
Also used : Filter(com.intellij.ide.util.treeView.smartTree.Filter) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) StructureViewComposite(com.intellij.ide.structureView.impl.StructureViewComposite) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with StructureViewModel

use of com.intellij.ide.structureView.StructureViewModel in project android by JetBrains.

the class StructureViewTest method testLayoutStructure.

public void testLayoutStructure() throws Exception {
    VirtualFile file = copyFileToProject("layout/structure_view_test.xml", "/res/layout/layout.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<LayoutViewElement> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), LayoutViewElement.class);
    assertNotNull(element);
    final StructureViewModel model = new LayoutStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "LinearLayout\n" + "  TextView\n" + "  TextView (@+id/login)\n" + "  TextView (@+id/password)\n" + "  LinearLayout\n" + "    Include @layout/some_other_layout\n" + "    TextView\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayoutViewElement(org.jetbrains.android.dom.layout.LayoutViewElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) LayoutStructureViewBuilder(org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)

Example 13 with StructureViewModel

use of com.intellij.ide.structureView.StructureViewModel in project android by JetBrains.

the class StructureViewTest method testResourceStructure.

public void testResourceStructure() throws Exception {
    VirtualFile file = copyFileToProject("resources/resources_structure.xml", "/res/values/styles.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<Resources> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), Resources.class);
    assertNotNull(element);
    StructureViewModel model = new ResourceStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "Resources file 'styles.xml'\n" + "  Style - AppTheme\n" + "  String - test_string\n" + "  Style - SecondStyle\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ResourceStructureViewBuilder(org.jetbrains.android.dom.structure.resources.ResourceStructureViewBuilder) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) Resources(org.jetbrains.android.dom.resources.Resources)

Example 14 with StructureViewModel

use of com.intellij.ide.structureView.StructureViewModel in project android by JetBrains.

the class StructureViewTest method testLayoutStructureOrder1.

public void testLayoutStructureOrder1() throws Exception {
    VirtualFile file = copyFileToProject("layout/structure_view_test_order_1.xml", "/res/layout/layout.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<LayoutViewElement> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), LayoutViewElement.class);
    assertNotNull(element);
    final StructureViewModel model = new LayoutStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "LinearLayout\n" + "  Fragment\n" + "  Include\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayoutViewElement(org.jetbrains.android.dom.layout.LayoutViewElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) LayoutStructureViewBuilder(org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)

Example 15 with StructureViewModel

use of com.intellij.ide.structureView.StructureViewModel in project intellij-plugins by JetBrains.

the class CfmlStructureViewTest method getTopLevelItems.

private Object[] getTopLevelItems() {
    StructureView structureView = createStructureViewModel();
    final StructureViewModel structureViewModel = structureView.getTreeModel();
    AbstractTreeStructure jsTreeStructure = new SmartTreeStructure(getProject(), structureViewModel);
    Object[] items = jsTreeStructure.getChildElements(jsTreeStructure.getRootElement());
    structureViewModel.dispose();
    Disposer.dispose(structureView);
    return items;
}
Also used : StructureView(com.intellij.ide.structureView.StructureView) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) SmartTreeStructure(com.intellij.ide.util.treeView.smartTree.SmartTreeStructure) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Aggregations

StructureViewModel (com.intellij.ide.structureView.StructureViewModel)16 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)8 TreeBasedStructureViewBuilder (com.intellij.ide.structureView.TreeBasedStructureViewBuilder)7 PsiFile (com.intellij.psi.PsiFile)7 LanguageStructureViewBuilder (com.intellij.lang.LanguageStructureViewBuilder)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 XmlFile (com.intellij.psi.xml.XmlFile)4 LayoutViewElement (org.jetbrains.android.dom.layout.LayoutViewElement)3 LayoutStructureViewBuilder (org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)3 StructureView (com.intellij.ide.structureView.StructureView)2 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)2 Editor (com.intellij.openapi.editor.Editor)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 CommanderPanel (com.intellij.ide.commander.CommanderPanel)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 StructureViewComposite (com.intellij.ide.structureView.impl.StructureViewComposite)1 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)1 FileStructureDialog (com.intellij.ide.util.FileStructureDialog)1 AbstractTreeStructure (com.intellij.ide.util.treeView.AbstractTreeStructure)1