Package org.rssowl.core.util

Examples of org.rssowl.core.util.TreeTraversal


      startingNodes.addAll(CoreUtils.loadRootFolders());

      /* Select from all available Starting Nodes */
      ITreeNode targetNode = null;
      for (IFolderChild startingNode : startingNodes) {
        TreeTraversal traversal = new TreeTraversal(startingNode instanceof IFolder ? new ModelTreeNode((IFolder) startingNode) : new ModelTreeNode((IMark) startingNode)) {

          @Override
          public boolean select(ITreeNode node) {
            Object data = node.getData();

            /* Check for Unread news if required */
            if (data instanceof INewsMark) {
              INewsMark newsmark = (INewsMark) data;
              if (fType.isUnread() && newsmark.getNewsCount(EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED)) == 0)
                return false;
            }

            /* Folders are no valid navigation nodes */
            else if (data instanceof IFolder)
              return false;

            return true;
          }
        };

        targetNode = fType.isNext() ? traversal.nextNode() : traversal.previousNode();
        if (targetNode != null)
          break;
      }

      /* Open Node if present */
 
View Full Code Here


  }

  private ITreeNode navigate(ITreeNode startingNode, boolean next, final boolean unread) {

    /* Create Traverse-Helper */
    TreeTraversal traverse = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return isValidNavigation(node, unread);
      }
    };

    /* Retrieve and select new Target Node */
    ITreeNode targetNode = (next ? traverse.nextNode() : traverse.previousNode());

    return targetNode;
  }
View Full Code Here

  }

  private ISelection navigate(ITreeNode startingNode, boolean next) {

    /* Create Traverse-Helper */
    TreeTraversal traverse = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return node.getData() instanceof INews;
      }
    };

    /* Retrieve and select new Target Node */
    ITreeNode targetNode = (next ? traverse.nextNode() : traverse.previousNode());
    if (targetNode != null) {
      ISelection selection = new StructuredSelection(targetNode.getData());
      return selection;
    }

View Full Code Here

    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;
      }
    };

    assertEquals(subRootFolder1, t.nextNode().getData());
    assertEquals(subRoot1Folder1, t.nextNode().getData());
    assertEquals(subRoot11Folder1, t.nextNode().getData());
    assertEquals(subRoot11Mark1, t.nextNode().getData());
    assertEquals(subRoot1Mark1, t.nextNode().getData());
    assertEquals(subRoot1Mark2, t.nextNode().getData());
    assertEquals(subRootFolder2, t.nextNode().getData());
    assertEquals(subRoot2Folder1, t.nextNode().getData());
    assertEquals(subRoot21Folder1, t.nextNode().getData());
    assertEquals(subRoot211Mark1, t.nextNode().getData());
    assertEquals(subRoot2Mark1, t.nextNode().getData());
    assertEquals(subRootFolder3, t.nextNode().getData());
    assertEquals(subRoot3Folder1, t.nextNode().getData());
    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());

  }
View Full Code Here

    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;
      }
    };

    assertEquals(subRoot11Mark1, t.nextNode().getData());
    assertEquals(subRoot1Mark1, t.nextNode().getData());
    assertEquals(subRoot1Mark2, t.nextNode().getData());
    assertEquals(subRoot211Mark1, t.nextNode().getData());
    assertEquals(subRoot2Mark1, t.nextNode().getData());
    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }
View Full Code Here

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

    TreeTraversal t = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return true;
      }
    };

    assertEquals("SubRoot11Folder1", ((IFolder) t.previousNode().getData()).getName());
  }
View Full Code Here

    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;
      }
    };

    assertEquals(subRoot2Mark1, t.nextNode().getData());
    assertEquals(subRootFolder3, t.nextNode().getData());
    assertEquals(subRoot3Folder1, t.nextNode().getData());
    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }
View Full Code Here

    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;
      }
    };

    assertEquals(subRoot2Mark1, t.nextNode().getData());
    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }
View Full Code Here

  }

  private boolean navigate(ITreeNode startingNode, boolean next, final boolean unread) {

    /* Create Traverse-Helper */
    TreeTraversal traverse = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return isValidNavigation(node, unread);
      }
    };

    /* Retrieve and select new Target Node */
    ITreeNode targetNode = (next ? traverse.nextNode() : traverse.previousNode());
    if (targetNode != null) {
      ISelection selection = new StructuredSelection(targetNode.getData());
      fNewsTableControl.getViewer().setSelection(selection, true);
      return true;
    }
View Full Code Here

  }

  private boolean navigate(ITreeNode startingNode, boolean next, final boolean unread) {

    /* Create Traverse-Helper */
    TreeTraversal traverse = new TreeTraversal(startingNode) {
      @Override
      public boolean select(ITreeNode node) {
        return isValidNavigation(node, unread);
      }
    };

    /* Retrieve and select new Target Node */
    ITreeNode targetNode = (next ? traverse.nextNode() : traverse.previousNode());
    if (targetNode != null) {
      ISelection selection = new StructuredSelection(targetNode.getData());
      fNewsTableControl.getViewer().setSelection(selection, true);
      return true;
    }
View Full Code Here

TOP

Related Classes of org.rssowl.core.util.TreeTraversal

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.