3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.annotatedlineeditor
;
12 import java
.util
.Iterator
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.text
.DefaultInformationControl
;
16 import org
.eclipse
.jface
.text
.DefaultTextHover
;
17 import org
.eclipse
.jface
.text
.IInformationControl
;
18 import org
.eclipse
.jface
.text
.IInformationControlCreator
;
19 import org
.eclipse
.jface
.text
.IRegion
;
20 import org
.eclipse
.jface
.text
.ITextHover
;
21 import org
.eclipse
.jface
.text
.ITextHoverExtension
;
22 import org
.eclipse
.jface
.text
.ITextViewer
;
23 import org
.eclipse
.jface
.text
.Position
;
24 import org
.eclipse
.jface
.text
.reconciler
.IReconciler
;
25 import org
.eclipse
.jface
.text
.reconciler
.IReconcilingStrategy
;
26 import org
.eclipse
.jface
.text
.reconciler
.MonoReconciler
;
27 import org
.eclipse
.jface
.text
.source
.Annotation
;
28 import org
.eclipse
.jface
.text
.source
.IAnnotationModel
;
29 import org
.eclipse
.jface
.text
.source
.ISourceViewer
;
30 import org
.eclipse
.jface
.text
.source
.SourceViewerConfiguration
;
31 import org
.eclipse
.swt
.widgets
.Shell
;
32 import org
.eclipse
.ui
.editors
.text
.EditorsUI
;
36 * <p>AnnotatedLineEditorSourceViewerConfiguration class.</p>
42 public class AnnotatedLineEditorSourceViewerConfiguration
extends
43 SourceViewerConfiguration
{
44 @SuppressWarnings("unused")
45 private static final Logger logger
= Logger
.getLogger(AnnotatedLineEditorSourceViewerConfiguration
.class);
48 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)
51 public IReconciler
getReconciler(ISourceViewer sourceViewer
) {
53 IReconcilingStrategy strategy
= new AnnotatedLineEditorReconcilingStrategy(sourceViewer
);
54 IReconciler reconciler
= new MonoReconciler(strategy
, true);
60 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String, int)
64 public ITextHover
getTextHover(ISourceViewer sourceViewer
, String contentType
) {
66 * http://dev.eclipse.org/newslists/news.eclipse.platform/msg76821.html
68 * The Javadoc hover is shown in a Browser widget
70 return new TextHover(sourceViewer
);
73 private final class TextHover
extends DefaultTextHover
implements ITextHoverExtension
{
75 private ISourceViewer sourceViewer
;
77 public TextHover(ISourceViewer sourceViewer
) {
80 this.sourceViewer
= sourceViewer
;
84 * @see org.eclipse.jface.text.DefaultTextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
87 public String
getHoverInfo(ITextViewer textViewer
, IRegion hoverRegion
) {
89 IAnnotationModel model
= sourceViewer
.getAnnotationModel();
90 Iterator e
= model
.getAnnotationIterator();
92 Annotation annotation
= (Annotation
) e
.next();
93 if (isIncluded(annotation
)) {
94 Position p
= model
.getPosition(annotation
);
95 if (p
!= null && p
.overlapsWith(hoverRegion
.getOffset(), hoverRegion
.getLength())) {
96 return ((LineAnnotation
) annotation
).getHoverText();
104 * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
106 public IInformationControlCreator
getHoverControlCreator() {
107 return new IInformationControlCreator() {
108 public IInformationControl
createInformationControl(Shell parent
) {
109 return new DefaultInformationControl(parent
, EditorsUI
.getTooltipAffordanceString());