@Test public void testOnSelectionChanged_OneSelected_appEnabled() { uut = new AnalysesToolBarImpl(appearanceMock, presenterMock, loaderMock){ @Override boolean canCancelSelection(final List<Analysis> selection){ return true; } @Override boolean canDeleteSelection(List<Analysis> selection) { return true; } }; mockMenuItems(uut); final Analysis mockAnalysis = mock(Analysis.class); when(mockAnalysis.isAppDisabled()).thenReturn(false); when(mockAnalysis.getUserName()).thenReturn("user@iplantcollaborative.org"); when(mockUserInfo.getFullUsername()).thenReturn("user@iplantcollaborative.org"); when(mockSelectionEvent.getSelection()).thenReturn(Lists.newArrayList(mockAnalysis)); when(mockAnalysis.getStatus()).thenReturn(COMPLETED.toString()); uut.onSelectionChanged(mockSelectionEvent); verify(goToFolderMiMock).setEnabled(eq(true)); verify(viewParamsMiMock).setEnabled(eq(true)); verify(relaunchMock).setEnabled(eq(true)); verify(cancelMiMock).setEnabled(eq(true)); verify(deleteMiMock).setEnabled(eq(true)); verify(renameMiMock).setEnabled(eq(true)); verify(updateCommentsMiMock).setEnabled(eq(true)); }
@Override public void onSelectionChanged(SelectionChangedEvent<Analysis> event) { GWT.log("user--->" + userInfo.getFullUsername()); currentSelection = event.getSelection(); int size = currentSelection.size(); final boolean canCancelSelection = canCancelSelection(currentSelection); final boolean canDeleteSelection = canDeleteSelection(currentSelection); boolean isOwner = isOwner(currentSelection); boolean can_share = isSharable(currentSelection); boolean goToFolderEnabled, viewParamsEnabled, relaunchEnabled, cancelEnabled, deleteEnabled; boolean renameEnabled, updateCommentsEnabled, shareEnabled; switch (size) { case 0: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = false; deleteEnabled = false; renameEnabled = false; updateCommentsEnabled = false; shareEnabled = false; break; case 1: goToFolderEnabled = true; viewParamsEnabled = true; relaunchEnabled = !currentSelection.get(0).isAppDisabled(); cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; renameEnabled = isOwner; updateCommentsEnabled = isOwner; shareEnabled = isOwner && can_share; break; default: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; shareEnabled = isOwner && can_share; renameEnabled = false; updateCommentsEnabled = false; } goToFolderMI.setEnabled(goToFolderEnabled); viewParamsMI.setEnabled(viewParamsEnabled); viewJobInfoMI.setEnabled(viewParamsEnabled); relaunchMI.setEnabled(relaunchEnabled); cancelMI.setEnabled(cancelEnabled); deleteMI.setEnabled(deleteEnabled); share_menu.setEnabled(shareEnabled); shareCollabMI.setEnabled(shareEnabled); renameMI.setEnabled(renameEnabled); updateCommentsMI.setEnabled(updateCommentsEnabled); }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { @Override public void onSelectionChanged(SelectionChangedEvent<Analysis> event) { GWT.log("user--->" + userInfo.getFullUsername()); currentSelection = event.getSelection(); int size = currentSelection.size(); final boolean canCancelSelection = canCancelSelection(currentSelection); final boolean canDeleteSelection = canDeleteSelection(currentSelection); boolean isOwner = isOwner(currentSelection); boolean can_share = isSharable(currentSelection); boolean goToFolderEnabled, viewParamsEnabled, relaunchEnabled, cancelEnabled, deleteEnabled; boolean renameEnabled, updateCommentsEnabled, shareEnabled; switch (size) { case 0: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = false; deleteEnabled = false; renameEnabled = false; updateCommentsEnabled = false; shareEnabled = false; break; case 1: goToFolderEnabled = true; viewParamsEnabled = true; relaunchEnabled = !currentSelection.get(0).isAppDisabled(); cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; renameEnabled = isOwner; updateCommentsEnabled = isOwner; shareEnabled = isOwner && can_share; break; default: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; shareEnabled = isOwner && can_share; renameEnabled = false; updateCommentsEnabled = false; } goToFolderMI.setEnabled(goToFolderEnabled); viewParamsMI.setEnabled(viewParamsEnabled); viewJobInfoMI.setEnabled(viewParamsEnabled); relaunchMI.setEnabled(relaunchEnabled); cancelMI.setEnabled(cancelEnabled); deleteMI.setEnabled(deleteEnabled); share_menu.setEnabled(shareEnabled); shareCollabMI.setEnabled(shareEnabled); renameMI.setEnabled(renameEnabled); updateCommentsMI.setEnabled(updateCommentsEnabled); } }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { @Override public void onSelectionChanged(SelectionChangedEvent<Analysis> event) { GWT.log("user--->" + userInfo.getFullUsername()); currentSelection = event.getSelection(); int size = currentSelection.size(); final boolean canCancelSelection = canCancelSelection(currentSelection); final boolean canDeleteSelection = canDeleteSelection(currentSelection); boolean isOwner = isOwner(currentSelection); boolean can_share = isSharable(currentSelection); boolean goToFolderEnabled, viewParamsEnabled, relaunchEnabled, cancelEnabled, deleteEnabled; boolean renameEnabled, updateCommentsEnabled, shareEnabled; switch (size) { case 0: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = false; deleteEnabled = false; renameEnabled = false; updateCommentsEnabled = false; shareEnabled = false; break; case 1: goToFolderEnabled = true; viewParamsEnabled = true; relaunchEnabled = !currentSelection.get(0).isAppDisabled(); cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; renameEnabled = isOwner; updateCommentsEnabled = isOwner; shareEnabled = isOwner && can_share; break; default: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; shareEnabled = isOwner && can_share; renameEnabled = false; updateCommentsEnabled = false; } goToFolderMI.setEnabled(goToFolderEnabled); viewParamsMI.setEnabled(viewParamsEnabled); viewJobInfoMI.setEnabled(viewParamsEnabled); relaunchMI.setEnabled(relaunchEnabled); cancelMI.setEnabled(cancelEnabled); deleteMI.setEnabled(deleteEnabled); share_menu.setEnabled(shareEnabled); shareCollabMI.setEnabled(shareEnabled); renameMI.setEnabled(renameEnabled); updateCommentsMI.setEnabled(updateCommentsEnabled); } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { @Override public void onSelectionChanged(SelectionChangedEvent<Analysis> event) { GWT.log("user--->" + userInfo.getFullUsername()); currentSelection = event.getSelection(); int size = currentSelection.size(); final boolean canCancelSelection = canCancelSelection(currentSelection); final boolean canDeleteSelection = canDeleteSelection(currentSelection); boolean isOwner = isOwner(currentSelection); boolean can_share = isSharable(currentSelection); boolean goToFolderEnabled, viewParamsEnabled, relaunchEnabled, cancelEnabled, deleteEnabled; boolean renameEnabled, updateCommentsEnabled, shareEnabled; switch (size) { case 0: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = false; deleteEnabled = false; renameEnabled = false; updateCommentsEnabled = false; shareEnabled = false; break; case 1: goToFolderEnabled = true; viewParamsEnabled = true; relaunchEnabled = !currentSelection.get(0).isAppDisabled(); cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; renameEnabled = isOwner; updateCommentsEnabled = isOwner; shareEnabled = isOwner && can_share; break; default: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; shareEnabled = isOwner && can_share; renameEnabled = false; updateCommentsEnabled = false; } goToFolderMI.setEnabled(goToFolderEnabled); viewParamsMI.setEnabled(viewParamsEnabled); viewJobInfoMI.setEnabled(viewParamsEnabled); relaunchMI.setEnabled(relaunchEnabled); cancelMI.setEnabled(cancelEnabled); deleteMI.setEnabled(deleteEnabled); share_menu.setEnabled(shareEnabled); shareCollabMI.setEnabled(shareEnabled); renameMI.setEnabled(renameEnabled); updateCommentsMI.setEnabled(updateCommentsEnabled); } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); @Override void filterByAnalysisId(String analysisId, String name); @Override void filterByParentAnalysisId(String analysisId); @Override void onSelectionChanged(SelectionChangedEvent<Analysis> event); @Override void setFilterInView(AnalysisFilter filter); }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { @Override public void onSelectionChanged(SelectionChangedEvent<Analysis> event) { GWT.log("user--->" + userInfo.getFullUsername()); currentSelection = event.getSelection(); int size = currentSelection.size(); final boolean canCancelSelection = canCancelSelection(currentSelection); final boolean canDeleteSelection = canDeleteSelection(currentSelection); boolean isOwner = isOwner(currentSelection); boolean can_share = isSharable(currentSelection); boolean goToFolderEnabled, viewParamsEnabled, relaunchEnabled, cancelEnabled, deleteEnabled; boolean renameEnabled, updateCommentsEnabled, shareEnabled; switch (size) { case 0: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = false; deleteEnabled = false; renameEnabled = false; updateCommentsEnabled = false; shareEnabled = false; break; case 1: goToFolderEnabled = true; viewParamsEnabled = true; relaunchEnabled = !currentSelection.get(0).isAppDisabled(); cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; renameEnabled = isOwner; updateCommentsEnabled = isOwner; shareEnabled = isOwner && can_share; break; default: goToFolderEnabled = false; viewParamsEnabled = false; relaunchEnabled = false; cancelEnabled = canCancelSelection && isOwner; deleteEnabled = canDeleteSelection && isOwner; shareEnabled = isOwner && can_share; renameEnabled = false; updateCommentsEnabled = false; } goToFolderMI.setEnabled(goToFolderEnabled); viewParamsMI.setEnabled(viewParamsEnabled); viewJobInfoMI.setEnabled(viewParamsEnabled); relaunchMI.setEnabled(relaunchEnabled); cancelMI.setEnabled(cancelEnabled); deleteMI.setEnabled(deleteEnabled); share_menu.setEnabled(shareEnabled); shareCollabMI.setEnabled(shareEnabled); renameMI.setEnabled(renameEnabled); updateCommentsMI.setEnabled(updateCommentsEnabled); } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); @Override void filterByAnalysisId(String analysisId, String name); @Override void filterByParentAnalysisId(String analysisId); @Override void onSelectionChanged(SelectionChangedEvent<Analysis> event); @Override void setFilterInView(AnalysisFilter filter);  }