Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract common class to adapt a JFace hyperlink to a console hyperlink

  • Loading branch information...
commit f0cd11d8611de141da8b61ad52741c6069048fb8 1 parent b0363f5
@sgtcoolguy sgtcoolguy authored
View
3  plugins/com.aptana.console/META-INF/MANIFEST.MF
@@ -15,5 +15,6 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
-Export-Package: com.aptana.console.process
+Export-Package: com.aptana.console,
+ com.aptana.console.process
Eclipse-ExtensibleAPI: true
View
43 plugins/com.aptana.console/src/com/aptana/console/AdaptingHyperlink.java
@@ -0,0 +1,43 @@
+/**
+ * Aptana Studio
+ * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved.
+ * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions).
+ * Please see the license.html included with this distribution for details.
+ * Any modifications to this file must keep this entire header intact.
+ */
+package com.aptana.console;
+
+import org.eclipse.ui.console.IHyperlink;
+
+/**
+ * Adapts a JFace hyperlink to a console hyperlink.
+ *
+ * @author cwilliams
+ */
+public class AdaptingHyperlink implements IHyperlink
+{
+
+ private org.eclipse.jface.text.hyperlink.IHyperlink wrapped;
+
+ public AdaptingHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink wrapped)
+ {
+ this.wrapped = wrapped;
+ }
+
+ public void linkEntered()
+ {
+ // TODO Show a hover with the link text?
+
+ }
+
+ public void linkExited()
+ {
+ // TODO Hide the hover?
+ }
+
+ public void linkActivated()
+ {
+ wrapped.open();
+ }
+
+}
View
39 plugins/com.aptana.git.ui/src/com/aptana/git/ui/hyperlink/GitConsoleLineTracker.java
@@ -13,6 +13,7 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
+import com.aptana.console.AdaptingHyperlink;
import com.aptana.core.logging.IdeLog;
import com.aptana.git.core.IDebugScopes;
import com.aptana.git.ui.GitUIPlugin;
@@ -25,12 +26,12 @@
public class GitConsoleLineTracker implements IConsoleLineTracker
{
- private IConsole console;
+ private IConsole fConsole;
private HyperlinkDetector detector;
public void init(IConsole console)
{
- this.console = console;
+ this.fConsole = console;
this.detector = new HyperlinkDetector();
}
@@ -38,14 +39,14 @@ public void lineAppended(IRegion line)
{
try
{
- String lineContents = console.getDocument().get(line.getOffset(), line.getLength());
+ String lineContents = fConsole.getDocument().get(line.getOffset(), line.getLength());
IHyperlink[] links = detector.detectHyperlinks(lineContents);
if (links != null)
{
for (IHyperlink link : links)
{
- console.addLink(new WrappingConsoleHyperlink(link), line.getOffset()
+ fConsole.addLink(new AdaptingHyperlink(link), line.getOffset()
+ link.getHyperlinkRegion().getOffset(), link.getHyperlinkRegion().getLength());
}
}
@@ -59,34 +60,6 @@ public void lineAppended(IRegion line)
public void dispose()
{
this.detector = null;
- this.console = null;
- }
-
- /**
- * Wraps a JFace hyperlink to conform to the console IHyperlink interface.
- *
- * @author cwilliams
- */
- private static class WrappingConsoleHyperlink implements org.eclipse.ui.console.IHyperlink
- {
- private IHyperlink link;
-
- WrappingConsoleHyperlink(IHyperlink link)
- {
- this.link = link;
- }
-
- public void linkEntered()
- {
- }
-
- public void linkExited()
- {
- }
-
- public void linkActivated()
- {
- link.open();
- }
+ this.fConsole = null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.