From e3877148ff272797b4ed469504d2cdf3d2ca3bac Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Wed, 20 Aug 2008 12:53:53 +0400 Subject: [PATCH] Ruby test runner: Statistics navigation in table was improved. Go to parent suite now selects corresponding child suite in parent's statistics table --- .../ui/statistics/RTestUnitStatisticsPanel.java | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/ruby/src/org/jetbrains/plugins/ruby/testing/testunit/runner/ui/statistics/RTestUnitStatisticsPanel.java b/plugins/ruby/src/org/jetbrains/plugins/ruby/testing/testunit/runner/ui/statistics/RTestUnitStatisticsPanel.java index 19d4ac63e6..997092631f 100644 --- a/plugins/ruby/src/org/jetbrains/plugins/ruby/testing/testunit/runner/ui/statistics/RTestUnitStatisticsPanel.java +++ b/plugins/ruby/src/org/jetbrains/plugins/ruby/testing/testunit/runner/ui/statistics/RTestUnitStatisticsPanel.java @@ -176,12 +176,14 @@ public class RTestUnitStatisticsPanel extends JPanel { if (ColumnTest.TestsCellRenderer.isFirstLine(i)) { final RTestUnitTestProxy parentSuite = selectedProxy.getParent(); if (parentSuite != null) { - showInTableAndSelectFirstRow(parentSuite, selectionListener); + // go to parent and current suit in it + showInTableAndSelectRow(parentSuite, selectionListener, selectedProxy); } } else { // if selected element is suite - we should expand it if (selectedProxy.isSuite()) { - showInTableAndSelectFirstRow(selectedProxy, selectionListener); + // expand and select first (Total) row + showInTableAndSelectRow(selectedProxy, selectionListener, selectedProxy); } } } @@ -201,6 +203,19 @@ public class RTestUnitStatisticsPanel extends JPanel { }); } + /** + * Selects row in table + * @param rowIndex Row's index + */ + protected void selectRowOf(final RTestUnitTestProxy proxy) { + UIUtil.addToInvokeLater(new Runnable() { + public void run() { + final int rowIndex = myTableModel.getIndexOf(proxy); + myStatisticsTableView.setRowSelectionInterval(rowIndex, rowIndex >= 0 ? rowIndex : 0); + } + }); + } + @Nullable protected RTestUnitTestProxy getSelectedItem() { return myStatisticsTableView.getSelectedObject(); @@ -231,10 +246,11 @@ public class RTestUnitStatisticsPanel extends JPanel { myStatisticsTableView = new TableView(); } - private void showInTableAndSelectFirstRow(final RTestUnitTestProxy suite, - final RTestUnitResultsForm.FormSelectionListener selectionListener) { + private void showInTableAndSelectRow(final RTestUnitTestProxy suite, + final RTestUnitResultsForm.FormSelectionListener selectionListener, + final RTestUnitTestProxy suiteProxy) { selectionListener.onSelectedRequest(suite); - selectRow(0); + selectRowOf(suiteProxy); } /** -- 2.11.4.GIT