001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.vmd.inspector;
043:
044: import org.netbeans.modules.vmd.api.inspector.InspectorFolderPath;
045: import org.openide.nodes.Node;
046:
047: /**
048: *
049: * @author Karol Harezlak
050: */
051: final class DebugInspector {
052:
053: private static String tabs = ""; // NOI18N
054: private static final String space = " "; // NOI18N
055: private static Node childTest;
056:
057: static void printPath(InspectorFolderPath path) {
058: System.out.println("InspectorPath" + path.toString()); // NOI18N
059: }
060:
061: static void printFoldersTree(InspectorFolderWrapper folderWrapper) {
062: tabs = ""; // NOI18N
063: System.out.println(folderWrapper.getNode());
064: System.out
065: .println(tabs
066: + " -Node children =:"
067: + folderWrapper.getNode().getChildren()
068: .getNodesCount()); // NOI18N
069: deepDive(folderWrapper);
070: }
071:
072: private static void deepDive(
073: InspectorFolderWrapper parentFolderWrapper) {
074: if (parentFolderWrapper.getChildren() == null)
075: return;
076: tabs = tabs + space;
077: for (InspectorFolderWrapper folderWrapper : parentFolderWrapper
078: .getChildren()) {
079: System.out.println(tabs + "|-" + folderWrapper); // NOI18N
080: System.out.println(tabs
081: + " -Node children =:"
082: + folderWrapper.getNode().getChildren()
083: .getNodesCount()); // NOI18N
084: if (folderWrapper.getChildren() != null)
085: deepDive(folderWrapper);
086: }
087: tabs = tabs.replaceFirst(space, ""); // NOI18N
088: }
089:
090: static void printNodesTree(Node parentNode) {
091: tabs = ""; // NOI18N
092: System.out.println(parentNode);
093: System.out.println(tabs + " -Node children =:"
094: + parentNode.getChildren().getNodesCount()); // NOI18N
095: deepDive(parentNode);
096: }
097:
098: private static void deepDive(Node parentNode) {
099: tabs = tabs + space;
100: for (Node node : parentNode.getChildren().getNodes()) {
101: System.out.println(tabs + "|-" + node.getDisplayName()
102: + " " + node); // NOI18N
103: System.out.println(tabs + " -Node children =:"
104: + node.getChildren().getNodesCount()); // NOI18N
105: if (node.getChildren().getNodes().length > 0)
106: deepDive(node);
107: }
108: tabs = tabs.replaceFirst(space, ""); // NOI18N
109: }
110:
111: static void checkRootNode(Node rootNode, Node child) {
112: childTest = child;
113: System.out.println("Test start: root node: " + rootNode
114: + " child: " + child); //NOI18N
115: checkParent(rootNode, child);
116: }
117:
118: private static void checkParent(Node rootNode, Node child) {
119: if (child.getParentNode() != null)
120: checkParent(rootNode, child.getParentNode());
121: else if (child == rootNode)
122: System.out.println("Node: " + rootNode
123: + " is root node of node : " + childTest);//NOI18N
124: else
125: System.out.println("Node: " + rootNode
126: + " is NOT root node of node : " + childTest
127: + " real root node: " + child);//NOI18N
128: }
129:
130: }
|