public void selected(SegmentEditArticleSelectionEvent event) { if (!event.getArticleSelections().isEmpty()) { // we check if all articles are non-allocated, allocated or reversed, only then they can // be removed ArticleStatusCheckResult articleStatusCheckResult = getArticleStatusCheckResult(event.getArticleSelections()); deleteSelectionButton.setEnabled( articleStatusCheckResult.isAllArticlesAllocatedOrReversed()); } else { deleteSelectionButton.setEnabled(false); } }
private void checkAllArticlesAreAllocatedOrReversed( Collection<? extends Article> deletedArticles) { ArticleStatusCheckResult articleStatusCheckResult = new ArticleStatusCheckResult(getArticleContainerEdit().getArticles()); articlesWithWrongState.addAll(articleStatusCheckResult.getNotAllocatedNorReversedArticles()); articlesWithWrongState.removeAll(articleStatusCheckResult.getAllocatedOrReversedArticles()); if (deletedArticles != null) articlesWithWrongState.removeAll(deletedArticles); if (buttonComp != null && !buttonComp.isDisposed()) buttonComp.setEnabled(articlesWithWrongState.isEmpty()); }