Java 类com.intellij.ui.treeStructure.filtered.FilteringTreeStructure 实例源码

项目:intellij-ce-playground    文件:FileStructureTestFixture.java   
@Nullable
public FilteringTreeStructure.FilteringNode update() {
  final Ref<FilteringTreeStructure.FilteringNode> nodeRef = new Ref<FilteringTreeStructure.FilteringNode>();
  final FileStructurePopup popup = getPopup();
  popup.getTreeBuilder().refilter().doWhenProcessed(new Runnable() {
    @Override
    public void run() {
      getStructure().rebuild();
      updateTree();
      getBuilder().updateFromRoot();
      TreeUtil.expandAll(getTree());
      nodeRef.set(popup.selectPsiElement(popup.getCurrentElement(myFile)));
      getBuilder().getUi().select(nodeRef.get(), null);
    }
  });
  return nodeRef.get();
}
项目:intellij-ce-playground    文件:OptionsTree.java   
private ConfigurableGroup getGroup(int offset) {
  TreePath path = myTree.getClosestPathForLocation(-myTree.getX(), -myTree.getY() + offset);
  SimpleNode node = myTree.getNodeFor(path);
  if (node instanceof FilteringTreeStructure.FilteringNode) {
    Object delegate = ((FilteringTreeStructure.FilteringNode)node).getDelegate();
    while (delegate instanceof EditorNode) {
      EditorNode editor = (EditorNode)delegate;
      ConfigurableGroup group = editor.getGroup();
      if (group != null) {
        return group;
      }
      delegate = editor.getParent();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
private FilteringTreeStructure.FilteringNode findNode(Set<PsiElement> parents, FilteringTreeStructure.FilteringNode node) {
  while (node != null) {
    boolean changed = false;
    for (FilteringTreeStructure.FilteringNode n : node.children()) {
      final PsiElement psiElement = getPsi(n);
      if (psiElement != null && parents.contains(psiElement)) {
        node = n;
        changed = true;
        break;
      }
    }
    if (!changed) {
      myAbstractTreeBuilder.select(node);
      if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) {
        TreeUtil.selectFirstNode(myTree);
      }
      myInitialNodeIsLeaf = node.getChildren().length == 0;
      return node;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
@Nullable
private AbstractTreeNode getSelectedNode() {
  final TreePath path = myTree.getSelectionPath();
  if (path != null) {
    Object component = path.getLastPathComponent();
    if (component instanceof DefaultMutableTreeNode) {
      component = ((DefaultMutableTreeNode)component).getUserObject();
      if (component instanceof FilteringTreeStructure.FilteringNode) {
        component = ((FilteringTreeStructure.FilteringNode)component).getDelegate();
        if (component instanceof AbstractTreeNode) {
          return (AbstractTreeNode)component;
        }
      }
    }
  }
  return null;
}
项目:tools-idea    文件:FileStructurePopup.java   
@Nullable
private AbstractTreeNode getSelectedNode() {
  final TreePath path = myTree.getSelectionPath();
  if (path != null) {
    Object component = path.getLastPathComponent();
    if (component instanceof DefaultMutableTreeNode) {
      component = ((DefaultMutableTreeNode)component).getUserObject();
      if (component instanceof FilteringTreeStructure.FilteringNode) {
        component = ((FilteringTreeStructure.FilteringNode)component).getDelegate();
        if (component instanceof AbstractTreeNode) {
          return (AbstractTreeNode)component;
        }
      }
    }
  }
  return null;
}
项目:consulo    文件:FileStructurePopup.java   
private FilteringTreeStructure.FilteringNode findNode(Set<PsiElement> parents, FilteringTreeStructure.FilteringNode node) {
  while (node != null) {
    boolean changed = false;
    for (FilteringTreeStructure.FilteringNode n : node.children()) {
      final PsiElement psiElement = getPsi(n);
      if (psiElement != null && parents.contains(psiElement)) {
        node = n;
        changed = true;
        break;
      }
    }
    if (!changed) {
      myAbstractTreeBuilder.select(node);
      if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) {
        TreeUtil.selectFirstNode(myTree);
      }
      myInitialNodeIsLeaf = node.getChildren().length == 0;
      return node;
    }
  }
  return null;
}
项目:consulo    文件:FileStructurePopup.java   
@Nullable
private AbstractTreeNode getSelectedNode() {
  final TreePath path = myTree.getSelectionPath();
  if (path != null) {
    Object component = path.getLastPathComponent();
    if (component instanceof DefaultMutableTreeNode) {
      component = ((DefaultMutableTreeNode)component).getUserObject();
      if (component instanceof FilteringTreeStructure.FilteringNode) {
        component = ((FilteringTreeStructure.FilteringNode)component).getDelegate();
        if (component instanceof AbstractTreeNode) {
          return (AbstractTreeNode)component;
        }
      }
    }
  }
  return null;
}
项目:consulo    文件:FileStructurePopup.java   
public FileStructureTree(Object rootElement, boolean fastExpand) {
  super(new DefaultMutableTreeNode(rootElement));
  if (fastExpand) {
    Hashtable hashtable = new Hashtable() {
      @Override
      public synchronized Object get(Object key) {
        return Boolean.TRUE;
      }
    };
    fast = ReflectionUtil.setField(JTree.class, this, Hashtable.class, "expandedState", hashtable);
  }
  else {
    fast = false;
  }

  //TODO[kb]: hack expanded states in getUI().treeState

  setRootVisible(false);
  setShowsRootHandles(true);
  setHorizontalAutoScrollingEnabled(false);

  HintUpdateSupply.installHintUpdateSupply(this, o -> getPsi(
          (FilteringTreeStructure.FilteringNode)((DefaultMutableTreeNode)o).getUserObject()));
}
项目:intellij-ce-playground    文件:OptionsTree.java   
@Nullable
private Base extractNode(Object object) {
  if (object instanceof DefaultMutableTreeNode) {
    final DefaultMutableTreeNode uiNode = (DefaultMutableTreeNode)object;
    final Object o = uiNode.getUserObject();
    if (o instanceof FilteringTreeStructure.FilteringNode) {
      return (Base)((FilteringTreeStructure.FilteringNode)o).getDelegate();
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:TreePopupImpl.java   
private Object extractUserObject(Object aNode) {
  Object object = ((DefaultMutableTreeNode) aNode).getUserObject();
  if (object instanceof FilteringTreeStructure.FilteringNode) {
    return ((FilteringTreeStructure.FilteringNode) object).getDelegate();
  }
  return object;
}
项目:intellij-ce-playground    文件:StructureViewComponent.java   
@Nullable
private static Object getNodeValue(DefaultMutableTreeNode mutableTreeNode) {
  Object userObject = mutableTreeNode.getUserObject();
  if (userObject instanceof FilteringTreeStructure.FilteringNode) {
    userObject = ((FilteringTreeStructure.FilteringNode)userObject).getDelegate();
  }
  return userObject instanceof AbstractTreeNode ? ((AbstractTreeNode)userObject).getValue() : null;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
@Nullable
private PsiElement getPsi(FilteringTreeStructure.FilteringNode n) {
  final Object delegate = n.getDelegate();
  if (delegate instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
    final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper)delegate).getValue();
    if (value instanceof StructureViewTreeElement) {
      final Object element = ((StructureViewTreeElement)value).getValue();
      if (element instanceof PsiElement) {
        return (PsiElement)element;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
@NotNull
private List<PsiElement> getPsiElementsFromSelection() {
  Set<Object> nodes = myAbstractTreeBuilder.getSelectedElements();
  if (nodes.isEmpty()) return Collections.emptyList();
  List<PsiElement> result = ContainerUtil.newArrayListWithCapacity(nodes.size());
  for (Object o : nodes) {
    if (!(o instanceof FilteringTreeStructure.FilteringNode)) continue;
    ContainerUtil.addIfNotNull(result, getPsi((FilteringTreeStructure.FilteringNode)o));
  }
  return result;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
@Override
public boolean shouldBeShowing(Object value) {
  if (!isShouldNarrowDown()) return true;

  String filter = getSearchPrefix();
  if (!StringUtil.equals(myLastFilter, filter)) {
    myVisibleParents.clear();
    myLastFilter = filter;
  }
  if (filter != null) {
    if (myVisibleParents.contains(value)) {
      return true;
    }

    final String text = getSpeedSearchText(value);
    if (text == null) return false;

    if (matches(text)) {
      Object o = value;
      while (o instanceof FilteringTreeStructure.FilteringNode && (o = ((FilteringTreeStructure.FilteringNode)o).getParent()) != null) {
        myVisibleParents.add(o);
      }
      return true;
    }
    else {
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
public MyTreeSpeedSearch() {
  super(myTree, new Convertor<TreePath, String>() {
    @Override
    @Nullable
    public String convert(TreePath path) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject instanceof FilteringTreeStructure.FilteringNode) {
        return getSpeedSearchText(((FilteringTreeStructure.FilteringNode)userObject).getDelegate());
      }
      return "";
    }
  }, true);
}
项目:tools-idea    文件:FileStructureTestBase.java   
public void update() throws InterruptedException {
  myPopup.getTreeBuilder().refilter().doWhenProcessed(new Runnable() {
    @Override
    public void run() {

      getStructure().rebuild();
      updateTree();
      getBuilder().updateFromRoot();
      TreeUtil.expandAll(getTree());
      final FilteringTreeStructure.FilteringNode node = myPopup.selectPsiElement(myPopup.getCurrentElement(getFile()));
      getBuilder().getUi().select(node, null);
    }
  });
}
项目:tools-idea    文件:OptionsTree.java   
@Nullable
private Base extractNode(Object object) {
  if (object instanceof DefaultMutableTreeNode) {
    final DefaultMutableTreeNode uiNode = (DefaultMutableTreeNode)object;
    final Object o = uiNode.getUserObject();
    if (o instanceof FilteringTreeStructure.FilteringNode) {
      return (Base)((FilteringTreeStructure.FilteringNode)o).getDelegate();
    }
  }

  return null;
}
项目:tools-idea    文件:TreePopupImpl.java   
private Object extractUserObject(Object aNode) {
  Object object = ((DefaultMutableTreeNode) aNode).getUserObject();
  if (object instanceof FilteringTreeStructure.FilteringNode) {
    return ((FilteringTreeStructure.FilteringNode) object).getDelegate();
  }
  return object;
}
项目:tools-idea    文件:FileStructurePopup.java   
@Nullable
public FilteringTreeStructure.FilteringNode selectPsiElement(PsiElement element) {
  Set<PsiElement> parents = getAllParents(element);

  FilteringTreeStructure.FilteringNode node = (FilteringTreeStructure.FilteringNode)myAbstractTreeBuilder.getRootElement();
  while (node != null) {
    boolean changed = false;
    for (FilteringTreeStructure.FilteringNode n : node.children()) {
      final PsiElement psiElement = getPsi(n);
      if (psiElement != null && parents.contains(psiElement)) {
        node = n;
        changed = true;
        break;
      }
    }
    if (!changed) {
      myAbstractTreeBuilder.select(node);
      if (myAbstractTreeBuilder.getSelectedElements().isEmpty()) {
        TreeUtil.selectFirstNode(myTree);
      }
      myInitialNodeIsLeaf = node.getChildren().length == 0;
      return node;
    }
  }
  TreeUtil.selectFirstNode(myTree);
  return null;
}
项目:tools-idea    文件:FileStructurePopup.java   
@Nullable
private PsiElement getPsi(FilteringTreeStructure.FilteringNode n) {
  final Object delegate = n.getDelegate();
  if (delegate instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
    final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper)delegate).getValue();
    if (value instanceof StructureViewTreeElement) {
      final Object element = ((StructureViewTreeElement)value).getValue();
      if (element instanceof PsiElement) {
        return (PsiElement)element;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:FileStructurePopup.java   
@Override
public boolean shouldBeShowing(Object value) {
  if (!myShouldNarrowDown) return true;

  String filter = getSearchPrefix();
  if (!StringUtil.equals(myLastFilter, filter)) {
    myVisibleParents.clear();
    myLastFilter = filter;
  }
  if (filter != null) {
    if (myVisibleParents.contains(value)) {
      return true;
    }

    final String text = getSpeedSearchText(value);
    if (text == null) return false;

    if (matches(text)) {
      Object o = value;
      while (o instanceof FilteringTreeStructure.FilteringNode && (o = ((FilteringTreeStructure.FilteringNode)o).getParent()) != null) {
        myVisibleParents.add(o);
      }
      return true;
    } else {
      return false;
    }

  }
  return true;
}
项目:tools-idea    文件:FileStructurePopup.java   
public MyTreeSpeedSearch() {
  super(myTree, new Convertor<TreePath, String>() {
    @Override
    @Nullable
    public String convert(TreePath path) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject instanceof FilteringTreeStructure.FilteringNode) {
        return getSpeedSearchText(((FilteringTreeStructure.FilteringNode)userObject).getDelegate());
      }
      return "";
    }
  }, true);
}
项目:consulo    文件:FileStructureTestBase.java   
public void update() throws InterruptedException {
  myPopup.getTreeBuilder().refilter().doWhenProcessed(new Runnable() {
    @Override
    public void run() {

      getStructure().rebuild();
      updateTree();
      getBuilder().updateFromRoot();
      TreeUtil.expandAll(getTree());
      final FilteringTreeStructure.FilteringNode node = myPopup.selectPsiElement(myPopup.getCurrentElement(getFile()));
      getBuilder().getUi().select(node, null);
    }
  });
}
项目:consulo    文件:OptionsTree.java   
@Nullable
private Base extractNode(Object object) {
  if (object instanceof DefaultMutableTreeNode) {
    final DefaultMutableTreeNode uiNode = (DefaultMutableTreeNode)object;
    final Object o = uiNode.getUserObject();
    if (o instanceof FilteringTreeStructure.FilteringNode) {
      return (Base)((FilteringTreeStructure.FilteringNode)o).getDelegate();
    }
  }

  return null;
}
项目:consulo    文件:TreePopupImpl.java   
private Object extractUserObject(Object aNode) {
  Object object = ((DefaultMutableTreeNode) aNode).getUserObject();
  if (object instanceof FilteringTreeStructure.FilteringNode) {
    return ((FilteringTreeStructure.FilteringNode) object).getDelegate();
  }
  return object;
}
项目:consulo    文件:StructureViewComponent.java   
@Nullable
private static Object getNodeValue(DefaultMutableTreeNode mutableTreeNode) {
  Object userObject = mutableTreeNode.getUserObject();
  if (userObject instanceof FilteringTreeStructure.FilteringNode) {
    userObject = ((FilteringTreeStructure.FilteringNode)userObject).getDelegate();
  }
  return userObject instanceof AbstractTreeNode ? ((AbstractTreeNode)userObject).getValue() : null;
}
项目:consulo    文件:FileStructurePopup.java   
@Nullable
private PsiElement getPsi(FilteringTreeStructure.FilteringNode n) {
  final Object delegate = n.getDelegate();
  if (delegate instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
    final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper)delegate).getValue();
    if (value instanceof StructureViewTreeElement) {
      final Object element = ((StructureViewTreeElement)value).getValue();
      if (element instanceof PsiElement) {
        return (PsiElement)element;
      }
    }
  }
  return null;
}
项目:consulo    文件:FileStructurePopup.java   
@Nonnull
private List<PsiElement> getPsiElementsFromSelection() {
  Set<Object> nodes = myAbstractTreeBuilder.getSelectedElements();
  if (nodes.isEmpty()) return Collections.emptyList();
  List<PsiElement> result = ContainerUtil.newArrayListWithCapacity(nodes.size());
  for (Object o : nodes) {
    if (!(o instanceof FilteringTreeStructure.FilteringNode)) continue;
    ContainerUtil.addIfNotNull(result, getPsi((FilteringTreeStructure.FilteringNode)o));
  }
  return result;
}
项目:consulo    文件:FileStructurePopup.java   
@Override
public boolean shouldBeShowing(Object value) {
  if (!isShouldNarrowDown()) return true;

  String filter = getSearchPrefix();
  if (!StringUtil.equals(myLastFilter, filter)) {
    myVisibleParents.clear();
    myLastFilter = filter;
  }
  if (filter != null) {
    if (myVisibleParents.contains(value)) {
      return true;
    }

    final String text = getSpeedSearchText(value);
    if (text == null) return false;

    if (matches(text)) {
      Object o = value;
      while (o instanceof FilteringTreeStructure.FilteringNode && (o = ((FilteringTreeStructure.FilteringNode)o).getParent()) != null) {
        myVisibleParents.add(o);
      }
      return true;
    }
    else {
      return false;
    }
  }
  return true;
}
项目:consulo    文件:FileStructurePopup.java   
public MyTreeSpeedSearch() {
  super(myTree, path -> {
    final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    final Object userObject = node.getUserObject();
    if (userObject instanceof FilteringTreeStructure.FilteringNode) {
      return getSpeedSearchText(((FilteringTreeStructure.FilteringNode)userObject).getDelegate());
    }
    return "";
  }, true);
}
项目:intellij-ce-playground    文件:FileStructureTestFixture.java   
public FilteringTreeStructure getStructure() {
  final FilteringTreeStructure structure = (FilteringTreeStructure)getBuilder().getTreeStructure();
  assert structure != null;
  return structure;
}
项目:intellij-ce-playground    文件:FileStructureTestFixture.java   
public FilteringTreeStructure.FilteringNode getRootNode() {
  return getStructure().getRootElement();
}
项目:intellij-ce-playground    文件:FileStructureTestFixture.java   
public void updateRecursively(final FilteringTreeStructure.FilteringNode node) {
  node.update();
  for (FilteringTreeStructure.FilteringNode child : node.children()) {
    updateRecursively(child);
  }
}
项目:intellij-ce-playground    文件:SettingsTreeView.java   
ActionCallback select(@Nullable final Configurable configurable) {
  if (myBuilder.isSelectionBeingAdjusted()) {
    return ActionCallback.REJECTED;
  }
  final ActionCallback callback = new ActionCallback();
  myQueuedConfigurable = configurable;
  myQueue.queue(new Update(this) {
    public void run() {
      if (configurable == myQueuedConfigurable) {
        if (configurable == null) {
          fireSelected(null, callback);
        }
        else {
          myBuilder.getReady(this).doWhenDone(new Runnable() {
            @Override
            public void run() {
              if (configurable != myQueuedConfigurable) return;

              MyNode editorNode = findNode(configurable);
              FilteringTreeStructure.FilteringNode editorUiNode = myBuilder.getVisibleNodeFor(editorNode);
              if (editorUiNode == null) return;

              if (!myBuilder.getSelectedElements().contains(editorUiNode)) {
                myBuilder.select(editorUiNode, new Runnable() {
                  public void run() {
                    fireSelected(configurable, callback);
                  }
                });
              }
              else {
                myBuilder.scrollSelectionToVisible(new Runnable() {
                  public void run() {
                    fireSelected(configurable, callback);
                  }
                }, false);
              }
            }
          });
        }
      }
    }

    @Override
    public void setRejected() {
      super.setRejected();
      callback.setRejected();
    }
  });
  return callback;
}
项目:intellij-ce-playground    文件:OptionsTree.java   
ActionCallback queueSelection(final Configurable configurable) {
  if (myBuilder.isSelectionBeingAdjusted()) {
    return ActionCallback.REJECTED;
  }

  final ActionCallback callback = new ActionCallback();

  myQueuedConfigurable = configurable;
  final Update update = new Update(this) {
    public void run() {
      if (configurable != myQueuedConfigurable) return;

      if (configurable == null) {
        myTree.getSelectionModel().clearSelection();
        myFilter.myContext.fireSelected(null, OptionsTree.this);
      }
      else {
        myBuilder.getReady(this).doWhenDone(new Runnable() {
          @Override
          public void run() {
            if (configurable != myQueuedConfigurable) return;

            final EditorNode editorNode = myConfigurable2Node.get(configurable);
            FilteringTreeStructure.FilteringNode editorUiNode = myBuilder.getVisibleNodeFor(editorNode);
            if (editorUiNode == null) return;

            if (!myBuilder.getSelectedElements().contains(editorUiNode)) {
              myBuilder.select(editorUiNode, new Runnable() {
                public void run() {
                  fireSelected(configurable, callback);
                }
              });
            } else {
              myBuilder.scrollSelectionToVisible(new Runnable() {
                public void run() {
                  fireSelected(configurable, callback);
                }
              }, false);
            }
          }
        });
      }
    }

    @Override
    public void setRejected() {
      super.setRejected();
      callback.setRejected();
    }
  };
  mySelection.queue(update);
  return callback;
}
项目:intellij-ce-playground    文件:FilteringTreeBuilderTest.java   
private void select(String element) throws Exception {
  FilteringTreeStructure.FilteringNode node = myBuilder.getVisibleNodeFor(findNode(element));
  select(new Object[] {node}, false);
}
项目:intellij-ce-playground    文件:FileStructurePopup.java   
@Override
protected PsiElement getPsiElementForHint(Object selectedValue) {
  //noinspection ConstantConditions
  return getPsi((FilteringTreeStructure.FilteringNode)((DefaultMutableTreeNode)selectedValue).getUserObject());
}
项目:tools-idea    文件:FileStructureTestBase.java   
protected FilteringTreeStructure getStructure() {
  final FilteringTreeStructure structure = (FilteringTreeStructure)getBuilder().getTreeStructure();
  assert structure != null;
  return structure;
}
项目:tools-idea    文件:FileStructureTestBase.java   
protected FilteringTreeStructure.FilteringNode getRootNode() {
  return (FilteringTreeStructure.FilteringNode)getStructure().getRootElement();
}
项目:tools-idea    文件:FileStructureTestBase.java   
protected void updateRecursively(final FilteringTreeStructure.FilteringNode node) {
  node.update();
  for (FilteringTreeStructure.FilteringNode child : node.children()) {
    updateRecursively(child);
  }
}