Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-01-30 15:01:47 -0500
committerDarin Wright2006-01-30 15:01:47 -0500
commit00a71a262175c23637e45a5ef7bc70b1127181f2 (patch)
tree061cd7982a6c8d4d7a2db3478248c3adcce7a4c2 /org.eclipse.ui.console
parent0730b007578620f94ede7da71d979aedc1fc8aae (diff)
downloadeclipse.platform.debug-00a71a262175c23637e45a5ef7bc70b1127181f2.tar.gz
eclipse.platform.debug-00a71a262175c23637e45a5ef7bc70b1127181f2.tar.xz
eclipse.platform.debug-00a71a262175c23637e45a5ef7bc70b1127181f2.zip
Bug 120863 - Support Ctrl modifier on console hyperlinks
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java33
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java28
2 files changed, 53 insertions, 8 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java
new file mode 100644
index 000000000..3895f1583
--- /dev/null
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.console;
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Optional extension to {@link IHyperlink}.
+ * <p>
+ * Clients implementing {@link IHyperlink} may also implement this interface.
+ * When implemented, the method <code>linkActivated(Event)</code> is called instead of
+ * <code>linkActivated()</code>.
+ * </p>
+ * @since 3.2
+ */
+public interface IHyperlink2 extends IHyperlink {
+
+ /**
+ * Notification that this link has been activated. Performs
+ * context specific linking.
+ *
+ * @param event the SWT event which triggered this hyperlink
+ */
+ public void linkActivated(Event event);
+}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java
index 0c6a1c199..f985028ee 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java
@@ -50,6 +50,8 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.internal.console.ConsoleDocumentAdapter;
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
import org.eclipse.ui.progress.WorkbenchJob;
@@ -88,6 +90,23 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener
updateLinks(event.fOffset);
}
};
+ // event listener used to send event to hyperlink for IHyperlink2
+ private Listener mouseUpListener = new Listener() {
+ public void handleEvent(Event event) {
+ if (hyperlink != null) {
+ String selection = getTextWidget().getSelectionText();
+ if (selection.length() <= 0) {
+ if (event.button == 1) {
+ if (hyperlink instanceof IHyperlink2) {
+ ((IHyperlink2) hyperlink).linkActivated(event);
+ } else {
+ hyperlink.linkActivated();
+ }
+ }
+ }
+ }
+ }
+ };
WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
@@ -143,6 +162,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener
styledText.setEditable(true);
setFont(console.getFont());
styledText.addMouseTrackListener(this);
+ styledText.addListener(SWT.MouseUp, mouseUpListener);
ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
propertyChangeListener = new HyperlinkColorChangeListener();
@@ -518,14 +538,6 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener
* @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
public void mouseUp(MouseEvent e) {
- if (hyperlink != null) {
- String selection = getTextWidget().getSelectionText();
- if (selection.length() <= 0) {
- if (e.button == 1) {
- hyperlink.linkActivated();
- }
- }
- }
}
/*

Back to the top