1 11 package org.eclipse.debug.internal.ui.views.console; 12 13 import java.io.ByteArrayInputStream ; 14 import java.io.File ; 15 import java.io.FileNotFoundException ; 16 import java.io.FileOutputStream ; 17 import java.io.IOException ; 18 import java.util.ArrayList ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.eclipse.core.resources.IFile; 23 import org.eclipse.core.resources.IStorage; 24 import org.eclipse.core.resources.IWorkspace; 25 import org.eclipse.core.resources.IWorkspaceRoot; 26 import org.eclipse.core.resources.ResourcesPlugin; 27 import org.eclipse.core.runtime.CoreException; 28 import org.eclipse.core.runtime.IProgressMonitor; 29 import org.eclipse.core.runtime.IStatus; 30 import org.eclipse.core.runtime.NullProgressMonitor; 31 import org.eclipse.core.runtime.Path; 32 import org.eclipse.core.runtime.PlatformObject; 33 import org.eclipse.core.runtime.Status; 34 import org.eclipse.core.runtime.jobs.Job; 35 import org.eclipse.core.variables.IStringVariableManager; 36 import org.eclipse.core.variables.VariablesPlugin; 37 import org.eclipse.debug.core.DebugEvent; 38 import org.eclipse.debug.core.DebugPlugin; 39 import org.eclipse.debug.core.IDebugEventSetListener; 40 import org.eclipse.debug.core.ILaunchConfiguration; 41 import org.eclipse.debug.core.ILaunchConfigurationType; 42 import org.eclipse.debug.core.IStreamListener; 43 import org.eclipse.debug.core.model.IFlushableStreamMonitor; 44 import org.eclipse.debug.core.model.IProcess; 45 import org.eclipse.debug.core.model.IStreamMonitor; 46 import org.eclipse.debug.core.model.IStreamsProxy; 47 import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; 48 import org.eclipse.debug.internal.ui.DebugPluginImages; 49 import org.eclipse.debug.internal.ui.DebugUIPlugin; 50 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 51 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; 52 import org.eclipse.debug.ui.DebugUITools; 53 import org.eclipse.debug.ui.IDebugUIConstants; 54 import org.eclipse.debug.ui.console.IConsole; 55 import org.eclipse.debug.ui.console.IConsoleColorProvider; 56 import org.eclipse.debug.ui.console.IConsoleHyperlink; 57 import org.eclipse.debug.ui.console.IConsoleLineTracker; 58 import org.eclipse.jface.preference.IPreferenceStore; 59 import org.eclipse.jface.resource.ImageDescriptor; 60 import org.eclipse.jface.resource.JFaceResources; 61 import org.eclipse.jface.text.BadLocationException; 62 import org.eclipse.jface.text.IRegion; 63 import org.eclipse.jface.util.IPropertyChangeListener; 64 import org.eclipse.jface.util.PropertyChangeEvent; 65 import org.eclipse.swt.graphics.Color; 66 import org.eclipse.ui.IEditorInput; 67 import org.eclipse.ui.IPersistableElement; 68 import org.eclipse.ui.IStorageEditorInput; 69 import org.eclipse.ui.IWorkbenchPage; 70 import org.eclipse.ui.PartInitException; 71 import org.eclipse.ui.console.ConsolePlugin; 72 import org.eclipse.ui.console.IHyperlink; 73 import org.eclipse.ui.console.IOConsole; 74 import org.eclipse.ui.console.IOConsoleInputStream; 75 import org.eclipse.ui.console.IOConsoleOutputStream; 76 import org.eclipse.ui.console.IPatternMatchListener; 77 import org.eclipse.ui.console.PatternMatchEvent; 78 import org.eclipse.ui.console.TextConsole; 79 import org.eclipse.ui.editors.text.EditorsUI; 80 import org.eclipse.ui.part.FileEditorInput; 81 82 import com.ibm.icu.text.MessageFormat; 83 84 93 public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSetListener, IPropertyChangeListener { 94 private IProcess fProcess = null; 95 96 private List fStreamListeners = new ArrayList (); 97 98 private IConsoleColorProvider fColorProvider; 99 100 private IOConsoleInputStream fInput; 101 102 private FileOutputStream fFileOutputStream; 103 104 private boolean fAllocateConsole = true; 105 106 private boolean fStreamsClosed = false; 107 108 111 public ProcessConsole(IProcess process, IConsoleColorProvider colorProvider) { 112 this(process, colorProvider, null); 113 } 114 115 121 public ProcessConsole(IProcess process, IConsoleColorProvider colorProvider, String encoding) { 122 super("", IDebugUIConstants.ID_PROCESS_CONSOLE_TYPE, null, encoding, true); fProcess = process; 124 125 ILaunchConfiguration configuration = process.getLaunch().getLaunchConfiguration(); 126 String file = null; 127 boolean append = false; 128 if (configuration != null) { 129 try { 130 file = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String ) null); 131 if (file != null) { 132 IStringVariableManager stringVariableManager = VariablesPlugin.getDefault().getStringVariableManager(); 133 file = stringVariableManager.performStringSubstitution(file); 134 append = configuration.getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); 135 } 136 } catch (CoreException e) { 137 } 138 } 139 140 if (file != null) { 141 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 142 IWorkspaceRoot root = workspace.getRoot(); 143 Path path = new Path(file); 144 IFile ifile = root.getFileForLocation(path); 145 String message = null; 146 147 try { 148 String fileLoc = null; 149 if (ifile != null) { 150 if (append && ifile.exists()) { 151 ifile.appendContents(new ByteArrayInputStream (new byte[0]), true, true, new NullProgressMonitor()); 152 } else { 153 if (ifile.exists()) { 154 ifile.delete(true, new NullProgressMonitor()); 155 } 156 ifile.create(new ByteArrayInputStream (new byte[0]), true, new NullProgressMonitor()); 157 } 158 } 159 160 File outputFile = new File (file); 161 fFileOutputStream = new FileOutputStream (outputFile, append); 162 fileLoc = outputFile.getAbsolutePath(); 163 164 message = MessageFormat.format(ConsoleMessages.ProcessConsole_1, new String [] {fileLoc}); 165 addPatternMatchListener(new ConsoleLogFilePatternMatcher(fileLoc)); 166 } catch (FileNotFoundException e) { 167 message = MessageFormat.format(ConsoleMessages.ProcessConsole_2, new String [] {file}); 168 } catch (CoreException e) { 169 DebugUIPlugin.log(e); 170 } 171 if (message != null) { 172 try { 173 IOConsoleOutputStream stream = newOutputStream(); 174 stream.write(message); 175 stream.close(); 176 } catch (IOException e) { 177 DebugUIPlugin.log(e); 178 } 179 } 180 try { 181 fAllocateConsole = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); 182 } catch (CoreException e) { 183 } 184 } 185 186 fColorProvider = colorProvider; 187 fInput = getInputStream(); 188 colorProvider.connect(fProcess, this); 189 190 setName(computeName()); 191 192 Color color = fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_INPUT_STREAM); 193 fInput.setColor(color); 194 195 IConsoleLineTracker[] lineTrackers = DebugUIPlugin.getDefault().getProcessConsoleManager().getLineTrackers(process); 196 if (lineTrackers.length > 0) { 197 addPatternMatchListener(new ConsoleLineNotifier()); 198 } 199 } 200 201 206 protected ImageDescriptor computeImageDescriptor() { 207 ILaunchConfiguration configuration = getProcess().getLaunch().getLaunchConfiguration(); 208 if (configuration != null) { 209 ILaunchConfigurationType type; 210 try { 211 type = configuration.getType(); 212 return DebugPluginImages.getImageDescriptor(type.getIdentifier()); 213 } catch (CoreException e) { 214 DebugUIPlugin.log(e); 215 } 216 } 217 return null; 218 } 219 220 225 protected String computeName() { 226 String label = null; 227 IProcess process = getProcess(); 228 ILaunchConfiguration config = process.getLaunch().getLaunchConfiguration(); 229 230 label = process.getAttribute(IProcess.ATTR_PROCESS_LABEL); 231 if (label == null) { 232 if (config == null) { 233 label = process.getLabel(); 234 } else { 235 if (DebugUITools.isPrivate(config)) { 237 label = process.getLabel(); 238 } else { 239 String type = null; 240 try { 241 type = config.getType().getName(); 242 } catch (CoreException e) { 243 } 244 StringBuffer buffer = new StringBuffer (); 245 buffer.append(config.getName()); 246 if (type != null) { 247 buffer.append(" ["); buffer.append(type); 249 buffer.append("] "); } 251 buffer.append(process.getLabel()); 252 label = buffer.toString(); 253 } 254 } 255 } 256 257 if (process.isTerminated()) { 258 return MessageFormat.format(ConsoleMessages.ProcessConsole_0, new String [] { label }); 259 } 260 return label; 261 } 262 263 266 public void propertyChange(PropertyChangeEvent evt) { 267 String property = evt.getProperty(); 268 IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); 269 if (property.equals(IDebugPreferenceConstants.CONSOLE_WRAP) || property.equals(IDebugPreferenceConstants.CONSOLE_WIDTH)) { 270 boolean fixedWidth = store.getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP); 271 if (fixedWidth) { 272 int width = store.getInt(IDebugPreferenceConstants.CONSOLE_WIDTH); 273 setConsoleWidth(width); 274 } else { 275 setConsoleWidth(-1); 276 } 277 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT) || property.equals(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK) || property.equals(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK)) { 278 boolean limitBufferSize = store.getBoolean(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT); 279 if (limitBufferSize) { 280 int highWater = store.getInt(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK); 281 int lowWater = store.getInt(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK); 282 if (highWater > lowWater) { 283 setWaterMarks(lowWater, highWater); 284 } 285 } else { 286 setWaterMarks(-1, -1); 287 } 288 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH)) { 289 int tabWidth = store.getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH); 290 setTabWidth(tabWidth); 291 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT)) { 292 boolean activateOnOut = store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT); 293 IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); 294 if (stream != null) { 295 stream.setActivateOnWrite(activateOnOut); 296 } 297 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR)) { 298 boolean activateOnErr = store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR); 299 IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_ERROR_STREAM); 300 if (stream != null) { 301 stream.setActivateOnWrite(activateOnErr); 302 } 303 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR)) { 304 IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); 305 if (stream != null) { 306 stream.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM)); 307 } 308 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_SYS_ERR_COLOR)) { 309 IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_ERROR_STREAM); 310 if (stream != null) { 311 stream.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM)); 312 } 313 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_SYS_IN_COLOR)) { 314 if (fInput != null) { 315 fInput.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_INPUT_STREAM)); 316 } 317 } else if (property.equals(IDebugUIConstants.PREF_CONSOLE_FONT)) { 318 setFont(JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT)); 319 } else if (property.equals(IDebugPreferenceConstants.CONSOLE_BAKGROUND_COLOR)) { 320 setBackground(DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.CONSOLE_BAKGROUND_COLOR)); 321 } 322 } 323 324 327 public IOConsoleOutputStream getStream(String streamIdentifier) { 328 for (Iterator i = fStreamListeners.iterator(); i.hasNext();) { 329 StreamListener listener = (StreamListener) i.next(); 330 if (listener.fStreamId.equals(streamIdentifier)) { 331 return listener.fStream; 332 } 333 } 334 return null; 335 } 336 337 340 public IProcess getProcess() { 341 return fProcess; 342 } 343 344 347 protected void dispose() { 348 super.dispose(); 349 fColorProvider.disconnect(); 350 closeStreams(); 351 disposeStreams(); 352 DebugPlugin.getDefault().removeDebugEventListener(this); 353 DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); 354 JFaceResources.getFontRegistry().removeListener(this); 355 } 356 357 360 private synchronized void closeStreams() { 361 if (fStreamsClosed) { 362 return; 363 } 364 for (Iterator i = fStreamListeners.iterator(); i.hasNext();) { 365 StreamListener listener = (StreamListener) i.next(); 366 listener.closeStream(); 367 } 368 if (fFileOutputStream != null) { 369 synchronized (fFileOutputStream) { 370 try { 371 fFileOutputStream.flush(); 372 fFileOutputStream.close(); 373 } catch (IOException e) { 374 } 375 } 376 } 377 try { 378 fInput.close(); 379 } catch (IOException e) { 380 } 381 fStreamsClosed = true; 382 } 383 384 387 private synchronized void disposeStreams() { 388 for (Iterator i = fStreamListeners.iterator(); i.hasNext();) { 389 StreamListener listener = (StreamListener) i.next(); 390 listener.dispose(); 391 } 392 fFileOutputStream = null; 393 fInput = null; 394 } 395 396 399 protected void init() { 400 super.init(); 401 if (fProcess.isTerminated()) { 402 closeStreams(); 403 resetName(); 404 } else { 405 DebugPlugin.getDefault().addDebugEventListener(this); 406 } 407 IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); 408 store.addPropertyChangeListener(this); 409 JFaceResources.getFontRegistry().addListener(this); 410 if (store.getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP)) { 411 setConsoleWidth(store.getInt(IDebugPreferenceConstants.CONSOLE_WIDTH)); 412 } 413 setTabWidth(store.getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH)); 414 415 if (store.getBoolean(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT)) { 416 int highWater = store.getInt(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK); 417 int lowWater = store.getInt(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK); 418 setWaterMarks(lowWater, highWater); 419 } 420 421 DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable () { 422 public void run() { 423 setFont(JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT)); 424 setBackground(DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.CONSOLE_BAKGROUND_COLOR)); 425 } 426 }); 427 } 428 429 434 public void handleDebugEvents(DebugEvent[] events) { 435 for (int i = 0; i < events.length; i++) { 436 DebugEvent event = events[i]; 437 if (event.getSource().equals(getProcess())) { 438 439 if (event.getKind() == DebugEvent.TERMINATE) { 440 closeStreams(); 441 DebugPlugin.getDefault().removeDebugEventListener(this); 442 } 443 444 resetName(); 445 } 446 } 447 } 448 449 452 private void resetName() { 453 final String newName = computeName(); 454 String name = getName(); 455 if (!name.equals(newName)) { 456 Runnable r = new Runnable () { 457 public void run() { 458 setName(newName); 459 warnOfContentChange(); 460 } 461 }; 462 DebugUIPlugin.getStandardDisplay().asyncExec(r); 463 } 464 } 465 466 469 private void warnOfContentChange() { 470 ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(DebugUITools.getConsole(fProcess)); 471 } 472 473 476 public void connect(IStreamsProxy streamsProxy) { 477 IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); 478 IStreamMonitor streamMonitor = streamsProxy.getErrorStreamMonitor(); 479 if (streamMonitor != null) { 480 connect(streamMonitor, IDebugUIConstants.ID_STANDARD_ERROR_STREAM, 481 store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR)); 482 } 483 streamMonitor = streamsProxy.getOutputStreamMonitor(); 484 if (streamMonitor != null) { 485 connect(streamMonitor, IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM, 486 store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT)); 487 } 488 InputReadJob readJob = new InputReadJob(streamsProxy); 489 readJob.setSystem(true); 490 readJob.schedule(); 491 } 492 493 496 public void connect(IStreamMonitor streamMonitor, String streamIdentifier) { 497 connect(streamMonitor, streamIdentifier, false); 498 } 499 500 507 private void connect(IStreamMonitor streamMonitor, String streamIdentifier, boolean activateOnWrite) { 508 IOConsoleOutputStream stream = null; 509 if (fAllocateConsole) { 510 stream = newOutputStream(); 511 Color color = fColorProvider.getColor(streamIdentifier); 512 stream.setColor(color); 513 stream.setActivateOnWrite(activateOnWrite); 514 } 515 synchronized (streamMonitor) { 516 StreamListener listener = new StreamListener(streamIdentifier, streamMonitor, stream); 517 fStreamListeners.add(listener); 518 } 519 } 520 521 524 public void addLink(IConsoleHyperlink link, int offset, int length) { 525 try { 526 addHyperlink(link, offset, length); 527 } catch (BadLocationException e) { 528 DebugUIPlugin.log(e); 529 } 530 } 531 532 535 public void addLink(IHyperlink link, int offset, int length) { 536 try { 537 addHyperlink(link, offset, length); 538 } catch (BadLocationException e) { 539 DebugUIPlugin.log(e); 540 } 541 } 542 543 546 public IRegion getRegion(IConsoleHyperlink link) { 547 return super.getRegion(link); 548 } 549 550 553 private class StreamListener implements IStreamListener { 554 555 private IOConsoleOutputStream fStream; 556 557 private IStreamMonitor fStreamMonitor; 558 559 private String fStreamId; 560 561 private boolean fFlushed = false; 562 563 private boolean fListenerRemoved = false; 564 565 public StreamListener(String streamIdentifier, IStreamMonitor monitor, IOConsoleOutputStream stream) { 566 this.fStreamId = streamIdentifier; 567 this.fStreamMonitor = monitor; 568 this.fStream = stream; 569 fStreamMonitor.addListener(this); 570 streamAppended(null, monitor); 572 } 573 574 580 public void streamAppended(String text, IStreamMonitor monitor) { 581 String encoding = getEncoding(); 582 if (fFlushed) { 583 try { 584 if (fStream != null) { 585 if (encoding == null) 586 fStream.write(text); 587 else 588 fStream.write(text.getBytes(encoding)); 589 } 590 if (fFileOutputStream != null) { 591 synchronized (fFileOutputStream) { 592 if (encoding == null) 593 fFileOutputStream.write(text.getBytes()); 594 else 595 fFileOutputStream.write(text.getBytes(encoding)); 596 } 597 } 598 } catch (IOException e) { 599 DebugUIPlugin.log(e); 600 } 601 } else { 602 String contents = null; 603 synchronized (fStreamMonitor) { 604 fFlushed = true; 605 contents = fStreamMonitor.getContents(); 606 if (fStreamMonitor instanceof IFlushableStreamMonitor) { 607 IFlushableStreamMonitor m = (IFlushableStreamMonitor) fStreamMonitor; 608 m.flushContents(); 609 m.setBuffered(false); 610 } 611 } 612 try { 613 if (contents != null && contents.length() > 0) { 614 if (fStream != null) { 615 fStream.write(contents); 616 } 617 if (fFileOutputStream != null) { 618 synchronized (fFileOutputStream) { 619 fFileOutputStream.write(contents.getBytes()); 620 } 621 } 622 } 623 } catch (IOException e) { 624 DebugUIPlugin.log(e); 625 } 626 } 627 } 628 629 public IStreamMonitor getStreamMonitor() { 630 return fStreamMonitor; 631 } 632 633 public void closeStream() { 634 if (fStreamMonitor == null) { 635 return; 636 } 637 synchronized (fStreamMonitor) { 638 fStreamMonitor.removeListener(this); 639 if (!fFlushed) { 640 String contents = fStreamMonitor.getContents(); 641 streamAppended(contents, fStreamMonitor); 642 } 643 fListenerRemoved = true; 644 try { 645 if (fStream != null) { 646 fStream.close(); 647 } 648 } catch (IOException e) { 649 } 650 } 651 } 652 653 public void dispose() { 654 if (!fListenerRemoved) { 655 closeStream(); 656 } 657 fStream = null; 658 fStreamMonitor = null; 659 fStreamId = null; 660 } 661 } 662 663 private class InputReadJob extends Job { 664 665 private IStreamsProxy streamsProxy; 666 667 InputReadJob(IStreamsProxy streamsProxy) { 668 super("Process Console Input Job"); this.streamsProxy = streamsProxy; 670 } 671 672 677 protected IStatus run(IProgressMonitor monitor) { 678 try { 679 byte[] b = new byte[1024]; 680 int read = 0; 681 while (fInput != null && read >= 0) { 682 read = fInput.read(b); 683 if (read > 0) { 684 String s = new String (b, 0, read); 685 streamsProxy.write(s); 686 } 687 } 688 } catch (IOException e) { 689 DebugUIPlugin.log(e); 690 } 691 return Status.OK_STATUS; 692 } 693 } 694 695 700 public ImageDescriptor getImageDescriptor() { 701 if (super.getImageDescriptor() == null) { 702 setImageDescriptor(computeImageDescriptor()); 703 } 704 return super.getImageDescriptor(); 705 } 706 707 private class ConsoleLogFilePatternMatcher implements IPatternMatchListener { 708 String fFilePath; 709 710 public ConsoleLogFilePatternMatcher(String filePath) { 711 fFilePath = escape(filePath); 712 } 713 714 private String escape(String path) { 715 StringBuffer buffer = new StringBuffer (path); 716 int index = buffer.indexOf("\\"); while (index >= 0) { 718 buffer.insert(index, '\\'); 719 index = buffer.indexOf("\\", index+2); } 721 return buffer.toString(); 722 } 723 724 public String getPattern() { 725 return fFilePath; 726 } 727 728 public void matchFound(PatternMatchEvent event) { 729 try { 730 addHyperlink(new ConsoleLogFileHyperlink(fFilePath), event.getOffset(), event.getLength()); 731 removePatternMatchListener(this); 732 } catch (BadLocationException e) { 733 } 734 } 735 736 public int getCompilerFlags() { 737 return 0; 738 } 739 740 public String getLineQualifier() { 741 return null; 742 } 743 744 public void connect(TextConsole console) { 745 } 746 747 public void disconnect() { 748 } 749 } 750 751 private class ConsoleLogFileHyperlink implements IHyperlink { 752 String fFilePath; 753 ConsoleLogFileHyperlink(String filePath) { 754 fFilePath = filePath; 755 } 756 757 public void linkActivated() { 758 IEditorInput input; 759 Path path = new Path(fFilePath); 760 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 761 IFile ifile = root.getFileForLocation(path); 762 if (ifile == null) { File file = new File (fFilePath); 764 LocalFileStorage lfs = new LocalFileStorage(file); 765 input = new StorageEditorInput(lfs, file); 766 767 } else { 768 input = new FileEditorInput(ifile); 769 } 770 771 IWorkbenchPage activePage = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage(); 772 try { 773 activePage.openEditor(input, EditorsUI.DEFAULT_TEXT_EDITOR_ID, true); 774 } catch (PartInitException e) { 775 } 776 } 777 public void linkEntered() { 778 } 779 public void linkExited() { 780 } 781 } 782 783 class StorageEditorInput extends PlatformObject implements IStorageEditorInput { 784 private File fFile; 785 private IStorage fStorage; 786 787 public StorageEditorInput(IStorage storage, File file) { 788 fStorage = storage; 789 fFile = file; 790 } 791 792 public IStorage getStorage() { 793 return fStorage; 794 } 795 796 public ImageDescriptor getImageDescriptor() { 797 return null; 798 } 799 800 public String getName() { 801 return getStorage().getName(); 802 } 803 804 public IPersistableElement getPersistable() { 805 return null; 806 } 807 808 public String getToolTipText() { 809 return getStorage().getFullPath().toOSString(); 810 } 811 812 public boolean equals(Object object) { 813 return object instanceof StorageEditorInput && 814 getStorage().equals(((StorageEditorInput)object).getStorage()); 815 } 816 817 public int hashCode() { 818 return getStorage().hashCode(); 819 } 820 821 public boolean exists() { 822 return fFile.exists(); 823 } 824 } 825 826 829 public String getHelpContextId() { 830 return IDebugHelpContextIds.PROCESS_CONSOLE; 831 } 832 } 833 | Popular Tags |