Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INews


    }
  }

  private void onNewsUpdated(Set<NewsEvent> events) {
    for (NewsEvent event : events) {
      INews currentNews = event.getEntity();
      INews oldNews = event.getOldNews();
      Assert.isNotNull(oldNews, "oldNews cannot be null on newsUpdated");
      FeedLinkReference feedRef = currentNews.getFeedReference();

      boolean oldStateUnread = ModelUtils.isUnread(oldNews.getState());
      boolean currentStateUnread = ModelUtils.isUnread(currentNews.getState());

      boolean oldStateNew = INews.State.NEW.equals(oldNews.getState());
      boolean currentStateNew = INews.State.NEW.equals(currentNews.getState());

      boolean oldStateSticky = oldNews.isFlagged();
      boolean newStateSticky = currentNews.isFlagged() && currentNews.isVisible();

      /* No Change - continue */
      if (oldStateUnread == currentStateUnread && oldStateNew == currentStateNew && oldStateSticky == newStateSticky)
        continue;
View Full Code Here


  /*
   * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
   */
  @Override
  public String getToolTipText(Object element) {
    INews news = (INews) element;
    FeedLinkReference feedRef = news.getFeedReference();
    IBookMark bookMark = Controller.getDefault().getCacheService().getBookMark(feedRef);
    if (bookMark != null)
      return bookMark.getName();

    return null;
View Full Code Here

  protected String getColumnText(Object element, int columnIndex) {
    String text = null;

    /* Handle News */
    if (element instanceof INews) {
      INews news = (INews) element;

      switch (columnIndex) {
        case NewsTableControl.COL_TITLE:
          text = ModelUtils.getHeadline(news);
          break;

        case NewsTableControl.COL_PUBDATE:
          Date date = DateUtils.getRecentDate(news);
          text = fDateFormat.format(date);
          break;

        case NewsTableControl.COL_AUTHOR:
          IPerson author = news.getAuthor();
          if (author != null) {
            if (author.getName() != null)
              text = author.getName();
            else if (author.getEmail() != null)
              text = author.getEmail().toString();
          }
          break;

        case NewsTableControl.COL_CATEGORY:
          List<ICategory> categories = news.getCategories();
          if (categories.size() > 0) {
            ICategory category = categories.get(0);
            if (category.getName() != null)
              text = category.getName();
            else if (category.getDomain() != null)
View Full Code Here

   */
  protected Image getColumnImage(Object element, int columnIndex) {

    /* News */
    if (element instanceof INews) {
      INews news = (INews) element;

      /* News Icon */
      if (columnIndex == NewsTableControl.COL_TITLE) {
        if (news.getState() == INews.State.UNREAD)
          return fNewsUnreadIcon;
        else if (news.getState() == INews.State.NEW)
          return fNewsNewIcon;
        else if (news.getState() == INews.State.UPDATED)
          return fNewsUpdatedIcon;
        else if (news.getState() == INews.State.READ)
          return fNewsReadIcon;
      }

      /* Feed Column */
      else if (columnIndex == NewsTableControl.COL_FEED && !(fViewer.getInput() instanceof FeedLinkReference)) {
        FeedLinkReference feedRef = news.getFeedReference();
        IBookMark bookMark = Controller.getDefault().getCacheService().getBookMark(feedRef);
        if (bookMark != null) {
          ImageDescriptor favicon = OwlUI.getFavicon(bookMark);
          return OwlUI.getImage(fResources, favicon != null ? favicon : OwlUI.BOOKMARK);
        }
      }

      /* Sticky State */
      else if (columnIndex == NewsTableControl.COL_STICKY) {
        if (news.isFlagged())
          return fNewsStickyIcon;

        return fNewsNonStickyIcon;
      }
    }
View Full Code Here

  protected Font getFont(Object element, @SuppressWarnings("unused")
  int columnIndex) {

    /* Use a Bold Font for Unread News */
    if (element instanceof INews) {
      INews news = (INews) element;
      INews.State state = news.getState();
      if (state == null)
        return null;

      /* Bold for New, Updated and Unread News */
      if (state == INews.State.NEW || state == INews.State.UPDATED || state == INews.State.UNREAD)
View Full Code Here

      }

      /* This is a NewsReference */
      else if (object instanceof NewsReference) {
        NewsReference newsRef = (NewsReference) object;
        INews news = obtainFromCache(newsRef);
        if (news != null)
          elements.add(news);
      }

      /* This is a FeedReference */
 
View Full Code Here

          /* Avoid to resolve an already shown News */
          if (onlyAdd && hasCachedNews(newsRef))
            continue;

          /* Resolve and Add News */
          INews resolvedNews = newsRef.resolve();
          if (resolvedNews != null) //TODO Remove once Bug 173 is fixed
            addedNews.add(resolvedNews);
        }
      }
    }
View Full Code Here

            for (NewsEvent event : events) {
              if (isInputRelatedTo(event.getEntity(), EventType.PERSIST)) {
                if (addedNews == null)
                  addedNews = new ArrayList<INews>();

                INews news = event.getEntity();
                addedNews.add(news);

                /* Update Cache */
                synchronized (NewsContentProvider.this) {
                  fCachedNews.add(news);
                }
              }
            }

            /* Event not interesting for us or we are disposed */
            if (addedNews == null || addedNews.size() == 0)
              return;

            /* Ask Group */
            if (fGrouping.needsRefresh(INews.class, events, false)) {
              fFeedView.refresh(true, false);
              return;
            }

            /* Add to Table-Viewer if Visible */
            if (fFeedView.isTableViewerVisible())
              fTableViewer.add(fTableViewer.getInput(), addedNews.toArray());

            /* Add to Browser-Viewer if showing entire Feed */
            if (fBrowserViewer.getInput() instanceof BookMarkReference)
              fBrowserViewer.add(fBrowserViewer.getInput(), addedNews.toArray());
          }
        });
      }

      /* News got Updated */
      @Override
      public void entitiesUpdated(final Set<NewsEvent> events) {
        JobRunner.runInUIThread(fFeedView.getEditorControl(), new Runnable() {
          public void run() {
            List<INews> deletedNews = null;
            List<INews> updatedNews = null;

            /* Filter News which are from a different Feed than displayed */
            for (NewsEvent event : events) {
              if (isInputRelatedTo(event.getEntity(), EventType.UPDATE)) {
                INews news = event.getEntity();

                /* News got Deleted */
                if (!news.isVisible()) {
                  if (deletedNews == null)
                    deletedNews = new ArrayList<INews>();
                  deletedNews.add(news);

                  synchronized (NewsContentProvider.this) {
                    fCachedNews.remove(news);
                  }
                }

                /* News got Updated */
                else {
                  if (updatedNews == null)
                    updatedNews = new ArrayList<INews>();
                  updatedNews.add(news);
                }
              }
            }

            /* Event not interesting for us or we are disposed */
            if (deletedNews == null && updatedNews == null)
              return;

            /* News got Deleted */
            if (deletedNews != null && !isGroupingEnabled()) {

              /* Remove from Table-Viewer */
              if (fFeedView.isTableViewerVisible())
                fTableViewer.remove(deletedNews.toArray());

              /* Remove from Browser-Viewer */
              if (contains(fBrowserViewer.getInput(), deletedNews))
                fBrowserViewer.remove(deletedNews.toArray());
            }

            /* Ask Group */
            if (fGrouping.needsRefresh(INews.class, events, true))
              fFeedView.refresh(false, false);

            /* News got Updated */
            if (updatedNews != null) {

              /* Update in Table-Viewer */
              if (fFeedView.isTableViewerVisible())
                fTableViewer.update(updatedNews.toArray(), null);

              /* Update in Browser-Viewer */
              if (contains(fBrowserViewer.getInput(), updatedNews))
                fBrowserViewer.update(updatedNews.toArray(), null);
            }
          }
        });
      }

      /* News got Deleted */
      @Override
      public void entitiesDeleted(final Set<NewsEvent> events) {
        JobRunner.runInUIThread(fFeedView.getEditorControl(), new Runnable() {
          public void run() {
            List<INews> deletedNews = null;

            /* Filter News which are from a different Feed or invisible */
            for (NewsEvent event : events) {
              INews news = event.getEntity();
              if (news.isVisible() && isInputRelatedTo(news, EventType.REMOVE)) {
                if (deletedNews == null)
                  deletedNews = new ArrayList<INews>();
                deletedNews.add(news);

                synchronized (NewsContentProvider.this) {
View Full Code Here

            ScoredNews scoredNews = ((ScoredNews) object);
            NewsReference newsRef = scoredNews.getNewsReference();

            /* News is part of the list */
            if (newsRef.references(event.getEntity())) {
              INews news = event.getEntity();

              /* News got Deleted */
              if (!news.isVisible()) {
                if (fDeletedScoredNews == null)
                  fDeletedScoredNews = new ArrayList<ScoredNews>();
                fDeletedScoredNews.add(scoredNews);
              }

View Full Code Here

    if (event.button == 1 && item.getImageBounds(COL_TITLE).contains(p)) {
      Object data = item.getData();

      /* Toggle State between Read / Unread */
      if (data instanceof ScoredNews) {
        INews news = ((ScoredNews) data).getNews();
        INews.State newState = (news.getState() == INews.State.READ) ? INews.State.UNREAD : INews.State.READ;
        setNewsState(new ArrayList<INews>(Arrays.asList(new INews[] { news })), newState);
      }
    }

    /* Mouse-Up over Sticky-State-Column */
 
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.INews

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.