1 22 package org.aspectj.debugger.ide; 23 24 import java.io.File ; 25 26 import org.aspectj.debugger.base.Options; 27 import org.aspectj.debugger.base.Debugger; 28 import org.aspectj.debugger.base.AJDebugger; 29 import org.aspectj.debugger.base.Modes; 30 import org.aspectj.debugger.gui.ComponentDirector; 31 32 38 public class IDEDebugger { 39 40 41 public static ComponentDirector director; 42 43 44 private String mainClass; 45 46 47 private String sourcePath; 48 49 50 private String classPath; 51 52 53 private String workingdir; 54 55 70 private String mode; 71 72 73 private String [] args; 74 75 88 public static void launch(String mainClass, 89 String sourcePath, 90 String classPath, 91 String workingdir, 92 String mode, 93 String [] args, 94 SourceShower shower, 95 IDEInterface ide) { 96 new IDEDebugger(mainClass, sourcePath, classPath, workingdir, mode, args, shower, ide).go(); 97 } 98 99 public static void launch(String mainClass, 101 String sourcePath, 102 String classPath, 103 String mode, 104 String [] args, 105 SourceShower shower, 106 IDEInterface ide) { 107 new IDEDebugger(mainClass, sourcePath, classPath, null, mode, args, shower, ide).go(); 108 } 109 110 private IDEDebugger(String mainClass, 111 String sourcePath, 112 String classPath, 113 String workingdir, 114 String mode, 115 String [] args, 116 SourceShower sourceShower, 117 IDEInterface ide) { 118 this.mainClass = mainClass; 119 this.sourcePath = sourcePath; 120 this.classPath = classPath; 121 this.workingdir = workingdir; 122 this.mode = mode; 123 this.args = args; 124 if (ide == null) { 125 ide = new IDEInterfaceImpl(); 126 } 127 } 136 137 private void go() { 138 director.go(); 139 Debugger debugger = director.getGUIDebugger().getDebugger(); 140 Options options = debugger.getOptions(); 141 if (check(classPath)) options.setClassPath(classPath); 142 if (check(sourcePath)) options.setSourcePath(sourcePath); 143 if (check(mainClass)) options.setMainClass(mainClass); 144 debugger.setOptions(options); 145 debugger.execute("use " + debugger.getSourcePath()); 147 if (check(workingdir)) { 148 debugger.execute("workingdir " + workingdir); 149 } 150 if (director instanceof IDEComponentDirector) { 155 ((IDEComponentDirector)director).finishUp(); 156 } 157 try { 158 if (check(mainClass)) debugger.run(mainClass, args); 159 } catch (Throwable t) { 160 org.aspectj.debugger.base.ErrorLogger.error(t); 161 } 162 } 163 164 private boolean check(String str) { 165 return str != null && str.length() > 0; 166 } 167 } 168 | Popular Tags |