コード例 #1
0
  protected void deleteSelection() {
    // We remove the lines from the server - therefore find out first, what lines shall be handled
    // here.
    SegmentEdit segmentEdit = getArticleContainerEdit().getActiveSegmentEdit();
    Set<? extends ArticleSelection> articleSelections = segmentEdit.getArticleSelections();

    if (!articleSelections.isEmpty()) {
      Set<ArticleID> articleIDs = new HashSet<ArticleID>();
      for (ArticleSelection articleSelection : articleSelections) {
        for (Article article : articleSelection.getSelectedArticles()) {
          articleIDs.add((ArticleID) JDOHelper.getObjectId(article));
        }
      }

      final Composite composite = getArticleContainerEdit().getActiveSegmentEdit().getComposite();
      //			Composite composite = articleContainerEdit;
      try {
        if (!composite.isDisposed()) {
          composite.setEnabled(false);
          buttonComp.setEnabled(false);
        }
        ArticleChangeListener articleChangeListener =
            new ArticleChangeListener() {
              @Override
              public void articlesChanged(ArticleChangeEvent articleChangeEvent) {
                if (!composite.isDisposed()) {
                  composite.setEnabled(true);
                  buttonComp.setEnabled(true);
                }
                getArticleContainerEdit().removeArticleChangeListener(this);
              }
            };
        getArticleContainerEdit().addArticleChangeListener(articleChangeListener);

        //				TradeManager tradeManager = TradePlugin.getDefault().getTradeManager();
        //				Collection<Article> articles = tradeManager.releaseArticles(articleIDs,
        //						true, false, null, NLJDOHelper.MAX_FETCH_DEPTH_NO_LIMIT);
        //				tradeManager.deleteArticles(articleIDs, true);

        ClientArticleSegmentGroupSet clientArticleSegmentGroupSet =
            getArticleContainerEdit().getArticleSegmentGroupSet();

        List<Article> articles =
            ArticleDAO.sharedInstance()
                .deleteArticles(
                    articleIDs,
                    true,
                    true,
                    clientArticleSegmentGroupSet.getFetchGroupsArticle(),
                    clientArticleSegmentGroupSet.getMaxFetchDepthArticle(),
                    new NullProgressMonitor());
        Set<ArticleID> deletedArticleIDs = new HashSet<ArticleID>(articleIDs);
        for (Article article : articles) {
          deletedArticleIDs.remove(JDOHelper.getObjectId(article));
        }

        clientArticleSegmentGroupSet.updateArticles(deletedArticleIDs, articles);
      } catch (Exception e) {
        if (!composite.isDisposed()) {
          composite.setEnabled(true);
          buttonComp.setEnabled(true);
        }
        throw new RuntimeException(e);
      }
    }
  }
コード例 #2
0
 /**
  * Returns a Set of all {@link ArticleID} of those {@link Article}s which do not have the
  * allocated or reversed status form the given Set of {@link ArticleSelection}s.
  *
  * @param selections a Set of {@link ArticleSelection} which should be checked
  * @return a Set of all {@link ArticleID} of those {@link Article}s which do not have the
  *     allocated or reversed status
  */
 protected ArticleStatusCheckResult getArticleStatusCheckResult(Set<ArticleSelection> selections) {
   return new ArticleStatusCheckResult(ArticleSelection.getSelectedArticles(selections));
 }