Search in sources :

Example 1 with DPropertyElement

use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DPropertyElement in project intellij-community by JetBrains.

the class GrDynamicImplicitProperty method navigate.

@Override
public void navigate(boolean requestFocus) {
    if (canNavigateToSource()) {
        super.navigate(requestFocus);
        return;
    }
    DynamicToolWindowWrapper.getInstance(myProject).getToolWindow().activate(() -> {
        DynamicToolWindowWrapper toolWindowWrapper = DynamicToolWindowWrapper.getInstance(myProject);
        final TreeTable treeTable = toolWindowWrapper.getTreeTable();
        final ListTreeTableModelOnColumns model = toolWindowWrapper.getTreeTableModel();
        Object root = model.getRoot();
        if (root == null || !(root instanceof DefaultMutableTreeNode))
            return;
        DefaultMutableTreeNode treeRoot = ((DefaultMutableTreeNode) root);
        final PsiClass psiClass = getContainingClassElement();
        if (psiClass == null)
            return;
        final DefaultMutableTreeNode desiredNode;
        DPropertyElement dynamicProperty = null;
        PsiClass trueSuper = null;
        for (PsiClass aSuper : PsiUtil.iterateSupers(psiClass, true)) {
            dynamicProperty = DynamicManager.getInstance(myProject).findConcreteDynamicProperty(aSuper.getQualifiedName(), getName());
            if (dynamicProperty != null) {
                trueSuper = aSuper;
                break;
            }
        }
        if (trueSuper == null)
            return;
        final DefaultMutableTreeNode classNode = TreeUtil.findNodeWithObject(treeRoot, new DClassElement(myProject, trueSuper.getQualifiedName()));
        if (classNode == null)
            return;
        desiredNode = TreeUtil.findNodeWithObject(classNode, dynamicProperty);
        if (desiredNode == null)
            return;
        final TreePath path = TreeUtil.getPathFromRoot(desiredNode);
        treeTable.getTree().expandPath(path);
        treeTable.getTree().setSelectionPath(path);
        treeTable.getTree().fireTreeExpanded(path);
        ToolWindowManager.getInstance(myProject).getFocusManager().requestFocus(treeTable, true);
        treeTable.revalidate();
        treeTable.repaint();
    }, true);
}
Also used : ListTreeTableModelOnColumns(com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DPropertyElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DPropertyElement) DClassElement(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement) TreePath(javax.swing.tree.TreePath) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable)

Aggregations

ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)1 TreeTable (com.intellij.ui.treeStructure.treetable.TreeTable)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1 DClassElement (org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DClassElement)1 DPropertyElement (org.jetbrains.plugins.groovy.annotator.intentions.dynamic.elements.DPropertyElement)1