Package org.rssowl.core.model.events

Examples of org.rssowl.core.model.events.ModelEvent


        case REMOVE:
          eventTypeString = " Removed ("; //$NON-NLS-1$
          break;
      }
      IExtendableType type = null;
      ModelEvent event = events.iterator().next();
      if (eventType != EventType.REMOVE)
        type = event.getEntity();

      String typeName = type == null ? "" : type.getClass().getSimpleName();
      String typeString = type == null ? "" : type.toString();

      if (events.size() > 0 && typeName == "")
        typeName = events.iterator().next().getClass().getSimpleName();

      System.out.println(typeName + eventTypeString + typeString + ", events = " + events.size() + ", isRoot = " + event.isRoot() + ")");
    }
  }
View Full Code Here


      List<INews> changedNews = new ArrayList<INews>(newsList.size());

      for (INews news : newsList) {
        INews oldNews = fDb.ext().peekPersisted(news, 2, true);
        if (oldNews == null || !checkIfNewsIsIdentical || !news.isIdentical(oldNews)) {
          ModelEvent eventTemplate = new NewsEvent(oldNews, news, true);
          DBHelper.putEventTemplate(eventTemplate);
          changedNews.add(news);
        }
      }
View Full Code Here

  public IFeed saveFeed(IFeed feed, List<INews> newsToRemove) {
    fWriteLock.lock();
    try {
      DBHelper.saveFeed(fDb, feed);
      for (INews newsItem : newsToRemove) {
        ModelEvent eventTemplate = new NewsEvent(null, newsItem, true);
        DBHelper.putEventTemplate(eventTemplate);
        fDb.delete(newsItem);
      }
      fDb.commit();
    } catch (Db4oException e) {
View Full Code Here

    int id = System.identityHashCode(modelEvent.getEntity());
    EventsMap.getInstance().putEventTemplate(id, modelEvent);
  }
 
  static final void saveFeed(ObjectContainer db, IFeed feed) {
    ModelEvent feedEventTemplate = new FeedEvent(feed, true);
    DBHelper.putEventTemplate(feedEventTemplate);
    List<INews> changedNews = new ArrayList<INews>(feed.getNews().size());
   
    for (INews news : feed.getNews()) {
      INews oldNews = db.ext().peekPersisted(news, 2, true);
      if (oldNews == null) {
        changedNews.add(news);
      }
      else if (!news.isIdentical(oldNews)) {
        ModelEvent newsEventTemplate = new NewsEvent(oldNews, news, false);
        DBHelper.putEventTemplate(newsEventTemplate);
        changedNews.add(news);
      }
    }
    for (INews news : changedNews) {
View Full Code Here

  private void processUpdatedEvent(EventArgs args) {
    IEntity entity = getEntity(args);
    if (entity == null)
      return;
   
    ModelEvent event = createModelEvent(entity);
    if (event != null)
      EventsMap.getInstance().putUpdateEvent(event);
   
  }
View Full Code Here

  private void processCreatedEvent(EventArgs args) {
    IEntity entity = getEntity(args);
    if (entity == null)
      return;

    ModelEvent event = createModelEvent(entity);
    if (event != null)
      EventsMap.getInstance().putPersistEvent(event);
  }
View Full Code Here

  private void processDeletedEvent(EventArgs args) {
    IEntity entity = getEntity(args);
    if (entity == null)
      return;
   
    ModelEvent event = createModelEvent(entity);
    if (event != null)
      EventsMap.getInstance().putRemoveEvent(event);
  }
View Full Code Here

    }
    return null;
  }

  private ModelEvent createModelEvent(IEntity entity) {
    ModelEvent modelEvent = null;
    Map<Integer, ModelEvent> templatesMap = EventsMap.getInstance().getEventTemplatesMap();
    ModelEvent template = templatesMap.get(System.identityHashCode(entity));
    //TODO In some cases, the template is complete. We can save some object allocation
    //by reusing it.
   
    boolean root = isRoot(template);
    if (entity instanceof INews) {
View Full Code Here

    }
    return modelEvent;
  }

  private ModelEvent createNewsEvent(INews news, ModelEvent template, boolean root) {
    ModelEvent modelEvent;
    NewsEvent newsTemplate = (NewsEvent) template;
    INews oldNews = newsTemplate == null ? null : newsTemplate.getOldNews();
   
    modelEvent = new NewsEvent(oldNews, news, root);
    return modelEvent;
View Full Code Here

 
  /*
   * @see org.rssowl.core.model.dao.IModelDAO#saveBookMark(org.rssowl.core.model.types.IBookMark)
   */
  public IBookMark saveBookMark(IBookMark bookMark) throws PersistenceException  {
    ModelEvent event = new BookMarkEvent(bookMark, null, true);
    saveCommitAndFireEvents(event, false);
    return bookMark;
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.events.ModelEvent

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.