diff options
11 files changed, 287 insertions, 86 deletions
diff --git a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html index 973da66c7..06a8b299e 100644 --- a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html +++ b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui.html @@ -23,7 +23,8 @@ stepping, terminating, etc. <br> <p>The following extension points are used to support and extend the debug UI.: <ul> - <li><a href="org_eclipse_debug_ui_consoleContentProviders.html">org.eclipse.debug.ui.consoleContentProviders</a></li> + <li><a href="org_eclipse_debug_ui_consoleColorProviders.html">org.eclipse.debug.ui.consoleColorProviders</a></li> + <li><a href="org_eclipse_debug_ui_consoleLineTrackers.html">org.eclipse.debug.ui.consoleLineTrackers</a></li> <li><a href="org_eclipse_debug_ui_debugActionGroups.html">org.eclipse.debug.ui.debugActionGroups</a></li> <li><a href="org_eclipse_debug_ui_debugModelPresentations.html">org.eclipse.debug.ui.debugModelPresentations</a></li> <li><a href="org_eclipse_debug_ui_launchConfigurationTabGroups.html">org.eclipse.debug.ui.launchConfigurationTabGroups</a></li> diff --git a/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_consoleLineTrackers.html b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_consoleLineTrackers.html new file mode 100644 index 000000000..b115c2eac --- /dev/null +++ b/org.eclipse.debug.ui/doc/org_eclipse_debug_ui_consoleLineTrackers.html @@ -0,0 +1,60 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> + +<head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<title>README Console Content Providers Extension Point</title> +</head> + +<body link="#0000FF" vlink="#800080"> + +<h1 align="center">Console Line Trackers</h1> + +<p><b><i>Identifier: </i></b>org.eclipse.debug.ui.consoleLineTrackers</p> + +<p><b><i>Description: </i></b>This extension point provides a mechanism to listen + to console output for a type of process.</p> + +<p><b><i>Configuration Markup:</i></b> </p> + +<pre> +<tt> <!ELEMENT consoleColorProvider</tt>> +<tt> <!ATTLIST consoleLineTracker</tt> <br><tt> id CDATA #REQUIRED</tt><br><tt> class CDATA #REQUIRED + processType CDATA #REQUIRED</tt>> +</pre> + +<ul> + <li><code>id</code> specifies a unique identifier for this console line tracker.</li> + <li><code>class</code> specifies a fully qualified name of a Java class that + implements <code>IConsoleLineTracker</code>.</li> + <li><font face="Courier New, Courier, mono">processType</font> specifies the + type of process this line tacker is for. This attribute corresponds to the + process attribute <font face="Courier New, Courier, mono">IProcess.ATTR_PROCESS_TYPE</font>.</li> +</ul> + +<p><b><i>Examples:</i></b> </p> + +<p>The following is an example of a console line tacker extension point: </p> + +<pre> +<extension point="org.eclipse.debug.ui.consoleColorProviders"> + <consoleLineTracker + id="com.example.ExampleConsoleLineTracker" + class="com.example.ExampleConsoleLineTracker" + processType="ExampleProcessType"> + </consoleLineTracker> +</extension> +</pre> +<p>In the above example, the contributed line tracker will be notified as lines + are appended to the console fo processes of type "ExampleProcessType", + which corresponds to the process attribute <font face="Courier New, Courier, mono">IProcess.ATTR_PROCESS_TYPE</font>. + Process types are client defined, and are set by clients that create processes.</p> + +<p><b><i>API Information: </i></b>Value of the attribute <b>class</b> must be + a fully qualified name of a Java class that implements the interface <b> org.eclipse.debug.ui.console.IConsoleLineTracker</b>. +</p> + +<p><a href="hglegal.htm"><img src="ngibmcpy.gif" alt="Copyright IBM Corp. 2000, 2001. All Rights Reserved." +border="0" width="195" height="12"></a></p> +</body> +</html> diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index b91a25bc6..ad649c7ce 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties @@ -14,6 +14,7 @@ pluginName=Debug UI BreakpointsView.name=Breakpoints commonTabName=&Common ConsoleColorProvidersExtensionName= Console Color Providers +ConsoleLineTrackersExtensionName= Console Line Trackers ConsolePreferencePage.name=Console ConsoleView.name=Console CopyToClipboardAction.label=&Copy Stack diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 866171e12..3554731c6 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -28,6 +28,7 @@ <extension-point id="launchConfigurationTypeImages" name="%LaunchConfigurationTypeImageExtensionName"/> <extension-point id="debugActionGroups" name="%DebugActionGroupsExtensionName"/> <extension-point id="consoleColorProviders" name="%ConsoleColorProvidersExtensionName"/> +<extension-point id="consoleLineTrackers" name="%ConsoleLineTrackersExtensionName"/> <extension-point id="launchGroups" name="%LaunchGroupsExtensionName"/> <!-- Extensions --> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java index ba9529e01..c9191ae78 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java @@ -8,7 +8,10 @@ http://www.eclipse.org/legal/cpl-v10.html **********************************************************************/ import java.text.MessageFormat; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; import org.eclipse.core.runtime.CoreException; @@ -56,7 +59,12 @@ public class ConsoleDocumentManager implements ILaunchListener { /** * Console document content provider extensions, keyed by extension id
*/ - private Map fContentProviders; + private Map fColorProviders; + + /** + * Console line trackers; keyed by process type to list of trackers (1:N) + */ + private Map fLineTrackers; /** * Default document provider.
*/ @@ -307,21 +315,21 @@ public class ConsoleDocumentManager implements ILaunchListener { } /** - * Returns a new console document content provider extension for the given + * Returns a new console document color provider extension for the given * process type, or <code>null</code> if none. *
* @param type corresponds to <code>IProcess.ATTR_PROCESS_TYPE</code>
* @return IConsoleColorProvider
*/ - public IConsoleColorProvider getContentProvider(String type) { - if (fContentProviders == null) { - fContentProviders = new HashMap(); + public IConsoleColorProvider getColorProvider(String type) { + if (fColorProviders == null) { + fColorProviders = new HashMap(); IPluginDescriptor descriptor = DebugUIPlugin.getDefault().getDescriptor(); IExtensionPoint extensionPoint = descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_CONSOLE_COLOR_PROVIDERS); IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement extension = elements[i]; - fContentProviders.put(extension.getAttributeAsIs("processType"), extension); + fColorProviders.put(extension.getAttributeAsIs("processType"), extension); } } - IConfigurationElement extension = (IConfigurationElement)fContentProviders.get(type); + IConfigurationElement extension = (IConfigurationElement)fColorProviders.get(type); if (extension != null) { try { Object contentProvider = extension.createExecutableExtension("class"); //$NON-NLS-1$ @@ -336,4 +344,51 @@ public class ConsoleDocumentManager implements ILaunchListener { } return null; } + + /** + * Creates and retuns a new line notifier for the given type of process, or + * <code>null</code> if none. The notifier will be seeded with new console + * line listeners registered for the given process type. + * + * @param type process type + * @return line notifier or <code>null</code> + */ + public ConsoleLineNotifier newLineNotifier(String type) { + if (fLineTrackers == null) { + fLineTrackers = new HashMap(); + IPluginDescriptor descriptor = DebugUIPlugin.getDefault().getDescriptor(); + IExtensionPoint extensionPoint = descriptor.getExtensionPoint(IDebugUIConstants.EXTENSION_POINT_CONSOLE_LINE_TRACKERS); + IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); + for (int i = 0; i < elements.length; i++) { + IConfigurationElement extension = elements[i]; + String processType = extension.getAttributeAsIs("processType"); + List list = (List)fLineTrackers.get(processType); + if (list == null) { + list = new ArrayList(); + fLineTrackers.put(processType, list); + } + list.add(extension); + } + } + List extensions = (List)fLineTrackers.get(type); + ConsoleLineNotifier lineNotifier = null; + if (extensions != null) { + lineNotifier = new ConsoleLineNotifier(); + Iterator iter = extensions.iterator(); + while (iter.hasNext()) { + IConfigurationElement extension = (IConfigurationElement)iter.next(); + try { + Object tracker = extension.createExecutableExtension("class"); //$NON-NLS-1$ + if (tracker instanceof IConsoleLineTracker) { + lineNotifier.addConsoleListener((IConsoleLineTracker)tracker); + } else { + DebugUIPlugin.logErrorMessage(MessageFormat.format("Invalid extension {0} - class must be an instance of IConsoleLineTracker",new String[]{extension.getDeclaringExtension().getUniqueIdentifier()})); + } + } catch (CoreException e) { + DebugUIPlugin.log(e); + } + } + } + return lineNotifier; + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java index 5a646c3c4..c3879428c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java @@ -185,6 +185,11 @@ public class ConsoleDocumentPartitioner implements IDocumentPartitioner, IDocume * Queue of hyperlinks to be added to the console */ private Vector fPendingLinks = new Vector(); + + /** + * The line notifier associated with this partitioner or <code>null</code> if none + */ + private ConsoleLineNotifier fLineNotifier = null; /** * @see org.eclipse.jface.text.IDocumentPartitioner#connect(org.eclipse.jface.text.IDocument) @@ -205,6 +210,9 @@ public class ConsoleDocumentPartitioner implements IDocumentPartitioner, IDocume */ public void disconnect() { kill(); + if (fLineNotifier != null) { + fLineNotifier.disconnect(); + } fContentProvider.disconnect(); fDocument.setDocumentPartitioner(null); } @@ -286,6 +294,9 @@ public class ConsoleDocumentPartitioner implements IDocumentPartitioner, IDocume if (isAppendInProgress()) { // stream input addPartition(new OutputPartition(fLastStreamIdentifier, event.getOffset(), text.length())); + if (fLineNotifier != null) { + fLineNotifier.consoleChanged(event); + } } else { // console keyboard input int amountDeleted = event.getLength() - text.length(); @@ -714,5 +725,15 @@ public class ConsoleDocumentPartitioner implements IDocumentPartitioner, IDocume public IProcess getProcess() { return fProcess; } + + /** + * Connects the given line notifier to this console document partitioner + * + * @param lineNotifier + */ + public void connectLineNotifier(ConsoleLineNotifier lineNotifier) { + fLineNotifier = lineNotifier; + lineNotifier.connect(this); + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java index ac69ba1ca..35d6a54fd 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java @@ -10,9 +10,9 @@ http://www.eclipse.org/legal/cpl-v10.html import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.model.IProcess; -import org.eclipse.debug.ui.console.*; +import org.eclipse.debug.ui.console.ConsoleColorProvider; +import org.eclipse.debug.ui.console.IConsoleColorProvider; import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.ui.texteditor.AbstractDocumentProvider; @@ -30,8 +30,12 @@ public class ConsoleDocumentProvider extends AbstractDocumentProvider { IProcess process = (IProcess)element; IConsoleColorProvider contentProvider = getContentProvider(process); ConsoleDocument doc= new ConsoleDocument(contentProvider); - IDocumentPartitioner partitioner = new ConsoleDocumentPartitioner(process, contentProvider); + ConsoleDocumentPartitioner partitioner = new ConsoleDocumentPartitioner(process, contentProvider); + ConsoleLineNotifier lineNotifier = getLineNotifier(process); partitioner.connect(doc); + if (lineNotifier != null) { + partitioner.connectLineNotifier(lineNotifier); + } return doc; } return null; @@ -72,7 +76,7 @@ public class ConsoleDocumentProvider extends AbstractDocumentProvider { String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE); IConsoleColorProvider contentProvider = null; if (type != null) { - contentProvider = ConsoleDocumentManager.getDefault().getContentProvider(type); + contentProvider = ConsoleDocumentManager.getDefault().getColorProvider(type); } if (contentProvider == null) { contentProvider = new ConsoleColorProvider(); @@ -81,15 +85,15 @@ public class ConsoleDocumentProvider extends AbstractDocumentProvider { } /** - * Returns the line tracker for this console, or <code>null</code> if none. + * Returns the line notifier for this console, or <code>null</code> if none. * * @param process - * @return line tracker, or <code>null</code> + * @return line notifier, or <code>null</code> */ - protected ConsoleDocumentLineTracker getLineTracker(IProcess process) { + protected ConsoleLineNotifier getLineNotifier(IProcess process) { String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE); if (type != null) { - // TODO: + return ConsoleDocumentManager.getDefault().newLineNotifier(type); } return null; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentLineTracker.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java index 30c020fe9..99a547c9d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentLineTracker.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java @@ -9,7 +9,7 @@ http://www.eclipse.org/legal/cpl-v10.html import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.ui.console.IConsole; -import org.eclipse.debug.ui.console.IConsoleListener; +import org.eclipse.debug.ui.console.IConsoleLineTracker; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; @@ -20,7 +20,7 @@ import org.eclipse.jface.util.ListenerList; * Tracks text appended to the console and notifies listeners in terms of whole * lines. */ -public class ConsoleDocumentLineTracker { +public class ConsoleLineNotifier { /** * Number of lines processed in the console @@ -33,40 +33,67 @@ public class ConsoleDocumentLineTracker { private ListenerList fListeners = new ListenerList(2); /** - * Constructor for ConsoleDocumentLineTracker. + * The console this notifier is tracking */ - public ConsoleDocumentLineTracker() { - super(); + private IConsole fConsole = null; + + /** + * Connects this notifier to the given console. + * + * @param console + */ + public void connect(IConsole console) { + fConsole = console; + Object[] listeners = fListeners.getListeners(); + for (int i = 0; i < listeners.length; i++) { + IConsoleLineTracker listener = (IConsoleLineTracker)listeners[i]; + listener.init(console); + } } - + + /** + * Disposes this notifier + */ + public void disconnect() { + Object[] listeners = fListeners.getListeners(); + for (int i = 0; i < listeners.length; i++) { + IConsoleLineTracker listener = (IConsoleLineTracker)listeners[i]; + listener.dispose(); + } + fListeners = null; + fConsole = null; + } + /** * Notification the console has changed based on the given event */ - public void consoleChanged(IConsole console, DocumentEvent event) { + public void consoleChanged(DocumentEvent event) { IDocument document = event.getDocument(); int lines = document.getNumberOfLines(); - for (int line = fLinesProcessed; line <= lines; line++) { - String delimiter; + Object[] listeners = fListeners.getListeners(); + for (int line = fLinesProcessed; line < lines; line++) { + String delimiter = null; try { delimiter = document.getLineDelimiter(line); } catch (BadLocationException e) { DebugUIPlugin.log(e); return; } - if (delimiter != null) { - fLinesProcessed++; - IRegion lineRegion = null; - try { - lineRegion = document.getLineInformation(line); - } catch (BadLocationException e) { - DebugUIPlugin.log(e); - return; - } - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - IConsoleListener listener = (IConsoleListener)listeners[i]; - listener.lineAppended(console, lineRegion); - } + if (delimiter == null) { + // line not complete yet + return; + } + fLinesProcessed++; + IRegion lineRegion = null; + try { + lineRegion = document.getLineInformation(line); + } catch (BadLocationException e) { + DebugUIPlugin.log(e); + return; + } + for (int i = 0; i < listeners.length; i++) { + IConsoleLineTracker listener = (IConsoleLineTracker)listeners[i]; + listener.lineAppended(lineRegion); } } // TODO: what about the last line? @@ -78,17 +105,8 @@ public class ConsoleDocumentLineTracker { * * @param listener */ - public void addConsoleListener(IConsoleListener listener) { + public void addConsoleListener(IConsoleLineTracker listener) { fListeners.add(listener); } - /** - * Removes the given listener from the list of listeners notified when a - * line of text is appended to the console. - * - * @param listener - */ - public void removeConsoleListener(IConsoleListener listener) { - fListeners.remove(listener); - } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index dd8e407bf..babcb8d84 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -704,6 +704,14 @@ public interface IDebugUIConstants { * * @since 2.1 */ - public static final String EXTENSION_POINT_LAUNCH_GROUPS = "launchGroups"; //$NON-NLS-1$ + public static final String EXTENSION_POINT_LAUNCH_GROUPS = "launchGroups"; //$NON-NLS-1$ + + /** + * Console line trackers extension point identifier (value + * <code>"consoleLineTrackers"</code>). + * + * @since 2.1 + */ + public static final String EXTENSION_POINT_CONSOLE_LINE_TRACKERS = "consoleLineTrackers"; //$NON-NLS-1$ }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleLineTracker.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleLineTracker.java new file mode 100644 index 000000000..ddbc4ac78 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleLineTracker.java @@ -0,0 +1,68 @@ +package org.eclipse.debug.ui.console; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +import org.eclipse.jface.text.IRegion; + +/** + * Notified of lines appended to the console. A line tracker registers itself + * as an extension via plug-in XML, via the extension point + * <code>org.eclipse.debug.ui.consoleLineTrackers</code>. A line tracker is + * associated with a type of process. Following is an example definition of + * a console line tracker extension. + * <pre> + * <extension point="org.eclipse.debug.ui.consoleLineTrackers"> + * <consoleLineTracker + * id="com.example.ExampleConsoleLineTracker" + * class="com.example.ExampleConsoleLineTrackerClass" + * processType="ExampleProcessType"> + * </consoleLineTracker> + * </extension> + * </pre> + * The attributes are specified as follows: + * <ul> + * <li><code>id</code> specifies a unique identifier for this line tracker.</li> + * <li><code>class</code> specifies a fully qualified name of a Java class + * that implements <code>IConsoleLineTracker</code>.</li> + * <li><code>processType</code> specifies the identifier of the process type + * this line tracker is associated with (which corresponds to the + * <code>ATTR_PROCESS_TYPE</code> attribute on a process).</li> + * </ul> + * <p> + * Clients may implement this interface. + * </p> + * <p> + * <b>This interface is still evolving</b> + * </p> + * @since 2.1 + */ +public interface IConsoleLineTracker { + + /** + * Notification that a console document has been created for which this + * listener is registered. + * + * @param console console that has been created + */ + public void init(IConsole console); + + /** + * Notification that a line of text has been appended to the console. The + * given region describes the offset and length of the line appended to the + * console, excluding the line delimiter. + * + * @param line region describing the offset and length of line appended to + * the console, excluding the line delimiter + */ + public void lineAppended(IRegion line); + + /** + * Disposes this console line tracker. + */ + public void dispose(); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleListener.java deleted file mode 100644 index 303ce8484..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/IConsoleListener.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.eclipse.debug.ui.console; - -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. All rights reserved. -This file is made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html -**********************************************************************/ - -import org.eclipse.jface.text.IRegion; - -/** - * Notified of lines appended to the console. - * <p> - * Clients may implement this interface. - * </p> - * <p> - * <b>This interface is still evolving</b> - * </p> - * @since 2.1 - */ -public interface IConsoleListener { - - /** - * Notification that a line of text has been appended to the console. The - * given region describes the offset and length of the line appended to the - * console, excluding the line delimiter. - * - * @param console console to which a line has been appeneded - * @param line region describing the offset and length of line appended to - * the console, excluding the line delimiter - */ - public void lineAppended(IConsole console, IRegion line); - - // TODO: do we need connect/disconnect? -} |