diff options
author | Dani Megert | 2009-03-09 13:02:31 +0000 |
---|---|---|
committer | Dani Megert | 2009-03-09 13:02:31 +0000 |
commit | be8bfa757da09fe4c1b684b364a776983ad17263 (patch) | |
tree | 6404b9e7127979ba86bfbb1ea419aa7f55c8174e /org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink | |
parent | 66b0d307352421bed37d8a974136b943b3599b07 (diff) | |
download | eclipse.platform.text-be8bfa757da09fe4c1b684b364a776983ad17263.tar.gz eclipse.platform.text-be8bfa757da09fe4c1b684b364a776983ad17263.tar.xz eclipse.platform.text-be8bfa757da09fe4c1b684b364a776983ad17263.zip |
Fixed bug 267368: [navigation] Open Implementation hyperlink should not open type hierarchy on caret location
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink')
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java index a5bb0a70145..e65dc1d29b0 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2009 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 @@ -315,6 +315,7 @@ public class MultipleHyperlinkPresenter extends DefaultHyperlinkPresenter { TableItem selection= fTable.getSelection()[0]; IHyperlink link= (IHyperlink)selection.getData(); fManager.hideInformationControl(); + fManager.setCaret(); link.open(); } } @@ -581,6 +582,15 @@ public class MultipleHyperlinkPresenter extends DefaultHyperlinkPresenter { fIsControlVisible= true; } + /** + * Sets the caret where hyperlinking got initiated. + * + * @since 3.5 + */ + private void setCaret() { + fHyperlinkPresenter.setCaret(); + } + /* * @see org.eclipse.jface.text.AbstractInformationControlManager#hideInformationControl() */ @@ -653,6 +663,12 @@ public class MultipleHyperlinkPresenter extends DefaultHyperlinkPresenter { private MultipleHyperlinkHoverManager fManager; /** + * The offset in the text viewer where hyperlinking got initiated. + * @since 3.5 + */ + private int fCursorOffset; + + /** * Creates a new multiple hyperlink presenter which uses * {@link #HYPERLINK_COLOR} to read the color from the given preference store. * @@ -743,7 +759,20 @@ public class MultipleHyperlinkPresenter extends DefaultHyperlinkPresenter { } fSubjectRegion= new Region(start, end - start); + fCursorOffset= JFaceTextUtil.getOffsetForCursorLocation(fTextViewer); fManager.showInformation(); } + + /** + * Sets the caret where hyperlinking got initiated. + * + * @since 3.5 + */ + private void setCaret() { + Point selectedRange= fTextViewer.getSelectedRange(); + if (fCursorOffset != -1 && !(fSubjectRegion.getOffset() <= selectedRange.x && selectedRange.x + selectedRange.y <= fSubjectRegion.getOffset() + fSubjectRegion.getLength())) + fTextViewer.setSelectedRange(fCursorOffset, 0); + } + } |