Package org.rssowl.ui.internal.notifier

Examples of org.rssowl.ui.internal.notifier.NotificationService


    /* Create the News-Service */
    fNewsService = new NewsService();

    /* Create the Notification Service */
    if (!InternalOwl.TESTING)
      fNotificationService = new NotificationService();

    /* Create the Saved Search Service */
    if (!InternalOwl.TESTING)
      fSavedSearchService = new SavedSearchService();

View Full Code Here


      }
    });

    /* Create the Notification Service */
    if (!InternalOwl.TESTING)
      fNotificationService = new NotificationService();

    /* Create the Saved Search Service */
    fSavedSearchService = new SavedSearchService();

    /* Create the Download Service */
 
View Full Code Here

    fTrayMenu = trayMenuManager.createContextMenu(shell);
    fTrayMenu.setVisible(true);
  }

  private void onSingleClick(Shell shell) {
    NotificationService service = Controller.getDefault().getNotificationService();
    List<INews> newsToShow = new ArrayList<INews>();
    Mode mode;

    /* Return early if Notifier already showing */
    if (service.isPopupVisible())
      return;

    /* Show News Downloaded while Minimized */
    if (!fTeasingNewsCache.isEmpty()) {
      synchronized (fTeasingNewsCache) {
        int counter = 0;
        for (int i = fTeasingNewsCache.size() - 1; i >= 0; i--) {
          NewsReference reference = new NewsReference(fTeasingNewsCache.get(i));
          INews newsitem = reference.resolve();
          if (newsitem != null) {
            newsToShow.add(newsitem);

            if (++counter >= TEASE_LIMIT)
              break;
          }

          /* Return early if Notifier already showing */
          if (service.isPopupVisible())
            return;
        }
      }
      mode = Mode.INCOMING_MANUAL;
    }

    /* Show Recent News */
    else {

      /* Build the Search if not yet done */
      if (fTodaysNewsSearch == null) {
        IModelFactory factory = Owl.getModelFactory();

        String newsClassName = INews.class.getName();
        ISearchField ageInDaysField = factory.createSearchField(INews.AGE_IN_DAYS, newsClassName);
        ISearchField ageInMinutesField = factory.createSearchField(INews.AGE_IN_MINUTES, newsClassName);

        ISearchCondition dayCondition = factory.createSearchCondition(ageInDaysField, SearchSpecifier.IS_LESS_THAN, 1); // From Today after Midnight
        ISearchCondition recentCondition = factory.createSearchCondition(ageInMinutesField, SearchSpecifier.IS_LESS_THAN, -60 * 6); // Up to 6 Hours Ago

        fTodaysNewsSearch = factory.createSearch(null);
        fTodaysNewsSearch.setMatchAllConditions(false);
        fTodaysNewsSearch.addSearchCondition(dayCondition);
        fTodaysNewsSearch.addSearchCondition(recentCondition);
      }

      /* Sort by Id (simulate sorting by date) */
      List<SearchHit<NewsReference>> result = Owl.getPersistenceService().getModelSearch().searchNews(fTodaysNewsSearch);
      Set<NewsReference> recentNews = new TreeSet<NewsReference>(new Comparator<NewsReference>() {
        public int compare(NewsReference ref1, NewsReference ref2) {
          if (ref1.equals(ref2))
            return 0;

          return ref1.getId() > ref2.getId() ? -1 : 1;
        }
      });

      for (SearchHit<NewsReference> hit : result) {
        recentNews.add(hit.getResult());
      }

      /* Resolve and Add News from Result */
      int counter = 0;
      for (NewsReference reference : recentNews) {
        INews newsitem = reference.resolve();
        if (newsitem != null && newsitem.isVisible()) {
          newsToShow.add(newsitem);

          if (++counter >= TEASE_LIMIT)
            break;
        }

        /* Return early if Notifier already showing */
        if (service.isPopupVisible())
          return;
      }

      mode = Mode.RECENT;
    }

    /* Return early if Notifier already showing */
    if (service.isPopupVisible())
      return;

    /* Tease with News */
    if (!newsToShow.isEmpty()) {
      service.show(newsToShow, null, mode);
      clearTease(true);
    }

    /* Otherwise show Context Menu */
    else
View Full Code Here

        if (isDoubleClick)
          lastDoubleClickTime = System.currentTimeMillis();

        /* Invoke Single Click Action if this is not a double click and we are on Windows */
        if (!isDoubleClick && restoreOnDoubleclick && Application.IS_WINDOWS) {
          NotificationService service = Controller.getDefault().getNotificationService();

          /* Notifier showing - close it instantly */
          if (service.isPopupVisible()) {
            service.closePopup();
          }

          /* Notifier not showing - invoke single click action (only if not recently closed) */
          else if (!service.wasPopupRecentlyClosed()) {
            JobRunner.runInBackgroundThread(doubleClickTime, new Runnable() {
              public void run() {
                if (lastDoubleClickTime < System.currentTimeMillis() - doubleClickTime) {
                  JobRunner.runInUIThread(tray, new Runnable() {
                    public void run() {
View Full Code Here

    /* Ensure to Pickup Replaces */
    news = CoreUtils.replace(news, replacements);

    /* Run Filter */
    NotificationService notificationService = Controller.getDefault().getNotificationService();
    if (data != null && data instanceof String)
      notificationService.show(news, OwlUI.getRGB((String) data), Mode.INCOMING_AUTOMATIC);
    else
      notificationService.show(news, null, Mode.INCOMING_AUTOMATIC);

    /* Nothing to Save */
    return Collections.emptyList();
  }
View Full Code Here

      }
    });

    /* Create the Notification Service */
    if (!InternalOwl.TESTING)
      fNotificationService = new NotificationService();

    /* Create the Saved Search Service */
    fSavedSearchService = new SavedSearchService();

    /* Create the Download Service */
 
View Full Code Here

    /* Ensure to Pickup Replaces */
    news = CoreUtils.replace(news, replacements);

    /* Run Filter */
    NotificationService notificationService = Controller.getDefault().getNotificationService();
    if (data != null && data instanceof String)
      notificationService.show(news, OwlUI.getRGB((String) data), Mode.INCOMING_AUTOMATIC, true);
    else
      notificationService.show(news, null, Mode.INCOMING_AUTOMATIC, true);

    /* Nothing to Save */
    return Collections.emptyList();
  }
View Full Code Here

        if (isDoubleClick)
          lastDoubleClickTime = System.currentTimeMillis();

        /* Invoke Single Click Action if this is not a double click and we are on Windows */
        if (!isDoubleClick && restoreOnDoubleclick && Application.IS_WINDOWS) {
          NotificationService service = Controller.getDefault().getNotificationService();

          /* Notifier showing - close it instantly */
          if (service.isPopupVisible()) {
            service.closePopup();
          }

          /* Notifier not showing - invoke single click action (only if not recently closed) */
          else if (!service.wasPopupRecentlyClosed()) {
            JobRunner.runInBackgroundThread(doubleClickTime, new Runnable() {
              public void run() {
                if (lastDoubleClickTime < System.currentTimeMillis() - doubleClickTime) {
                  JobRunner.runInUIThread(tray, new Runnable() {
                    public void run() {
View Full Code Here

    fTrayMenu = trayMenuManager.createContextMenu(shell);
    fTrayMenu.setVisible(true);
  }

  private void onSingleClick(Shell shell) {
    NotificationService service = Controller.getDefault().getNotificationService();
    List<INews> newsToShow = new ArrayList<INews>();
    Mode mode = Mode.RECENT;

    /* Return early if Notifier already showing */
    if (service.isPopupVisible())
      return;

    /* Show News Downloaded while Minimized */
    if (!fTeasingNewsCache.isEmpty()) {
      synchronized (fTeasingNewsCache) {
        int counter = 0;
        for (int i = fTeasingNewsCache.size() - 1; i >= 0; i--) {
          NewsReference reference = new NewsReference(fTeasingNewsCache.get(i));
          INews newsitem = reference.resolve();
          if (newsitem != null && newsitem.getState() == INews.State.NEW && service.shouldShow(newsitem)) {
            newsToShow.add(newsitem);

            if (++counter >= TEASE_LIMIT)
              break;
          } else
            CoreUtils.reportIndexIssue();

          /* Return early if Notifier already showing */
          if (service.isPopupVisible())
            return;
        }
      }
      mode = Mode.INCOMING_MANUAL;
    }

    /* Show Recent News if no teasing news present */
    if (newsToShow.isEmpty()) {

      /* Build the Search if not yet done */
      if (fTodaysNewsSearch == null) {
        IModelFactory factory = Owl.getModelFactory();

        String newsClassName = INews.class.getName();
        ISearchField ageInDaysField = factory.createSearchField(INews.AGE_IN_DAYS, newsClassName);
        ISearchField ageInMinutesField = factory.createSearchField(INews.AGE_IN_MINUTES, newsClassName);

        ISearchCondition dayCondition = factory.createSearchCondition(ageInDaysField, SearchSpecifier.IS_LESS_THAN, 1); // From Today after Midnight
        ISearchCondition recentCondition = factory.createSearchCondition(ageInMinutesField, SearchSpecifier.IS_LESS_THAN, -60 * 6); // Up to 6 Hours Ago

        fTodaysNewsSearch = factory.createSearch(null);
        fTodaysNewsSearch.setMatchAllConditions(false);
        fTodaysNewsSearch.addSearchCondition(dayCondition);
        fTodaysNewsSearch.addSearchCondition(recentCondition);
      }

      /* Sort by Id (simulate sorting by date) */
      List<SearchHit<NewsReference>> result = Owl.getPersistenceService().getModelSearch().searchNews(fTodaysNewsSearch);
      Set<NewsReference> recentNews = new TreeSet<NewsReference>(new Comparator<NewsReference>() {
        public int compare(NewsReference ref1, NewsReference ref2) {
          if (ref1.equals(ref2))
            return 0;

          return ref1.getId() > ref2.getId() ? -1 : 1;
        }
      });

      for (SearchHit<NewsReference> hit : result) {
        recentNews.add(hit.getResult());
      }

      /* Resolve and Add News from Result */
      int counter = 0;
      for (NewsReference reference : recentNews) {
        INews newsitem = reference.resolve();
        if (newsitem != null && newsitem.isVisible() && service.shouldShow(newsitem)) {
          newsToShow.add(newsitem);

          if (++counter >= TEASE_LIMIT)
            break;
        } else if (newsitem == null)
          CoreUtils.reportIndexIssue();

        /* Return early if Notifier already showing */
        if (service.isPopupVisible())
          return;
      }

      mode = Mode.RECENT;
    }

    /* Return early if Notifier already showing */
    if (service.isPopupVisible())
      return;

    /* Tease with News */
    if (!newsToShow.isEmpty()) {
      service.show(newsToShow, null, mode);
      clearTease(true);
    }

    /* Otherwise show Context Menu */
    else
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.notifier.NotificationService

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.