1 19 20 package ca.mcgill.sable.soot.launching; 21 22 import java.io.*; 23 import java.lang.reflect.InvocationTargetException ; 24 import ca.mcgill.sable.soot.interaction.*; 25 26 import org.eclipse.core.runtime.IProgressMonitor; 27 import org.eclipse.jface.operation.IRunnableWithProgress; 28 import org.eclipse.swt.widgets.Display; 29 import ca.mcgill.sable.soot.util.*; 30 import java.util.*; 31 import org.eclipse.jface.dialogs.*; 32 33 36 public class SootRunner implements IRunnableWithProgress { 37 38 Display display; 39 String [] cmd; 40 String mainClass; 41 ArrayList cfgList; 42 private SootLauncher parent; 43 44 47 public SootRunner(String [] cmd, Display display , String mainClass) { 48 setDisplay(display); 49 setCmd(cmd); 50 setMainClass(mainClass); 51 52 } 53 54 57 public void run(IProgressMonitor monitor) 58 throws InvocationTargetException , InterruptedException { 59 try { 60 61 final PipedInputStream pis = new PipedInputStream(); 62 63 final PipedOutputStream pos = new PipedOutputStream(pis); 64 final PrintStream sootOut = new PrintStream(pos); 65 66 final String [] cmdFinal = getCmd(); 67 68 SootThread sootThread = new SootThread(getDisplay(), getMainClass(), this); 69 70 sootThread.setCmd(cmdFinal); 71 sootThread.setSootOut(sootOut); 72 sootThread.start(); 73 74 StreamGobbler out = new StreamGobbler(getDisplay(), pis, StreamGobbler.OUTPUT_STREAM_TYPE); 75 out.start(); 76 77 sootThread.join(); 78 getParent().setCfgList(getCfgList()); 79 } 80 catch (Exception e) { 81 System.out.println(e.getStackTrace()); 82 } 83 } 84 85 86 90 public String [] getCmd() { 91 return cmd; 92 } 93 94 98 public Display getDisplay() { 99 return display; 100 } 101 102 106 public void setCmd(String [] cmd) { 107 this.cmd = cmd; 108 } 109 110 114 public void setDisplay(Display display) { 115 this.display = display; 116 } 117 118 121 public String getMainClass() { 122 return mainClass; 123 } 124 125 128 public void setMainClass(String string) { 129 mainClass = string; 130 } 131 132 135 public ArrayList getCfgList() { 136 return cfgList; 137 } 138 139 142 public void setCfgList(ArrayList list) { 143 cfgList = list; 144 } 145 146 149 public SootLauncher getParent() { 150 return parent; 151 } 152 153 156 public void setParent(SootLauncher launcher) { 157 parent = launcher; 158 } 159 160 } 161 | Popular Tags |