mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix for 48208 (sticky hover help)
This commit is contained in:
parent
4e4d3f592a
commit
9b8671d00b
9 changed files with 446 additions and 13 deletions
|
@ -114,6 +114,9 @@ ActionDefinition.format.description=Format Source Code
|
|||
ActionDefinition.gotoMatchingBracket.name= Go to Matching Bracket
|
||||
ActionDefinition.gotoMatchingBracket.description= Moves the cursor to the matching bracket
|
||||
|
||||
ActionDefinition.showTooltip.name= Show Tooltip Description
|
||||
ActionDefinition.showTooltip.description= Shows the tooltip description for the element at the cursor
|
||||
|
||||
CEditor.name=C/C++ Editor
|
||||
|
||||
CPluginPreferencePage.name=C/C++
|
||||
|
|
|
@ -919,6 +919,13 @@
|
|||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="M1+M2+J"/>
|
||||
|
||||
<key
|
||||
sequence="F2"
|
||||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||
commandId="org.eclipse.cdt.ui.edit.text.c.show.tooltip"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
|
@ -1039,6 +1046,12 @@
|
|||
categoryId="org.eclipse.cdt.ui.category.source"
|
||||
id="org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket">
|
||||
</command>
|
||||
<command
|
||||
name="%ActionDefinition.showTooltip.name"
|
||||
description="%ActionDefinition.showTooltip.description"
|
||||
categoryId="org.eclipse.cdt.ui.category.source"
|
||||
id="org.eclipse.cdt.ui.edit.text.c.show.tooltip">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
id="pdomSearchPage"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2006 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
|
||||
|
@ -162,5 +162,7 @@ public interface ICHelpContextIds {
|
|||
public static final String C_SEARCH_VIEW = PREFIX + "search_view"; //$NON-NLS-1$
|
||||
|
||||
public static final String PATHENTRY_VARIABLES_PREFERENCE_PAGE= PREFIX + "pathentry_variables_preference_page_context"; //$NON-NLS-1$
|
||||
|
||||
public static final String SHOW_TOOLTIP_ACTION= PREFIX + "show_tooltip_action"; //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.editor;
|
|||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -23,25 +24,43 @@ import org.eclipse.jface.action.Action;
|
|||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IStatusLineManager;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.AbstractInformationControlManager;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.DefaultInformationControl;
|
||||
import org.eclipse.jface.text.DefaultLineTracker;
|
||||
import org.eclipse.jface.text.DocumentCommand;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IInformationControl;
|
||||
import org.eclipse.jface.text.IInformationControlCreator;
|
||||
import org.eclipse.jface.text.ILineTracker;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITextHover;
|
||||
import org.eclipse.jface.text.ITextOperationTarget;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.jface.text.ITextViewerExtension2;
|
||||
import org.eclipse.jface.text.ITextViewerExtension4;
|
||||
import org.eclipse.jface.text.ITextViewerExtension5;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.jface.text.TextUtilities;
|
||||
import org.eclipse.jface.text.contentassist.ContentAssistant;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||
import org.eclipse.jface.text.information.IInformationProvider;
|
||||
import org.eclipse.jface.text.information.IInformationProviderExtension;
|
||||
import org.eclipse.jface.text.information.IInformationProviderExtension2;
|
||||
import org.eclipse.jface.text.information.InformationPresenter;
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||
import org.eclipse.jface.text.source.IAnnotationHoverExtension;
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
import org.eclipse.jface.text.source.ICharacterPairMatcher;
|
||||
import org.eclipse.jface.text.source.ILineRange;
|
||||
import org.eclipse.jface.text.source.ISharedTextColors;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.jface.text.source.ISourceViewerExtension3;
|
||||
import org.eclipse.jface.text.source.IVerticalRuler;
|
||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
||||
import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
|
||||
import org.eclipse.jface.text.source.projection.ProjectionSupport;
|
||||
|
@ -53,6 +72,7 @@ import org.eclipse.jface.viewers.ISelectionProvider;
|
|||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.search.ui.actions.TextSearchGroup;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.dnd.DND;
|
||||
import org.eclipse.swt.dnd.DragSource;
|
||||
|
@ -64,6 +84,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorActionBarContributor;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
|
@ -84,7 +105,9 @@ import org.eclipse.ui.texteditor.IEditorStatusLine;
|
|||
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
|
||||
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
|
||||
import org.eclipse.ui.texteditor.ITextEditorDropTargetListener;
|
||||
import org.eclipse.ui.texteditor.ResourceAction;
|
||||
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
|
||||
import org.eclipse.ui.texteditor.TextEditorAction;
|
||||
import org.eclipse.ui.texteditor.TextOperationAction;
|
||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||
|
||||
|
@ -117,6 +140,9 @@ import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
|||
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
|
||||
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
|
||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
|
||||
import org.eclipse.cdt.internal.ui.text.ICPartitions;
|
||||
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
|
||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||
import org.eclipse.cdt.internal.ui.util.CUIHelp;
|
||||
|
||||
|
@ -126,6 +152,13 @@ import org.eclipse.cdt.internal.ui.util.CUIHelp;
|
|||
*/
|
||||
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource , IReconcilingParticipant{
|
||||
|
||||
|
||||
/**
|
||||
* The information provider used to present focusable information
|
||||
* shells.
|
||||
*/
|
||||
private InformationPresenter fInformationPresenter;
|
||||
|
||||
/**
|
||||
* Updates the Java outline page selection and this editor's range indicator.
|
||||
*
|
||||
|
@ -142,6 +175,312 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Information provider used to present focusable information shells.
|
||||
*
|
||||
* @since 3.1.1
|
||||
*/
|
||||
private static final class InformationProvider implements
|
||||
IInformationProvider, IInformationProviderExtension,
|
||||
IInformationProviderExtension2 {
|
||||
|
||||
private IRegion fHoverRegion;
|
||||
private Object fHoverInfo;
|
||||
private IInformationControlCreator fControlCreator;
|
||||
|
||||
InformationProvider(IRegion hoverRegion, Object hoverInfo,
|
||||
IInformationControlCreator controlCreator) {
|
||||
fHoverRegion = hoverRegion;
|
||||
fHoverInfo = hoverInfo;
|
||||
fControlCreator = controlCreator;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer,
|
||||
* int)
|
||||
*/
|
||||
public IRegion getSubject(ITextViewer textViewer, int invocationOffset) {
|
||||
return fHoverRegion;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
|
||||
* org.eclipse.jface.text.IRegion)
|
||||
*/
|
||||
public String getInformation(ITextViewer textViewer, IRegion subject) {
|
||||
return fHoverInfo.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
|
||||
* org.eclipse.jface.text.IRegion)
|
||||
* @since 3.2
|
||||
*/
|
||||
public Object getInformation2(ITextViewer textViewer, IRegion subject) {
|
||||
return fHoverInfo;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
|
||||
*/
|
||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||
return fControlCreator;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This action behaves in two different ways: If there is no current text
|
||||
* hover, the tooltip is displayed using information presenter. If there is
|
||||
* a current text hover, it is converted into a information presenter in
|
||||
* order to make it sticky.
|
||||
*
|
||||
* @since 3.1.1
|
||||
*/
|
||||
class InformationDispatchAction extends TextEditorAction {
|
||||
|
||||
/** The wrapped text operation action. */
|
||||
private final TextOperationAction fTextOperationAction;
|
||||
|
||||
/**
|
||||
* Creates a dispatch action.
|
||||
*
|
||||
* @param resourceBundle
|
||||
* the resource bundle
|
||||
* @param prefix
|
||||
* the prefix
|
||||
* @param textOperationAction
|
||||
* the text operation action
|
||||
*/
|
||||
public InformationDispatchAction(ResourceBundle resourceBundle,
|
||||
String prefix, final TextOperationAction textOperationAction) {
|
||||
super(resourceBundle, prefix, CEditor.this);
|
||||
if (textOperationAction == null)
|
||||
throw new IllegalArgumentException();
|
||||
fTextOperationAction = textOperationAction;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.action.IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
|
||||
ISourceViewer sourceViewer = getSourceViewer();
|
||||
if (sourceViewer == null) {
|
||||
fTextOperationAction.run();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sourceViewer instanceof ITextViewerExtension4) {
|
||||
ITextViewerExtension4 extension4 = (ITextViewerExtension4) sourceViewer;
|
||||
if (extension4.moveFocusToWidgetToken())
|
||||
return;
|
||||
}
|
||||
|
||||
if (sourceViewer instanceof ITextViewerExtension2) {
|
||||
// does a text hover exist?
|
||||
ITextHover textHover = ((ITextViewerExtension2) sourceViewer)
|
||||
.getCurrentTextHover();
|
||||
if (textHover != null
|
||||
&& makeTextHoverFocusable(sourceViewer, textHover))
|
||||
return;
|
||||
}
|
||||
|
||||
if (sourceViewer instanceof ISourceViewerExtension3) {
|
||||
// does an annotation hover exist?
|
||||
IAnnotationHover annotationHover = ((ISourceViewerExtension3) sourceViewer)
|
||||
.getCurrentAnnotationHover();
|
||||
if (annotationHover != null
|
||||
&& makeAnnotationHoverFocusable(sourceViewer,
|
||||
annotationHover))
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, just display the tooltip
|
||||
// fTextOperationAction.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to make a text hover focusable (or "sticky").
|
||||
*
|
||||
* @param sourceViewer
|
||||
* the source viewer to display the hover over
|
||||
* @param textHover
|
||||
* the hover to make focusable
|
||||
* @return <code>true</code> if successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
private boolean makeTextHoverFocusable(ISourceViewer sourceViewer,
|
||||
ITextHover textHover) {
|
||||
Point hoverEventLocation = ((ITextViewerExtension2) sourceViewer)
|
||||
.getHoverEventLocation();
|
||||
int offset = computeOffsetAtLocation(sourceViewer,
|
||||
hoverEventLocation.x, hoverEventLocation.y);
|
||||
if (offset == -1)
|
||||
return false;
|
||||
|
||||
try {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(sourceViewer,
|
||||
offset);
|
||||
if (hoverRegion == null)
|
||||
return false;
|
||||
|
||||
String hoverInfo = textHover.getHoverInfo(sourceViewer,
|
||||
hoverRegion);
|
||||
|
||||
IInformationControlCreator controlCreator = null;
|
||||
if (textHover instanceof IInformationProviderExtension2)
|
||||
controlCreator = ((IInformationProviderExtension2) textHover)
|
||||
.getInformationPresenterControlCreator();
|
||||
|
||||
IInformationProvider informationProvider = new InformationProvider(
|
||||
hoverRegion, hoverInfo, controlCreator);
|
||||
|
||||
fInformationPresenter.setOffset(offset);
|
||||
fInformationPresenter
|
||||
.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM);
|
||||
fInformationPresenter.setMargins(6, 6); // default values from
|
||||
// AbstractInformationControlManager
|
||||
String contentType = TextUtilities.getContentType(sourceViewer
|
||||
.getDocument(), ICPartitions.C_PARTITIONING, offset,
|
||||
true);
|
||||
fInformationPresenter.setInformationProvider(
|
||||
informationProvider, contentType);
|
||||
fInformationPresenter.showInformation();
|
||||
|
||||
return true;
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to make an annotation hover focusable (or "sticky").
|
||||
*
|
||||
* @param sourceViewer
|
||||
* the source viewer to display the hover over
|
||||
* @param annotationHover
|
||||
* the hover to make focusable
|
||||
* @return <code>true</code> if successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
private boolean makeAnnotationHoverFocusable(
|
||||
ISourceViewer sourceViewer, IAnnotationHover annotationHover) {
|
||||
IVerticalRulerInfo info = getVerticalRuler();
|
||||
int line = info.getLineOfLastMouseButtonActivity();
|
||||
if (line == -1)
|
||||
return false;
|
||||
|
||||
try {
|
||||
|
||||
// compute the hover information
|
||||
Object hoverInfo;
|
||||
if (annotationHover instanceof IAnnotationHoverExtension) {
|
||||
IAnnotationHoverExtension extension = (IAnnotationHoverExtension) annotationHover;
|
||||
ILineRange hoverLineRange = extension.getHoverLineRange(
|
||||
sourceViewer, line);
|
||||
if (hoverLineRange == null)
|
||||
return false;
|
||||
final int maxVisibleLines = Integer.MAX_VALUE; // allow any
|
||||
// number of
|
||||
// lines
|
||||
// being
|
||||
// displayed,
|
||||
// as we
|
||||
// support
|
||||
// scrolling
|
||||
hoverInfo = extension.getHoverInfo(sourceViewer,
|
||||
hoverLineRange, maxVisibleLines);
|
||||
} else {
|
||||
hoverInfo = annotationHover
|
||||
.getHoverInfo(sourceViewer, line);
|
||||
}
|
||||
|
||||
// hover region: the beginning of the concerned line to place
|
||||
// the control right over the line
|
||||
IDocument document = sourceViewer.getDocument();
|
||||
int offset = document.getLineOffset(line);
|
||||
String contentType = TextUtilities.getContentType(document,
|
||||
ICPartitions.C_PARTITIONING, offset, true);
|
||||
|
||||
IInformationControlCreator controlCreator = null;
|
||||
|
||||
/*
|
||||
* XXX: This is a hack to avoid API changes at the end of 3.2,
|
||||
* and should be fixed for 3.3, see:
|
||||
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=137967
|
||||
*/
|
||||
if ("org.eclipse.jface.text.source.projection.ProjectionAnnotationHover".equals(annotationHover.getClass().getName())) { //$NON-NLS-1$
|
||||
controlCreator = new IInformationControlCreator() {
|
||||
public IInformationControl createInformationControl(
|
||||
Shell shell) {
|
||||
int shellStyle = SWT.RESIZE | SWT.TOOL
|
||||
| getOrientation();
|
||||
int style = SWT.V_SCROLL | SWT.H_SCROLL;
|
||||
return new SourceViewerInformationControl(shell,
|
||||
shellStyle, style);
|
||||
}
|
||||
};
|
||||
|
||||
} else {
|
||||
if (annotationHover instanceof IInformationProviderExtension2)
|
||||
controlCreator = ((IInformationProviderExtension2) annotationHover)
|
||||
.getInformationPresenterControlCreator();
|
||||
else if (annotationHover instanceof IAnnotationHoverExtension)
|
||||
controlCreator = ((IAnnotationHoverExtension) annotationHover)
|
||||
.getHoverControlCreator();
|
||||
}
|
||||
|
||||
IInformationProvider informationProvider = new InformationProvider(
|
||||
new Region(offset, 0), hoverInfo, controlCreator);
|
||||
|
||||
fInformationPresenter.setOffset(offset);
|
||||
fInformationPresenter
|
||||
.setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
|
||||
fInformationPresenter.setMargins(4, 0); // AnnotationBarHoverManager
|
||||
// sets (5,0), minus
|
||||
// SourceViewer.GAP_SIZE_1
|
||||
fInformationPresenter.setInformationProvider(
|
||||
informationProvider, contentType);
|
||||
fInformationPresenter.showInformation();
|
||||
|
||||
return true;
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// modified version from TextViewer
|
||||
private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) {
|
||||
|
||||
StyledText styledText = textViewer.getTextWidget();
|
||||
IDocument document = textViewer.getDocument();
|
||||
|
||||
if (document == null)
|
||||
return -1;
|
||||
|
||||
try {
|
||||
int widgetOffset = styledText.getOffsetAtLocation(new Point(x,
|
||||
y));
|
||||
Point p = styledText.getLocationAtOffset(widgetOffset);
|
||||
if (p.x > x)
|
||||
widgetOffset--;
|
||||
|
||||
if (textViewer instanceof ITextViewerExtension5) {
|
||||
ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
|
||||
return extension.widgetOffset2ModelOffset(widgetOffset);
|
||||
} else {
|
||||
IRegion visibleRegion = textViewer.getVisibleRegion();
|
||||
return widgetOffset + visibleRegion.getOffset();
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor selection changed listener.
|
||||
*
|
||||
|
@ -650,6 +989,13 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
|
||||
fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());
|
||||
|
||||
// Sticky hover support
|
||||
ResourceAction resAction= new TextOperationAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
|
||||
ResourceAction resAction2= new InformationDispatchAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", (TextOperationAction) resAction); //$NON-NLS-1$
|
||||
resAction2.setActionDefinitionId(ICEditorActionDefinitionIds.SHOW_TOOLTIP);
|
||||
setAction("ShowToolTip", resAction2); //$NON-NLS-1$
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction2, ICHelpContextIds.SHOW_TOOLTIP_ACTION);
|
||||
|
||||
// Default text editing menu items
|
||||
Action action= new GotoMatchingBracketAction(this);
|
||||
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
|
||||
|
@ -802,7 +1148,25 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
*/
|
||||
public void createPartControl(Composite parent) {
|
||||
super.createPartControl(parent);
|
||||
|
||||
// Sticky hover support
|
||||
IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
|
||||
public IInformationControl createInformationControl(Shell shell) {
|
||||
boolean cutDown = false;
|
||||
int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
return new DefaultInformationControl(shell, SWT.RESIZE
|
||||
| SWT.TOOL, style, new HTMLTextPresenter(cutDown));
|
||||
}
|
||||
};
|
||||
|
||||
fInformationPresenter = new InformationPresenter(
|
||||
informationControlCreator);
|
||||
fInformationPresenter.setSizeConstraints(60, 10, true, true);
|
||||
fInformationPresenter.install(getSourceViewer());
|
||||
fInformationPresenter
|
||||
.setDocumentPartitioning(ICPartitions.C_PARTITIONING);
|
||||
|
||||
|
||||
ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
|
||||
|
||||
fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
|
||||
|
|
|
@ -192,3 +192,5 @@ GotoNextMember.tooltip=Goes to next member
|
|||
GotoPrevMember.description=Goes to previous member
|
||||
GotoPrevMember.label=Go to &previous member
|
||||
GotoPrevMember.tooltip=Goes to previous member.
|
||||
|
||||
ShowToolTip.label=Show T&ooltip Description
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2006 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
@ -155,4 +156,11 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
|||
*/
|
||||
public static final String GOTO_MATCHING_BRACKET= "org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Action definition ID of the edit -> show tooltip action
|
||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.show.tooltip"</code>).
|
||||
*
|
||||
* @since 3.1.1
|
||||
*/
|
||||
public static final String SHOW_TOOLTIP = "org.eclipse.cdt.ui.edit.text.c.show.tooltip"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2006 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text;
|
||||
|
@ -38,5 +39,11 @@ public interface ICPartitions {
|
|||
* The identifier of the C character partition content type.
|
||||
*/
|
||||
String C_CHARACTER= "c_character"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The identifier of the C partitioning.
|
||||
*/
|
||||
String C_PARTITIONING= "___c_partitioning"; //$NON-NLS-1$
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||
|
@ -22,9 +23,14 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.keys.IBindingService;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
|
||||
|
||||
|
@ -38,6 +44,15 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover,
|
|||
|
||||
private IEditorPart fEditor;
|
||||
|
||||
/* Mapping key to action */
|
||||
private IBindingService fBindingService;
|
||||
|
||||
// initialization block, called during constructor call
|
||||
{
|
||||
fBindingService = (IBindingService) PlatformUI.getWorkbench()
|
||||
.getAdapter(IBindingService.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICEditorTextHover#setEditor(IEditorPart)
|
||||
*/
|
||||
|
@ -88,7 +103,7 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover,
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the tool tip affordance string.
|
||||
*
|
||||
|
@ -97,9 +112,20 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover,
|
|||
* @since 3.0
|
||||
*/
|
||||
protected String getTooltipAffordanceString() {
|
||||
//TLETODO [hover] provide affordance string
|
||||
// @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover
|
||||
return null;
|
||||
|
||||
if (fBindingService == null
|
||||
|| !CUIPlugin.getDefault().getPreferenceStore().getBoolean(
|
||||
PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE))
|
||||
return null;
|
||||
|
||||
String keySequence = fBindingService
|
||||
.getBestActiveBindingFormattedFor(ICEditorActionDefinitionIds.SHOW_TOOLTIP);
|
||||
if (keySequence == null)
|
||||
return null;
|
||||
|
||||
return CHoverMessages
|
||||
.getFormattedString(
|
||||
"CTextHover.makeStickyHint", keySequence == null ? "" : keySequence); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,14 +11,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
/**
|
||||
* Preference constants used in the CDT-UI preference store. Clients should only read the
|
||||
|
@ -374,6 +372,15 @@ public class PreferenceConstants {
|
|||
return CUIPlugin.getDefault().getPreferenceStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* A named preference that defines whether the hint to make hover sticky should be shown.
|
||||
*
|
||||
* @see JavaUI
|
||||
* @since 3.1.1
|
||||
*/
|
||||
public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE"; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the given preference store with the default values.
|
||||
*
|
||||
|
@ -395,7 +402,8 @@ public class PreferenceConstants {
|
|||
String mod1Name= Action.findModifierString(SWT.MOD1); // SWT.COMMAND on Mac; SWT.CONTROL elsewhere
|
||||
store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + mod1Name); //$NON-NLS-1$
|
||||
store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + SWT.MOD1); //$NON-NLS-1$
|
||||
//store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
|
||||
|
||||
store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
|
||||
|
||||
// folding
|
||||
store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, false);
|
||||
|
|
Loading…
Add table
Reference in a new issue