@Test public void testGetOpened() throws Exception { WindowUtilities.tcProvider = () -> Arrays.asList(createMyOtherTC("A"), createMyTC("B"), createTC("C"), createTC("D"), createMyOtherTC("E")); assertEquals(5, WindowUtilities.getOpened(TopComponent.class).count()); assertEquals(3, WindowUtilities.getOpened(MyTopComponent.class).count()); assertEquals(2, WindowUtilities.getOpened(MyOtherTopComponent.class).count()); assertEquals(2, WindowUtilities.getOpened(Runnable.class).count()); }
public static <T> Stream<T> getOpened(final Class<T> type) { return tcProvider.getOpened().stream() .flatMap(topComponent -> { if (topComponent instanceof WindowContainer) { return Stream.concat(Stream.of(topComponent), ((WindowContainer) topComponent).getOpenedWindows().stream()); } return Stream.of(topComponent); }) .filter(topComponent -> type.isAssignableFrom(topComponent.getClass())) .map(topComponent -> (T) topComponent); }
WindowUtilities { public static <T> Stream<T> getOpened(final Class<T> type) { return tcProvider.getOpened().stream() .flatMap(topComponent -> { if (topComponent instanceof WindowContainer) { return Stream.concat(Stream.of(topComponent), ((WindowContainer) topComponent).getOpenedWindows().stream()); } return Stream.of(topComponent); }) .filter(topComponent -> type.isAssignableFrom(topComponent.getClass())) .map(topComponent -> (T) topComponent); } }
WindowUtilities { public static <T> Stream<T> getOpened(final Class<T> type) { return tcProvider.getOpened().stream() .flatMap(topComponent -> { if (topComponent instanceof WindowContainer) { return Stream.concat(Stream.of(topComponent), ((WindowContainer) topComponent).getOpenedWindows().stream()); } return Stream.of(topComponent); }) .filter(topComponent -> type.isAssignableFrom(topComponent.getClass())) .map(topComponent -> (T) topComponent); }  }
WindowUtilities { public static <T> Stream<T> getOpened(final Class<T> type) { return tcProvider.getOpened().stream() .flatMap(topComponent -> { if (topComponent instanceof WindowContainer) { return Stream.concat(Stream.of(topComponent), ((WindowContainer) topComponent).getOpenedWindows().stream()); } return Stream.of(topComponent); }) .filter(topComponent -> type.isAssignableFrom(topComponent.getClass())) .map(topComponent -> (T) topComponent); }  static String getUniqueTitle(String titleBase, Class<? extends TopComponent> windowType); static Stream<T> getOpened(final Class<T> type); }
WindowUtilities { public static <T> Stream<T> getOpened(final Class<T> type) { return tcProvider.getOpened().stream() .flatMap(topComponent -> { if (topComponent instanceof WindowContainer) { return Stream.concat(Stream.of(topComponent), ((WindowContainer) topComponent).getOpenedWindows().stream()); } return Stream.of(topComponent); }) .filter(topComponent -> type.isAssignableFrom(topComponent.getClass())) .map(topComponent -> (T) topComponent); }  static String getUniqueTitle(String titleBase, Class<? extends TopComponent> windowType); static Stream<T> getOpened(final Class<T> type);  }