|
|
@ -19,6 +19,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
package jode.swingui; |
|
|
|
package jode.swingui; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
|
|
|
|
import jode.bytecode.ClassPath; |
|
|
|
|
|
|
|
|
|
|
|
///#def JAVAX_SWING javax.swing
|
|
|
|
///#def JAVAX_SWING javax.swing
|
|
|
|
import javax.swing.JProgressBar; |
|
|
|
import javax.swing.JProgressBar; |
|
|
@ -40,7 +41,7 @@ import java.util.Set; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
///#enddef
|
|
|
|
///#enddef
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.NoSuchElementException; |
|
|
|
import java.util.NoSuchElementException; |
|
|
|
|
|
|
|
|
|
|
@ -95,6 +96,7 @@ public class HierarchyTreeModel implements TreeModel, Runnable { |
|
|
|
private TreeElement handleClass(HashMap classes, ClassInfo clazz) { |
|
|
|
private TreeElement handleClass(HashMap classes, ClassInfo clazz) { |
|
|
|
if (clazz == null) |
|
|
|
if (clazz == null) |
|
|
|
return root; |
|
|
|
return root; |
|
|
|
|
|
|
|
|
|
|
|
TreeElement elem = (TreeElement) classes.get(clazz); |
|
|
|
TreeElement elem = (TreeElement) classes.get(clazz); |
|
|
|
if (elem != null) |
|
|
|
if (elem != null) |
|
|
|
return elem; |
|
|
|
return elem; |
|
|
@ -102,6 +104,12 @@ public class HierarchyTreeModel implements TreeModel, Runnable { |
|
|
|
elem = new TreeElement(clazz.getName()); |
|
|
|
elem = new TreeElement(clazz.getName()); |
|
|
|
classes.put(clazz, elem); |
|
|
|
classes.put(clazz, elem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
clazz.load(ClassInfo.HIERARCHY); |
|
|
|
|
|
|
|
} catch (IOException ex) { |
|
|
|
|
|
|
|
clazz.guess(ClassInfo.HIERARCHY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!clazz.isInterface()) { |
|
|
|
if (!clazz.isInterface()) { |
|
|
|
ClassInfo superClazz = clazz.getSuperclass(); |
|
|
|
ClassInfo superClazz = clazz.getSuperclass(); |
|
|
|
handleClass(classes, superClazz).addChild(elem); |
|
|
|
handleClass(classes, superClazz).addChild(elem); |
|
|
@ -116,20 +124,20 @@ public class HierarchyTreeModel implements TreeModel, Runnable { |
|
|
|
|
|
|
|
|
|
|
|
public int readPackage(int depth, HashMap classes, String packageName, |
|
|
|
public int readPackage(int depth, HashMap classes, String packageName, |
|
|
|
int count) { |
|
|
|
int count) { |
|
|
|
|
|
|
|
ClassPath classPath = main.getClassPath(); |
|
|
|
if (depth++ >= MAX_PACKAGE_LEVEL) |
|
|
|
if (depth++ >= MAX_PACKAGE_LEVEL) |
|
|
|
return count; |
|
|
|
return count; |
|
|
|
String prefix = packageName.length() == 0 ? "" : packageName + "."; |
|
|
|
String prefix = packageName.length() == 0 ? "" : packageName + "."; |
|
|
|
Enumeration enum = |
|
|
|
Enumeration enum = classPath.listClassesAndPackages(packageName); |
|
|
|
ClassInfo.getClassesAndPackages(packageName); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
//insert sorted and remove double elements;
|
|
|
|
//insert sorted and remove double elements;
|
|
|
|
String name = (String)enum.nextElement(); |
|
|
|
String name = (String)enum.nextElement(); |
|
|
|
String fqn = prefix + name; |
|
|
|
String fqn = prefix + name; |
|
|
|
if (ClassInfo.isPackage(fqn)) { |
|
|
|
if (classPath.isPackage(fqn)) { |
|
|
|
count = readPackage(depth, classes, fqn, count); |
|
|
|
count = readPackage(depth, classes, fqn, count); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
TreeElement elem = handleClass |
|
|
|
TreeElement elem = handleClass |
|
|
|
(classes, main.getClassPath().getClassInfo(fqn)); |
|
|
|
(classes, classPath.getClassInfo(fqn)); |
|
|
|
if (progressBar != null) |
|
|
|
if (progressBar != null) |
|
|
|
progressBar.setValue(++count); |
|
|
|
progressBar.setValue(++count); |
|
|
|
|
|
|
|
|
|
|
@ -140,17 +148,17 @@ public class HierarchyTreeModel implements TreeModel, Runnable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int countClasses(int depth, String packageName) { |
|
|
|
public int countClasses(int depth, String packageName) { |
|
|
|
|
|
|
|
ClassPath classPath = main.getClassPath(); |
|
|
|
if (depth++ >= MAX_PACKAGE_LEVEL) |
|
|
|
if (depth++ >= MAX_PACKAGE_LEVEL) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
int number = 0; |
|
|
|
int number = 0; |
|
|
|
String prefix = packageName.length() == 0 ? "" : packageName + "."; |
|
|
|
String prefix = packageName.length() == 0 ? "" : packageName + "."; |
|
|
|
Enumeration enum = |
|
|
|
Enumeration enum = classPath.listClassesAndPackages(packageName); |
|
|
|
ClassInfo.getClassesAndPackages(packageName); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
//insert sorted and remove double elements;
|
|
|
|
//insert sorted and remove double elements;
|
|
|
|
String name = (String)enum.nextElement(); |
|
|
|
String name = (String)enum.nextElement(); |
|
|
|
String fqn = prefix + name; |
|
|
|
String fqn = prefix + name; |
|
|
|
if (ClassInfo.isPackage(fqn)) { |
|
|
|
if (classPath.isPackage(fqn)) { |
|
|
|
number += countClasses(depth, fqn); |
|
|
|
number += countClasses(depth, fqn); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
number++; |
|
|
|
number++; |
|
|
|