@Ignore("Test is not longer valid with code-splitting in the method. REFACTOR NEEDED.") @Test public void multipleSimilarWindowTypesCycleToFront_show_type() { Window window1 = mock(Window.class); Window window2 = mock(Window.class); Window window3 = mock(Window.class); Window window4 = mock(Window.class); when(window1.isVisible()).thenReturn(true); when(window2.isVisible()).thenReturn(true); when(window3.isVisible()).thenReturn(true); when(window4.isVisible()).thenReturn(true); when(window1.getStateId()).thenReturn(WindowType.ABOUT.toString()); when(window2.getStateId()).thenReturn(WindowType.DATA.toString() + "1"); when(window3.getStateId()).thenReturn(WindowType.DATA.toString() + "2"); when(window4.getStateId()).thenReturn(WindowType.ANALYSES.toString()); final Stack<Widget> windowStack = new Stack<>(); windowStack.push(window2); windowStack.push(window3); when(windowManagerMock.getStack()).thenReturn(windowStack); uut.show(WindowType.DATA); verify(windowManagerMock).bringToFront(eq(window2)); windowStack.clear(); windowStack.push(window1); windowStack.push(window4); windowStack.push(window2); windowStack.push(window3); uut.show(WindowType.DATA); verify(windowManagerMock, times(2)).bringToFront(eq(window2)); windowStack.clear(); windowStack.push(window1); windowStack.push(window2); windowStack.push(window3); windowStack.push(window4); uut.show(WindowType.DATA); verify(windowManagerMock).bringToFront(eq(window3)); }
public void show(final WindowState windowState) { final WindowConfig config = getConfig(windowState); String windowId = constructWindowId(config); for (Widget w : windowManager.getWindows()) { String currentId = ((Window) w).getStateId(); if (windowId.equals(currentId)) { ((IPlantWindowInterface) w).asWindow().show(); return; } } getOrCreateWindow(config).get(new AsyncCallback<IPlantWindowInterface>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(IPlantWindowInterface window) { window.setPixelSize(windowState.getWidth(), windowState.getHeight()); window.setPagePosition(windowState.getWinLeft(), windowState.getWinTop()); if (desktopContainer != null) { window.setContainer(desktopContainer); } window.show(config, constructWindowId(config), true); if (sticky != null) { windowManager.bringToFront(sticky); } } }); }
DesktopWindowManager { public void show(final WindowState windowState) { final WindowConfig config = getConfig(windowState); String windowId = constructWindowId(config); for (Widget w : windowManager.getWindows()) { String currentId = ((Window) w).getStateId(); if (windowId.equals(currentId)) { ((IPlantWindowInterface) w).asWindow().show(); return; } } getOrCreateWindow(config).get(new AsyncCallback<IPlantWindowInterface>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(IPlantWindowInterface window) { window.setPixelSize(windowState.getWidth(), windowState.getHeight()); window.setPagePosition(windowState.getWinLeft(), windowState.getWinTop()); if (desktopContainer != null) { window.setContainer(desktopContainer); } window.show(config, constructWindowId(config), true); if (sticky != null) { windowManager.bringToFront(sticky); } } }); } }
DesktopWindowManager { public void show(final WindowState windowState) { final WindowConfig config = getConfig(windowState); String windowId = constructWindowId(config); for (Widget w : windowManager.getWindows()) { String currentId = ((Window) w).getStateId(); if (windowId.equals(currentId)) { ((IPlantWindowInterface) w).asWindow().show(); return; } } getOrCreateWindow(config).get(new AsyncCallback<IPlantWindowInterface>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(IPlantWindowInterface window) { window.setPixelSize(windowState.getWidth(), windowState.getHeight()); window.setPagePosition(windowState.getWinLeft(), windowState.getWinTop()); if (desktopContainer != null) { window.setContainer(desktopContainer); } window.show(config, constructWindowId(config), true); if (sticky != null) { windowManager.bringToFront(sticky); } } }); } @Inject  DesktopWindowManager(final WindowManager windowManager,
                         final WindowFactory windowFactory); }
DesktopWindowManager { public void show(final WindowState windowState) { final WindowConfig config = getConfig(windowState); String windowId = constructWindowId(config); for (Widget w : windowManager.getWindows()) { String currentId = ((Window) w).getStateId(); if (windowId.equals(currentId)) { ((IPlantWindowInterface) w).asWindow().show(); return; } } getOrCreateWindow(config).get(new AsyncCallback<IPlantWindowInterface>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(IPlantWindowInterface window) { window.setPixelSize(windowState.getWidth(), windowState.getHeight()); window.setPagePosition(windowState.getWinLeft(), windowState.getWinTop()); if (desktopContainer != null) { window.setContainer(desktopContainer); } window.show(config, constructWindowId(config), true); if (sticky != null) { windowManager.bringToFront(sticky); } } }); } @Inject  DesktopWindowManager(final WindowManager windowManager,
                         final WindowFactory windowFactory); void closeActiveWindow(); void show(final WindowState windowState); void show(WindowType windowType); void show(final WindowConfig config, final boolean updateExistingWindow); void stickWindowToTop(Window window); }
DesktopWindowManager { public void show(final WindowState windowState) { final WindowConfig config = getConfig(windowState); String windowId = constructWindowId(config); for (Widget w : windowManager.getWindows()) { String currentId = ((Window) w).getStateId(); if (windowId.equals(currentId)) { ((IPlantWindowInterface) w).asWindow().show(); return; } } getOrCreateWindow(config).get(new AsyncCallback<IPlantWindowInterface>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); } @Override public void onSuccess(IPlantWindowInterface window) { window.setPixelSize(windowState.getWidth(), windowState.getHeight()); window.setPagePosition(windowState.getWinLeft(), windowState.getWinTop()); if (desktopContainer != null) { window.setContainer(desktopContainer); } window.show(config, constructWindowId(config), true); if (sticky != null) { windowManager.bringToFront(sticky); } } }); } @Inject  DesktopWindowManager(final WindowManager windowManager,
                         final WindowFactory windowFactory); void closeActiveWindow(); void show(final WindowState windowState); void show(WindowType windowType); void show(final WindowConfig config, final boolean updateExistingWindow); void stickWindowToTop(Window window);  }