/*******************************************************************************
* Copyright (c) 2000, 2008 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
* Brock Janiczak <brockj@tpg.com.au> - [implementation] Streams not being closed in Javadoc views - https://bugs.eclipse.org/bugs/show_bug.cgi?id=214854
*******************************************************************************/
package org.eclipse.imp.editor.hover;
import org.eclipse.imp.editor.UniversalEditor;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.ITextHoverExtension;
import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.editors.text.EditorsUI;
/**
* Abstract class for providing hover information for Java elements.
*
* @since 2.1
*/
public abstract class AbstractTextHover implements ITextHover, ITextHoverExtension, ITextHoverExtension2 {
private UniversalEditor fEditor;
/*
* @see IJavaEditorTextHover#setEditor(IEditorPart)
*/
public void setEditor(UniversalEditor editor) {
fEditor= editor;
}
protected UniversalEditor getEditor() {
return fEditor;
}
/*
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
* @since 3.4
*/
@SuppressWarnings("deprecation")
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
return getHoverInfo(textViewer, hoverRegion);
}
/*
* @see ITextHover#getHoverRegion(ITextViewer, int)
*/
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
//return JavaWordFinder.findWord(textViewer.getDocument(), offset);
return null;
}
/*
* @see ITextHoverExtension#getHoverControlCreator()
* @since 3.0
*/
public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
}
};
}
/*
* @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator()
* @since 3.4
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell shell) {
return new DefaultInformationControl(shell, true);
}
};
}
}