Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/BreakPartition.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java370
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java1003
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleOutputTextStore.java68
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java489
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/HyperlinkPosition.java52
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/InputPartition.java72
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/OutputPartition.java37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java63
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java68
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java67
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/StreamPartition.java101
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/WorkspaceOperationRunner.java75
17 files changed, 69 insertions, 2667 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/BreakPartition.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/BreakPartition.java
deleted file mode 100644
index 30a078cc6..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/BreakPartition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-
-/**
- * A partition in a console document that represents a break after an input
- * partition. This represents a hard break that the user cannot backspace/delete.
- */
-public class BreakPartition extends StreamPartition {
-
- /**
- * Partition type
- */
- public static final String BREAK_PARTITION_TYPE = DebugUIPlugin.getUniqueIdentifier() + ".BREAK_PARTITION_TYPE"; //$NON-NLS-1$
-
-
- public BreakPartition(String streamIdentifier, int offset, int length) {
- super(streamIdentifier, offset, length, BREAK_PARTITION_TYPE);
- }
-
- /**
- * @see org.eclipse.debug.internal.ui.views.console.StreamPartition#createNewPartition(String, int, int)
- */
- public StreamPartition createNewPartition(String streamIdentifier, int offset, int length) {
- return new BreakPartition(streamIdentifier, offset, length);
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java
deleted file mode 100644
index 6b37c3ff0..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.ui.console.IConsoleColorProvider;
-import org.eclipse.jface.text.AbstractDocument;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.ITextStore;
-
-public class ConsoleDocument extends AbstractDocument {
-
- private IConsoleColorProvider fColorProvider;
-
- public ConsoleDocument(IConsoleColorProvider colorProvider) {
- fColorProvider = colorProvider;
- setTextStore(newTextStore());
- setLineTracker(new DefaultLineTracker());
- completeInitialization();
- }
-
- /**
- * Returns whether this document is read-only.
- */
- public boolean isReadOnly() {
- return fColorProvider.isReadOnly();
- }
-
- /**
- * Creates a new text store for this document.
- */
- protected ITextStore newTextStore() {
- return new ConsoleOutputTextStore(2500);
- }
-}
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
deleted file mode 100644
index 2fa82933c..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentManager.java
+++ /dev/null
@@ -1,370 +0,0 @@
-///*******************************************************************************
-// * Copyright (c) 2000, 2004 IBM Corporation and others.
-// * All rights reserved. This program and the accompanying materials
-// * are 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
-// *
-// * Contributors:
-// * IBM Corporation - initial API and implementation
-// *******************************************************************************/
-//package org.eclipse.debug.internal.ui.views.console;
-//
-//
-//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;
-//import org.eclipse.core.runtime.IConfigurationElement;
-//import org.eclipse.core.runtime.IExtensionPoint;
-//import org.eclipse.core.runtime.Platform;
-//import org.eclipse.debug.core.DebugPlugin;
-//import org.eclipse.debug.core.ILaunch;
-//import org.eclipse.debug.core.ILaunchListener;
-//import org.eclipse.debug.core.ILaunchManager;
-//import org.eclipse.debug.core.model.IProcess;
-//import org.eclipse.debug.internal.ui.DebugUIPlugin;
-//import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-//import org.eclipse.debug.ui.IDebugUIConstants;
-//import org.eclipse.debug.ui.console.IConsoleColorProvider;
-//import org.eclipse.debug.ui.console.IConsoleLineTracker;
-//import org.eclipse.jface.text.IDocument;
-//import org.eclipse.ui.console.ConsolePlugin;
-//import org.eclipse.ui.console.IConsole;
-//import org.eclipse.ui.console.IConsoleManager;
-//import org.eclipse.ui.texteditor.IDocumentProvider;
-//
-///**
-// * Creates documents for processes as they are registered with a launch.
-// * The singleton manager is accessible from the debug UI plugin.
-// */
-//public class ConsoleDocumentManager implements ILaunchListener {
-//
-// /**
-// * Console document content provider extensions, keyed by extension id
-// */
-// private Map fColorProviders;
-//
-// /**
-// * Console line trackers; keyed by process type to list of trackers (1:N)
-// */
-// private Map fLineTrackers;
-//
-// /**
-// * Default document provider.
-// */
-// protected IDocumentProvider fDefaultDocumentProvider = null;
-//
-// /**
-// * Map of processes for a launch to compute removed processes
-// */
-// private Map fProcesses;
-//
-// /**
-// * @see ILaunchListener#launchRemoved(ILaunch)
-// */
-// public void launchRemoved(ILaunch launch) {
-// removeLaunch(launch);
-// }
-//
-// protected void removeLaunch(ILaunch launch) {
-// IProcess[] processes= launch.getProcesses();
-// for (int i= 0; i < processes.length; i++) {
-// IProcess iProcess = processes[i];
-// removeProcess(iProcess);
-// }
-// if (fProcesses != null) {
-// fProcesses.remove(launch);
-// }
-// }
-//
-// /**
-// * Removes the console and document associated with the given process.
-// *
-// * @param iProcess process to clean up
-// */
-// private void removeProcess(IProcess iProcess) {
-// IConsole console = getConsole(iProcess);
-// if (console != null) {
-// IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
-// manager.removeConsoles(new IConsole[]{console});
-// }
-// IDocumentProvider provider = getDocumentProvider();
-// provider.disconnect(iProcess);
-// }
-//
-// /**
-// * Returns the console for the given process, or <code>null</code> if none.
-// *
-// * @param process
-// * @return the console for the given process, or <code>null</code> if none
-// */
-// public IConsole getConsole(IProcess process) {
-// IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
-// IConsole[] consoles = manager.getConsoles();
-// for (int i = 0; i < consoles.length; i++) {
-// IConsole console = consoles[i];
-// if (console instanceof ProcessConsole) {
-// ProcessConsole pc = (ProcessConsole)console;
-// if (pc.getProcess().equals(process)) {
-// return pc;
-// }
-// }
-// }
-// return null;
-// }
-//
-// /**
-// * @see ILaunchListener#launchAdded(ILaunch)
-// */
-// public void launchAdded(ILaunch launch) {
-// launchChanged(launch);
-// }
-//
-// /**
-// * @see ILaunchListener#launchChanged(ILaunch)
-// */
-// public void launchChanged(final ILaunch launch) {
-// DebugUIPlugin.getStandardDisplay().syncExec(new Runnable () {
-// public void run() {
-// IProcess[] processes= launch.getProcesses();
-// for (int i= 0; i < processes.length; i++) {
-// if (getConsoleDocument(processes[i]) == null) {
-// // create new document
-// IProcess process = processes[i];
-// IDocumentProvider provider = getDocumentProvider();
-// try {
-// provider.connect(process);
-// } catch (CoreException e) {
-// }
-// ProcessConsole pc = new ProcessConsole(process);
-// ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{pc});
-// }
-// }
-// List removed = getRemovedProcesses(launch);
-// if (removed != null) {
-// Iterator iterator = removed.iterator();
-// while (iterator.hasNext()) {
-// IProcess p = (IProcess) iterator.next();
-// removeProcess(p);
-// }
-// }
-// }
-// });
-// }
-//
-// /**
-// * Returns the document for the process, or <code>null</code>
-// * if none.
-// */
-// public IDocument getConsoleDocument(IProcess process) {
-// IDocumentProvider provider = getDocumentProvider();
-// return provider.getDocument(process);
-// }
-//
-// /**
-// * Returns the document provider.
-// *
-// * @return document provider
-// */
-// private IDocumentProvider getDocumentProvider() {
-// if (fDefaultDocumentProvider == null) {
-// fDefaultDocumentProvider = new ConsoleDocumentProvider();
-// }
-// return fDefaultDocumentProvider;
-// }
-//
-// /**
-// * Called by the debug ui plug-in on startup.
-// * The console document manager starts listening for
-// * launches to be registered and initializes if any launches
-// * already exist.
-// */
-// public void startup() {
-// ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
-// launchManager.addLaunchListener(this);
-//
-// //set up the docs for launches already registered
-// ILaunch[] launches= launchManager.getLaunches();
-// for (int i = 0; i < launches.length; i++) {
-// launchAdded(launches[i]);
-// }
-// }
-//
-// /**
-// * Called by the debug ui plug-in on shutdown.
-// * The console document manager de-registers as a
-// * launch listener and kills all existing console documents.
-// */
-// public void shutdown() {
-// ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
-// ILaunch[] launches = launchManager.getLaunches();
-// for (int i = 0; i < launches.length; i++) {
-// ILaunch launch = launches[i];
-// removeLaunch(launch);
-// }
-// launchManager.removeLaunchListener(this);
-// if (fProcesses != null) {
-// fProcesses.clear();
-// }
-// }
-//
-// /**
-// * Notifies the console document manager that system err is about to be written
-// * to the console. The manager will open the console if the preference is
-// * set to show the console on system err.
-// */
-// protected void aboutToWriteSystemErr(IProcess process) {
-// if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR)) {
-// showConsole(process);
-// }
-// }
-//
-// /**
-// * Notifies the console document manager that system out is about to be written
-// * to the console. The manager will open the console if the preference is
-// * set to show the console on system out and the console document being written
-// * is associated with the current process.
-// */
-// protected void aboutToWriteSystemOut(IProcess process) {
-// if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT)) {
-// showConsole(process);
-// }
-// }
-//
-// /**
-// * Opens the console view. If the view is already open, it is brought to the front.
-// */
-// protected void showConsole(final IProcess process) {
-// ConsolePlugin.getDefault().getConsoleManager().showConsoleView(getConsole(process));
-// }
-//
-// /**
-// * 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 getColorProvider(String type) {
-// if (fColorProviders == null) {
-// fColorProviders = new HashMap();
-// IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_CONSOLE_COLOR_PROVIDERS);
-// IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
-// for (int i = 0; i < elements.length; i++) {
-// IConfigurationElement extension = elements[i];
-// fColorProviders.put(extension.getAttributeAsIs("processType"), extension); //$NON-NLS-1$
-// }
-// }
-// IConfigurationElement extension = (IConfigurationElement)fColorProviders.get(type);
-// if (extension != null) {
-// try {
-// Object colorProvider = extension.createExecutableExtension("class"); //$NON-NLS-1$
-// if (colorProvider instanceof IConsoleColorProvider) {
-// return (IConsoleColorProvider)colorProvider;
-// }
-// DebugUIPlugin.logErrorMessage(MessageFormat.format(ConsoleMessages.getString("ConsoleDocumentManager.1"),new String[]{extension.getDeclaringExtension().getUniqueIdentifier()} )); //$NON-NLS-1$
-// } catch (CoreException e) {
-// DebugUIPlugin.log(e);
-// }
-// }
-// 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();
-// IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), 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"); //$NON-NLS-1$
-// 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(ConsoleMessages.getString("ConsoleDocumentManager.2"),new String[]{extension.getDeclaringExtension().getUniqueIdentifier()})); //$NON-NLS-1$
-// }
-// } catch (CoreException e) {
-// DebugUIPlugin.log(e);
-// }
-// }
-// }
-// return lineNotifier;
-// }
-//
-// /**
-// * Returns the processes that have been removed from the given
-// * launch, or <code>null</code> if none.
-// *
-// * @param launch launch that has changed
-// * @return removed processes or <code>null</code>
-// */
-// private List getRemovedProcesses(ILaunch launch) {
-// List removed = null;
-// if (fProcesses == null) {
-// fProcesses = new HashMap();
-// }
-// IProcess[] old = (IProcess[]) fProcesses.get(launch);
-// IProcess[] curr = launch.getProcesses();
-// if (old != null) {
-// for (int i = 0; i < old.length; i++) {
-// IProcess process = old[i];
-// if (!contains(curr, process)) {
-// if (removed == null) {
-// removed = new ArrayList();
-// }
-// removed.add(process);
-// }
-// }
-// }
-// // update cache with current processes
-// fProcesses.put(launch, curr);
-// return removed;
-// }
-//
-// /**
-// * Returns whether the given object is contained in the list.
-// *
-// * @param list list to search
-// * @param object object to search for
-// * @return whether the given object is contained in the list
-// */
-// private boolean contains(Object[] list, Object object) {
-// for (int i = 0; i < list.length; i++) {
-// Object object2 = list[i];
-// if (object2.equals(object)) {
-// return true;
-// }
-// }
-// return false;
-// }
-//}
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
deleted file mode 100644
index ab6d5b934..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentPartitioner.java
+++ /dev/null
@@ -1,1003 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IFlushableStreamMonitor;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.debug.ui.console.IConsole;
-import org.eclipse.debug.ui.console.IConsoleColorProvider;
-import org.eclipse.debug.ui.console.IConsoleHyperlink;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IPatternMatchListener;
-
-/**
- * Default console document partitioner. Partitions a document into
- * color regions for standard in, out, err.
- */
-public class ConsoleDocumentPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension, IPropertyChangeListener, IConsole, IDebugEventSetListener {
-
- protected IProcess fProcess;
- protected IConsoleColorProvider fColorProvider;
- private IStreamsProxy fProxy;
- protected List fStreamListeners = new ArrayList(2);
-
- private String[] fSortedLineDelimiters;
-
- // high and low water marks for buffering output
- private boolean fUpdatingBuffer = false;
- private int fLowWaterMark;
- private int fHighWaterMark;
-
- // max amount of output (characters) processed per poll
- private int fMaxAppendSize;
-
- class StreamEntry {
- /**
- * Identifier of the stream written to.
- */
- private String fStreamIdentifier;
- /**
- * The text written
- */
- private String fText = null;
-
- StreamEntry(String text, String streamIdentifier) {
- fText = text;
- fStreamIdentifier = streamIdentifier;
- }
-
- /**
- * Returns the stream identifier
- */
- public String getStreamIdentifier() {
- return fStreamIdentifier;
- }
-
- /**
- * Returns the text written
- */
- public String getText() {
- return fText;
- }
-
- public boolean isClosedEntry() {
- return false;
- }
- }
-
- /**
- * A stream entry representing stream closure
- */
- class StreamsClosedEntry extends StreamEntry {
- StreamsClosedEntry() {
- super("", ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isClosedEntry() {
- return true;
- }
- }
-
- class StreamListener implements IStreamListener {
-
- private String fStreamIdentifier;
- private IStreamMonitor fStreamMonitor;
- private boolean fIsSystemOut = false;
- private boolean fIsSystemErr = false;
-
- public StreamListener(String streamIdentifier, IStreamMonitor streamMonitor) {
- fStreamIdentifier = streamIdentifier;
- fStreamMonitor = streamMonitor;
- fIsSystemOut = IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM.equals(streamIdentifier);
- fIsSystemErr = IDebugUIConstants.ID_STANDARD_ERROR_STREAM.equals(streamIdentifier);
- }
-
- public void streamAppended(String newText, IStreamMonitor monitor) {
- if (fIsSystemOut) {
- DebugUIPlugin.getDefault().getProcessConsoleManager().aboutToWriteSystemOut(getProcess());
- } else if (fIsSystemErr) {
- DebugUIPlugin.getDefault().getProcessConsoleManager().aboutToWriteSystemErr(getProcess());
- }
- ConsoleDocumentPartitioner.this.streamAppended(newText, fStreamIdentifier);
- }
-
- public void streamClosed(IStreamMonitor monitor) {
- //ConsoleDocumentPartitioner.this.streamClosed(fStreamIdentifier);
- }
-
- public void connect() {
- fStreamMonitor.addListener(this);
- String contents= fStreamMonitor.getContents();
- if (fStreamMonitor instanceof IFlushableStreamMonitor) {
- // flush the underlying buffer and do not duplicate storage
- IFlushableStreamMonitor flushableStreamMonitor = (IFlushableStreamMonitor)fStreamMonitor;
- flushableStreamMonitor.flushContents();
- flushableStreamMonitor.setBuffered(false);
- }
- if (contents.length() > 0) {
- streamAppended(contents, fStreamMonitor);
- }
- }
-
- public void disconnect() {
- fStreamMonitor.removeListener(this);
- }
- }
-
-
- /**
- * A queue of stream entries written to standard out and standard err.
- * Entries appended to the end of the queue and removed from the front.
- * Intentionally a vector to obtain synchronization as entries are
- * added and removed.
- */
- private Vector fQueue = new Vector(10);
-
- /**
- * Thread that polls the queue for new output
- */
- private Thread fPollingThread = null;
-
- /**
- * Whether an append is still in progress or to be run
- */
- private boolean fAppending = false;
-
- /**
- * Whether the console has been killed/disconnected
- */
- private boolean fKilled = false;
-
- /**
- * Whether to keep polling
- */
- private boolean fPoll = false;
-
- /**
- * Whether the streams coonnected to the associated process are closed
- */
- private boolean fClosed= false;
-
- /**
- * The associated document
- */
- private IDocument fDocument = null;
-
- /**
- * The length of the current line
- */
- private int fLineLength = 0;
-
- /**
- * Maximum line length before wrapping.
- */
- private int fMaxLineLength = 80;
-
- /**
- * Whether using auto-wrap mode
- */
- private boolean fWrap = false;
-
- /**
- * List of partitions
- */
- private List fPartitions = new ArrayList(5);
-
- /**
- * The base number of milliseconds to pause
- * between polls.
- */
- private static final long BASE_DELAY= 100L;
-
- /**
- * The identifier of the stream that was last appended to
- */
- private String fLastStreamIdentifier= null;
-
- /**
- * Keyboard input buffer
- */
- private StringBuffer fInputBuffer = new StringBuffer();
-
- /**
- * 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)
- */
- public void connect(IDocument document) {
- fDocument = document;
- fDocument.addPositionCategory(HyperlinkPosition.HYPER_LINK_CATEGORY);
- document.setDocumentPartitioner(this);
- IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
- fWrap = store.getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP);
- fMaxLineLength = store.getInt(IDebugPreferenceConstants.CONSOLE_WIDTH);
- store.addPropertyChangeListener(this);
- fColorProvider.connect(fProcess, this);
- DebugPlugin.getDefault().addDebugEventListener(this);
- if (fProcess.isTerminated()) {
- // it is possible the terminate event will have been fired before the
- // document is connected - in this case, ensure we have closed the streams
- // and notified the line tracker
- streamsClosed();
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
- kill();
- if (fLineNotifier != null) {
- fLineNotifier.disconnect();
- }
- fColorProvider.disconnect();
- fDocument.setDocumentPartitioner(null);
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent event) {
- return documentChanged2(event) != null;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- return new String[] {InputPartition.INPUT_PARTITION_TYPE, OutputPartition.OUTPUT_PARTITION_TYPE, BreakPartition.BREAK_PARTITION_TYPE};
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
- ITypedRegion partition = getPartition(offset);
- if (partition != null) {
- return partition.getType();
- }
- return null;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#computePartitioning(int, int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
- if (offset == 0 && length == fDocument.getLength()) {
- return (ITypedRegion[])fPartitions.toArray(new ITypedRegion[fPartitions.size()]);
- }
- int end = offset + length;
- List list = new ArrayList();
- for (int i = 0; i < fPartitions.size(); i++) {
- ITypedRegion partition = (ITypedRegion)fPartitions.get(i);
- int partitionStart = partition.getOffset();
- int partitionEnd = partitionStart + partition.getLength();
- if ((offset >= partitionStart && offset <= partitionEnd) ||
- (offset < partitionStart && end >= partitionStart)) {
- list.add(partition);
- }
- }
- return (ITypedRegion[])list.toArray(new ITypedRegion[list.size()]);
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- for (int i = 0; i < fPartitions.size(); i++) {
- ITypedRegion partition = (ITypedRegion)fPartitions.get(i);
- int start = partition.getOffset();
- int end = start + partition.getLength();
- if (offset >= start && offset < end) {
- return partition;
- }
- }
- return null;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension#documentChanged2(org.eclipse.jface.text.DocumentEvent)
- */
- public IRegion documentChanged2(DocumentEvent event) {
- if (fUpdatingBuffer) {
- return new Region(0, fDocument.getLength());
- }
- addPendingLinks();
- String text = event.getText();
- 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();
- int docLength = fDocument.getLength();
- int bufferStartOffset = docLength + amountDeleted - fInputBuffer.length();
- int bufferModifyOffset = event.getOffset() - bufferStartOffset;
- int bufferModifyOffsetEnd = bufferModifyOffset + event.getLength();
-
- if (docLength == 0) {
- // cleared
- fQueue.clear();
- fInputBuffer.setLength(0);
- fPartitions.clear();
- // reset lines processed to 0
-// if (fLineNotifier != null) {
-// fLineNotifier.setLinesProcessed(0);
-// }
- // remove existing positions
- try {
- Position[] positions = fDocument.getPositions(HyperlinkPosition.HYPER_LINK_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- fDocument.removePosition(HyperlinkPosition.HYPER_LINK_CATEGORY, position);
- }
- } catch (BadPositionCategoryException e) {
- }
- return new Region(0,0);
- }
-
- if (amountDeleted > 0) {
- // deletion
- fInputBuffer.replace(bufferModifyOffset, bufferModifyOffsetEnd, text);
- // replace the last partition
- InputPartition partition = new InputPartition(IDebugUIConstants.ID_STANDARD_INPUT_STREAM, bufferStartOffset, fInputBuffer.length());
- fPartitions.set(fPartitions.size() - 1, partition);
- } else {
- // insert/replace - must process entire buffer in case of
- // line delimiter insertion in middle of buffer
-
- // parse for line delimiters (indicate chunks to write to standard in)
- String[] lineDelimiters= getLegalLineDelimiters();
- StringBuffer temp =new StringBuffer(fInputBuffer.toString());
- temp.replace(bufferModifyOffset, bufferModifyOffsetEnd, text);
- String remaining = temp.toString();
- int partitionOffset = bufferStartOffset;
- fInputBuffer.setLength(0);
- boolean includesLF = false;
- // line delimiters are sorted by length (compare longest ones first)
- for (int i= lineDelimiters.length - 1; i >= 0; i--) {
- int lf = remaining.indexOf(lineDelimiters[i]);
- while (lf >= 0) {
- includesLF = true;
- int split = lf + lineDelimiters[i].length();
- fInputBuffer.append(remaining.substring(0, split));
- remaining = remaining.substring(split);
- String buffer = fInputBuffer.toString();
- fInputBuffer.setLength(0);
- InputPartition written = (InputPartition)addPartition(new InputPartition(IDebugUIConstants.ID_STANDARD_INPUT_STREAM, partitionOffset, split));
- written.setReadOnly(true);
- partitionOffset += split;
- addPartition(new InputPartition(IDebugUIConstants.ID_STANDARD_INPUT_STREAM, partitionOffset, 0));
- if (fProxy != null) {
- try {
- fProxy.write(buffer);
- } catch (IOException ioe) {
- DebugUIPlugin.log(ioe);
- }
- }
- lf = remaining.indexOf(lineDelimiters[i]);
- }
- if (includesLF) {
- break;
- }
- }
- if (remaining.length() > 0) {
- fInputBuffer.append(remaining);
- addPartition(new InputPartition(IDebugUIConstants.ID_STANDARD_INPUT_STREAM, partitionOffset, remaining.length()));
- }
- }
- }
- ITypedRegion[] affectedRegions = computePartitioning(event.getOffset(), text.length());
- if (affectedRegions.length == 0) {
- return null;
- }
- if (affectedRegions.length == 1) {
- return affectedRegions[0];
- }
- int affectedLength = affectedRegions[0].getLength();
- for (int i = 1; i < affectedRegions.length; i++) {
- ITypedRegion region = affectedRegions[i];
- affectedLength += region.getLength();
- }
- return new Region(affectedRegions[0].getOffset(), affectedLength);
- }
-
- /**
- * Adds a new colored input partition, combining with the previous partition if
- * possible.
- */
- protected StreamPartition addPartition(StreamPartition partition) {
- if (fPartitions.isEmpty()) {
- fPartitions.add(partition);
- } else {
- int index = fPartitions.size() - 1;
- StreamPartition last = (StreamPartition)fPartitions.get(index);
- if (last.canBeCombinedWith(partition)) {
- // replace with a single partition
- partition = last.combineWith(partition);
- fPartitions.set(index, partition);
- } else {
- // different kinds - add a new parition
- fPartitions.add(partition);
- }
- }
- return partition;
- }
-
- /**
- * Add any pending links to the document that are now within the document's
- * bounds.
- */
- protected void addPendingLinks() {
- synchronized (fPendingLinks) {
- if (fPendingLinks.isEmpty()) {
- return;
- }
- Iterator links = fPendingLinks.iterator();
- while (links.hasNext()) {
- HyperlinkPosition link = (HyperlinkPosition)links.next();
- if ((link.getOffset() + link.getLength()) <= fDocument.getLength()) {
- links.remove();
- addLink(link.getHyperLink(), link.getOffset(), link.getLength());
- }
- }
- }
- }
-
- public ConsoleDocumentPartitioner(IProcess process, IConsoleColorProvider colorProvider) {
- fProcess= process;
- fColorProvider = colorProvider;
- IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
- boolean limit = store.getBoolean(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT);
- if (limit) {
- fLowWaterMark = store.getInt(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK);
- fHighWaterMark = store.getInt(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK);
- fMaxAppendSize = fLowWaterMark;
- } else {
- fLowWaterMark = -1;
- fHighWaterMark = -1;
- fMaxAppendSize = 80000;
- }
- }
-
- /**
- * Stops reading/polling immediately
- */
- public synchronized void kill() {
- if (!fKilled) {
- fKilled = true;
- if (fPollingThread != null && fPollingThread.isAlive()) {
- fPollingThread.interrupt();
- }
- fPoll = false;
- Iterator iter = fStreamListeners.iterator();
- while (iter.hasNext()) {
- StreamListener listener = (StreamListener)iter.next();
- listener.disconnect();
- }
- DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
- }
-
- public synchronized void startReading() {
- if (fPollingThread != null) {
- // already polling
- return;
- }
- Runnable r = new Runnable() {
- public void run() {
- pollAndSleep();
- }
- };
- fPoll = true;
- fPollingThread = new Thread(r, "Console Polling Thread"); //$NON-NLS-1$
- fPollingThread.start();
- }
-
- /**
- * Polls and sleeps until closed or the associated
- * process terminates
- */
- protected void pollAndSleep() {
- while (!fKilled && fPoll && (!isClosed() || !fQueue.isEmpty())) {
- poll();
- try {
- Thread.sleep(BASE_DELAY);
- } catch (InterruptedException e) {
- }
- }
- }
-
- /**
- * Polls the queue for new output and updates this document
- */
- protected void poll() {
- if (isAppendInProgress()) {
- return;
- }
- synchronized(fQueue) {
- StringBuffer buffer = null;
- StreamEntry prev = null;
- int processed = 0;
- int amount = 0;
- String[] lds = fDocument.getLegalLineDelimiters();
- boolean closed= false;
- while (!fKilled && !closed && processed < fQueue.size() && amount < fMaxAppendSize) {
- StreamEntry entry = (StreamEntry)fQueue.get(processed);
- if (entry.isClosedEntry()) {
- closed = true;
- processed++;
- } else if (prev == null || prev.getStreamIdentifier().equals(entry.getStreamIdentifier())) {
- String text = entry.getText();
- if (buffer == null) {
- buffer = new StringBuffer(text.length());
- }
- if (isWrap()) {
- for (int i = 0; i < text.length(); i++) {
- if (fLineLength >= fMaxLineLength) {
- String d = getLineDelimiter(text, i, lds);
- if (d == null) {
- buffer.append(lds[0]);
- } else {
- buffer.append(d);
- i = i + d.length();
- }
- fLineLength = 0;
- }
- if (i < text.length()) {
- String lineDelimiter = getLineDelimiter(text, i, lds);
- if (lineDelimiter == null) {
- buffer.append(text.charAt(i));
- fLineLength++;
- } else {
- buffer.append(lineDelimiter);
- fLineLength = 0;
- i = i + lineDelimiter.length() - 1;
- }
- }
- }
- } else {
- buffer.append(text);
- }
- prev = entry;
- processed++;
- amount+= entry.getText().length();
- } else {
- // change streams - write the contents of the current stream
- // and start processing the next stream
- if (buffer != null) {
- appendToDocument(buffer.toString(), prev.getStreamIdentifier());
- buffer.setLength(0);
- prev = null;
- }
- }
- }
- if (buffer != null) {
- appendToDocument(buffer.toString(), prev.getStreamIdentifier());
- }
- if (closed) {
- Display display= DebugUIPlugin.getStandardDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (fLineNotifier != null) {
- fLineNotifier.streamsClosed();
- }
- }
- });
- }
- }
- for (int i = 0; i < processed; i++) {
- fQueue.remove(0);
- }
- }
- }
-
- /**
- * Returns the longest line delimiter at the given position in the given text,
- * or <code>null</code> if none.
- *
- * @param text the text in which to look for a line delimiter
- * @param pos the position at which to look for a line delimiter
- * @param lineDelimiters the line delimiters to look for
- */
- protected String getLineDelimiter(String text, int pos, String[] lineDelimiters) {
- String ld = null;
- for (int i = 0; i < lineDelimiters.length; i++) {
- if (text.regionMatches(pos, lineDelimiters[i], 0, lineDelimiters[i].length())) {
- if (ld == null) {
- ld = lineDelimiters[i];
- } else {
- if (ld.length() < lineDelimiters[i].length()) {
- ld = lineDelimiters[i];
- }
- }
- }
- }
- return ld;
- }
-
- /**
- * Returns whether this console document is performing auto-wrap
- */
- protected boolean isWrap() {
- return fWrap;
- }
-
- /**
- * The stream with the given identifier has had text appended to it.
- * Adds the new text to the document.
- *
- * @see IStreamListener#streamAppended(String, IStreamMonitor)
- */
- protected void appendToDocument(final String text, final String streamIdentifier) {
- Runnable r = new Runnable() {
- public void run() {
- setAppendInProgress(true);
- fLastStreamIdentifier = streamIdentifier;
- try {
- fDocument.replace(fDocument.getLength(), 0, text);
- warnOfContentChange();
- } catch (BadLocationException e) {
- }
- setAppendInProgress(false);
- checkOverflow();
- }
- };
- Display display = DebugUIPlugin.getStandardDisplay();
- if (display != null) {
- display.asyncExec(r);
- }
- }
-
- /**
- * Checks to see if the console buffer has overflowed, and empties the
- * overflow if needed, updating partitions and hyperlink positions.
- */
- protected void checkOverflow() {
- if (fHighWaterMark >= 0) {
- if (fDocument.getLength() > fHighWaterMark) {
-// int lineDifference = 0;
- if (fLineNotifier != null) {
-// int processed = fLineNotifier.getLinesProcessed();
-// int numLines = fDocument.getNumberOfLines();
-// lineDifference = numLines - processed;
- }
- int overflow = fDocument.getLength() - fLowWaterMark;
- fUpdatingBuffer = true;
- try {
- // update partitions
- List newParitions = new ArrayList(fPartitions.size());
- Iterator partitions = fPartitions.iterator();
- while (partitions.hasNext()) {
- ITypedRegion region = (ITypedRegion)partitions.next();
- if (region instanceof StreamPartition) {
- StreamPartition streamPartition = (StreamPartition)region;
- ITypedRegion newPartition = null;
- int offset = region.getOffset();
- if (offset < overflow) {
- int endOffset = offset + region.getLength();
- if (endOffset < overflow) {
- // remove partition
- } else {
- // split partition
- int length = endOffset - overflow;
- newPartition = streamPartition.createNewPartition(streamPartition.getStreamIdentifier(), 0, length);
- }
- } else {
- // modify parition offset
- newPartition = streamPartition.createNewPartition(streamPartition.getStreamIdentifier(), streamPartition.getOffset() - overflow, streamPartition.getLength());
- }
- if (newPartition != null) {
- newParitions.add(newPartition);
- }
- }
- }
- fPartitions = newParitions;
- // update hyperlinks
- try {
- Position[] hyperlinks = fDocument.getPositions(HyperlinkPosition.HYPER_LINK_CATEGORY);
- for (int i = 0; i < hyperlinks.length; i++) {
- HyperlinkPosition position = (HyperlinkPosition)hyperlinks[i];
- // remove old the position
- fDocument.removePosition(HyperlinkPosition.HYPER_LINK_CATEGORY, position);
- if (position.getOffset() >= overflow) {
- // add new poisition
- try {
- fDocument.addPosition(HyperlinkPosition.HYPER_LINK_CATEGORY, new HyperlinkPosition(position.getHyperLink(), position.getOffset() - overflow, position.getLength()));
- } catch (BadLocationException e) {
- }
- }
- }
- } catch (BadPositionCategoryException e) {
- }
- synchronized (fPendingLinks) {
- // update pending hyperlinks
- Vector newPendingLinks = new Vector(fPendingLinks.size());
- Iterator pendingLinks = fPendingLinks.iterator();
- while (pendingLinks.hasNext()) {
- HyperlinkPosition position = (HyperlinkPosition)pendingLinks.next();
- if (position.getOffset() >= overflow) {
- newPendingLinks.add(new HyperlinkPosition(position.getHyperLink(), position.getOffset() - overflow, position.getLength()));
- }
- }
- fPendingLinks = newPendingLinks;
- }
-
- // remove overflow text
- try {
- fDocument.replace(0, overflow, ""); //$NON-NLS-1$
- } catch (BadLocationException e) {
- DebugUIPlugin.log(e);
- }
- } finally {
- // update number of lines processed
- if (fLineNotifier != null) {
-// fLineNotifier.setLinesProcessed(fDocument.getNumberOfLines() - lineDifference);
- }
- fUpdatingBuffer = false;
- }
- }
- }
- }
-
- /**
- * The stream with the given identifier has had text appended to it.
- * Adds a new entry to the queue.
- */
- protected void streamAppended(String text, String streamIdentifier) {
- synchronized (fQueue) {
- if (fClosed) {
- // ERROR - attempt to append after console is closed
- DebugUIPlugin.logErrorMessage("An attempt was made to append text to the console, after it was closed."); //$NON-NLS-1$
- } else {
- fQueue.add(new StreamEntry(text, streamIdentifier));
- }
- }
- }
-
- /**
- * The streams associated with this process have been closed.
- * Adds a new "stream closed" entry to the queue.
- */
- protected void streamsClosed() {
- synchronized (fQueue) {
- if (!fClosed) {
- fQueue.add(new StreamsClosedEntry());
- fClosed = true;
- }
- }
- }
-
- /**
- * Sets whether a runnable has been submitted to update the console
- * document.
- */
- protected void setAppendInProgress(boolean appending) {
- fAppending = appending;
- }
-
- /**
- * Returns whether a runnable has been submitted to update the console
- * document.
- */
- protected boolean isAppendInProgress() {
- return fAppending;
- }
-
- /**
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IDebugPreferenceConstants.CONSOLE_WRAP)) {
- fWrap = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP);
- } else if (event.getProperty().equals(IDebugPreferenceConstants.CONSOLE_WIDTH)) {
- fMaxLineLength = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.CONSOLE_WIDTH);
- }
- }
-
- /**
- * Returns a collection of legal line delimiters for this partitioner's
- * associated document, sorted by length in descending order.
- */
- protected String[] getLegalLineDelimiters() {
- if (fSortedLineDelimiters == null) {
- String[] lineDelimiters = fDocument.getLegalLineDelimiters();
- List list = new ArrayList(lineDelimiters.length);
- for (int i = 0; i < lineDelimiters.length; i++) {
- list.add(lineDelimiters[i]);
- }
- Comparator comparator = new Comparator() {
- /**
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object a, Object b) {
- String s1 = (String)a;
- String s2 = (String)b;
- return s2.length() - s1.length();
- }
-
- };
- Collections.sort(list, comparator);
- fSortedLineDelimiters = (String[])list.toArray(new String[lineDelimiters.length]);
- }
- return fSortedLineDelimiters;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#connect(org.eclipse.debug.core.model.IStreamMonitor, java.lang.String)
- */
- public void connect(IStreamMonitor streamMonitor, String streamIdentifer) {
- if (streamMonitor != null) {
- StreamListener listener = new StreamListener(streamIdentifer, streamMonitor);
- fStreamListeners.add(listener);
- listener.connect();
- // ensure we start polling for output
- startReading();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#connect(org.eclipse.debug.core.model.IStreamsProxy)
- */
- public void connect(IStreamsProxy streamsProxy) {
- fProxy = streamsProxy;
- connect(streamsProxy.getOutputStreamMonitor(), IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM);
- connect(streamsProxy.getErrorStreamMonitor(), IDebugUIConstants.ID_STANDARD_ERROR_STREAM);
- }
-
- /**
- * Returns whether the streams assocaited with this console's process
- * have been closed.
- */
- protected boolean isClosed() {
- return fClosed;
- }
-
- protected IConsoleColorProvider getColorProvider() {
- return fColorProvider;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#addLink(org.eclipse.debug.ui.console.IConsoleHyperlink, int, int)
- */
- public void addLink(IConsoleHyperlink link, int offset, int length) {
- HyperlinkPosition hyperlinkPosition = new HyperlinkPosition(link, offset, length);
- try {
- fDocument.addPosition(HyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition);
- } catch (BadPositionCategoryException e) {
- // internal error
- DebugUIPlugin.log(e);
- } catch (BadLocationException e) {
- // queue the link
- fPendingLinks.add(hyperlinkPosition);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#getProcess()
- */
- 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);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#getRegion(org.eclipse.debug.ui.console.IConsoleHyperlink)
- */
- public IRegion getRegion(IConsoleHyperlink link) {
- try {
- Position[] positions = getDocument().getPositions(HyperlinkPosition.HYPER_LINK_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- HyperlinkPosition position = (HyperlinkPosition)positions[i];
- if (position.getHyperLink().equals(link)) {
- return new Region(position.getOffset(), position.getLength());
- }
- }
- } catch (BadPositionCategoryException e) {
- }
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
- */
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(getProcess())) {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- streamsClosed();
- }
- }
-
- }
-
- private void warnOfContentChange() {
- ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(DebugUITools.getConsole(fProcess));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.console.IConsole#addPatternMatchHandler(org.eclipse.ui.console.IPatternMatchListener)
- */
- public void addPatternMatchListener(IPatternMatchListener matchHandler) {
- //
- }
- public void removePatternMatchListener(IPatternMatchListener matchHandler) {
- }
-}
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
deleted file mode 100644
index f102a0fee..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocumentProvider.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.ui.console.ConsoleColorProvider;
-import org.eclipse.debug.ui.console.IConsoleColorProvider;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.texteditor.AbstractDocumentProvider;
-
-/**
- * Default document provider for the processes. By default a document is created
- * which is connected to the streams proxy of the associated process.
- */
-public class ConsoleDocumentProvider extends AbstractDocumentProvider {
-
- /**
- * The runnable context for that provider.
- * @since 3.0
- */
- private WorkspaceOperationRunner fOperationRunner;
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(java.lang.Object)
- */
- protected IDocument createDocument(Object element) {
- if (element instanceof IProcess) {
- IProcess process = (IProcess)element;
- IConsoleColorProvider colorProvider = getColorProvider(process);
- ConsoleDocument doc= new ConsoleDocument(colorProvider);
- ConsoleDocumentPartitioner partitioner = new ConsoleDocumentPartitioner(process, colorProvider);
- ConsoleLineNotifier lineNotifier = getLineNotifier(process);
- partitioner.connect(doc);
- if (lineNotifier != null) {
- partitioner.connectLineNotifier(lineNotifier);
- }
- return doc;
- }
- return null;
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createAnnotationModel(java.lang.Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) {
- return null;
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) {
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#disposeElementInfo(java.lang.Object, org.eclipse.ui.texteditor.AbstractDocumentProvider.ElementInfo)
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
- ConsoleDocument document = (ConsoleDocument)info.fDocument;
- document.getDocumentPartitioner().disconnect();
- super.disposeElementInfo(element, info);
- }
-
- /**
- * Returns a color provider for the given process.
- *
- * @param process
- * @return IConsoleColorProvider
- */
- protected IConsoleColorProvider getColorProvider(IProcess process) {
- String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE);
- IConsoleColorProvider colorProvider = null;
- if (type != null) {
- colorProvider = getProcessConsoleManager().getColorProvider(type);
- }
- if (colorProvider == null) {
- colorProvider = new ConsoleColorProvider();
- }
- return colorProvider;
- }
-
- /**
- * Returns the line notifier for this console, or <code>null</code> if none.
- *
- * @param process
- * @return line notifier, or <code>null</code>
- */
- protected ConsoleLineNotifier getLineNotifier(IProcess process) {
- String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE);
- if (type != null) {
- return getProcessConsoleManager().newLineNotifier(type);
- }
- return null;
- }
-
- /**
- * Convenience accessor
- *
- * @return ConsoleDocumentManager
- */
- private ProcessConsoleManager getProcessConsoleManager() {
- return DebugUIPlugin.getDefault().getProcessConsoleManager();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- if (fOperationRunner == null)
- fOperationRunner = new WorkspaceOperationRunner();
- fOperationRunner.setProgressMonitor(monitor);
- return fOperationRunner;
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
index 1622a7a53..cf82c6d6d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
@@ -11,22 +11,26 @@
package org.eclipse.debug.internal.ui.views.console;
-import org.eclipse.debug.ui.console.IConsole;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.console.IConsoleLineTracker;
import org.eclipse.debug.ui.console.IConsoleLineTrackerExtension;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
-import org.eclipse.ui.console.IPatternMatchListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IOConsole;
+import org.eclipse.ui.console.IPatternMatchListenerDelegate;
import org.eclipse.ui.console.PatternMatchEvent;
/**
* Tracks text appended to the console and notifies listeners in terms of whole
* lines.
*/
-public class ConsoleLineNotifier implements IPatternMatchListener {
+public class ConsoleLineNotifier implements IPatternMatchListenerDelegate, IPropertyChangeListener {
/**
* Console listeners
*/
@@ -35,7 +39,7 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
/**
* The console this notifier is tracking
*/
- private IConsole fConsole = null;
+ private ProcessConsole fConsole = null;
/**
* Connects this notifier to the given console.
@@ -43,13 +47,17 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
* @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);
- }
- fConsole.addPatternMatchListener(this);
+ if (console instanceof ProcessConsole) {
+ fConsole = (ProcessConsole)console;
+
+ IConsoleLineTracker[] lineTrackers = DebugUIPlugin.getDefault().getProcessConsoleManager().getLineTrackers(fConsole.getProcess());
+ for (int i = 0; i < lineTrackers.length; i++) {
+ lineTrackers[i].init(fConsole);
+ addConsoleListener(lineTrackers[i]);
+ }
+
+ fConsole.addPropertyChangeListener(this);
+ }
}
/**
@@ -59,12 +67,15 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
if (fConsole == null) {
return; //already disconnected
}
- fConsole.removePatternMatchListener(this);
+
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
IConsoleLineTracker listener = (IConsoleLineTracker)listeners[i];
listener.dispose();
}
+
+ fConsole.removePropertyChangeListener(this);
+
fListeners = null;
fConsole = null;
}
@@ -106,20 +117,6 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
public void addConsoleListener(IConsoleLineTracker listener) {
fListeners.add(listener);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListener#getPattern()
- */
- public String getPattern() {
- return ".*\r(\n?)|.*\n"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListener#getModifiers()
- */
- public int getCompilerFlags() {
- return 0;
- }
/* (non-Javadoc)
* @see org.eclipse.ui.console.IPatternMatchListener#matchFound(org.eclipse.ui.console.PatternMatchEvent)
@@ -152,5 +149,13 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getProperty().equals(IOConsole.P_CONSOLE_OUTPUT_COMPLETE)) {
+ streamsClosed();
+ }
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
index d6d5d3a32..726bfa133 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
@@ -9,9 +9,6 @@
# IBM Corporation - initial API and implementation
###############################################################################
-ConsoleDocumentManager.1=Invalid extension {0} - class must be an instance of IConsoleColorProvider.
-ConsoleDocumentManager.2=Invalid extension {0} - class must be an instance of IConsoleLineTracker
-
ConsoleRemoveAllTerminatedAction.0=&Remove All Terminated
ConsoleRemoveAllTerminatedAction.1=Remove All Terminated Launches
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleOutputTextStore.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleOutputTextStore.java
deleted file mode 100644
index c98fb8995..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleOutputTextStore.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.jface.text.ITextStore;
-
-public class ConsoleOutputTextStore implements ITextStore {
-
- private StringBuffer fBuffer;
-
- public ConsoleOutputTextStore(int bufferSize) {
- fBuffer= new StringBuffer(bufferSize);
- }
-
- /**
- * @see ITextStore#get(int)
- */
- public char get(int pos) {
- return fBuffer.charAt(pos);
- }
-
- /**
- * @see ITextStore#get(int, int)
- */
- public String get(int pos, int length) {
- return fBuffer.substring(pos, pos + length);
- }
-
- /**
- * @see ITextStore#getLength()
- */
- public int getLength() {
- return fBuffer.length();
- }
-
- /**
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int pos, int length, String text) {
- if (text == null) {
- text= ""; //$NON-NLS-1$
- }
- fBuffer.replace(pos, pos + length, text);
- }
-
- /**
- * @see ITextStore#set(String)
- */
- public void set(String text) {
- fBuffer= new StringBuffer(text);
- }
-
- /**
- * @see StringBuffer#ensureCapacity(int)
- */
- public void setMinimalBufferSize(int bufferSize) {
- fBuffer.ensureCapacity(bufferSize);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java
deleted file mode 100644
index a6fc96850..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java
+++ /dev/null
@@ -1,489 +0,0 @@
-///*******************************************************************************
-// * Copyright (c) 2000, 2004 IBM Corporation and others.
-// * All rights reserved. This program and the accompanying materials
-// * are 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
-// *
-// * Contributors:
-// * IBM Corporation - initial API and implementation
-// *******************************************************************************/
-//package org.eclipse.debug.internal.ui.views.console;
-//
-//
-//import org.eclipse.debug.internal.ui.DebugUIPlugin;
-//import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-//import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-//import org.eclipse.debug.ui.console.IConsoleColorProvider;
-//import org.eclipse.debug.ui.console.IConsoleHyperlink;
-//import org.eclipse.jface.resource.JFaceResources;
-//import org.eclipse.jface.text.BadLocationException;
-//import org.eclipse.jface.text.BadPositionCategoryException;
-//import org.eclipse.jface.text.DocumentEvent;
-//import org.eclipse.jface.text.IDocument;
-//import org.eclipse.jface.text.IDocumentListener;
-//import org.eclipse.jface.text.IDocumentPartitioner;
-//import org.eclipse.jface.text.IRegion;
-//import org.eclipse.jface.text.ITypedRegion;
-//import org.eclipse.jface.text.Position;
-//import org.eclipse.jface.text.TextViewer;
-//import org.eclipse.jface.util.IPropertyChangeListener;
-//import org.eclipse.jface.util.PropertyChangeEvent;
-//import org.eclipse.swt.SWT;
-//import org.eclipse.swt.custom.LineStyleEvent;
-//import org.eclipse.swt.custom.LineStyleListener;
-//import org.eclipse.swt.custom.StyleRange;
-//import org.eclipse.swt.custom.StyledText;
-//import org.eclipse.swt.events.MouseEvent;
-//import org.eclipse.swt.events.MouseListener;
-//import org.eclipse.swt.events.MouseMoveListener;
-//import org.eclipse.swt.events.MouseTrackListener;
-//import org.eclipse.swt.events.PaintEvent;
-//import org.eclipse.swt.events.PaintListener;
-//import org.eclipse.swt.events.VerifyEvent;
-//import org.eclipse.swt.graphics.Color;
-//import org.eclipse.swt.graphics.Cursor;
-//import org.eclipse.swt.graphics.FontMetrics;
-//import org.eclipse.swt.graphics.Point;
-//import org.eclipse.swt.widgets.Composite;
-//import org.eclipse.swt.widgets.Control;
-//import org.eclipse.swt.widgets.Event;
-//import org.eclipse.swt.widgets.Listener;
-//import org.eclipse.ui.console.IConsoleConstants;
-//
-//public class ConsoleViewer extends TextViewer implements IPropertyChangeListener, MouseTrackListener, MouseMoveListener, MouseListener, PaintListener, LineStyleListener, Listener {
-//
-// /**
-// * Hand cursor
-// */
-// private Cursor fHandCursor;
-//
-// /**
-// * Text cursor
-// */
-// private Cursor fTextCursor;
-//
-// /**
-// * The active hyperlink, or <code>null</code>
-// */
-// private IConsoleHyperlink fHyperLink = null;
-//
-// protected InternalDocumentListener fInternalDocumentListener= new InternalDocumentListener();
-//
-// /**
-// * Whether the console scrolls as output is appended.
-// */
-// private boolean fAutoScroll = true;
-//
-// /**
-// * Internal document listener.
-// */
-// class InternalDocumentListener implements IDocumentListener {
-// /**
-// * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
-// */
-// public void documentAboutToBeChanged(DocumentEvent e) {
-// }
-//
-// /**
-// * @see IDocumentListener#documentChanged(DocumentEvent)
-// */
-// public void documentChanged(DocumentEvent e) {
-// ConsoleDocument doc= (ConsoleDocument)getDocument();
-// if (doc == null) {
-// getTextWidget().setEditable(false);
-// return;
-// }
-// getTextWidget().setEditable(!doc.isReadOnly());
-// revealEndOfDocument();
-// }
-// }
-//
-// /**
-// * Creates a new console viewer and adds verification checking
-// * to only allow text modification if the text is being modified
-// * in the editable portion of the underlying document.
-// *
-// * @see org.eclipse.swt.events.VerifyListener
-// */
-// public ConsoleViewer(Composite parent) {
-// super(parent, getSWTStyles());
-//
-// getTextWidget().setDoubleClickEnabled(true);
-//
-// DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-// JFaceResources.getFontRegistry().addListener(this);
-//
-// getTextWidget().setFont(JFaceResources.getFont(IConsoleConstants.CONSOLE_FONT));
-// getTextWidget().addMouseTrackListener(this);
-// getTextWidget().addPaintListener(this);
-// getTextWidget().addLineStyleListener(this);
-// getTextWidget().addListener(SWT.KeyUp, this);
-// getTextWidget().setTabs(DebugUIPlugin.getDefault().getPluginPreferences().getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH));
-// }
-//
-// /**
-// * Returns the SWT style flags used when instantiating this viewer
-// */
-// private static int getSWTStyles() {
-// int styles= SWT.H_SCROLL | SWT.V_SCROLL;
-// return styles;
-// }
-//
-// /**
-// * Reveals (makes visible) the end of the current document
-// */
-// protected void revealEndOfDocument() {
-// if (isAutoScroll()) {
-// IDocument doc = getDocument();
-// int lines = doc.getNumberOfLines();
-// try {
-// // lines are 0-based
-// int lineStartOffset = doc.getLineOffset(lines - 1);
-// StyledText widget= getTextWidget();
-// if (lineStartOffset > 0) {
-// widget.setCaretOffset(lineStartOffset);
-// widget.showSelection();
-// }
-// int lineEndOffset = lineStartOffset + doc.getLineLength(lines - 1);
-// if (lineEndOffset > 0) {
-// widget.setCaretOffset(lineEndOffset);
-// }
-// } catch (BadLocationException e) {
-// }
-// }
-// }
-//
-// /**
-// * @see ITextViewer#setDocument(IDocument)
-// */
-// public void setDocument(IDocument doc) {
-// IDocument oldDoc= getDocument();
-// IDocument document= doc;
-// if (oldDoc == null && document == null) {
-// return;
-// }
-// if (oldDoc != null) {
-// oldDoc.removeDocumentListener(fInternalDocumentListener);
-// if (oldDoc.equals(document)) {
-// document.addDocumentListener(fInternalDocumentListener);
-// return;
-// }
-// }
-//
-// super.setDocument(document);
-// if (document != null) {
-// revealEndOfDocument();
-// document.addDocumentListener(fInternalDocumentListener);
-// }
-// }
-//
-// /**
-// * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
-// */
-// public void propertyChange(PropertyChangeEvent event) {
-// String propertyName= event.getProperty();
-// if (propertyName.equals(IDebugPreferenceConstants.CONSOLE_SYS_IN_COLOR) ||
-// propertyName.equals(IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR) ||
-// propertyName.equals(IDebugPreferenceConstants.CONSOLE_SYS_ERR_COLOR)) {
-// getTextWidget().redraw();
-// } else if (propertyName.equals(IConsoleConstants.CONSOLE_FONT)) {
-// getTextWidget().setFont(JFaceResources.getFont(IConsoleConstants.CONSOLE_FONT));
-// } else if (propertyName.equals(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH)) {
-// getTextWidget().setTabs(DebugUIPlugin.getDefault().getPluginPreferences().getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH));
-// } else if (propertyName.equals(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK)) {
-// setAutoScroll(!DebugUIPlugin.getDefault().getPluginPreferences().getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK));
-// }
-// }
-//
-// /**
-// * Dispose this viewer and resources
-// */
-// public void dispose() {
-// Control control = getTextWidget();
-// if (control != null) {
-// control.removeMouseTrackListener(this);
-// control.removePaintListener(this);
-// }
-// if (fHandCursor != null) {
-// fHandCursor.dispose();
-// }
-// if (fTextCursor != null) {
-// fTextCursor.dispose();
-// }
-// DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
-// JFaceResources.getFontRegistry().removeListener(this);
-// }
-//
-// /**
-// * Only allow text to be typed at the end of the document.
-// *
-// * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
-// */
-// protected void handleVerifyEvent(VerifyEvent e) {
-// ConsoleDocument doc= (ConsoleDocument)getDocument();
-// if (doc != null) {
-// if (doc.isReadOnly()) {
-// e.doit = false;
-// return;
-// }
-// IDocumentPartitioner partitioner = doc.getDocumentPartitioner();
-// if (partitioner != null) {
-// int length = doc.getLength();
-// ITypedRegion[] partitions = partitioner.computePartitioning(length, 0);
-// if (partitions.length == 0) {
-// } else {
-// ITypedRegion partition = partitions[partitions.length - 1];
-// if (partition.getType().equals(InputPartition.INPUT_PARTITION_TYPE)) {
-// // > 1 char in the input buffer
-// e.doit = (e.start >= partition.getOffset()) && (e.end <= (partition.getLength() + partition.getOffset()));
-// } else {
-// // first character in the input buffer
-// e.doit = length == e.start;
-// }
-// }
-// }
-// }
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseEnter(MouseEvent e) {
-// getTextWidget().addMouseMoveListener(this);
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseExit(MouseEvent e) {
-// getTextWidget().removeMouseMoveListener(this);
-// if (fHyperLink != null) {
-// linkExited(fHyperLink);
-// }
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseHover(MouseEvent e) {
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseMove(MouseEvent e) {
-// int offset = -1;
-// try {
-// Point p = new Point(e.x, e.y);
-// offset = getTextWidget().getOffsetAtLocation(p);
-// } catch (IllegalArgumentException ex) {
-// // out of the document range
-// }
-// updateLinks(offset);
-// }
-//
-// public IConsoleHyperlink getHyperlink(int offset) {
-// if (offset >= 0 && getDocument() != null) {
-// Position[] positions = null;
-// try {
-// positions = getDocument().getPositions(HyperlinkPosition.HYPER_LINK_CATEGORY);
-// } catch (BadPositionCategoryException ex) {
-// // no links have been added
-// return null;
-// }
-// for (int i = 0; i < positions.length; i++) {
-// Position position = positions[i];
-// if (offset >= position.getOffset() && offset <= (position.getOffset() + position.getLength())) {
-// return ((HyperlinkPosition)position).getHyperLink();
-// }
-// }
-// }
-// return null;
-// }
-//
-// protected void linkEntered(IConsoleHyperlink link) {
-// Control control = getTextWidget();
-// control.setRedraw(false);
-// if (fHyperLink != null) {
-// linkExited(fHyperLink);
-// }
-// fHyperLink = link;
-// fHyperLink.linkEntered();
-// control.setCursor(getHandCursor());
-// control.setRedraw(true);
-// control.redraw();
-// control.addMouseListener(this);
-// }
-//
-// protected void linkExited(IConsoleHyperlink link) {
-// link.linkExited();
-// fHyperLink = null;
-// Control control = getTextWidget();
-// control.setCursor(getTextCursor());
-// control.redraw();
-// control.removeMouseListener(this);
-// }
-// /**
-// * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
-// */
-// public void paintControl(PaintEvent e) {
-// if (fHyperLink != null) {
-// IDocument doc = getDocument();
-// if (doc == null) {
-// return;
-// }
-// ConsoleDocumentPartitioner partitioner = (ConsoleDocumentPartitioner)doc.getDocumentPartitioner();
-// if (partitioner == null) {
-// return;
-// }
-// IRegion linkRegion = partitioner.getRegion(fHyperLink);
-// if (linkRegion != null) {
-// int start = linkRegion.getOffset();
-// int end = start + linkRegion.getLength();
-// IConsoleColorProvider colorProvider = partitioner.getColorProvider();
-// try {
-// ITypedRegion partition = doc.getPartition(start);
-// Color fontColor = e.gc.getForeground();
-// if (partition instanceof StreamPartition) {
-// StreamPartition streamPartition = (StreamPartition)partition;
-// fontColor = colorProvider.getColor(streamPartition.getStreamIdentifier());
-// }
-// int startLine = doc.getLineOfOffset(start);
-// int endLine = doc.getLineOfOffset(end);
-// for (int i = startLine; i <= endLine; i++) {
-// IRegion lineRegion = doc.getLineInformation(i);
-// int lineStart = lineRegion.getOffset();
-// int lineEnd = lineStart + lineRegion.getLength();
-// Color color = e.gc.getForeground();
-// e.gc.setForeground(fontColor);
-// if (lineStart < end) {
-// lineStart = Math.max(start, lineStart);
-// lineEnd = Math.min(end, lineEnd);
-// Point p1 = getTextWidget().getLocationAtOffset(lineStart);
-// Point p2 = getTextWidget().getLocationAtOffset(lineEnd);
-// FontMetrics metrics = e.gc.getFontMetrics();
-// int height = metrics.getHeight();
-// e.gc.drawLine(p1.x, p1.y + height, p2.x, p2.y + height);
-// }
-// e.gc.setForeground(color);
-// }
-// } catch (BadLocationException ex) {
-// }
-// }
-// }
-// }
-//
-// protected Cursor getHandCursor() {
-// if (fHandCursor == null) {
-// fHandCursor = new Cursor(DebugUIPlugin.getStandardDisplay(), SWT.CURSOR_HAND);
-// }
-// return fHandCursor;
-// }
-//
-// protected Cursor getTextCursor() {
-// if (fTextCursor == null) {
-// fTextCursor = new Cursor(DebugUIPlugin.getStandardDisplay(), SWT.CURSOR_IBEAM);
-// }
-// return fTextCursor;
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseDoubleClick(MouseEvent e) {
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseDown(MouseEvent e) {
-// }
-//
-// /**
-// * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
-// */
-// public void mouseUp(MouseEvent e) {
-// if (fHyperLink != null) {
-// String selection = getTextWidget().getSelectionText();
-// if (selection.length() <= 0) {
-// if (e.button == 1) {
-// fHyperLink.linkActivated();
-// }
-// }
-// }
-// }
-//
-// /**
-// * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent)
-// */
-// public void lineGetStyle(LineStyleEvent event) {
-// IDocument document = getDocument();
-// if (document != null) {
-// ConsoleDocumentPartitioner partitioner = (ConsoleDocumentPartitioner)document.getDocumentPartitioner();
-// if (partitioner != null) {
-// IConsoleColorProvider colorProvider = partitioner.getColorProvider();
-// ITypedRegion[] regions = partitioner.computePartitioning(event.lineOffset, event.lineOffset + event.lineText.length());
-// StyleRange[] styles = new StyleRange[regions.length];
-// for (int i = 0; i < regions.length; i++) {
-// StreamPartition partition = (StreamPartition)regions[i];
-// Color color = colorProvider.getColor(partition.getStreamIdentifier());
-// styles[i] = new StyleRange(partition.getOffset(), partition.getLength(), color, null);
-// }
-// event.styles = styles;
-// }
-// }
-// }
-//
-// /**
-// * Sets whether this viewer should auto-scroll as output is appended to the
-// * document.
-// *
-// * @param scroll
-// */
-// public void setAutoScroll(boolean scroll) {
-// fAutoScroll = scroll;
-// }
-//
-// /**
-// * Returns whether this viewer should auto-scroll as output is appended to
-// * the document.
-// */
-// public boolean isAutoScroll() {
-// return fAutoScroll;
-// }
-//
-// /**
-// * On KeyUp events, see if we need to enter/exit a link.
-// *
-// * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
-// */
-// public void handleEvent(Event event) {
-// int offset = getTextWidget().getCaretOffset();
-// updateLinks(offset);
-// }
-//
-// /**
-// * The cursor has just be moved to the given offset, the mouse has
-// * hovered over the given offset. Update link rendering.
-// *
-// * @param offset
-// */
-// protected void updateLinks(int offset) {
-// if (offset >= 0) {
-// IConsoleHyperlink link = getHyperlink(offset);
-// if (link != null) {
-// if (link.equals(fHyperLink)) {
-// return;
-// }
-// linkEntered(link);
-// return;
-// }
-// }
-// if (fHyperLink != null) {
-// linkExited(fHyperLink);
-// }
-// }
-//
-//}
-//
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/HyperlinkPosition.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/HyperlinkPosition.java
deleted file mode 100644
index 1d2dce43f..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/HyperlinkPosition.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.ui.console.IConsoleHyperlink;
-import org.eclipse.jface.text.Position;
-
-/**
- */
-public class HyperlinkPosition extends Position {
-
- public static final String HYPER_LINK_CATEGORY = DebugUIPlugin.getUniqueIdentifier() + ".HYPER_LINK"; //$NON-NLS-1$
-
- private IConsoleHyperlink fLink = null;
-
- /**
- *
- */
- public HyperlinkPosition(IConsoleHyperlink link, int offset, int length) {
- super(offset, length);
- fLink = link;
- }
-
- public IConsoleHyperlink getHyperLink() {
- return fLink;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg) {
- return arg instanceof HyperlinkPosition && super.equals(arg) && getHyperLink().equals(((HyperlinkPosition)arg).getHyperLink());
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return super.hashCode() + getHyperLink().hashCode();
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/InputPartition.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/InputPartition.java
deleted file mode 100644
index 3d6f8f045..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/InputPartition.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-
-/**
- * A partition in a console document that contains input from the keyboard.
- */
-public class InputPartition extends StreamPartition {
-
- /**
- * Once an input partition has been written to standard-in, it cannot
- * be modified.
- */
- private boolean fReadOnly = false;
-
- /**
- * Partition type
- */
- public static final String INPUT_PARTITION_TYPE = DebugUIPlugin.getUniqueIdentifier() + ".INPUT_PARTITION_TYPE"; //$NON-NLS-1$
-
-
- public InputPartition(String streamIdentifier, int offset, int length) {
- super(streamIdentifier, offset, length, INPUT_PARTITION_TYPE);
- }
-
- /**
- * @see org.eclipse.debug.internal.ui.views.console.StreamPartition#createNewPartition(String, int, int)
- */
- public StreamPartition createNewPartition(String streamIdentifier, int offset, int length) {
- return new InputPartition(streamIdentifier, offset, length);
- }
-
- /**
- * Sets whether this partition is read-only.
- *
- * @param readOnly whether this partition is read-only
- */
- public void setReadOnly(boolean readOnly) {
- fReadOnly = readOnly;
- }
-
- /**
- * Returns whether this partition is read-only.
- *
- * @return whether this partition is read-only
- */
- public boolean isReadOnly() {
- return fReadOnly;
- }
-
- /**
- * Returns whether this partition is allowed to be combined with the
- * given partition. Once read-only, this partition cannot be combined.
- *
- * @param partition
- * @return boolean
- */
- public boolean canBeCombinedWith(StreamPartition partition) {
- return (!isReadOnly() && super.canBeCombinedWith(partition));
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/OutputPartition.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/OutputPartition.java
deleted file mode 100644
index ed8ad1f12..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/OutputPartition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-
-/**
- * A partition in a console document that contains output from a process.
- */
-public class OutputPartition extends StreamPartition {
-
- /**
- * Partition type
- */
- public static final String OUTPUT_PARTITION_TYPE = DebugUIPlugin.getUniqueIdentifier() + ".OUTPUT_PARTITION_TYPE"; //$NON-NLS-1$
-
-
- public OutputPartition(String streamIdentifier, int offset, int length) {
- super(streamIdentifier, offset, length, OUTPUT_PARTITION_TYPE);
- }
-
- /**
- * @see org.eclipse.debug.internal.ui.views.console.StreamPartition#createNewPartition(String, int, int)
- */
- public StreamPartition createNewPartition(String streamIdetifier, int offset, int length) {
- return new OutputPartition(streamIdetifier, offset, length);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
index d69b03d6f..0bd7537cd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
@@ -62,18 +62,19 @@ import org.eclipse.ui.part.IPageBookViewPage;
* @since 3.0
*/
public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSetListener, IPropertyChangeListener {
+ public static final String TYPE = "org.eclipse.debug.ProcessConsole"; //$NON-NLS-1$
private IProcess fProcess = null;
private List streamListeners = new ArrayList();
private IConsoleColorProvider fColorProvider;
private IOConsoleInputStream in;
- private ConsoleLineNotifier fLineNotifier;
+
/**
* Proxy to a console document
*/
public ProcessConsole(IProcess process, IConsoleColorProvider colorProvider) {
- super("", null); //$NON-NLS-1$
+ super("", TYPE, null); //$NON-NLS-1$
fProcess = process;
fColorProvider = colorProvider;
@@ -281,36 +282,27 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
*/
public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if (event.getSource().equals(getProcess())) {
-
- if (event.getKind() == DebugEvent.TERMINATE) {
- setFinished();
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
-
- Runnable r = new Runnable() {
- public void run() {
- setName(computeName());
- warnOfContentChange();
- }
- };
- DebugUIPlugin.getStandardDisplay().asyncExec(r);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IOConsole#partitionerFinished()
- */
- public void partitionerFinished() {
- super.partitionerFinished();
- if (fLineNotifier != null) {
- fLineNotifier.streamsClosed();
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (event.getSource().equals(getProcess())) {
+
+ if (event.getKind() == DebugEvent.TERMINATE) {
+ setFinished();
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ Runnable r = new Runnable() {
+ public void run() {
+ setName(computeName());
+ warnOfContentChange();
+ }
+ };
+ DebugUIPlugin.getStandardDisplay().asyncExec(r);
+ }
}
}
+
private void warnOfContentChange() {
ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(DebugUITools.getConsole(fProcess));
}
@@ -435,17 +427,4 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
return Status.OK_STATUS;
}
}
-
-
- /**
- * @param lineNotifier
- */
- public void setLineNotifier(ConsoleLineNotifier lineNotifier) {
- fLineNotifier = lineNotifier;
- fLineNotifier.connect(this);
- if (fProcess.isTerminated()) {
- setFinished();
- }
- }
-
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java
index 30884a499..c0fa85095 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java
@@ -50,7 +50,8 @@ public class ProcessConsoleManager implements ILaunchListener {
private Map fColorProviders;
/**
- *
+ * The default color provider. Used if no color provider is contributed
+ * for the given process type.
*/
private IConsoleColorProvider fDefaultColorProvider;
@@ -92,11 +93,6 @@ public class ProcessConsoleManager implements ILaunchListener {
private void removeProcess(IProcess iProcess) {
IConsole console = getConsole(iProcess);
- ConsoleLineNotifier lineNotifier = getLineNotifier(iProcess);
- if (lineNotifier != null) {
- lineNotifier.disconnect();
- }
-
if (console != null) {
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
manager.removeConsoles(new IConsole[]{console});
@@ -144,11 +140,6 @@ public class ProcessConsoleManager implements ILaunchListener {
//create a new console.
IConsoleColorProvider colorProvider = getColorProvider(process.getAttribute(IProcess.ATTR_PROCESS_TYPE));
ProcessConsole pc = new ProcessConsole(process, colorProvider);
- //connect Line Notifier
- ConsoleLineNotifier lineNotifier = getLineNotifier(process);
- if(lineNotifier != null) {
- pc.setLineNotifier(lineNotifier);
- }
//add new console to console manager.
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{pc});
}
@@ -275,30 +266,14 @@ public class ProcessConsoleManager implements ILaunchListener {
return fDefaultColorProvider;
}
-
/**
- * Returns the line notifier for this console, or <code>null</code> if none.
- *
- * @param process
- * @return line notifier, or <code>null</code>
+ * Returns the Line Trackers for a given process type.
+ * @param process The process for which line trackers are required.
+ * @return An array of line trackers which match the given process type.
*/
- protected ConsoleLineNotifier getLineNotifier(IProcess process) {
+ public IConsoleLineTracker[] getLineTrackers(IProcess process) {
String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE);
- if (type != null) {
- return newLineNotifier(type);
- }
- 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();
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_CONSOLE_LINE_TRACKERS);
@@ -314,26 +289,17 @@ public class ProcessConsoleManager implements ILaunchListener {
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(ConsoleMessages.getString("ConsoleDocumentManager.2"),new String[]{extension.getDeclaringExtension().getUniqueIdentifier()})); //$NON-NLS-1$
- }
- } catch (CoreException e) {
- DebugUIPlugin.log(e);
- }
- }
+
+ ArrayList trackers = new ArrayList();
+ for(Iterator i = ((List)fLineTrackers.get(type)).iterator(); i.hasNext(); ) {
+ IConfigurationElement element = (IConfigurationElement) i.next();
+ try {
+ trackers.add(element.createExecutableExtension("class")); //$NON-NLS-1$
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ }
}
- return lineNotifier;
+ return (IConsoleLineTracker[]) trackers.toArray(new IConsoleLineTracker[0]);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java
deleted file mode 100644
index c42f199ef..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.debug.internal.ui.DebugPluginImages;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
-import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Toggles console auto-scroll
- */
-public class ScrollLockAction extends Action implements IPropertyChangeListener {
-
- private IPreferenceStore fStore = DebugUIPlugin.getDefault().getPreferenceStore();
-
- public ScrollLockAction() {
- super(ActionMessages.getString("ScrollLockAction.Scroll_Lock_1")); //$NON-NLS-1$
- setToolTipText(ActionMessages.getString("ScrollLockAction.Scroll_Lock_1")); //$NON-NLS-1$
- setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_LOCK));
- setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_LOCK));
- setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_LOCK));
- WorkbenchHelp.setHelp(
- this,
- IDebugHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION);
- setChecked(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK));
- fStore.addPropertyChangeListener(this);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- fStore.setValue(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK, isChecked());
- }
-
- public void dispose() {
- fStore.removePropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK)) {
- setChecked(fStore.getBoolean(IInternalDebugUIConstants.PREF_CONSOLE_SCROLL_LOCK));
- }
-
- }
-}
-
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/StreamPartition.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/StreamPartition.java
deleted file mode 100644
index b1212445e..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/StreamPartition.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.console;
-
-
-import org.eclipse.jface.text.TypedRegion;
-
-/**
- * A partition from an input/output stream connected to the console.
- */
-public abstract class StreamPartition extends TypedRegion {
-
- /**
- * Stream identifier
- */
- private String fStreamIdentifier;
-
- public StreamPartition(String streamIdentifier, int offset, int length, String type) {
- super(offset, length, type);
- fStreamIdentifier = streamIdentifier;
- }
-
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object partition) {
- if (super.equals(partition)) {
- fStreamIdentifier.equals(((StreamPartition)partition).getStreamIdentifier());
- }
- return false;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return super.hashCode() + fStreamIdentifier.hashCode();
- }
-
- /**
- * Returns this partition's stream identifier
- *
- * @return this partition's stream identifier
- */
- public String getStreamIdentifier() {
- return fStreamIdentifier;
- }
-
- /**
- * Returns whether this partition is allowed to be combined with the
- * given partition.
- *
- * @param partition
- * @return boolean
- */
- public boolean canBeCombinedWith(StreamPartition partition) {
- int start = getOffset();
- int end = start + getLength();
- int otherStart = partition.getOffset();
- int otherEnd = otherStart + partition.getLength();
- boolean overlap = (otherStart >= start && otherStart <= end) || (start >= otherStart && start <= otherEnd);
- return overlap && getType().equals(partition.getType()) && getStreamIdentifier().equals(partition.getStreamIdentifier());
- }
-
- /**
- * Returns a new partition representing this and the given parition
- * combined.
- *
- * @param partition
- * @return partition
- */
- public StreamPartition combineWith(StreamPartition partition) {
- int start = getOffset();
- int end = start + getLength();
- int otherStart = partition.getOffset();
- int otherEnd = otherStart + partition.getLength();
- int theStart = Math.min(start, otherStart);
- int theEnd = Math.max(end, otherEnd);
- return createNewPartition(getStreamIdentifier(), theStart, theEnd - theStart);
- }
-
- /**
- * Creates a new patition of this type with the given color, offset,
- * and length.
- *
- * @param streamIdentifer
- * @param offset
- * @param length
- * @return ColorPartition
- */
- public abstract StreamPartition createNewPartition(String streamIdentifier, int offset, int length);
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/WorkspaceOperationRunner.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/WorkspaceOperationRunner.java
deleted file mode 100644
index e8a97abf9..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/WorkspaceOperationRunner.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.debug.internal.ui.views.console;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.texteditor.ISchedulingRuleProvider;
-
-/**
- * @since 3.0
- */
-class WorkspaceOperationRunner implements IRunnableContext {
-
- private IProgressMonitor fProgressMonitor;
-
- public WorkspaceOperationRunner() {
- }
-
- /**
- * Sets the progress monitor.
- *
- * @param progressMonitor the progress monitor to set
- */
- public void setProgressMonitor(IProgressMonitor progressMonitor) {
- fProgressMonitor= progressMonitor;
- }
-
- /**
- * Returns the progress monitor. It there is no progress monitor the monitor\
- * is set to the <code>NullProgressMonitor</code>.
- *
- * @return the progress monitor
- */
- public IProgressMonitor getProgressMonitor() {
- if (fProgressMonitor == null)
- fProgressMonitor= new NullProgressMonitor();
- return fProgressMonitor;
- }
-
- /*
- * @see org.eclipse.jface.operation.IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- if (runnable instanceof ISchedulingRuleProvider)
- run(fork, cancelable, runnable, ((ISchedulingRuleProvider)runnable).getSchedulingRule());
- else
- run(fork, cancelable, runnable, ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /*
- * @see org.eclipse.jface.operation.IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable, ISchedulingRule schedulingRule) throws InvocationTargetException, InterruptedException {
- WorkspaceModifyDelegatingOperation operation= new WorkspaceModifyDelegatingOperation(runnable, schedulingRule);
- operation.run(getProgressMonitor());
- }
-}

Back to the top