Java 类com.intellij.ui.TreeTableSpeedSearch 实例源码

项目:nosql4idea    文件:JsonTreeTableView.java   
public JsonTreeTableView(TreeNode rootNode, ColumnInfo[] columnInfos) {
    super(new ListTreeTableModelOnColumns(rootNode, columnInfos));
    this.columns = columnInfos;

    final TreeTableTree tree = getTree();

    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    UIUtil.setLineStyleAngled(tree);
    setTreeCellRenderer(new KeyCellRenderer());

    TreeUtil.expand(tree, 2);

    new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
        @Override
        public String convert(final TreePath path) {
            final NoSqlTreeNode node = (NoSqlTreeNode) path.getLastPathComponent();
            NodeDescriptor descriptor = node.getDescriptor();
            return descriptor.getFormattedKey();
        }
    });
}
项目:vso-intellij    文件:WorkItemsPanel.java   
public WorkItemsPanel(CheckinParametersForm form) {
  myForm = form;

  myWorkItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myWorkItemsTable.getTree().setRootVisible(false);
  myWorkItemsTable.setShowGrid(true);
  myWorkItemsTable.setGridColor(UIUtil.getTableGridColor());
  myWorkItemsTable.setMaxItemsForSizeCalculation(1);
  new TreeTableSpeedSearch(myWorkItemsTable);

  setupWorkItemQueries();
}
项目:intellij-ce-playground    文件:AbstractFileTreeTable.java   
/**
 * Due to historical reasons, passed filter does not perform all jobs - fileIndex.isInContent is checked in addition.
 * Flag showContentFilesOnly allows you to disable such behavior.
 */
