@Test public void taskButtonRemovedWhenWindowIsUnregisteredAndNotMinimized() { DesktopViewImpl uut = new DesktopViewImpl(tourStringsMock, windowManagerMock); verifyViewInit(uut); uut.taskBar = mock(TaskBar.class); TaskButton mockTaskButton = mock(TaskButton.class); List<TaskButton> tbList = Lists.newArrayList(mockTaskButton); when(uut.taskBar.getButtons()).thenReturn(tbList); final Window window = mock(Window.class, withSettings().extraInterfaces(IPlantWindowInterface.class)); when(unregisterEventMock.getItem()).thenReturn(window); when(mockTaskButton.getWindow()).thenReturn(window); uut.onUnregister(unregisterEventMock); verify(mockTaskButton).getWindow(); verify(uut.taskBar).removeTaskButton(eq(mockTaskButton)); verifyNoMoreInteractions(mockTaskButton, windowManagerMock); }
@Override public void onUnregister(UnregisterEvent<Widget> event) { final Widget eventItem = event.getItem(); if(eventItem instanceof IPlantWindowInterface) { IPlantWindowInterface iplantWindow = (IPlantWindowInterface) eventItem; TaskButton taskButton = null; for(TaskButton btn : taskBar.getButtons()){ if(btn.getWindow() == iplantWindow){ taskButton = btn; break; } } Preconditions.checkNotNull(taskButton, "TaskButton should not be null"); if(iplantWindow.isMinimized()){ windowManager.register(eventItem); return; } taskBar.removeTaskButton(taskButton); } }
DesktopViewImpl implements DesktopView, UnregisterEvent.UnregisterHandler<Widget>, RegisterEvent.RegisterHandler<Widget> { @Override public void onUnregister(UnregisterEvent<Widget> event) { final Widget eventItem = event.getItem(); if(eventItem instanceof IPlantWindowInterface) { IPlantWindowInterface iplantWindow = (IPlantWindowInterface) eventItem; TaskButton taskButton = null; for(TaskButton btn : taskBar.getButtons()){ if(btn.getWindow() == iplantWindow){ taskButton = btn; break; } } Preconditions.checkNotNull(taskButton, "TaskButton should not be null"); if(iplantWindow.isMinimized()){ windowManager.register(eventItem); return; } taskBar.removeTaskButton(taskButton); } } }
DesktopViewImpl implements DesktopView, UnregisterEvent.UnregisterHandler<Widget>, RegisterEvent.RegisterHandler<Widget> { @Override public void onUnregister(UnregisterEvent<Widget> event) { final Widget eventItem = event.getItem(); if(eventItem instanceof IPlantWindowInterface) { IPlantWindowInterface iplantWindow = (IPlantWindowInterface) eventItem; TaskButton taskButton = null; for(TaskButton btn : taskBar.getButtons()){ if(btn.getWindow() == iplantWindow){ taskButton = btn; break; } } Preconditions.checkNotNull(taskButton, "TaskButton should not be null"); if(iplantWindow.isMinimized()){ windowManager.register(eventItem); return; } taskBar.removeTaskButton(taskButton); } } @Inject  DesktopViewImpl(final IplantNewUserTourStrings tourStrings,
                    final WindowManager windowManager); }
DesktopViewImpl implements DesktopView, UnregisterEvent.UnregisterHandler<Widget>, RegisterEvent.RegisterHandler<Widget> { @Override public void onUnregister(UnregisterEvent<Widget> event) { final Widget eventItem = event.getItem(); if(eventItem instanceof IPlantWindowInterface) { IPlantWindowInterface iplantWindow = (IPlantWindowInterface) eventItem; TaskButton taskButton = null; for(TaskButton btn : taskBar.getButtons()){ if(btn.getWindow() == iplantWindow){ taskButton = btn; break; } } Preconditions.checkNotNull(taskButton, "TaskButton should not be null"); if(iplantWindow.isMinimized()){ windowManager.register(eventItem); return; } taskBar.removeTaskButton(taskButton); } } @Inject  DesktopViewImpl(final IplantNewUserTourStrings tourStrings,
                    final WindowManager windowManager); void hideNotificationMenu(); @Override void onRegister(RegisterEvent<Widget> event); @Override void onUnregister(UnregisterEvent<Widget> event); @Override Widget asWidget(); @Override void ensureDebugId(String baseID); @Override Element getDesktopContainer(); @Override ListStore<NotificationMessage> getNotificationStore(); @Override int getUnseenNotificationCount(); @Override void setPresenter(final DesktopView.Presenter presenter); @Override void setUnseenNotificationCount(int count); @Override void setUnseenSystemMessageCount(int count); }
DesktopViewImpl implements DesktopView, UnregisterEvent.UnregisterHandler<Widget>, RegisterEvent.RegisterHandler<Widget> { @Override public void onUnregister(UnregisterEvent<Widget> event) { final Widget eventItem = event.getItem(); if(eventItem instanceof IPlantWindowInterface) { IPlantWindowInterface iplantWindow = (IPlantWindowInterface) eventItem; TaskButton taskButton = null; for(TaskButton btn : taskBar.getButtons()){ if(btn.getWindow() == iplantWindow){ taskButton = btn; break; } } Preconditions.checkNotNull(taskButton, "TaskButton should not be null"); if(iplantWindow.isMinimized()){ windowManager.register(eventItem); return; } taskBar.removeTaskButton(taskButton); } } @Inject  DesktopViewImpl(final IplantNewUserTourStrings tourStrings,
                    final WindowManager windowManager); void hideNotificationMenu(); @Override void onRegister(RegisterEvent<Widget> event); @Override void onUnregister(UnregisterEvent<Widget> event); @Override Widget asWidget(); @Override void ensureDebugId(String baseID); @Override Element getDesktopContainer(); @Override ListStore<NotificationMessage> getNotificationStore(); @Override int getUnseenNotificationCount(); @Override void setPresenter(final DesktopView.Presenter presenter); @Override void setUnseenNotificationCount(int count); @Override void setUnseenSystemMessageCount(int count);  }