1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.text.java.hover;
14 import net.sourceforge.phpdt.ui.text.java.hover.IJavaEditorTextHover;
16 import org.eclipse.jface.text.IRegion;
17 import org.eclipse.jface.text.ITextViewer;
18 import org.eclipse.ui.IEditorPart;
22 * Proxy for JavaEditorTextHovers.
26 public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
28 private JavaEditorTextHoverDescriptor fHoverDescriptor;
29 private IJavaEditorTextHover fHover;
31 public JavaEditorTextHoverProxy(JavaEditorTextHoverDescriptor descriptor, IEditorPart editor) {
32 fHoverDescriptor= descriptor;
37 * @see IJavaEditorTextHover#setEditor(IEditorPart)
39 public void setEditor(IEditorPart editor) {
40 super.setEditor(editor);
43 fHover.setEditor(getEditor());
46 public boolean isEnabled() {
51 * @see ITextHover#getHoverRegion(ITextViewer, int)
53 public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
54 if (!isEnabled() || fHoverDescriptor == null)
57 if (isCreated() || createHover())
58 return fHover.getHoverRegion(textViewer, offset);
64 * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
66 public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
67 if (!isEnabled() || fHoverDescriptor == null)
70 if (isCreated() || createHover())
71 return fHover.getHoverInfo(textViewer, hoverRegion);
76 private boolean isCreated() {
77 return fHover != null;
80 private boolean createHover() {
81 fHover= fHoverDescriptor.createTextHover();
83 fHover.setEditor(getEditor());