public AbstractFileTreeTable(@NotNull Project project,
                             @NotNull Class<T> valueClass,
                             @NotNull String valueTitle,
                             @NotNull VirtualFileFilter filter,
                             boolean showProjectNode,
                             boolean showContentFilesOnly) {
  super(new MyModel<T>(project, valueClass, valueTitle, showContentFilesOnly ? new ProjectContentFileFilter(project, filter) : filter));
  myProject = project;

  //noinspection unchecked
  myModel = (MyModel)getTableModel();
  myModel.setTreeTable(this);

  new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath o) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)o.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject == null) {
        return getProjectNodeText();
      }
      if (userObject instanceof VirtualFile) {
        return ((VirtualFile)userObject).getName();
      }
      return node.toString();
    }
  });
  final DefaultTreeExpander treeExpander = new DefaultTreeExpander(getTree());
  CommonActionsManager.getInstance().createExpandAllAction(treeExpander, this);
  CommonActionsManager.getInstance().createCollapseAllAction(treeExpander, this);

  getTree().setShowsRootHandles(true);
  getTree().setLineStyleAngled();
  getTree().setRootVisible(showProjectNode);
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  getTree().setCellRenderer(new DefaultTreeCellRenderer() {
    @Override
    public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded,
                                                  final boolean leaf, final int row, final boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof ProjectRootNode) {
        setText(getProjectNodeText());
        setIcon(AllIcons.Nodes.Project);
        return this;
      }
      FileNode fileNode = (FileNode)value;
      VirtualFile file = fileNode.getObject();
      setText(fileNode.getParent() instanceof FileNode ? file.getName() : file.getPresentableUrl());
      if (file.isDirectory()) {
        setIcon(fileIndex.isExcluded(file) ? AllIcons.Modules.ExcludeRoot : PlatformIcons.DIRECTORY_CLOSED_ICON);
      }
      else {
        setIcon(IconUtil.getIcon(file, 0, null));
      }
      return this;
    }
  });
  getTableHeader().setReorderingAllowed(false);

  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  setPreferredScrollableViewportSize(new Dimension(300, getRowHeight() * 10));

  getColumnModel().getColumn(0).setPreferredWidth(280);
  getColumnModel().getColumn(1).setPreferredWidth(60);
}
项目:tools-idea    文件:AbstractFileTreeTable.java   
public AbstractFileTreeTable(@NotNull Project project,
                             @NotNull Class<T> valueClass,
                             @NotNull String valueTitle,
                             @NotNull VirtualFileFilter filter,
                             boolean showProjectNode) {
  super(new MyModel<T>(project, valueClass, valueTitle, filter));
  myProject = project;

  myModel = (MyModel)getTableModel();
  myModel.setTreeTable(this);

  new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath o) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)o.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject == null) {
        return getProjectNodeText();
      }
      if (userObject instanceof VirtualFile) {
        return ((VirtualFile)userObject).getName();
      }
      return node.toString();
    }
  });
  final DefaultTreeExpander treeExpander = new DefaultTreeExpander(getTree());
  CommonActionsManager.getInstance().createExpandAllAction(treeExpander, this);
  CommonActionsManager.getInstance().createCollapseAllAction(treeExpander, this);

  getTree().setShowsRootHandles(true);
  getTree().setLineStyleAngled();
  getTree().setRootVisible(showProjectNode);
  getTree().setCellRenderer(new DefaultTreeCellRenderer() {
    @Override
    public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded,
                                                  final boolean leaf, final int row, final boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof ProjectRootNode) {
        setText(getProjectNodeText());
        setIcon(AllIcons.Nodes.Project);
        return this;
      }
      FileNode fileNode = (FileNode)value;
      VirtualFile file = fileNode.getObject();
      if (fileNode.getParent() instanceof FileNode) {
        setText(file.getName());
      }
      else {
        setText(file.getPresentableUrl());
      }

      Icon icon = file.isDirectory() ? PlatformIcons.DIRECTORY_CLOSED_ICON : IconUtil.getIcon(file, 0, null);
      setIcon(icon);
      return this;
    }
  });
  getTableHeader().setReorderingAllowed(false);


  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  setPreferredScrollableViewportSize(new Dimension(300, getRowHeight() * 10));

  getColumnModel().getColumn(0).setPreferredWidth(280);
  getColumnModel().getColumn(1).setPreferredWidth(60);
}
项目:consulo    文件:AbstractFileTreeTable.java   
public AbstractFileTreeTable(@Nonnull Project project,
                             @Nonnull Class<T> valueClass,
                             @Nonnull String valueTitle,
                             @Nonnull VirtualFileFilter filter,
                             boolean showProjectNode) {
  super(new MyModel<T>(project, valueClass, valueTitle, filter));
  myProject = project;

  myModel = (MyModel)getTableModel();
  myModel.setTreeTable(this);

  new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath o) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)o.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject == null) {
        return getProjectNodeText();
      }
      if (userObject instanceof VirtualFile) {
        return ((VirtualFile)userObject).getName();
      }
      return node.toString();
    }
  });
  final DefaultTreeExpander treeExpander = new DefaultTreeExpander(getTree());
  CommonActionsManager.getInstance().createExpandAllAction(treeExpander, this);
  CommonActionsManager.getInstance().createCollapseAllAction(treeExpander, this);

  getTree().setShowsRootHandles(true);
  getTree().setLineStyleAngled();
  getTree().setRootVisible(showProjectNode);
  getTree().setCellRenderer(new DefaultTreeCellRenderer() {
    @Override
    public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded,
                                                  final boolean leaf, final int row, final boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof ProjectRootNode) {
        setText(getProjectNodeText());
        setIcon(AllIcons.Nodes.ProjectTab);
        return this;
      }
      FileNode fileNode = (FileNode)value;
      VirtualFile file = fileNode.getObject();
      if (fileNode.getParent() instanceof FileNode) {
        setText(file.getName());
      }
      else {
        setText(file.getPresentableUrl());
      }

      Icon icon = file.isDirectory() ? AllIcons.Nodes.TreeClosed : VfsIconUtil.getIcon(file, 0, null);
      setIcon(icon);
      return this;
    }
  });
  getTableHeader().setReorderingAllowed(false);


  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  setPreferredScrollableViewportSize(new Dimension(300, getRowHeight() * 10));

  getColumnModel().getColumn(0).setPreferredWidth(280);
  getColumnModel().getColumn(1).setPreferredWidth(60);
}