Package org.rssowl.ui.internal.undo

Examples of org.rssowl.ui.internal.undo.NewsStateOperation


    /* Only affect equivalent News if not all News are affected */
    boolean affectEquivalentNews = !equalsRootFolders(folders);

    /* Support Undo */
    if (!news.isEmpty())
      UndoStack.getInstance().addOperation(new NewsStateOperation(news, INews.State.READ, affectEquivalentNews));

    /* Apply the state to the NewsItems for Retention to handle them properly */
    for (INews newsItem : news) {
      newsItem.setState(INews.State.READ);
    }
View Full Code Here


        /* Delete News in single Transaction */
        if (!newsToDelete.isEmpty()) {

          /* Support Undo */
          UndoStack.getInstance().addOperation(new NewsStateOperation(newsToDelete, INews.State.HIDDEN, false));

          /* Perform Operation */
          fNewsDAO.setState(newsToDelete, INews.State.HIDDEN, false, false);
        }
      }
View Full Code Here

      /* Only consider INews */
      List<INews> newsList = ModelUtils.getEntities(selection, INews.class);

      /* Support Undo */
      UndoStack.getInstance().addOperation(new NewsStateOperation(newsList, INews.State.UNREAD, true));

      /* Perform Operation */
      DynamicDAO.getDAO(INewsDAO.class).setState(newsList, INews.State.UNREAD, true, false);
    }
  }
View Full Code Here

          return;

        Set<INews> singleNewsSet = Collections.singleton(news);

        /* Add to UndoStack */
        UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, state, true));

        /* Perform Operation */
        fNewsDao.setState(singleNewsSet, state, true, false);
      }
    };
View Full Code Here

    else if (queryProvided && TOGGLE_READ_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {
        INews.State newState = (news.getState() == INews.State.READ) ? INews.State.UNREAD : INews.State.READ;
        Set<INews> singleNewsSet = Collections.singleton(news);
        UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, newState, true));
        fNewsDao.setState(singleNewsSet, newState, true, false);
      }
    }

    /*  Toggle Sticky */
    else if (queryProvided && TOGGLE_STICKY_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {
        Set<INews> singleNewsSet = Collections.singleton(news);
        UndoStack.getInstance().addOperation(new StickyOperation(singleNewsSet, !news.isFlagged()));
        news.setFlagged(!news.isFlagged());
        Controller.getDefault().getSavedSearchService().forceQuickUpdate();
        DynamicDAO.saveAll(singleNewsSet);
      }
    }

    /*  Delete */
    else if (queryProvided && DELETE_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {
        Set<INews> singleNewsSet = Collections.singleton(news);
        UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, INews.State.HIDDEN, false));
        fNewsDao.setState(singleNewsSet, INews.State.HIDDEN, false, false);
      }
    }

    /*  Labels Menu */
 
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setLink(new URI("http://www.news.com"));

    DynamicDAO.save(feed);

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.READ, false));

    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.READ, false, false);

    assertEquals(INews.State.READ, news.getState());

    UndoStack.getInstance().undo();
    assertEquals(INews.State.NEW, news.getState());

    UndoStack.getInstance().redo();
    assertEquals(INews.State.READ, news.getState());

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.HIDDEN, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.HIDDEN, false, false);

    assertEquals(INews.State.HIDDEN, news.getState());

    UndoStack.getInstance().undo();
View Full Code Here

    news2.setLink(new URI("http://www.news.com"));

    DynamicDAO.save(feed1);
    DynamicDAO.save(feed2);

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news1), INews.State.READ, true));

    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news1), INews.State.READ, true, false);

    assertEquals(INews.State.READ, news1.getState());
    assertEquals(INews.State.READ, news2.getState());
View Full Code Here

    DynamicDAO.save(root);

    assertEquals(1, bookmark.getStickyNewsCount());
    assertEquals(1, bookmark.getNewsCount(INews.State.getVisible()));

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singleton(news), INews.State.HIDDEN, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singleton(news), INews.State.HIDDEN, false, false);

    assertEquals(0, bookmark.getStickyNewsCount());
    assertEquals(0, bookmark.getNewsCount(INews.State.getVisible()));
View Full Code Here

    news.setLink(new URI("http://www.news.com"));
    news.setState(INews.State.READ);

    DynamicDAO.save(feed);

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.UNREAD, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.UNREAD, false, false);
    assertEquals(INews.State.UNREAD, news.getState());

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.READ, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.READ, false, false);
    assertEquals(INews.State.READ, news.getState());

    UndoStack.getInstance().undo();
    UndoStack.getInstance().undo();
    assertEquals(INews.State.READ, news.getState());

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.UNREAD, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.UNREAD, false, false);
    assertEquals(INews.State.UNREAD, news.getState());

    UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), INews.State.READ, false));
    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), INews.State.READ, false, false);
    assertEquals(INews.State.READ, news.getState());

    UndoStack.getInstance().undo();
    UndoStack.getInstance().undo();
View Full Code Here

    UndoStack.getInstance().addOperation(new StickyOperation(Collections.singletonList(news), true));
    news.setFlagged(true);
    DynamicDAO.save(news);

    for (int i = 0; i < 20; i++) {
      UndoStack.getInstance().addOperation(new NewsStateOperation(Collections.singletonList(news), i % 2 == 0 ? INews.State.UNREAD : INews.State.READ, false));
      DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(news), i % 2 == 0 ? INews.State.UNREAD : INews.State.READ, false, false);
    }

    int undos = 0;
    while (UndoStack.getInstance().isUndoSupported()) {
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.undo.NewsStateOperation

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.