package jetbrains.mps.baseLanguage.unitTest.execution.tool; /*Generated by MPS */ import javax.swing.event.TreeSelectionListener; import javax.swing.tree.TreeSelectionModel; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreePath; public class TestTreeSelectionListener implements TreeSelectionListener { private final TreeSelectionModel myFreeSelectionModel; private final StatisticsTableModel myStatisticsModel; private final TestOutputComponent myOutputComponent; public TestTreeSelectionListener(TestTree tree, StatisticsTableModel statistics, TestOutputComponent outputComponent) { myFreeSelectionModel = tree.getSelectionModel(); myStatisticsModel = statistics; myOutputComponent = outputComponent; } @Override public void valueChanged(TreeSelectionEvent event) { if (event.getNewLeadSelectionPath() == null) { return; } TreePath path = myFreeSelectionModel.getSelectionPath(); if (path == null) { return; } String className = null; String methodName = null; Object node = path.getLastPathComponent(); if (node instanceof TestCaseTreeNode) { TestCaseTreeNode n = (TestCaseTreeNode) node; className = n.getClassName(); } else if (node instanceof TestMethodTreeNode) { TestMethodTreeNode n = (TestMethodTreeNode) node; className = n.getClassName(); methodName = n.getMethodName(); } myOutputComponent.filter(className, methodName); myStatisticsModel.setFilter(className, methodName); } }