Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2004-10-26 21:28:55 +0000
committerKevin Barnes2004-10-26 21:28:55 +0000
commitd36edb44592cf1942ddc326841736fe2a72a7d59 (patch)
tree47e3a90bdfc3e87fd8e1a1f1e361385e723872ff
parentddd21e5bdb91c9a824be256a7085fe7cfe9e0452 (diff)
downloadeclipse.platform.debug-d36edb44592cf1942ddc326841736fe2a72a7d59.tar.gz
eclipse.platform.debug-d36edb44592cf1942ddc326841736fe2a72a7d59.tar.xz
eclipse.platform.debug-d36edb44592cf1942ddc326841736fe2a72a7d59.zip
Bug 74444 - Unable to paste into Java stack trace console
-rw-r--r--org.eclipse.ui.console/plugin.xml2
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java3
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java65
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java84
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java6
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java4
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsolePartition.java18
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java3
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java53
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/TextConsoleViewer.java40
10 files changed, 140 insertions, 138 deletions
diff --git a/org.eclipse.ui.console/plugin.xml b/org.eclipse.ui.console/plugin.xml
index a78f4f2a8..8c3388fcf 100644
--- a/org.eclipse.ui.console/plugin.xml
+++ b/org.eclipse.ui.console/plugin.xml
@@ -72,7 +72,7 @@ M4 = Platform-specific fourth key
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
namespace="org.eclipse.ui.console"
- type="org.eclipse.ui.console.IOConsole"
+ type="org.eclipse.ui.console.IConsole"
class="org.eclipse.ui.internal.console.ConsoleTypePropertyTester"
properties="consoleTypeTest"
id="org.eclipse.ui.console.ConsoleTypePropertyTester"/>
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java
index 3f5f35881..c0e17c761 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java
@@ -12,7 +12,10 @@
package org.eclipse.ui.console;
import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.swt.custom.StyleRange;
public interface IConsoleDocumentPartitioner extends IDocumentPartitioner {
public void clearBuffer();
+ public boolean isReadOnly(int offset);
+ public StyleRange[] getStyleRanges(int offset, int length);
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
index 63dc865ec..3a1435e08 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
@@ -13,15 +13,10 @@ package org.eclipse.ui.console;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.WorkbenchEncoding;
-import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
import org.eclipse.ui.internal.console.IOConsolePartitioner;
/**
@@ -44,13 +39,6 @@ public class IOConsole extends TextConsole {
* The stream from which user input may be read
*/
private IOConsoleInputStream inputStream;
-
-
- /**
- * Map of client defined attributes
- */
- private HashMap attributes = new HashMap();
-
/**
* A collection of open streams connected to this console.
@@ -123,30 +111,6 @@ public class IOConsole extends TextConsole {
}
/**
- * Returns the attribue associated with the specified key.
- *
- * @param key attribute key
- * @return Returns the attribue associated with the specified key
- */
- public Object getAttribute(String key) {
- synchronized (attributes) {
- return attributes.get(key);
- }
- }
-
- /**
- * Sets an attribute value.
- *
- * @param key attribute key
- * @param value attribute value
- */
- public void setAttribute(String key, Object value) {
- synchronized(attributes) {
- attributes.put(key, value);
- }
- }
-
- /**
* Creates and returns a new output stream which may be used to write to this console.
* A console may be connected to more than one output stream at once. Clients are
* responsible for closing any output streams created on this console.
@@ -256,32 +220,6 @@ public class IOConsole extends TextConsole {
}
- /**
- * Adds a hyperlink to this console.
- *
- * @param hyperlink the hyperlink to add
- * @param offset the offset in the console document at which the hyperlink should be added
- * @param length the length of the text which should be hyperlinked
- * @throws BadLocationException if the specified location is not valid.
- */
- public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException {
- ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length);
- try {
- getDocument().addPosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition);
- } catch (BadPositionCategoryException e) {
- ConsolePlugin.log(e);
- }
- }
-
- /**
- * Returns the region assocaited with the given hyperlink.
- *
- * @param link hyperlink
- * @return the region associated witht the hyperlink
- */
- public IRegion getRegion(IHyperlink link) {
- return partitioner.getRegion(link);
- }
/**
* Disposes this console.
@@ -294,8 +232,5 @@ public class IOConsole extends TextConsole {
} catch (IOException ioe) {
}
inputStream = null;
- synchronized(attributes) {
- attributes.clear();
- }
}
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java
index ff94a7e92..fa1f8d76c 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java
@@ -11,11 +11,16 @@
package org.eclipse.ui.console;
+import java.util.HashMap;
+
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
import org.eclipse.swt.graphics.Font;
import org.eclipse.ui.internal.console.ConsoleDocument;
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
@@ -82,6 +87,21 @@ public abstract class TextConsole extends AbstractConsole {
*/
private boolean fCompleteFired = false;
+
+ /**
+ * Map of client defined attributes
+ */
+ private HashMap fAttributes = new HashMap();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.AbstractConsole#dispose()
+ */
+ protected void dispose() {
+ super.dispose();
+ synchronized(fAttributes) {
+ fAttributes.clear();
+ }
+ }
/**
* Constructs a console with the given name, image descriptor, and lifecycle
*
@@ -396,4 +416,68 @@ public abstract class TextConsole extends AbstractConsole {
firePropertyChange(this, IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE, null, null);
}
}
+
+ /**
+ * Adds a hyperlink to this console.
+ *
+ * @param hyperlink the hyperlink to add
+ * @param offset the offset in the console document at which the hyperlink should be added
+ * @param length the length of the text which should be hyperlinked
+ * @throws BadLocationException if the specified location is not valid.
+ */
+ public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException {
+ ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length);
+ try {
+ getDocument().addPosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition);
+ } catch (BadPositionCategoryException e) {
+ ConsolePlugin.log(e);
+ }
+ }
+
+ /**
+ * Returns the region assocaited with the given hyperlink.
+ *
+ * @param link hyperlink
+ * @return the region associated witht the hyperlink
+ */
+ public IRegion getRegion(IHyperlink link) {
+ try {
+ IDocument doc = getDocument();
+ if (doc != null) {
+ Position[] positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
+ for (int i = 0; i < positions.length; i++) {
+ ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition)positions[i];
+ if (position.getHyperLink().equals(link)) {
+ return new Region(position.getOffset(), position.getLength());
+ }
+ }
+ }
+ } catch (BadPositionCategoryException e) {
+ }
+ return null;
+ }
+
+ /**
+ * Returns the attribue associated with the specified key.
+ *
+ * @param key attribute key
+ * @return Returns the attribue associated with the specified key
+ */
+ public Object getAttribute(String key) {
+ synchronized (fAttributes) {
+ return fAttributes.get(key);
+ }
+ }
+
+ /**
+ * Sets an attribute value.
+ *
+ * @param key attribute key
+ * @param value attribute value
+ */
+ public void setAttribute(String key, Object value) {
+ synchronized(fAttributes) {
+ fAttributes.put(key, value);
+ }
+ }
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
index bcfbaa98a..053f3a932 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
@@ -34,8 +34,8 @@ import org.eclipse.ui.console.IConsoleListener;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IConsolePageParticipant;
import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IPatternMatchListener;
+import org.eclipse.ui.console.TextConsole;
/**
* The singleton console manager.
@@ -143,8 +143,8 @@ public class ConsoleManager implements IConsoleManager {
List added = new ArrayList(consoles.length);
for (int i = 0; i < consoles.length; i++) {
IConsole console = consoles[i];
- if(console instanceof IOConsole) {
- IOConsole ioconsole = (IOConsole)console;
+ if(console instanceof TextConsole) {
+ TextConsole ioconsole = (TextConsole)console;
IPatternMatchListener[] matchListeners = getPatternMatchListeners(ioconsole);
for (int j = 0; j < matchListeners.length; j++) {
ioconsole.addPatternMatchListener(matchListeners[j]);
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java
index b9282dec6..aa743c768 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java
@@ -11,7 +11,7 @@
package org.eclipse.ui.internal.console;
import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.ui.console.IOConsole;
+import org.eclipse.ui.console.IConsole;
/**
* Tests if an IOConsole's type matches the expected value
@@ -24,7 +24,7 @@ public class ConsoleTypePropertyTester extends PropertyTester {
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- IOConsole console = (IOConsole) receiver;
+ IConsole console = (IConsole) receiver;
String type = console.getType();
return type != null ? type.equals(expectedValue) : false;
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsolePartition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsolePartition.java
deleted file mode 100644
index 7c6f5e1c7..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsolePartition.java
+++ /dev/null
@@ -1,18 +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.ui.internal.console;
-
-import org.eclipse.jface.text.ITypedRegion;
-
-public interface IConsolePartition extends ITypedRegion {
- public boolean isReadOnly();
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java
index 0377366c0..f243d35e9 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java
@@ -1,5 +1,6 @@
package org.eclipse.ui.internal.console;
+import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.console.ConsolePlugin;
@@ -11,7 +12,7 @@ import org.eclipse.ui.console.IOConsoleOutputStream;
* @since 3.1
*
*/
-public class IOConsolePartition implements IConsolePartition {
+public class IOConsolePartition implements ITypedRegion {
public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() + ".io_console_output_partition_type"; //$NON-NLS-1$
public static final String INPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() + ".io_console_input_partition_type"; //$NON-NLS-1$
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 245f38801..8c646dc07 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -20,18 +20,16 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
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.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.swt.custom.StyleRange;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
-import org.eclipse.ui.console.IHyperlink;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleInputStream;
import org.eclipse.ui.console.IOConsoleOutputStream;
@@ -251,27 +249,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
}
return lastPartition;
}
-
- /**
- * Returns the region occupied by the hyperlink
- */
- public IRegion getRegion(IHyperlink link) {
- try {
- IDocument doc = getDocument();
- if (doc != null) {
- Position[] positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition)positions[i];
- if (position.getHyperLink().equals(link)) {
- return new Region(position.getOffset(), position.getLength());
- }
- }
- }
- } catch (BadPositionCategoryException e) {
- }
- return null;
- }
-
+
/**
* Enforces the buffer size.
* When the number of lines in the document exceeds the high water mark, the
@@ -623,6 +601,33 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
return Status.OK_STATUS;
}
}
+
+
+
+
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int)
+ */
+ public boolean isReadOnly(int offset) {
+ return ((IOConsolePartition)getPartition(offset)).isReadOnly();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#computeStyleRange(int, int)
+ */
+ public StyleRange[] getStyleRanges(int offset, int length) {
+ IOConsolePartition[] partitions = (IOConsolePartition[])computePartitioning(offset, length);
+ StyleRange[] styles = new StyleRange[partitions.length];
+ for (int i = 0; i < partitions.length; i++) {
+ int rangeStart = Math.max(partitions[i].getOffset(), offset);
+ int rangeLength = partitions[i].getLength();
+ styles[i] = partitions[i].getStyleRange(rangeStart, rangeLength);
+ }
+ return styles;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/TextConsoleViewer.java
index 0ff270470..c1280da10 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/TextConsoleViewer.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/TextConsoleViewer.java
@@ -43,6 +43,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IHyperlink;
import org.eclipse.ui.console.TextConsole;
@@ -119,23 +120,20 @@ public class TextConsoleViewer extends TextViewer implements LineStyleListener,
String[] legalLineDelimiters = doc.getLegalLineDelimiters();
String eventString = e.text;
- try {
- IConsolePartition partition = (IConsolePartition) doc.getPartition(e.start);
- if (!partition.isReadOnly()) {
- boolean isCarriageReturn = false;
- for (int i = 0; i < legalLineDelimiters.length; i++) {
- if(e.text.equals(legalLineDelimiters[i])) {
- isCarriageReturn = true;
- break;
- }
+ IConsoleDocumentPartitioner partitioner = (IConsoleDocumentPartitioner) doc.getDocumentPartitioner();
+ if (!partitioner.isReadOnly(e.start)) {
+ boolean isCarriageReturn = false;
+ for (int i = 0; i < legalLineDelimiters.length; i++) {
+ if(e.text.equals(legalLineDelimiters[i])) {
+ isCarriageReturn = true;
+ break;
}
-
- if (!isCarriageReturn) {
- super.handleVerifyEvent(e);
- return;
- }
}
- } catch (BadLocationException e1) {
+
+ if (!isCarriageReturn) {
+ super.handleVerifyEvent(e);
+ return;
+ }
}
int length = doc.getLength();
@@ -165,13 +163,7 @@ public class TextConsoleViewer extends TextViewer implements LineStyleListener,
public void lineGetStyle(LineStyleEvent event) {
IDocument document = getDocument();
if (document != null && document.getLength() > 0){
- IOConsolePartition[] partitions = (IOConsolePartition[]) document.getDocumentPartitioner().computePartitioning(event.lineOffset, event.lineText.length());
- StyleRange[] styles = new StyleRange[partitions.length];
- for (int i = 0; i < partitions.length; i++) {
- int rangeStart = Math.max(partitions[i].getOffset(), event.lineOffset);
- int rangeLength = partitions[i].getLength();
- styles[i] = partitions[i].getStyleRange(rangeStart, rangeLength);
- }
+ StyleRange[] styles = ((IConsoleDocumentPartitioner)document.getDocumentPartitioner()).getStyleRanges(event.lineOffset, event.lineText.length());
event.styles = styles;
}
}
@@ -195,12 +187,12 @@ public class TextConsoleViewer extends TextViewer implements LineStyleListener,
return;
}
- IOConsolePartitioner partitioner = (IOConsolePartitioner)doc.getDocumentPartitioner();
+ IConsoleDocumentPartitioner partitioner = (IConsoleDocumentPartitioner)doc.getDocumentPartitioner();
if (partitioner == null) {
return;
}
- IRegion linkRegion = partitioner.getRegion(hyperlink);
+ IRegion linkRegion = console.getRegion(hyperlink);
if (linkRegion != null) {
int start = linkRegion.getOffset();
int end = start + linkRegion.getLength();

Back to the top