1 24 package org.aspectj.debugger.gui; 25 26 import com.sun.jdi.*; 27 import java.util.List ; 28 import java.util.*; 29 import javax.swing.tree.*; 30 31 public abstract class ClassNode extends AJClassNode implements Sourceable { 32 public ClassNode(ReferenceType refType) { 33 super(refType); 34 setUserObject(refType); 35 } 36 37 protected ReferenceType refType() { 38 return (ReferenceType) getUserObject(); 39 } 40 41 protected void addMethod(Method method) { 42 if (method.declaringType().equals(refType())) { 43 MethodNode methodNode = new NonAdvisableMethodNode(method); 44 add(methodNode); 45 } else { 46 addToSuper(method); 47 } 48 } 49 50 protected void addToSuper(Method method) { 51 TreeNode treeNode = getChildAt(0); 52 if (!(treeNode instanceof ClassNode)) return; 53 ClassNode classNode = (ClassNode) treeNode; 54 classNode.addMethod(method); 55 } 56 57 protected abstract String name(); 58 protected abstract String packageName(); 59 public String fullName() { 60 String pname = packageName(); 61 String name = name(); 62 if (pname == null || pname.equals("")) { 63 return name; 64 } 65 return pname + "." + name; 66 } 67 68 public String toString() { 69 String name = name(); 70 if (getParent() instanceof ClassTreePane.PackageNode) { 72 int idot = name.lastIndexOf('.'); 73 return idot != -1 ? name.substring(idot+1) : name; 74 } 75 return name; 76 } 77 78 public String getToolTipText() { 79 80 return 81 kind() + " " 82 + name(); 83 } 84 85 protected abstract String kind(); 86 87 protected AJClassNode newClassNode(ReferenceType refType) { 88 return ClassNodeFactory.classNode(refType); 89 } 90 91 public void showOnSource(AbstractSourcePane sourcePane) { 92 sourcePane.showSourceForFileAndLine(getRelativePath(), getLine()); 93 } 94 protected abstract String getRelativePath(); 95 protected abstract int getLine(); 96 97 public List getMethodStrings() { 98 List methodStrings = new Vector(); 99 if (children == null) return methodStrings; 100 Iterator iter = children.iterator(); 101 while (iter.hasNext()) { 102 methodStrings.add(((MethodNode) iter.next()).getBreakpoint()); 103 } 104 return methodStrings; 105 } 106 } 107 | Popular Tags |