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;
21 * Proxy for JavaEditorTextHovers.
25 public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
27 private JavaEditorTextHoverDescriptor fHoverDescriptor;
29 private IJavaEditorTextHover fHover;
31 public JavaEditorTextHoverProxy(JavaEditorTextHoverDescriptor descriptor,
33 fHoverDescriptor = descriptor;
38 * @see IJavaEditorTextHover#setEditor(IEditorPart)
40 public void setEditor(IEditorPart editor) {
41 super.setEditor(editor);
44 fHover.setEditor(getEditor());
47 public boolean isEnabled() {
52 * @see ITextHover#getHoverRegion(ITextViewer, int)
54 public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
55 if (!isEnabled() || fHoverDescriptor == null)
58 if (isCreated() || createHover())
59 return fHover.getHoverRegion(textViewer, offset);
65 * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
67 public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
68 if (!isEnabled() || fHoverDescriptor == null)
71 if (isCreated() || createHover())
72 return fHover.getHoverInfo(textViewer, hoverRegion);
77 private boolean isCreated() {
78 return fHover != null;
81 private boolean createHover() {
82 fHover = fHoverDescriptor.createTextHover();
84 fHover.setEditor(getEditor());