Code to get all TopComponents and EditorPanes in netbeans

Code to get all TopComponents in netbeans, here is very useful link http://wiki.netbeans.org/DevFaqGetOpenEditorWindows

Set < TopComponent > comps = TopComponent.getRegistry().getOpened();
for (TopComponent tc: comps) {
    ModuleLib.log("tc=" + tc);
    Node[] arr = tc.getActivatedNodes();
    if (arr != null) {
        for (int j = 0; j < arr.length; j++) {
            EditorCookie ec = (EditorCookie) arr[j].getCookie(EditorCookie.class);
            if (ec != null) {
                JEditorPane[] panes = ec.getOpenedPanes();
                if (panes != null) {
                    ModuleLib.log("panes=" + panes);
                }
            }
        }
    }
}