Java Code Examples for com.intellij.ui.treeStructure.Tree#addSelectionPath()

The following examples show how to use com.intellij.ui.treeStructure.Tree#addSelectionPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnalyzeSizeToolWindowTest.java    From size-analyzer with Apache License 2.0 6 votes vote down vote up
@Test
public void autofixIsNotShownWhenNull() {
  JPanel toolPanel = toolWindow.getContent();
  Component[] components = toolPanel.getComponents();
  OnePixelSplitter splitter = (OnePixelSplitter) components[0];
  JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent();
  JViewport leftView = leftPane.getViewport();
  Tree suggestionTree = (Tree) leftView.getView();
  JPanel rightPane = (JPanel) splitter.getSecondComponent();

  TreePath streamingPath =
      getTreePathWithString(suggestionTree, streamingSuggestionData.toString());
  suggestionTree.addSelectionPath(streamingPath);

  for (Component component : rightPane.getComponents()) {
    if (component instanceof JButton) {
      assertThat(component.isVisible()).isFalse();
    }
  }
}
 
Example 2
Source File: AnalyzeSizeToolWindowTest.java    From size-analyzer with Apache License 2.0 5 votes vote down vote up
@Test
public void selectingCategoryNodeChangesCategoryPanel() {
  JPanel toolPanel = toolWindow.getContent();
  Component[] components = toolPanel.getComponents();
  OnePixelSplitter splitter = (OnePixelSplitter) components[0];
  JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent();
  JViewport leftView = leftPane.getViewport();
  Tree suggestionTree = (Tree) leftView.getView();

  assertThat(suggestionTree.getSelectionCount()).isEqualTo(0);

  TreePath webPPath = getTreePathWithString(suggestionTree, webPCategoryData.toString());
  suggestionTree.addSelectionPath(webPPath);
  JPanel rightPane = (JPanel) splitter.getSecondComponent();

  assertThat(suggestionTree.getSelectionCount()).isEqualTo(1);
  for (Component component : rightPane.getComponents()) {
    if (component instanceof SimpleColoredComponent) {
      assertThat(component.toString()).contains(webPCategoryData.toString());
      assertThat(component.toString()).contains("Estimated savings: 29.30 KB");
    } else if (component instanceof JPanel) {
      Component[] suggestionPanelComponents = ((JPanel) component).getComponents();
      assertThat(suggestionPanelComponents).hasLength(1);
      for (Component linkLabel : suggestionPanelComponents) {
        assertThat(((LinkLabel<?>) linkLabel).getText()).isEqualTo(SuggestionDataFactory.issueTypeNodeNames.get(IssueType.WEBP));
      }
    }
  }
}
 
Example 3
Source File: CertificateTreeBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void selectFirstCertificate() {
  if (!isEmpty()) {
    Tree tree = (Tree)getTree();
    TreePath path = TreeUtil.getFirstLeafNodePath(tree);
    tree.addSelectionPath(path);
  }
}