KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > console > JavaConsoleTracker


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.console;
12
13
14 import org.eclipse.jface.text.BadLocationException;
15 import org.eclipse.ui.console.IHyperlink;
16 import org.eclipse.ui.console.IPatternMatchListenerDelegate;
17 import org.eclipse.ui.console.PatternMatchEvent;
18 import org.eclipse.ui.console.TextConsole;
19
20 /**
21  * Provides links for stack traces
22  */

23 public class JavaConsoleTracker implements IPatternMatchListenerDelegate {
24     
25     /**
26      * The console associated with this line tracker
27      */

28     private TextConsole fConsole;
29
30     /* (non-Javadoc)
31      * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.IConsole)
32      */

33     public void connect(TextConsole console) {
34         fConsole = console;
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#disconnect()
39      */

40     public void disconnect() {
41         fConsole = null;
42     }
43     
44     protected TextConsole getConsole() {
45         return fConsole;
46     }
47
48     /* (non-Javadoc)
49      * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#matchFound(org.eclipse.ui.console.PatternMatchEvent)
50      */

51     public void matchFound(PatternMatchEvent event) {
52         try {
53             int offset = event.getOffset();
54             int length = event.getLength();
55             IHyperlink link = new JavaStackTraceHyperlink(fConsole);
56             fConsole.addHyperlink(link, offset+1, length-2);
57         } catch (BadLocationException e) {
58         }
59     }
60
61 }
62
Popular Tags