1 33 34 package edu.rice.cs.drjava.model.repl; 35 36 import edu.rice.cs.drjava.model.repl.newjvm.*; 37 import edu.rice.cs.util.ClassPathVector; 38 import edu.rice.cs.util.text.EditDocumentInterface; 39 40 import java.net.URL ; 41 import java.io.File ; 42 43 48 public abstract class RMIInteractionsModel extends InteractionsModel { 49 50 51 protected final MainJVM _jvm; 52 53 59 public RMIInteractionsModel(MainJVM jvm, EditDocumentInterface adapter, File wd, int historySize, int writeDelay) { 60 super(adapter, wd, historySize, writeDelay); 61 _jvm = jvm; 62 } 63 64 67 protected void _interpret(String toEval) { _jvm.interpret(toEval); } 68 69 72 public String getVariableToString(String var) { return _jvm.getVariableToString(var); } 73 74 78 public String getVariableClassName(String var) { 79 return _jvm.getVariableClassName(var); 80 } 81 82 86 public void addProjectClassPath(URL path) { _jvm.addProjectClassPath(path); } 91 92 public void addBuildDirectoryClassPath(URL path) { _jvm.addBuildDirectoryClassPath(path); } 93 94 public void addProjectFilesClassPath(URL path) { 95 _jvm.addProjectFilesClassPath(path); 97 } 98 99 public void addExternalFilesClassPath(URL path) { _jvm.addExternalFilesClassPath(path); } 100 101 public void addExtraClassPath(URL path) { _jvm.addExtraClassPath(path); } 102 103 104 protected void _resetInterpreter(File wd) { _jvm.killInterpreter(wd); } 105 106 110 public void addJavaInterpreter(String name) { _jvm.addJavaInterpreter(name); } 111 112 117 public void addDebugInterpreter(String name, String className) { 118 _jvm.addDebugInterpreter(name, className); 119 } 120 121 124 public void removeInterpreter(String name) { 125 _jvm.removeInterpreter(name); 126 } 127 128 132 public void setActiveInterpreter(String name, String prompt) { 133 String currName = _jvm.getCurrentInterpreterName(); 134 boolean inProgress = _jvm.setActiveInterpreter(name); 135 _updateDocument(prompt, inProgress, !currName.equals(name)); 136 _notifyInterpreterChanged(inProgress); 137 } 138 139 140 public void setToDefaultInterpreter() { 141 String currName = _jvm.getCurrentInterpreterName(); 143 boolean printPrompt = !MainJVM.DEFAULT_INTERPRETER_NAME.equals(currName); 144 145 boolean inProgress = _jvm.setToDefaultInterpreter(); 146 147 _updateDocument(InteractionsDocument.DEFAULT_PROMPT, inProgress, printPrompt); 148 _notifyInterpreterChanged(inProgress); 149 } 150 151 156 private void _updateDocument(String prompt, boolean inProgress, boolean updatePrompt) { 157 if (updatePrompt) { 158 _document.acquireWriteLock(); 159 try { 160 _document.setPrompt(prompt); 161 _document.insertNewLine(_document.getLength()); 162 _document.insertPrompt(); 163 } 164 finally { _document.releaseWriteLock(); } 165 } 166 _document.setInProgress(inProgress); 167 } 168 169 173 protected abstract void _notifyInterpreterChanged(boolean inProgress); 174 175 176 public void setPrivateAccessible(boolean allow) { 177 _jvm.setPrivateAccessible(allow); 178 } 179 180 183 public ClassPathVector getClassPath() { return _jvm.getClassPath(); } 184 } | Popular Tags |