IntelliJStackTraceGroup implements StackTraceGroup { @Override @NotNull public StackTraceView createStackView(@NotNull StackTraceModel model) { IntelliJStackTraceView view = myViewGenerator.apply(myProject, model); myStackTraceViews.add(view); view.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (((JList)e.getSource()).getSelectedIndex() < 0) { return; } myStackTraceViews.forEach(otherView -> { if (otherView != view) { otherView.clearSelection(); } }); } }); return view; } IntelliJStackTraceGroup(@NotNull Project project); @VisibleForTesting  IntelliJStackTraceGroup(@NotNull Project project,
                          @NotNull BiFunction<Project, StackTraceModel, IntelliJStackTraceView> viewGenerator); @Override @NotNull StackTraceView createStackView(@NotNull StackTraceModel model);  }
@Test public void canOnlySelectOneStackTraceViewAtATime() { IntelliJStackTraceGroup group = new IntelliJStackTraceGroup( ProjectStub.getInstance(), ((project, model) -> IntelliJStackTraceViewTest.createStackTraceView(project, model))); StackTraceModel model1 = IntelliJStackTraceViewTest.createStackTraceModel(); StackTraceModel model2 = IntelliJStackTraceViewTest.createStackTraceModel(); IntelliJStackTraceView view1 = (IntelliJStackTraceView)group.createStackView(model1); IntelliJStackTraceView view2 = (IntelliJStackTraceView)group.createStackView(model2); model1.setStackFrames(STACK_STRING_A); model2.setStackFrames(STACK_STRING_B); assertThat(view1.getListView().getSelectedIndex()).isLessThan(0); assertThat(view2.getListView().getSelectedIndex()).isLessThan(0); view1.getListView().setSelectedIndex(1); assertThat(view1.getListView().getSelectedIndex()).isEqualTo(1); assertThat(view2.getListView().getSelectedIndex()).isLessThan(0); view2.getListView().setSelectedIndex(2); assertThat(view1.getListView().getSelectedIndex()).isLessThan(0); assertThat(view2.getListView().getSelectedIndex()).isEqualTo(2); }