Package org.rssowl.core.persist.reference

Examples of org.rssowl.core.persist.reference.FolderReference


      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      DynamicDAO.delete(root);

      assertNull("Expected this Entity to be NULL", new FolderReference(root.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = DynamicDAO.save(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = DynamicDAO.save(folder);

      IFeed feed = fFactory.createFeed(null, new URI("http://www.feed2.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(DynamicDAO.save(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
      folder = DynamicDAO.save(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      DynamicDAO.delete(folder);

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted #2) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = DynamicDAO.save(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = DynamicDAO.save(folder);

      IFeed feed = fFactory.createFeed(null, new URI("http://www.feed3.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(DynamicDAO.save(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
      folder = DynamicDAO.save(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      /* Delete by calling delete */
      DynamicDAO.delete(folder);

      final long rootFolderId = root.getId();
      FolderListener folderListener = new FolderAdapter() {
        @Override
        public void entitiesUpdated(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            if (event.getEntity().getId() == rootFolderId)
              assertTrue(event.isRoot());
            else
              assertFalse(event.isRoot());
          }
        }
      };
      DynamicDAO.addEntityListener(IFolder.class, folderListener);
      try {
        DynamicDAO.save(root);
      } finally {
        DynamicDAO.removeEntityListener(IFolder.class, folderListener);
      }

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

View Full Code Here


    /* Otherwise return visible root-folder */
    String selectedBookMarkSetPref = BookMarkExplorer.getSelectedBookMarkSetPref(OwlUI.getWindow());
    Long selectedRootFolderID = DynamicDAO.getDAO(IPreferenceDAO.class).load(selectedBookMarkSetPref).getLong();
    if (selectedRootFolderID != null)
      return new FolderReference(selectedRootFolderID).resolve();

    /* Finally return the first root folder */
    return Controller.getDefault().getCacheService().getRootFolders().iterator().next();
  }
View Full Code Here

  private int countNews(IEntity entity) throws PersistenceException {
    int count = 0;

    if (entity instanceof IFolder) {
      IFolder folder = new FolderReference(entity.getId()).resolve();
      List<IMark> marks = folder.getMarks();
      for (IMark mark : marks) {
        if (mark instanceof IBookMark) {
          IFeed feed = ((IBookMark) mark).getFeedLinkReference().resolve();
          count += feed.getVisibleNews().size();
View Full Code Here

    String selectedBookMarkSetPref = getSelectedBookMarkSetPref(fViewSite.getWorkbenchWindow());
    IPreference pref = fPrefDAO.load(selectedBookMarkSetPref);
    Assert.isTrue(fRootFolders.size() > 0, Messages.BookMarkExplorer_ERROR_NO_SET_FOUND);
    if (pref != null)
      fSelectedBookMarkSet = new FolderReference(pref.getLong().longValue()).resolve();
    else {
      fSelectedBookMarkSet = getRootFolderAt(0);

      /* Save this to make sure subsequent calls succeed */
      pref = Owl.getModelFactory().createPreference(selectedBookMarkSetPref);
View Full Code Here

  }

  void restoreExpandedElements() {
    for (Long expandedNodeId : fExpandedNodes) {
      if (fBookMarkGrouping.getType() == BookMarkGrouping.Type.NO_GROUPING)
        fViewer.setExpandedState(new FolderReference(expandedNodeId), true);
      else
        fViewer.setExpandedState(new EntityGroup(expandedNodeId, BookMarkGrouping.GROUP_CATEGORY_ID), true);
    }
  }
View Full Code Here

    if (preference != null) {
      Long selectedRootFolderID = preference.getLong();

      /* Check if available Parent is still valid */
      if (folder != null) {
        if (hasParent(folder, new FolderReference(selectedRootFolderID)))
          return folder;
      }

      /* Otherwise return visible root-folder */
      return new FolderReference(selectedRootFolderID).resolve();
    }

    Set<IFolder> roots = CoreUtils.loadRootFolders();
    if (!roots.isEmpty())
      return roots.iterator().next();
View Full Code Here

      String selectedBookMarkSetPref = BookMarkExplorer.getSelectedBookMarkSetPref(OwlUI.getWindow());
      IPreference preference = DynamicDAO.getDAO(IPreferenceDAO.class).load(selectedBookMarkSetPref);
      if (preference != null) {
        Long selectedRootFolderID = preference.getLong();
        if (selectedRootFolderID != null)
          folder = new FolderReference(selectedRootFolderID).resolve();
      }

      /* Finally use the first root folder */
      folder = CoreUtils.loadRootFolders().iterator().next();
    }
View Full Code Here

  public void run() {
    IStructuredSelection selection = (IStructuredSelection) fSelectionProvider.getSelection();
    if (selection.isEmpty()) {
      String selectedBookMarkSetPref = BookMarkExplorer.getSelectedBookMarkSetPref(OwlUI.getWindow());
      Long selectedRootFolderID = DynamicDAO.getDAO(IPreferenceDAO.class).load(selectedBookMarkSetPref).getLong();
      selection = new StructuredSelection(new FolderReference(selectedRootFolderID).resolve());
    }

    List<IFolderChild> entities = ModelUtils.getFoldersAndBookMarks(selection);
    List<IEntity> entitiesTmp = new ArrayList<IEntity>(entities);
View Full Code Here

    String selectedBookMarkSetPref = getSelectedBookMarkSetPref(fViewSite.getWorkbenchWindow());
    IPreference pref = fPrefDAO.load(selectedBookMarkSetPref);
    Assert.isTrue(fRootFolders.size() > 0, "Could not find any Bookmark Set!"); //$NON-NLS-1$
    if (pref != null)
      fSelectedBookMarkSet = new FolderReference(pref.getLong().longValue()).resolve();
    else {
      fSelectedBookMarkSet = getRootFolderAt(0);

      /* Save this to make sure subsequent calls succeed */
      pref = Owl.getModelFactory().createPreference(selectedBookMarkSetPref);
View Full Code Here

  }

  void restoreExpandedElements() {
    for (Long expandedNodeId : fExpandedNodes) {
      if (fBookMarkGrouping.getType() == BookMarkGrouping.Type.NO_GROUPING)
        fViewer.setExpandedState(new FolderReference(expandedNodeId), true);
      else
        fViewer.setExpandedState(new EntityGroup(expandedNodeId, BookMarkGrouping.GROUP_CATEGORY_ID), true);
    }
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.reference.FolderReference

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.