1 33 34 package edu.rice.cs.drjava.model.repl; 35 36 import java.io.File ; 37 38 import edu.rice.cs.drjava.DrJava; 39 import edu.rice.cs.drjava.config.OptionConstants; 40 import edu.rice.cs.drjava.config.OptionListener; 41 import edu.rice.cs.drjava.config.OptionEvent; 42 import edu.rice.cs.drjava.model.DefaultGlobalModel; 43 import edu.rice.cs.drjava.model.repl.newjvm.MainJVM; 44 import edu.rice.cs.util.StringOps; 45 import edu.rice.cs.util.text.ConsoleDocument; 46 import edu.rice.cs.util.text.*; 47 import edu.rice.cs.util.swing.Utilities; 48 49 53 public class DefaultInteractionsModel extends RMIInteractionsModel { 54 55 58 59 protected final DefaultGlobalModel _model; 60 61 66 public DefaultInteractionsModel(DefaultGlobalModel model, MainJVM control, EditDocumentInterface adapter, File wd) { 67 super(control, adapter, wd, DrJava.getConfig().getSetting(OptionConstants.HISTORY_MAX_SIZE).intValue(), 68 DefaultGlobalModel.WRITE_DELAY); 69 _model = model; 70 Boolean allow = DrJava.getConfig().getSetting(OptionConstants.RUN_WITH_ASSERT); 72 _jvm.setAllowAssertions(allow.booleanValue()); 73 74 DrJava.getConfig().addOptionListener(OptionConstants.HISTORY_MAX_SIZE, _document.getHistoryOptionListener()); 76 DrJava.getConfig().addOptionListener(OptionConstants.RUN_WITH_ASSERT, 77 new OptionListener<Boolean >() { 78 public void optionChanged(OptionEvent<Boolean > oce) { 79 _jvm.setAllowAssertions(oce.value.booleanValue()); 80 } 81 }); 82 } 83 84 87 public void replSystemOutPrint(String s) { 88 super.replSystemOutPrint(s); 89 _model.systemOutPrint(s); 90 } 91 92 95 public void replSystemErrPrint(String s) { 96 super.replSystemErrPrint(s); 97 _model.systemErrPrint(s); 98 } 99 100 101 public String getConsoleInput() { 102 String s = super.getConsoleInput(); 103 _model.systemInEcho(s); 104 return s; 105 } 106 107 108 111 protected void _interpreterResetFailed(Throwable t) { 112 _document.insertBeforeLastPrompt("Reset Failed! See the console tab for details." + _newLine, 113 InteractionsDocument.ERROR_STYLE); 114 _model.systemErrPrint(StringOps.getStackTrace(t)); 116 } 117 118 119 public void interpreterReady(File wd) { 120 _model.resetInteractionsClassPath(); super.interpreterReady(wd); 122 } 123 124 125 protected void _notifyInteractionStarted() { 126 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interactionStarted(); } }); 127 } 128 129 130 protected void _notifyInteractionEnded() { 131 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interactionEnded(); } }); 132 } 133 134 135 protected void _notifySyntaxErrorOccurred(final int offset, final int length) { 136 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interactionErrorOccurred(offset,length); } }); 137 } 138 139 142 protected void _notifyInterpreterChanged(final boolean inProgress) { 143 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interpreterChanged(inProgress); } }); 144 } 145 146 147 protected void _notifyInterpreterResetting() { 148 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interpreterResetting(); } }); 149 } 150 151 152 public void _notifyInterpreterReady(final File wd) { 153 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interpreterReady(wd); } }); 155 } 156 157 158 protected void _notifySlaveJVMUsed(final File wd) { 159 Utilities.invokeLater(new Runnable () { public void run() { _notifier.slaveJVMUsed(); } }); 160 } 161 162 165 protected void _notifyInterpreterExited(final int status) { 166 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interpreterExited(status); } }); 167 } 168 169 172 protected void _notifyInterpreterResetFailed(final Throwable t) { 173 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interpreterResetFailed(t); } }); 174 } 175 176 177 protected void _notifyInteractionIncomplete() { 178 Utilities.invokeLater(new Runnable () { public void run() { _notifier.interactionIncomplete(); } }); 179 } 180 181 182 protected void _notifySlaveJVMUsed() { 183 Utilities.invokeLater(new Runnable () { public void run() { _notifier.slaveJVMUsed(); } }); 184 } 185 186 public ConsoleDocument getConsoleDocument() { return _model.getConsoleDocument(); } 187 } 188 | Popular Tags |