Package org.sourceforge.jsonedit.core.outline.node

Examples of org.sourceforge.jsonedit.core.outline.node.JsonTreeNode


   
    if (jsonNodes == null) {
      return null;
    }
   
    JsonTreeNode root = null;
    JsonTreeNode parent = null;
   
    for (JsonNode jsonNode : jsonNodes) {
     
      if (isNodeOfType(jsonNode, JsonType.End)) {
        if (parent != null) {
          parent = parent.getParent();
        }
        continue;
      }
     
      JsonTreeNode treeNode = new JsonTreeNode(jsonNode, parent);
      if (root == null) {
        root = treeNode;
        parent = root;
      } else {
        if (parent == null) {
View Full Code Here


   
    if (oldRootObject == null && jsonNodes != null) {
      return parse(jsonNodes);
    }
   
    JsonTreeNode root = oldRootObject;
   
    JsonTreeNode parent = null;
   
    JsonTreeNode head = root;
   
    List<Integer> childIterStack = new ArrayList<Integer>();
   
    try {
      Integer childIter = 0;
      for (JsonNode jsonNode : jsonNodes) {
        //System.out.println(jsonNode);
       
        if (isNodeOfType(jsonNode, JsonType.End)) {
         
          // TODO: Check no more children if so remove
          List<JsonTreeNode> nodesToRemove = new LinkedList<JsonTreeNode>();
          while(childIter < parent.getChildren().size()) {
            head = parent.getChildren().get(childIter);
            nodesToRemove.add(head);
            childIter++;
          }
           
          //System.out.println(nodesToRemove.size());
          for (JsonTreeNode nodeToRemove: nodesToRemove) {
            nodeToRemove.removeFromParent();
          }
         
          if (childIterStack.size() > 0) {
            childIter = childIterStack.remove(0);
          } else {
            childIter = root.getChildren().size();
          }

          parent = parent.getParent();
          if (parent == null) {
            parent = root;
          }
          continue;
        }
       
        if (parent != null && childIter < parent.getChildren().size()) {
          head = parent.getChildren().get(childIter);
          //System.out.println("Next");
          childIter++;
        } else if (head != root || (head == root && parent != null)) {
          //System.out.println("Null");
          head = null;
        }

        if (head == null) {
          head = new JsonTreeNode(jsonNode, parent);
          parent.addChild(head);
          childIter++;
        }
       
        if (!jsonNode.equals(head.getJsonNode())) {
          head.setJsonNode(jsonNode);
        }
       
        if (isNodeOfType(jsonNode, JsonType.Object, JsonType.Array)) {
          parent = head;
          childIterStack.add(0, childIter);
          childIter = 0;
        } else {
          if (head.hasChildren()) {
            head.clearChildren();
          }
        }
      }
    //  System.out.println("returning");
    } catch (Exception e) {
View Full Code Here

   * <code>ILabelProvider</code> method returns <code>null</code>.
   * Subclasses may override.
   */
  public Image getImage(Object element) {
    if (element instanceof JsonTreeNode) {
      JsonTreeNode node = (JsonTreeNode) element;
      return node.getImage();
    }
    return null;
  }
View Full Code Here

   * Returns the styled text contained in the tree element.
   */
  public StyledString getStyledText(Object element) {
    StyledString styledString = new StyledString();
    if (element instanceof JsonTreeNode) {
      JsonTreeNode node = (JsonTreeNode) element;
      return node.getStyledString();
    }
    return styledString;
  }
View Full Code Here

    ISelection selection= event.getSelection();
   
    if (selection.isEmpty())
      fTextEditor.resetHighlightRange();
    else {
      JsonTreeNode jsonTreeNode = (JsonTreeNode) ((IStructuredSelection) selection).getFirstElement();
      if (jsonTreeNode.isTextSelection()) {
        jsonTreeNode.setTextSelection(false);
        return;
      }
     
      int start= jsonTreeNode.getStart();
      int length= jsonTreeNode.getLength();
      try {
        fTextEditor.selectAndReveal(start, length);
      } catch (IllegalArgumentException x) {
        fTextEditor.resetHighlightRange();
      }
View Full Code Here

    if (selection instanceof ITextSelection) {
      ITextSelection textSelection = (ITextSelection) selection;
      int start = textSelection.getOffset();
      int length = textSelection.getLength();
     
      JsonTreeNode element = fContentProvider.findNearestElement(start, length);
      if (element != null) {
        element.setTextSelection(true);
        getTreeViewer().reveal(element);
        TreeSelection treeSelection = new TreeSelection(new TreePath(new Object[]{element}));
        getTreeViewer().setSelection(treeSelection);
      }
    }
View Full Code Here

   * @param length
   * @return
   */
  private JsonTreeNode findNearestElement(JsonTreeNode parent, int start, int length) {
   
    JsonTreeNode previous = null;
    boolean found = false;
   
    if (parent.getChildren().size() == 0) {
      return parent;
    }
View Full Code Here

TOP

Related Classes of org.sourceforge.jsonedit.core.outline.node.JsonTreeNode

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.