|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| package edu.rice.cs.drjava.ui; |
|
38 |
| |
|
39 |
| import java.awt.*; |
|
40 |
| import java.awt.event.*; |
|
41 |
| import java.io.*; |
|
42 |
| import java.util.List; |
|
43 |
| import java.util.ArrayList; |
|
44 |
| import javax.swing.*; |
|
45 |
| |
|
46 |
| import edu.rice.cs.util.swing.Utilities; |
|
47 |
| import edu.rice.cs.util.ProcessCreator; |
|
48 |
| import edu.rice.cs.drjava.ui.predictive.*; |
|
49 |
| import edu.rice.cs.drjava.model.OpenDefinitionsDocument; |
|
50 |
| import edu.rice.cs.plt.concurrent.CompletionMonitor; |
|
51 |
| import edu.rice.cs.drjava.model.DrJavaFileUtils; |
|
52 |
| import static edu.rice.cs.drjava.ui.MainFrameStatics.GoToFileListEntry; |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| public class ExternalProcessPanel extends AbortablePanel { |
|
60 |
| |
|
61 |
| public final int BUFFER_SIZE = 10240; |
|
62 |
| |
|
63 |
| public final int BUFFER_READS_PER_TIMER = 5; |
|
64 |
| protected JTextArea _textArea; |
|
65 |
| protected ProcessCreator _pc = null; |
|
66 |
| protected Process _p = null; |
|
67 |
| protected InputStreamReader _is = null; |
|
68 |
| protected InputStreamReader _erris = null; |
|
69 |
| protected JButton _updateNowButton; |
|
70 |
| protected JButton _runAgainButton; |
|
71 |
| protected Thread _updateThread; |
|
72 |
| protected Thread _readThread; |
|
73 |
| protected Thread _deathThread; |
|
74 |
| protected StringBuilder _sb = new StringBuilder(); |
|
75 |
| protected volatile int _changeCount = 0; |
|
76 |
| private char[] _buf = new char[BUFFER_SIZE]; |
|
77 |
| private int _red = -1; |
|
78 |
| private char[] _errbuf = new char[BUFFER_SIZE]; |
|
79 |
| private int _errred = -1; |
|
80 |
| private int _retVal; |
|
81 |
| private String _header; |
|
82 |
| protected CompletionMonitor _abortMonitor = new CompletionMonitor(); |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
0
| public ExternalProcessPanel(MainFrame frame, String title, ProcessCreator pc) {
|
|
91 |
0
| super(frame, title);
|
|
92 |
0
| _sb = new StringBuilder("Command line: ");
|
|
93 |
0
| _sb.append(pc.cmdline());
|
|
94 |
0
| _sb.append('\n');
|
|
95 |
0
| _header = _sb.toString();
|
|
96 |
0
| _textArea.setText(_header);
|
|
97 |
0
| initThread(pc);
|
|
98 |
0
| _textArea.addMouseListener(new MouseListener() {
|
|
99 |
0
| public void mouseClicked(MouseEvent e) {
|
|
100 |
0
| if ((SwingUtilities.isLeftMouseButton(e)) &&
|
|
101 |
| (e.getClickCount() == 2)) { |
|
102 |
0
| doubleClicked(e);
|
|
103 |
| } |
|
104 |
| } |
|
105 |
0
| public void mouseEntered(MouseEvent e) { }
|
|
106 |
0
| public void mouseExited(MouseEvent e) { }
|
|
107 |
0
| public void mousePressed(MouseEvent e) { }
|
|
108 |
0
| public void mouseReleased(MouseEvent e) { }
|
|
109 |
| }); |
|
110 |
0
| EventQueue.invokeLater(new Runnable() {
|
|
111 |
0
| public void run() { updateText(); } });
|
|
112 |
| |
|
113 |
| } |
|
114 |
| |
|
115 |
0
| protected void initThread(ProcessCreator pc) {
|
|
116 |
0
| _abortMonitor.reset();
|
|
117 |
| |
|
118 |
0
| try {
|
|
119 |
0
| _pc = pc;
|
|
120 |
0
| _pc.getPropertyMaps().clearVariables();
|
|
121 |
0
| _readThread = new Thread(new Runnable() {
|
|
122 |
0
| public void run() {
|
|
123 |
0
| while((_is != null) || (_erris != null)) {
|
|
124 |
0
| readText(false);
|
|
125 |
| } |
|
126 |
| } |
|
127 |
| },"External Process Read Thread"); |
|
128 |
0
| _updateThread = new Thread(new Runnable() {
|
|
129 |
0
| public void run() {
|
|
130 |
0
| while((_is != null) || (_erris != null)) {
|
|
131 |
0
| try {
|
|
132 |
0
| Thread.sleep(edu.rice.cs.drjava.DrJava.getConfig().
|
|
133 |
| getSetting(edu.rice.cs.drjava.config.OptionConstants.FOLLOW_FILE_DELAY)); |
|
134 |
| } |
|
135 |
| catch(InterruptedException ie) { } |
|
136 |
0
| updateText();
|
|
137 |
| } |
|
138 |
| } |
|
139 |
| },"External Process Update Thread"); |
|
140 |
0
| _p = _pc.start();
|
|
141 |
0
| _sb.append("Evaluated command line: ");
|
|
142 |
0
| _sb.append(_pc.evaluatedCommandLine());
|
|
143 |
0
| _sb.append('\n');
|
|
144 |
0
| _is = new InputStreamReader(_p.getInputStream());
|
|
145 |
0
| _erris = new InputStreamReader(_p.getErrorStream());
|
|
146 |
0
| _readThread.start();
|
|
147 |
0
| _updateThread.start();
|
|
148 |
0
| _updateNowButton.setEnabled(true);
|
|
149 |
0
| _deathThread = new Thread(new Runnable() {
|
|
150 |
0
| public void run() {
|
|
151 |
0
| try {
|
|
152 |
0
| _retVal = _p.waitFor();
|
|
153 |
0
| Utilities.invokeLater(new Runnable() {
|
|
154 |
0
| public void run() {
|
|
155 |
0
| _sb.append("\n\nProcess returned ");
|
|
156 |
0
| _sb.append(_retVal);
|
|
157 |
0
| _sb.append("\n");
|
|
158 |
0
| _textArea.setText(_sb.toString());
|
|
159 |
| } |
|
160 |
| }); |
|
161 |
| } |
|
162 |
| catch(InterruptedException e) { |
|
163 |
0
| Utilities.invokeLater(new Runnable() {
|
|
164 |
0
| public void run() {
|
|
165 |
0
| _p.destroy();
|
|
166 |
0
| _sb.append("\n\nProcess returned ");
|
|
167 |
0
| _sb.append(_retVal);
|
|
168 |
0
| _sb.append("\n");
|
|
169 |
0
| _textArea.setText(_sb.toString());
|
|
170 |
| } |
|
171 |
| }); |
|
172 |
| } |
|
173 |
| finally { |
|
174 |
0
| abortActionPerformed(null);
|
|
175 |
| } |
|
176 |
| } |
|
177 |
| },"External Process Death Thread"); |
|
178 |
0
| _deathThread.start();
|
|
179 |
| |
|
180 |
| } |
|
181 |
| catch(Exception e) { |
|
182 |
0
| _sb.append("\n\nException from process:\n" + e.toString());
|
|
183 |
0
| _textArea.setText(_sb.toString());
|
|
184 |
0
| edu.rice.cs.util.GeneralProcessCreator.LOG.log(_sb.toString());
|
|
185 |
0
| abortActionPerformed(null);
|
|
186 |
| } |
|
187 |
| } |
|
188 |
| |
|
189 |
| |
|
190 |
0
| protected Component makeLeftPanel() {
|
|
191 |
0
| _textArea = new JTextArea();
|
|
192 |
0
| _textArea.setEditable(false);
|
|
193 |
0
| return _textArea;
|
|
194 |
| } |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
0
| protected void abortActionPerformed(ActionEvent e) {
|
|
199 |
0
| _abortButton.setEnabled(false);
|
|
200 |
0
| _updateNowButton.setEnabled(false);
|
|
201 |
0
| _runAgainButton.setEnabled(true);
|
|
202 |
| |
|
203 |
0
| new Thread(new Runnable() {
|
|
204 |
0
| public void run() {
|
|
205 |
0
| if (_is != null) {
|
|
206 |
0
| try {
|
|
207 |
| |
|
208 |
| |
|
209 |
0
| _p.getInputStream().close();
|
|
210 |
0
| _is.close();
|
|
211 |
| } |
|
212 |
| catch(IOException ioe) { } |
|
213 |
0
| _is = null;
|
|
214 |
0
| Utilities.invokeLater(new Runnable() { public void run() { updateButtons(); } });
|
|
215 |
| } |
|
216 |
0
| if (_erris != null) {
|
|
217 |
0
| try {
|
|
218 |
| |
|
219 |
| |
|
220 |
0
| _p.getErrorStream().close();
|
|
221 |
0
| _erris.close();
|
|
222 |
| } |
|
223 |
| catch(IOException ioe) { } |
|
224 |
0
| _erris = null;
|
|
225 |
0
| Utilities.invokeLater(new Runnable() { public void run() { updateButtons(); } });
|
|
226 |
| } |
|
227 |
0
| if (_p != null) {
|
|
228 |
0
| _p.destroy();
|
|
229 |
0
| _p = null;
|
|
230 |
| } |
|
231 |
0
| Utilities.invokeLater(new Runnable() { public void run() { updateText(); updateButtons(); } });
|
|
232 |
0
| _abortMonitor.signal();
|
|
233 |
| } |
|
234 |
| }).start(); |
|
235 |
| } |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
0
| protected void runAgainActionPerformed(ActionEvent e) {
|
|
240 |
0
| abortActionPerformed(e);
|
|
241 |
0
| _abortButton.setEnabled(false);
|
|
242 |
0
| _updateNowButton.setEnabled(false);
|
|
243 |
0
| _runAgainButton.setEnabled(false);
|
|
244 |
| |
|
245 |
0
| new Thread(new Runnable() {
|
|
246 |
0
| public void run() {
|
|
247 |
0
| _abortMonitor.attemptEnsureSignaled();
|
|
248 |
0
| _abortMonitor.reset();
|
|
249 |
0
| _sb = new StringBuilder("Command line: ");
|
|
250 |
0
| _sb.append(_pc.cmdline());
|
|
251 |
0
| _sb.append('\n');
|
|
252 |
0
| _header = _sb.toString();
|
|
253 |
0
| initThread(_pc);
|
|
254 |
0
| EventQueue.invokeLater(new Runnable() {
|
|
255 |
0
| public void run() {
|
|
256 |
0
| updateText();
|
|
257 |
| } }); |
|
258 |
| } |
|
259 |
| }).start(); |
|
260 |
| } |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
0
| public void doubleClicked(MouseEvent e) {
|
|
266 |
| |
|
267 |
| |
|
268 |
0
| List<OpenDefinitionsDocument> docs = _model.getOpenDefinitionsDocuments();
|
|
269 |
0
| if ((docs == null) || (docs.size() == 0)) return;
|
|
270 |
| |
|
271 |
0
| final String t = _textArea.getText();
|
|
272 |
0
| int caret = _textArea.getCaretPosition();
|
|
273 |
0
| int start = caret;
|
|
274 |
0
| int end = start;
|
|
275 |
0
| while((start-1 > 0) && (t.charAt(start-1) != '\n')) { --start; }
|
|
276 |
0
| while((end >= 0) && (end < t.length()) && (t.charAt(end) != '\n')) { ++end; }
|
|
277 |
| |
|
278 |
| |
|
279 |
0
| if ((start < 0) || (end < 0) || (start >= t.length()) || (end >= t.length())) return;
|
|
280 |
0
| final String line = t.substring(start,end);
|
|
281 |
| |
|
282 |
0
| caret -= start;
|
|
283 |
0
| if (caret>=line.length()) { caret = line.length()-1; }
|
|
284 |
0
| start = end = caret;
|
|
285 |
0
| char ch;
|
|
286 |
0
| while((end >= 0) && (end<line.length())) {
|
|
287 |
0
| ch = line.charAt(end);
|
|
288 |
0
| if (ch == ':') {
|
|
289 |
0
| if ((end + 1 < line.length()) && (Character.isDigit(line.charAt(end+1)))) {
|
|
290 |
| |
|
291 |
| |
|
292 |
0
| do {
|
|
293 |
0
| ++end;
|
|
294 |
0
| } while((end < line.length()) && (Character.isDigit(line.charAt(end))));
|
|
295 |
0
| break;
|
|
296 |
| } |
|
297 |
| else { |
|
298 |
| |
|
299 |
0
| break;
|
|
300 |
| } |
|
301 |
| } |
|
302 |
0
| else if (Character.isJavaIdentifierPart(ch)) {
|
|
303 |
| |
|
304 |
0
| ++end;
|
|
305 |
| } |
|
306 |
0
| else if ((ch=='.') || (ch == File.separatorChar)) {
|
|
307 |
| |
|
308 |
0
| ++end;
|
|
309 |
| } |
|
310 |
| else { |
|
311 |
| |
|
312 |
0
| break;
|
|
313 |
| } |
|
314 |
| } |
|
315 |
| |
|
316 |
0
| ArrayList<GoToFileListEntry> list;
|
|
317 |
0
| list = new ArrayList<GoToFileListEntry>(docs.size());
|
|
318 |
| |
|
319 |
0
| for(OpenDefinitionsDocument d: docs) {
|
|
320 |
| |
|
321 |
0
| try {
|
|
322 |
0
| String fullyQualified = d.getPackageName() + "." + d.toString();
|
|
323 |
0
| if (fullyQualified.startsWith(".")) { fullyQualified = fullyQualified.substring(1); }
|
|
324 |
0
| list.add(new GoToFileListEntry(d, fullyQualified));
|
|
325 |
| |
|
326 |
| } |
|
327 |
| catch(IllegalStateException ex) { } |
|
328 |
| } |
|
329 |
0
| PredictiveInputModel<GoToFileListEntry> pim =
|
|
330 |
| new PredictiveInputModel<GoToFileListEntry>(true, new PredictiveInputModel.PrefixLineNumStrategy<GoToFileListEntry>(), list); |
|
331 |
| |
|
332 |
0
| GoToFileListEntry uniqueMatch = null;
|
|
333 |
0
| String name, oldName = null, simpleName = null;
|
|
334 |
0
| while ((start >= 0) && (start < line.length()) && Character.isWhitespace(line.charAt(start))) {
|
|
335 |
0
| --start;
|
|
336 |
| } |
|
337 |
0
| while(start > 0) {
|
|
338 |
0
| ch = line.charAt(start);
|
|
339 |
0
| while(start > 0) {
|
|
340 |
0
| ch = line.charAt(start);
|
|
341 |
0
| if ((ch == ':') || (ch == '.') || (Character.isJavaIdentifierPart(ch))) { --start; } else { break; }
|
|
342 |
| } |
|
343 |
| |
|
344 |
0
| if ((start >= 0) && (end>=start) && (start<line.length()) && (end<line.length())) {
|
|
345 |
0
| name = line.substring(start,end).replace(File.separatorChar, '.');
|
|
346 |
0
| if ((name.length() > 0) && (! Character.isJavaIdentifierPart(name.charAt(0)))) { name = name.substring(1); }
|
|
347 |
0
| if (simpleName == null) { simpleName = name; }
|
|
348 |
0
| if (name.equals(oldName)) { break; }
|
|
349 |
0
| if (DrJavaFileUtils.isSourceFile(name)) {
|
|
350 |
| |
|
351 |
0
| uniqueMatch = getUniqueMatch(name, pim);
|
|
352 |
0
| if (uniqueMatch != null) {
|
|
353 |
| |
|
354 |
| |
|
355 |
0
| final OpenDefinitionsDocument newDoc = pim.getCurrentItem().getOpenDefinitionsDocument();
|
|
356 |
0
| if (newDoc != null) {
|
|
357 |
0
| final boolean docChanged = ! newDoc.equals(_model.getActiveDocument());
|
|
358 |
0
| final boolean docSwitch = _model.getActiveDocument() != newDoc;
|
|
359 |
0
| if (docSwitch) _model.setActiveDocument(newDoc);
|
|
360 |
0
| final int curLine = newDoc.getCurrentLine();
|
|
361 |
0
| final int last = name.lastIndexOf(':');
|
|
362 |
0
| if (last >= 0) {
|
|
363 |
0
| try {
|
|
364 |
0
| String nend = name.substring(last + 1);
|
|
365 |
0
| int val = Integer.parseInt(nend);
|
|
366 |
| |
|
367 |
0
| final int lineNum = Math.max(1, val);
|
|
368 |
0
| Runnable command = new Runnable() {
|
|
369 |
0
| public void run() {
|
|
370 |
0
| try { _frame._jumpToLine(lineNum); }
|
|
371 |
0
| catch (RuntimeException ex) { _frame._jumpToLine(curLine); }
|
|
372 |
| } |
|
373 |
| }; |
|
374 |
0
| if (docSwitch) {
|
|
375 |
| |
|
376 |
0
| EventQueue.invokeLater(command);
|
|
377 |
| } |
|
378 |
0
| else command.run();
|
|
379 |
| } |
|
380 |
| catch(RuntimeException ex) { } |
|
381 |
| } |
|
382 |
0
| else if (docChanged) {
|
|
383 |
| |
|
384 |
0
| EventQueue.invokeLater(new Runnable() { public void run() { _frame.addToBrowserHistory(); } });
|
|
385 |
| } |
|
386 |
| } |
|
387 |
0
| break;
|
|
388 |
| } |
|
389 |
| } |
|
390 |
0
| oldName = name;
|
|
391 |
| } |
|
392 |
| else { |
|
393 |
0
| break;
|
|
394 |
| } |
|
395 |
0
| if (ch==File.separatorChar) { --start; }
|
|
396 |
| } |
|
397 |
0
| if (uniqueMatch == null) {
|
|
398 |
| |
|
399 |
0
| if (simpleName == null) { simpleName = ""; }
|
|
400 |
0
| _frame.gotoFileMatchingMask(simpleName);
|
|
401 |
| } |
|
402 |
| } |
|
403 |
| |
|
404 |
| |
|
405 |
| |
|
406 |
| |
|
407 |
| |
|
408 |
0
| GoToFileListEntry getUniqueMatch(String mask, PredictiveInputModel<GoToFileListEntry> pim) {
|
|
409 |
0
| pim.setMask(mask);
|
|
410 |
| |
|
411 |
0
| if (pim.getMatchingItems().size() == 1) {
|
|
412 |
| |
|
413 |
0
| if (pim.getCurrentItem() != null) { return pim.getCurrentItem(); }
|
|
414 |
| } |
|
415 |
0
| return null;
|
|
416 |
| } |
|
417 |
| |
|
418 |
| |
|
419 |
0
| protected void updateButtons() {
|
|
420 |
0
| boolean ended = true;
|
|
421 |
0
| if (_p != null) {
|
|
422 |
0
| try {
|
|
423 |
| |
|
424 |
0
| _p.exitValue();
|
|
425 |
| |
|
426 |
0
| ended = true;
|
|
427 |
| } |
|
428 |
| catch(IllegalThreadStateException e) { |
|
429 |
| |
|
430 |
0
| ended = false;
|
|
431 |
| } |
|
432 |
| } |
|
433 |
0
| _abortButton.setEnabled((_is != null) && (_erris != null) && (!ended));
|
|
434 |
0
| _updateNowButton.setEnabled((_is != null) && (_erris != null) && (!ended));
|
|
435 |
0
| _runAgainButton.setEnabled((_is == null) || (_erris == null) || (ended));
|
|
436 |
| } |
|
437 |
| |
|
438 |
| |
|
439 |
0
| protected JComponent[] makeButtons() {
|
|
440 |
0
| _updateNowButton = new JButton("Update");
|
|
441 |
0
| _updateNowButton.addActionListener(new ActionListener() {
|
|
442 |
0
| public void actionPerformed(ActionEvent e) {
|
|
443 |
0
| EventQueue.invokeLater(new Runnable() { public void run() { updateText(); } }); }
|
|
444 |
| }); |
|
445 |
0
| _runAgainButton = new JButton("Run Again");
|
|
446 |
0
| _runAgainButton.addActionListener(new ActionListener() {
|
|
447 |
0
| public void actionPerformed(ActionEvent e) {
|
|
448 |
0
| runAgainActionPerformed(e);
|
|
449 |
| } |
|
450 |
| }); |
|
451 |
0
| return new JComponent[] { _updateNowButton, _runAgainButton };
|
|
452 |
| } |
|
453 |
| |
|
454 |
| |
|
455 |
| |
|
456 |
0
| protected void readText(final boolean finish) {
|
|
457 |
| |
|
458 |
0
| if (((_is != null) || (_erris != null))) {
|
|
459 |
0
| _changeCount = 0;
|
|
460 |
| |
|
461 |
0
| try {
|
|
462 |
| |
|
463 |
| |
|
464 |
| |
|
465 |
0
| while((_is != null) &&
|
|
466 |
| (_erris != null) && |
|
467 |
| (_changeCount <= BUFFER_READS_PER_TIMER) && |
|
468 |
| (_erris != null) && |
|
469 |
| ((_red = _is.read(_buf)) >= 0)) { |
|
470 |
| |
|
471 |
| |
|
472 |
0
| _sb.append(new String(_buf, 0, _red));
|
|
473 |
0
| if (finish) { _changeCount = 1; } else { ++_changeCount; }
|
|
474 |
| } |
|
475 |
0
| while((_changeCount <= BUFFER_READS_PER_TIMER) &&
|
|
476 |
| (_erris != null) && |
|
477 |
| ((_errred = _erris.read(_errbuf)) >= 0)) { |
|
478 |
| |
|
479 |
0
| _sb.append(new String(_errbuf, 0, _errred));
|
|
480 |
0
| if (finish) { _changeCount = 1; } else { ++_changeCount; }
|
|
481 |
| } |
|
482 |
0
| if ((_red > 0) && (_changeCount < BUFFER_READS_PER_TIMER)) {
|
|
483 |
0
| _sb.append(new String(_buf, 0, _red));
|
|
484 |
0
| if (finish) { _changeCount = 1; } else { ++_changeCount; }
|
|
485 |
| } |
|
486 |
0
| if ((_errred > 0) && (_changeCount<BUFFER_READS_PER_TIMER)) {
|
|
487 |
0
| _sb.append(new String(_errbuf, 0, _errred));
|
|
488 |
0
| if (finish) { _changeCount = 1; } else { ++_changeCount; }
|
|
489 |
| } |
|
490 |
0
| if ((_p != null) && (_is == null)) {
|
|
491 |
0
| try {
|
|
492 |
| |
|
493 |
0
| _p.exitValue();
|
|
494 |
| |
|
495 |
| } |
|
496 |
| catch(IllegalThreadStateException e) { |
|
497 |
| |
|
498 |
0
| _sb.append("\nInput stream suddenly became null.");
|
|
499 |
| } |
|
500 |
| } |
|
501 |
0
| if ((_p != null) && (_erris == null)) {
|
|
502 |
0
| try {
|
|
503 |
| |
|
504 |
0
| _p.exitValue();
|
|
505 |
| |
|
506 |
| } |
|
507 |
| catch(IllegalThreadStateException e) { |
|
508 |
| |
|
509 |
0
| _sb.append("\nError input stream suddenly became null.");
|
|
510 |
| } |
|
511 |
| } |
|
512 |
| } |
|
513 |
| catch(IOException ioe) { |
|
514 |
| |
|
515 |
| |
|
516 |
0
| if (_p != null) {
|
|
517 |
0
| try {
|
|
518 |
0
| _p.exitValue();
|
|
519 |
| |
|
520 |
| } |
|
521 |
| catch(IllegalThreadStateException e) { |
|
522 |
| |
|
523 |
0
| _sb.append("\n\nI/O Exception reading from process:\n" + ioe.toString());
|
|
524 |
0
| edu.rice.cs.util.GeneralProcessCreator.LOG.log("\n\nI/O Exception reading from process:");
|
|
525 |
0
| edu.rice.cs.util.GeneralProcessCreator.LOG.log(ioe.toString(),ioe);
|
|
526 |
| } |
|
527 |
| } |
|
528 |
0
| if (finish) { _changeCount = 1; } else { ++_changeCount; }
|
|
529 |
0
| abortActionPerformed(null);
|
|
530 |
| } |
|
531 |
| } |
|
532 |
| } |
|
533 |
| |
|
534 |
| |
|
535 |
0
| protected void updateText() {
|
|
536 |
| |
|
537 |
0
| if (_updateNowButton.isEnabled()) {
|
|
538 |
| |
|
539 |
| |
|
540 |
| |
|
541 |
| |
|
542 |
| |
|
543 |
| |
|
544 |
| |
|
545 |
| |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
| |
|
550 |
| |
|
551 |
| |
|
552 |
| |
|
553 |
| |
|
554 |
| |
|
555 |
0
| if (_changeCount > 0) {
|
|
556 |
0
| _changeCount = 0;
|
|
557 |
0
| EventQueue.invokeLater(new Runnable() {
|
|
558 |
0
| public void run() {
|
|
559 |
| |
|
560 |
0
| _textArea.setText(_sb.toString());
|
|
561 |
0
| int maxLines = edu.rice.cs.drjava.DrJava.getConfig().
|
|
562 |
| getSetting(edu.rice.cs.drjava.config.OptionConstants.FOLLOW_FILE_LINES); |
|
563 |
0
| if (maxLines > 0) {
|
|
564 |
0
| try {
|
|
565 |
0
| int start = 0;
|
|
566 |
0
| int len = _textArea.getText().length();
|
|
567 |
0
| int curLines = _textArea.getLineCount();
|
|
568 |
0
| if (curLines>maxLines) {
|
|
569 |
0
| start = _textArea.getLineStartOffset(curLines-maxLines);
|
|
570 |
0
| len -= start;
|
|
571 |
0
| _sb = new StringBuilder(_textArea.getText(start,len));
|
|
572 |
0
| _textArea.setText(_sb.toString());
|
|
573 |
| } |
|
574 |
| } |
|
575 |
| catch(javax.swing.text.BadLocationException e) { } |
|
576 |
| } |
|
577 |
| |
|
578 |
| } |
|
579 |
| }); |
|
580 |
| } |
|
581 |
| |
|
582 |
0
| updateButtons();
|
|
583 |
| } |
|
584 |
| } |
|
585 |
| } |