@Test public void testOpenInNewWindow() { JFrame f = new JFrame(); f.setContentPane(new JPanel()); f.getContentPane().add(new JButton("press me")); f.pack(); f.setVisible(true); @SuppressWarnings("unchecked") ComponentProvider provider = new MockComponentProvider(Collections .EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList( new ViewInfo(NodeViewManifestation.class, "test", ViewType.NODE))); ExternalComponentRegistryImpl.getInstance().refreshComponents(Collections.singletonList(new ExtendedComponentProvider(provider, ""))); AbstractComponent mockedComponent = Mockito.mock(AbstractComponent.class); Set<ViewInfo> returnedViewInfos = Collections.singleton(new ViewInfo(NodeViewManifestation.class, "t", ViewType.NODE)); Mockito.when(mockedComponent.getViewInfos(ViewType.NODE)).thenReturn(returnedViewInfos); Mockito.when(mockedComponent.getDisplayName()).thenReturn("testComponent"); Mockito.when(mockedComponent.isLeaf()).thenReturn(true); Assert.assertTrue(mockedComponent.isLeaf()); WindowManagerImplOverride windowMgr = new WindowManagerImplOverride(); windowMgr.openInNewWindow(mockedComponent); Assert.assertEquals(windowMgr.displayName, mockedComponent.getDisplayName()); Assert.assertSame(windowMgr.nodeView.getViewClass(), NodeViewManifestation.class); Assert.assertEquals(windowMgr.horizontalScale, WindowManagerImpl.LEAF_HORIZONTAL_SCALE); Assert.assertEquals(windowMgr.verticalScale, WindowManagerImpl.LEAF_VERTICAL_SCALE); Mockito.when(mockedComponent.isLeaf()).thenReturn(false); windowMgr.openInNewWindow(mockedComponent); Assert.assertEquals(windowMgr.horizontalScale, WindowManagerImpl.NON_LEAF_HORIZONTAL_SCALE); Assert.assertEquals(windowMgr.verticalScale, WindowManagerImpl.NON_LEAF_VERTICAL_SCALE); f.setVisible(false); f.dispose(); }
@Override public void openInNewWindow(AbstractComponent component) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); openInNewWindow(component, graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration()); }
WindowManagerImpl implements WindowManager { @Override public void openInNewWindow(AbstractComponent component) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); openInNewWindow(component, graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration()); } }
WindowManagerImpl implements WindowManager { @Override public void openInNewWindow(AbstractComponent component) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); openInNewWindow(component, graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration()); } protected  WindowManagerImpl(); }
WindowManagerImpl implements WindowManager { @Override public void openInNewWindow(AbstractComponent component) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); openInNewWindow(component, graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration()); } protected  WindowManagerImpl(); static WindowManagerImpl getInstance(); @Override void openInNewWindow(AbstractComponent component); @Override void openInNewWindow(AbstractComponent component, GraphicsConfiguration graphicsConfig); @Override AbstractComponent getWindowRootComponent(Component component); @Override View getWindowRootManifestation(Component component); @Override void refreshWindows(); @Override void closeWindows(String componentId); @SuppressWarnings("unchecked") @Override T showInputDialog(String title, String message, T[] options, T defaultOption, Map<String, Object> hints); }
WindowManagerImpl implements WindowManager { @Override public void openInNewWindow(AbstractComponent component) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); openInNewWindow(component, graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration()); } protected  WindowManagerImpl(); static WindowManagerImpl getInstance(); @Override void openInNewWindow(AbstractComponent component); @Override void openInNewWindow(AbstractComponent component, GraphicsConfiguration graphicsConfig); @Override AbstractComponent getWindowRootComponent(Component component); @Override View getWindowRootManifestation(Component component); @Override void refreshWindows(); @Override void closeWindows(String componentId); @SuppressWarnings("unchecked") @Override T showInputDialog(String title, String message, T[] options, T defaultOption, Map<String, Object> hints); static final String PARENT_COMPONENT; static final String OPTION_TYPE; static final String MESSAGE_TYPE; static final String MESSAGE_OBJECT; }