Package org.rssowl.ui.internal.undo

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


            /* Force quick update on Feed-Change or Tab Close */
            if ((event == UIEvent.FEED_CHANGE || event == UIEvent.TAB_CLOSE))
              Controller.getDefault().getSavedSearchService().forceQuickUpdate();

            /* Support Undo */
            UndoStack.getInstance().addOperation(new NewsStateOperation(newsToUpdate, markRead ? INews.State.READ : INews.State.UNREAD, true));

            /* Perform Operation */
            fNewsDao.setState(newsToUpdate, markRead ? INews.State.READ : INews.State.UNREAD, true, false);
          }

View Full Code Here


  }

  private void setNewsState(List<INews> news, INews.State state) {

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

    /* Perform Operation */
    Owl.getPersistenceService().getDAOService().getNewsDAO().setState(news, state, true, false);
  }
View Full Code Here

            /* Force quick update on Feed-Change or Tab Close */
            if ((event == UIEvent.FEED_CHANGE || event == UIEvent.TAB_CLOSE))
              Controller.getDefault().getSavedSearchService().forceQuickUpdate();

            /* Support Undo */
            UndoStack.getInstance().addOperation(new NewsStateOperation(newsToUpdate, markRead ? INews.State.READ : INews.State.UNREAD, OwlUI.markReadDuplicates()));

            /* Perform Operation */
            fNewsDao.setState(newsToUpdate, markRead ? INews.State.READ : INews.State.UNREAD, OwlUI.markReadDuplicates(), false);
          }

View Full Code Here

  private void setNewsState(List<INews> news, INews.State state) {
    boolean affectEquivalentNews = (state != INews.State.UNREAD && OwlUI.markReadDuplicates());

    /* Add to UndoStack */
    UndoStack.getInstance().addOperation(new NewsStateOperation(news, state, affectEquivalentNews));

    /* Perform Operation */
    Owl.getPersistenceService().getDAOService().getNewsDAO().setState(news, state, affectEquivalentNews, false);
  }
View Full Code Here

      final List<INews> news = getNewsList(query);
      Runnable runnable = new Runnable() {
        public void run() {
          INews.State newState = INews.State.READ;
          boolean affectEquivalentNews = OwlUI.markReadDuplicates();
          UndoStack.getInstance().addOperation(new NewsStateOperation(news, newState, affectEquivalentNews));
          fNewsDao.setState(news, newState, affectEquivalentNews, false);
        }
      };

      if (CBrowser.isMozillaRunningOnWindows()) //Bug in XULRunner, otherwise won't work
        delayInUI(runnable);
      else
        runnable.run();
    }

    /*  Toggle Read */
    else if (queryProvided && TOGGLE_READ_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {

        /* Remove Focus from Link */
        blur(Dynamic.TOGGLE_READ_LINK.getId(news));

        /* Update State */
        INews.State newState = (news.getState() == INews.State.READ) ? INews.State.UNREAD : INews.State.READ;
        Set<INews> singleNewsSet = Collections.singleton(news);
        boolean affectEquivalentNews = (newState != INews.State.UNREAD && OwlUI.markReadDuplicates());
        UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, newState, affectEquivalentNews));
        fNewsDao.setState(singleNewsSet, newState, affectEquivalentNews, false);
        if (newState == INews.State.UNREAD)
          fMarkedUnreadByUserCache.add(news.getId());
      }
    }

    /*  Toggle Sticky */
    else if (queryProvided && TOGGLE_STICKY_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {

        /* Remove Focus from Link */
        blur(Dynamic.TOGGLE_STICKY_LINK.getId(news));
        if (isHeadlinesLayout())
          blur(Dynamic.TINY_TOGGLE_STICKY_LINK.getId(news), true);

        /* Toggle Sticky State */
        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);
      }
    }

    /*  Archive */
    else if (queryProvided && ARCHIVE_HANDLER_ID.equals(id)) {
      INews news = getNews(query);
      if (news != null) {
        ArchiveNewsAction action = new ArchiveNewsAction(new StructuredSelection(news));
        action.run();
      }
    }

    /*  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

    /* Update State if not already marked as read */
    if (fMarkReadOnExpand && expanded && news.getState() != INews.State.READ && !isGroupingByState()) { //Ignore if grouping by state to avoid refresh
      Set<INews> singleNewsSet = Collections.singleton(news);
      boolean affectEquivalentNews = OwlUI.markReadDuplicates();
      UndoStack.getInstance().addOperation(new NewsStateOperation(singleNewsSet, INews.State.READ, affectEquivalentNews));
      fNewsDao.setState(singleNewsSet, INews.State.READ, affectEquivalentNews, false);
    }

    /* Update Cache of Expanded News */
    fViewModel.setNewsExpanded(news, expanded);
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

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.