From 024efc1e222e6d2e4f6a00c394fb61c1b30376a3 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 12 Jan 2010 14:37:04 +0000 Subject: [PATCH] Enable hovers for information presenter, related to bug 282495 --- .../ui/text/c/hover/CMacroExpansionHover.java | 39 ++++--------------- .../ui/text/c/hover/CSourceHover.java | 4 +- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java index d32027ed9c8..d51835d75a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. 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 @@ -10,18 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.c.hover; -import java.lang.ref.Reference; - import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.part.IWorkbenchPartOrientation; /** * A hover to explore macro expansion. @@ -30,8 +26,6 @@ import org.eclipse.ui.IEditorPart; */ public class CMacroExpansionHover extends AbstractCEditorTextHover { - private Reference fCache; - @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { Object hoverInfo= getHoverInfo2(textViewer, hoverRegion); @@ -66,30 +60,13 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover { public IInformationControlCreator getInformationPresenterControlCreator() { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { - return new CMacroExpansionExplorationControl(parent, getCachedMacroExpansionInput()); + IEditorPart editor= getEditor(); + int orientation= SWT.NONE; + if (editor instanceof IWorkbenchPartOrientation) + orientation= ((IWorkbenchPartOrientation) editor).getOrientation(); + return new SourceViewerInformationControl(parent, true, orientation, null); } }; } - protected CMacroExpansionInput getCachedMacroExpansionInput() { - if (fCache == null) { - return null; - } - CMacroExpansionInput input= fCache.get(); - fCache= null; - if (input == null) { - IEditorPart editor= getEditor(); - if (editor != null) { - ISelectionProvider provider= editor.getSite().getSelectionProvider(); - ISelection selection= provider.getSelection(); - if (selection instanceof ITextSelection) { - ITextSelection textSelection= (ITextSelection) selection; - IRegion region= new Region(textSelection.getOffset(), textSelection.getLength()); - input= CMacroExpansionInput.create(editor, region, true); - } - } - } - return input; - } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java index 49b51858a1a..dfe1f67b525 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 QNX Software Systems and others. + * Copyright (c) 2002, 2010 QNX Software Systems 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 @@ -834,7 +834,7 @@ public class CSourceHover extends AbstractCEditorTextHover { int orientation= SWT.NONE; if (editor instanceof IWorkbenchPartOrientation) orientation= ((IWorkbenchPartOrientation) editor).getOrientation(); - return new SourceViewerInformationControl(parent, true, orientation, getTooltipAffordanceString()); + return new SourceViewerInformationControl(parent, true, orientation, null); } }; }