当前位置: 首页>>代码示例>>Java>>正文


Java Tree类代码示例

本文整理汇总了Java中com.intellij.ui.treeStructure.Tree的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tree类属于com.intellij.ui.treeStructure包,在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectedPackage

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
@Nullable
private static PackageNode getSelectedPackage(final Tree tree) {
  TreePath[] paths = tree.getSelectionPaths();
  if (paths == null || paths.length != 1) return null;
  PackageDependenciesNode node = (PackageDependenciesNode)paths[0].getLastPathComponent();
  if (node.isRoot()) return null;
  if (node instanceof PackageNode) {
    return (PackageNode)node;
  }
  if (node instanceof FileNode) {
    return (PackageNode)node.getParent();
  }
  if (node instanceof ModuleNode){
    return (PackageNode)node.getChildAt(0);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CyclicDependenciesPanel.java

示例2: testToDo1

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public void testToDo1() throws Exception {
   AllTodosTreeBuilder all = new AllTodosTreeBuilder(new Tree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
   all.init();

   AbstractTreeStructure structure = all.getTreeStructure();
   ((TodoTreeStructure)structure).setFlattenPackages(true);
   ProjectViewTestUtil.assertStructureEqual(structure,
                                            "Root\n" +
                                            " Summary\n" +
                                            "  package2 toDoFileCount=1,toDoItemCount=2\n" +
                                            "   JavaClass.java\n" +
                                            "    Item: (62,78)\n" +
                                            "    Item: (145,162)\n",
                                            myPrintInfo);

   checkOccurrences(all, new String[]{"Item: (62,78)", "Item: (145,162)"});
   Disposer.dispose(all);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ToDoTreeStructureTest.java

示例3: createUIComponents

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
private void createUIComponents() {
  myTree = new Tree() {
    public Dimension getPreferredScrollableViewportSize() {
      Dimension size = super.getPreferredScrollableViewportSize();
      size = new Dimension(size.width + 20, size.height);
      return size;
    }

    @SuppressWarnings({"NonStaticInitializer"})
    public JToolTip createToolTip() {
      final JToolTip toolTip = new JToolTip() {
        {
          setUI(new MultiLineTooltipUI());
        }
      };
      toolTip.setComponent(this);
      return toolTip;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MasterDetailsComponent.java

示例4: dispose

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public void dispose() {
  final KeymapListener listener = myKeymapListener;
  if (listener != null) {
    myKeymapListener = null;
    listener.stopListen();
  }

  final AntExplorerTreeBuilder builder = myBuilder;
  if (builder != null) {
    Disposer.dispose(builder);
    myBuilder = null;
  }

  final Tree tree = myTree;
  if (tree != null) {
    ToolTipManager.sharedInstance().unregisterComponent(tree);
    for (KeyStroke keyStroke : tree.getRegisteredKeyStrokes()) {
      tree.unregisterKeyboardAction(keyStroke);
    }
    myTree = null;
  }

  myProject = null;
  myConfig = null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AntExplorer.java

示例5: testRemoveSelected

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public void testRemoveSelected() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root);
  DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(child1, root, 0);
  DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(child2, root, 1);
  DefaultMutableTreeNode child11 = new DefaultMutableTreeNode("11");
  model.insertNodeInto(child11, child1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.clearSelection();
  TreeUtil.removeSelected(tree);
  assertEquals(2, model.getChildCount(root));
  assertEquals(1, model.getChildCount(child1));
  tree.setSelectionPath(TreeUtil.getPathFromRoot(child11));
  TreeUtil.removeSelected(tree);
  assertSame(child1, tree.getSelectionPath().getLastPathComponent());
  TreeUtil.removeSelected(tree);
  assertSame(child2, tree.getSelectionPath().getLastPathComponent());
  tree.setSelectionPath(new TreePath(root));
  assertEquals(1, model.getChildCount(root));
  TreeUtil.removeSelected(tree);
  assertSame(root, model.getRoot());
  assertEquals(1, model.getChildCount(root));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TreeUtilTest.java

示例6: testMultiLevelRemove

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public void testMultiLevelRemove() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root) {
      @Override
      public void removeNodeFromParent(MutableTreeNode mutableTreeNode) {
        super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent());
      }
    };
  DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(node1, root, 0);
  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(node2, node1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.setSelectionPath(TreeUtil.getPathFromRoot(node2));
  TreeUtil.removeSelected(tree);
  assertEquals(0, root.getChildCount());
  assertEquals(root, tree.getSelectionPath().getLastPathComponent());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TreeUtilTest.java

示例7: createTree

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
private static Tree createTree(TreeModel treeModel) {
  final Tree tree = new Tree(treeModel);

  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setDragEnabled(false);
  tree.setEditable(false);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);


  final TreeSpeedSearch speedSearch = new TreeSpeedSearch(
    tree,
    new Convertor<TreePath, String>() {
      public String convert(TreePath object) {
        final Object userObject = ((DefaultMutableTreeNode)object.getLastPathComponent()).getUserObject();
        return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString();
      }
    }
  );
  tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch));

  return tree;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ExistingTemplatesComponent.java

示例8: paintRowData

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL)));
  final FontMetrics metrics = tree.getFontMetrics(g.getFont());
  int totalWidth = metrics.stringWidth(duration) + 2;
  int x = bounds.x + bounds.width - totalWidth;
  g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground());
  final int leftOffset = 5;
  g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height);
  g.translate(0, bounds.y - 1);
  if (isSelected) {
    if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) {
      g.setColor(UIUtil.getTreeForeground());
    }
    else {
      g.setColor(UIUtil.getTreeSelectionForeground());
    }
  }
  else {
    g.setColor(new JBColor(0x808080, 0x808080));
  }
  g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1);
  g.translate(0, -bounds.y + 1);
  config.restore();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TestTreeView.java

