Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IFolder


   */
  @Test
  public void testTreeTraversalFromLeafWithoutFilter() throws Exception {
    ITreeNode startingNode = getStartingNode(false);

    IFolder rootFolder = ((IBookMark) startingNode.getData()).getParent().getParent().getParent().getParent();

    IFolder subRootFolder2 = rootFolder.getFolders().get(1);
    IBookMark subRoot2Mark1 = (IBookMark) subRootFolder2.getMarks().get(0);

    IFolder subRootFolder3 = rootFolder.getFolders().get(2);
    IFolder subRoot3Folder1 = subRootFolder3.getFolders().get(0);
    IBookMark subRoot31Mark1 = (IBookMark) subRoot3Folder1.getMarks().get(0);

    TreeTraversal t = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return true;
View Full Code Here


   */
  @Test
  public void testTreeTraversalFromLeafWithFilter() throws Exception {
    ITreeNode startingNode = getStartingNode(false);

    IFolder rootFolder = ((IBookMark) startingNode.getData()).getParent().getParent().getParent().getParent();

    IFolder subRootFolder2 = rootFolder.getFolders().get(1);
    IBookMark subRoot2Mark1 = (IBookMark) subRootFolder2.getMarks().get(0);

    IFolder subRootFolder3 = rootFolder.getFolders().get(2);
    IFolder subRoot3Folder1 = subRootFolder3.getFolders().get(0);
    IBookMark subRoot31Mark1 = (IBookMark) subRoot3Folder1.getMarks().get(0);

    TreeTraversal t = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return node.getData() instanceof IBookMark;
View Full Code Here

    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }

  private ITreeNode getStartingNode(boolean beginFromRoot) throws URISyntaxException {
    IFolder root = new Folder(null, null, "Root");
    FeedLinkReference feed = new FeedLinkReference(new URI("http://www.link.com"));

    /* Sub Root 1 */
    IFolder subRootFolder1 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder1, null, false);

    IFolder subRoot1Folder1 = new Folder(null, subRootFolder1, "SubRoot1Folder1");
    subRootFolder1.addFolder(subRoot1Folder1, null, false);

    subRoot1Folder1.addFolder(new Folder(null, subRoot1Folder1, "SubRoot11Folder1"), null, false);
    subRoot1Folder1.addMark(new BookMark(null, subRoot1Folder1, feed, "SubRoot11Mark1"), null, false);

    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark1"), null, false);
    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark2"), null, false);

    /* Sub Root 2 */
    IFolder subRootFolder2 = new Folder(null, root, "SubRootFolder2");
    root.addFolder(subRootFolder2, null, false);

    subRootFolder2.addMark(new BookMark(null, subRootFolder2, feed, "SubRoot2Mark1"), null, false);

    IFolder subRoot2Folder1 = new Folder(null, subRootFolder2, "SubRoot2Folder1");
    subRootFolder2.addFolder(subRoot2Folder1, null, false);

    IFolder subRoot21Folder1 = new Folder(null, subRoot2Folder1, "SubRoot21Folder1");
    subRoot2Folder1.addFolder(subRoot21Folder1, null, false);

    IBookMark subRoot211Mark1 = new BookMark(null, subRoot21Folder1, feed, "SubRoot211Mark1");
    subRoot21Folder1.addMark(subRoot211Mark1, null, false);

    /* Sub Root 3 */
    IFolder subRootFolder3 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder3, null, false);

    IFolder subRoot3Folder1 = new Folder(null, subRootFolder3, "SubRoot3Folder1");
    subRootFolder3.addFolder(subRoot3Folder1, null, false);

    subRoot3Folder1.addMark(new BookMark(null, subRoot3Folder1, feed, "SubRoot31Mark1"), null, false);

    return beginFromRoot ? new ModelTreeNode(root) : new ModelTreeNode(subRoot211Mark1);
  }
View Full Code Here

    news.removeAttachment(attachment);
    fDb.set(news);
  }

  private void removeFromParentFolderAndCascade(IFolder folder) {
    IFolder parentFolder = folder.getParent();
    if (parentFolder != null) {
      parentFolder.removeChild(folder);
      fDb.set(parentFolder);
    }
    for (IFolder child : ReverseIterator.createInstance(folder.getFolders())) {
      cascadeFolderDeletion(child);
    }
View Full Code Here

    fDb.delete(folder);
  }

  private void removeFromParentFolder(IMark mark) {
    IFolder parentFolder = mark.getParent();
    parentFolder.removeChild(mark);
    if (mark.getProperty(PARENT_DELETED_KEY) == null)
      fDb.set(parentFolder);
    else {
      mark.removeProperty(PARENT_DELETED_KEY);
    }
View Full Code Here

   */
  @Override
  public boolean performFinish() {
    String link = fPage.getLink();
    String name = fPage.getBookmarkName();
    IFolder parent = fPage.getFolder();
    IModelFactory factory = Owl.getModelFactory();

    if (!StringUtils.isSet(link)) {
      fPage.setErrorMessage("Please enter the link to the feed.");
      fPage.focusInput(true);
      return false;
    }

    if (!StringUtils.isSet(name)) {
      fPage.setErrorMessage("Please enter a name for the new bookmark.");
      fPage.focusInput(false);
      return false;
    }

    URI uriObj = null;
    try {
      uriObj = new URI(link);
    } catch (URISyntaxException e) {
      fPage.setErrorMessage("Please enter a valid link.");
      fPage.focusInput(true);
      return false;
    }

    /* Check if a Feed with the URL already exists */
    FeedReference feedRef = DynamicDAO.getDAO(IFeedDAO.class).loadReference(uriObj);

    /* Create a new Feed then */
    if (feedRef == null) {
      IFeed feed = factory.createFeed(null, uriObj);
      feed = DynamicDAO.getDAO(IFeedDAO.class).save(feed);
    }

    /* Create the BookMark */
    FeedLinkReference feedLinkRef = new FeedLinkReference(uriObj);
    IBookMark bookmark = factory.createBookMark(null, parent, feedLinkRef, name);

    /* Copy all Properties from Parent into this Mark */
    Map<String, ?> properties = parent.getProperties();

    for (Map.Entry<String, ?> property : properties.entrySet())
      bookmark.setProperty(property.getKey(), property.getValue());

    parent = DynamicDAO.getDAO(IFolderDAO.class).save(parent);

    /* Auto-Reload added BookMark */
    for (IMark mark : parent.getMarks()) {
      if (mark.equals(bookmark)) {
        new ReloadTypesAction(new StructuredSelection(mark), (Shell) getShell().getParent()).run();
        break;
      }
    }
View Full Code Here

    if (fPage.fSearchConditionList.isEmpty()) {
      fPage.setErrorMessage("Please specify your search by defining some conditions below.");
      return false;
    }

    IFolder fParent = fPage.getFolder();

    ISearchMark searchMark = factory.createSearchMark(null, fParent, name);
    searchMark.setMatchAllConditions(fPage.fMatchAllRadio.getSelection());

    fPage.fSearchConditionList.createConditions(searchMark);
View Full Code Here

    return null;
  }

  private List<IEntity> processBody(Element body) {
    IFolder folder = Owl.getModelFactory().createFolder(null, null, "Imported"); //$NON-NLS-1$

    /* Interpret Children */
    List< ? > feedChildren = body.getChildren();
    for (Iterator< ? > iter = feedChildren.iterator(); iter.hasNext();) {
      Element child = (Element) iter.next();
View Full Code Here

        fNameInput.setText(getName(entity));
      }
    }

    /* Location */
    IFolder sameParent = getSameParent(fEntities);
    if (sameParent != null) {
      separateFromTop = true;

      Label locationLabel = new Label(container, SWT.None);
      locationLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
View Full Code Here

      fNameInput.selectAll();
    }
  }

  private IFolder getSameParent(List<IEntity> entities) {
    IFolder parent = null;

    for (IEntity entity : entities) {
      if (!(entity instanceof IFolderChild))
        return null;

      IFolderChild folderChild = (IFolderChild) entity;
      IFolder folder = folderChild.getParent();
      if (parent == null)
        parent = folder;
      else if (parent != folder)
        return null;
    }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IFolder

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.