示例9: createTree

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
@NotNull
@Override
public Tree createTree(@NotNull Pair<XValue, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(), descriptor.getFirst());
  tree.setRoot(root, true);
  tree.setSelectionRow(0);
  // expand root on load
  tree.expandNodesOnLoad(new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node == root;
    }
  });
  return tree;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XDebuggerTreeCreator.java

示例10: createTree

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
@NotNull
@Override
public Tree createTree(@NotNull Pair<XInstanceEvaluator, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(),
                                                 new InstanceEvaluatorTreeRootValue(descriptor.getFirst(), descriptor.getSecond()));
  tree.setRoot(root, false);
  Condition<TreeNode> visibleRootCondition = new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node.getParent() == root;
    }
  };
  tree.expandNodesOnLoad(visibleRootCondition);
  tree.selectNodeOnLoad(visibleRootCondition);

  return tree;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XDebuggerInstanceTreeCreator.java

示例11: init

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public void init() {
  final TreeNode root = createRoot(myProject);
  myModel = new DefaultTreeModel(root, true);
  myTree = new Tree(myModel);
  add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);

  myTree.getSelectionModel().setSelectionMode(mySelectionMode);
  myTree.setCellRenderer(new Cvs2Renderer());
  addSelectionListener();

  final TreeUIHelper uiHelper = TreeUIHelper.getInstance();
  uiHelper.installTreeSpeedSearch(myTree);
  TreeUtil.installActions(myTree);

  myTree.requestFocus();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CvsTree.java

示例12: MyUI

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public MyUI() {
  myStructureTree = new Tree();
  myStructureTree.setRootVisible(false);
  myStructureTree.setShowsRootHandles(true);
  myStructureTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(final TreeSelectionEvent e) {
      final List<FilePath> filePaths = new ArrayList<FilePath>(mySelection);

      mySelection.clear();
      final TreePath[] selectionPaths = myStructureTree.getSelectionPaths();
      if (selectionPaths != null) {
        for (TreePath selectionPath : selectionPaths) {
          Collections.addAll(mySelection, ((ChangesBrowserNode)selectionPath.getLastPathComponent()).getFilePathsUnder());
        }
      }

      if (Comparing.haveEqualElements(filePaths, mySelection)) return;

      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myScrollPane = ScrollPaneFactory.createScrollPane(myStructureTree);
  myBuilder = new TreeModelBuilder(myProject, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:StructureFilteringStrategy.java

示例13: ModulesDependenciesPanel

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
public ModulesDependenciesPanel(final Project project, final Module[] modules) {
  super(new BorderLayout());
  myProject = project;
  myModules = modules;

  //noinspection HardCodedStringLiteral
  myRightTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("Root"));
  myRightTree = new Tree(myRightTreeModel);
  initTree(myRightTree, true);

  initLeftTree();

  mySplitter = new Splitter();
  mySplitter.setFirstComponent(new MyTreePanel(myLeftTree, myProject));
  mySplitter.setSecondComponent(new MyTreePanel(myRightTree, myProject));

  setSplitterProportion();
  add(mySplitter, BorderLayout.CENTER);
  add(createNorthPanel(), BorderLayout.NORTH);

  project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ModulesDependenciesPanel.java

示例14: initTree

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
private static void initTree(Tree tree, boolean isRightTree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      return o.getLastPathComponent().toString();
    }
  }, true);
  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree, tree), ActionManager.getInstance());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ModulesDependenciesPanel.java

示例15: initUI

import com.intellij.ui.treeStructure.Tree; //导入依赖的package包/类
private void initUI() {
  myComponent = new JPanel(new BorderLayout());
  mySplitter = new JBSplitter("AssociationsEditor.dividerProportion", 0.3f);
  myComponent.add(mySplitter, BorderLayout.CENTER);

  JPanel leftPanel = new JPanel(new BorderLayout());
  leftPanel.setBorder(IdeBorderFactory.createTitledBorder("Project XSLT Files", false, new Insets(0, 0, 0, 0)));
  myTree = new Tree();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(false);
  leftPanel.add(new JBScrollPane(myTree), BorderLayout.CENTER);
  mySplitter.setFirstComponent(leftPanel);

  myList = new JBList();
  myList.setCellRenderer(new MyCellRenderer());
  myList.setMinimumSize(new Dimension(120, 200));
  myList.getEmptyText().setText("No associated files");
  JPanel rightPanel = ToolbarDecorator.createDecorator(myList)
    .addExtraAction(AnActionButton.fromAction(new AddAssociationActionWrapper()))
    .addExtraAction(AnActionButton.fromAction(new RemoveAssociationAction()))
    .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel();
  UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0)));
  mySplitter.setSecondComponent(rightPanel);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AssociationsEditor.java


注:本文中的com.intellij.ui.treeStructure.Tree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。