Committed part 2 of Markus's patch to fix bug 220215: [hovers] Bad API: IInformationControlExtension5#allowMoveIntoControl()
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
index 72fa18b..cfa0a97 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractHoverInformationControlManager.java
@@ -636,6 +636,13 @@
}
}
+ /**
+ * The delay in {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY} mode after which
+ * the hover is enriched when the mouse has stopped moving inside the hover.
+ * @since 3.4
+ */
+ private static final long HOVER_AUTO_REPLACING_DELAY= 200;
+
/** The mouse tracker on the subject control */
private MouseTracker fMouseTracker= new MouseTracker();
/**
@@ -654,11 +661,11 @@
private Job fReplacingDelayJob;
/**
- * While the mouse is inside the hover, the hover is automatically enriched after this delay (in ms),
- * unless the mouse is moved.
+ * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>.
* @since 3.4
*/
- private int fHoverAutoReplacingDelay;
+ private EnrichMode fEnrichMode;
+
/**
* Indicates whether we have received a MouseDown event and are waiting for a MouseUp
* (and don't replace the information control until that happened).
@@ -757,7 +764,7 @@
* control, <code>false</code> otherwise
*/
boolean canMoveIntoInformationControl(IInformationControl iControl) {
- return canReplace(iControl);
+ return fEnrichMode != null && canReplace(iControl);
}
/*
@@ -778,14 +785,7 @@
* @see ITextViewerExtension8#setHoverEnrichMode(org.eclipse.jface.text.ITextViewerExtension8.EnrichMode)
*/
void setHoverEnrichMode(EnrichMode mode) {
- if (mode == EnrichMode.AFTER_DELAY)
- fHoverAutoReplacingDelay= 200;
- else if (mode == EnrichMode.ON_CLICK)
- fHoverAutoReplacingDelay= Integer.MAX_VALUE;
- else if (mode == EnrichMode.IMMEDIATELY)
- fHoverAutoReplacingDelay= 0;
- else
- Assert.isLegal(false);
+ fEnrichMode= mode;
}
/*
@@ -816,7 +816,7 @@
/**
* Starts replacing the information control, considering the current
- * {@link #setHoverEnrichMode(ITextViewerExtension8.EnrichMode) enrichMode}.
+ * {@link ITextViewerExtension8.EnrichMode}.
* If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this
* method cancels previous requests and restarts the delay timer.
*
@@ -824,20 +824,20 @@
* {@link #replaceInformationControl(boolean)} in the UI thread
*/
private void startReplaceInformationControl(final Display display) {
- if (fHoverAutoReplacingDelay == Integer.MAX_VALUE)
+ if (fEnrichMode == EnrichMode.ON_CLICK)
return;
if (fReplacingDelayJob != null) {
if (fReplacingDelayJob.getState() != Job.RUNNING) {
if (fReplacingDelayJob.cancel()) {
- if (fHoverAutoReplacingDelay == 0) {
+ if (fEnrichMode == EnrichMode.IMMEDIATELY) {
fReplacingDelayJob= null;
if (! fWaitForMouseUp)
replaceInformationControl(false);
} else {
// if (DEBUG)
// System.out.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$
- fReplacingDelayJob.schedule(fHoverAutoReplacingDelay);
+ fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY);
}
}
}
@@ -865,7 +865,7 @@
fReplacingDelayJob.setPriority(Job.INTERACTIVE);
// if (DEBUG)
// System.out.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): scheduled"); //$NON-NLS-1$
- fReplacingDelayJob.schedule(fHoverAutoReplacingDelay);
+ fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY);
}
/*
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension2.java
index a20bc39..3c86494 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension2.java
@@ -14,8 +14,7 @@
/**
* Extension interface for {@link org.eclipse.jface.text.ITextHover}.
* <p>
- * Provides a way for hovers to specify the information control creator they
- * want to have used to create a rich hover control.
+ * Provides a way for hovers to return hover-specific information objects.
* </p>
*
* @see org.eclipse.jface.text.ITextHover
@@ -29,8 +28,13 @@
* as the region returned by {@link ITextHover#getHoverRegion(ITextViewer, int)}.
* If the returned information is <code>null</code>, no hover popup will be shown.
* <p>
- * Implementers should ignore the text returned by {@link ITextHover#getHoverInfo(ITextViewer, IRegion)}.
- * </p>
+ * <strong>Note:</strong> Implementers have to ensure that {@link ITextHoverExtension#getHoverControlCreator()}
+ * returns {@link IInformationControl}s that implement
+ * {@link IInformationControlExtension2} and whose
+ * {@link IInformationControlExtension2#setInput(Object)} can handle the
+ * information objects returned by this method.</p>
+ * <p>
+ * Callers should ignore the text returned by {@link ITextHover#getHoverInfo(ITextViewer, IRegion)}.</p>
*
* @param textViewer the viewer on which the hover popup should be shown
* @param hoverRegion the text range in the viewer which is used to determine
@@ -39,16 +43,4 @@
*/
Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion);
- /**
- * Returns the rich information control creator of this text hover.
- * <p>
- * This information control creator is used to create a rich hover, e.g.
- * when an existing hover from {@link ITextHoverExtension#getHoverControlCreator()}
- * needs to be {@link ITextViewerExtension8#setHoverEnrichMode(org.eclipse.jface.text.ITextViewerExtension8.EnrichMode) enriched}
- * or when it needs to be made sticky for other reasons.
- * </p>
- *
- * @return the information presenter control creator or <code>null</code> if none is available
- */
- IInformationControlCreator getInformationPresenterControlCreator();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension8.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension8.java
index cba37d5..782f349 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension8.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension8.java
@@ -15,7 +15,7 @@
/**
* Extension interface for {@link org.eclipse.jface.text.ITextViewer}. Adds the
- * ability to print and set whether to allow moving the mouse into a hover.
+ * ability to print and set how hovers should be enriched when the mouse is moved into them.
*
* @since 3.4
*/
@@ -29,22 +29,17 @@
void print(StyledTextPrintOptions options);
/**
- * Sets whether this viewer allows to move the mouse into a hover i.e. don't
- * close it automatically.
- *
- * @param state <code>true</code> to enable, <code>false</code>
- * otherwise
- */
- void setAllowMoveIntoHover(boolean state);
-
- /**
- * Sets when hovers should be enriched once the mouse is
- * moved into them.
+ * Sets the hover enrich mode.
+ * A non-<code>null</code> <code>mode</code> defines when hovers
+ * should be enriched once the mouse is moved into them.
+ * If <code>mode</code> is <code>null</code>, hovers are automatically closed
+ * when the mouse is moved out of the {@link ITextHover#getHoverRegion(ITextViewer, int) hover region}.
* <p>
- * Only applicable when {@link #setAllowMoveIntoHover(boolean)} has been
- * called with <code>true</code>.</p>
+ * Note that a hover can only be enriched if its {@link IInformationControlExtension5#getInformationPresenterControlCreator()}
+ * is not <code>null</code>.
+ * </p>
*
- * @param mode the enrich mode
+ * @param mode the enrich mode, or <code>null</code>
*/
void setHoverEnrichMode(EnrichMode mode);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index d1ce70a..2cda075 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -1796,6 +1796,7 @@
fTextHoverManager= new TextViewerHoverManager(this, fHoverControlCreator);
fTextHoverManager.install(this.getTextWidget());
fTextHoverManager.setSizeConstraints(TEXT_HOVER_WIDTH_CHARS, TEXT_HOVER_HEIGHT_CHARS, false, true);
+ fTextHoverManager.setInformationControlReplacer(new StickyHoverManager(this));
}
}
@@ -2200,19 +2201,6 @@
}
/*
- * @see org.eclipse.jface.text.ITextViewerExtension8#setAllowMoveIntoHover(boolean)
- * @since 3.4
- */
- public void setAllowMoveIntoHover(boolean state) {
- if (fTextHoverManager == null)
- return;
- if (state)
- fTextHoverManager.setInformationControlReplacer(new StickyHoverManager(this));
- else
- fTextHoverManager.setInformationControlReplacer(null);
- }
-
- /*
* @see org.eclipse.jface.text.ITextViewerExtension8#setHoverEnrichMode(org.eclipse.jface.text.ITextViewerExtension8.EnrichMode)
* @since 3.4
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
index be560a8..31dd488 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java
@@ -23,8 +23,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.information.IInformationProviderExtension2;
-
/**
* This manager controls the layout, content, and visibility of an information
@@ -354,8 +352,7 @@
return false;
IInformationControl iControl= getCurrentInformationControl();
- if (iControl instanceof IInformationControlExtension3 && (fTextHover instanceof ITextHoverExtension2 ||
- fTextHover instanceof IInformationProviderExtension2)) { // backwards compatibility
+ if (canReplace(iControl)) {
if (cancelReplacingDelay())
replaceInformationControl(true);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 5cb360e..2a70e29 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -447,7 +447,6 @@
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_MOVE_INTO_HOVER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE));
OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
@@ -494,15 +493,15 @@
}
private Control createAppearancePage(Composite parent) {
-
+
Composite appearanceComposite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.numColumns= 2;
layout.marginHeight= 0;
layout.marginWidth= 0;
-
+
appearanceComposite.setLayout(layout);
-
+
String label= TextEditorMessages.TextEditorPreferencePage_undoHistorySize;
Preference undoHistorySize= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, label, null);
IntegerDomain undoHistorySizeDomain= new IntegerDomain(0, 99999);
@@ -512,27 +511,27 @@
Preference tabWidth= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, label, null);
IntegerDomain tabWidthDomain= new IntegerDomain(1, 16);
addTextField(appearanceComposite, tabWidth, tabWidthDomain, 15, 0);
-
+
label= TextEditorMessages.TextEditorPreferencePage_convertTabsToSpaces;
Preference spacesForTabs= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, label, null);
addCheckBox(appearanceComposite, spacesForTabs, new BooleanDomain(), 0);
-
+
label= TextEditorMessages.TextEditorPreferencePage_highlightCurrentLine;
Preference highlightCurrentLine= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, label, null);
addCheckBox(appearanceComposite, highlightCurrentLine, new BooleanDomain(), 0);
-
+
label= TextEditorMessages.TextEditorPreferencePage_showPrintMargin;
Preference showPrintMargin= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, label, null);
final Button showPrintMarginButton= addCheckBox(appearanceComposite, showPrintMargin, new BooleanDomain(), 0);
-
+
label= TextEditorMessages.TextEditorPreferencePage_printMarginColumn;
Preference printMarginColumn= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, label, null);
final IntegerDomain printMarginDomain= new IntegerDomain(20, 200);
final Control[] printMarginControls= addTextField(appearanceComposite, printMarginColumn, printMarginDomain, 15, 20);
createDependency(showPrintMarginButton, showPrintMargin, printMarginControls);
-
+
showPrintMarginButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateStatus(printMarginDomain);
@@ -542,7 +541,7 @@
label= TextEditorMessages.TextEditorPreferencePage_showLineNumbers;
Preference showLineNumbers= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, label, null);
addCheckBox(appearanceComposite, showLineNumbers, new BooleanDomain(), 0);
-
+
label= TextEditorMessages.TextEditorDefaultsPreferencePage_range_indicator;
Preference showMagnet= new Preference(AbstractDecoratedTextEditorPreferenceConstants.SHOW_RANGE_INDICATOR, label, null);
addCheckBox(appearanceComposite, showMagnet, new BooleanDomain(), 0);
@@ -555,23 +554,19 @@
Preference showAffordance= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, label, null);
addCheckBox(appearanceComposite, showAffordance, new BooleanDomain(), 0);
- label= TextEditorMessages.TextEditorDefaultsPreferencePage_moveIntoHover;
- Preference moveIntoHover= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_MOVE_INTO_HOVER, label, null);
- final Button moveIntoHoverButton= addCheckBox(appearanceComposite, moveIntoHover, new BooleanDomain(), 0);
-
label= TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHoverMode;
Preference hoverReplace= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE, label, null);
EnumeratedDomain hoverReplaceDomain= new EnumeratedDomain();
+ hoverReplaceDomain.addValue(new EnumValue(-1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_disabled));
hoverReplaceDomain.addValue(new EnumValue(1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_immediately));
hoverReplaceDomain.addValue(new EnumValue(0, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_afterDelay));
hoverReplaceDomain.addValue(new EnumValue(2, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_onClick));
- Control[] hoverReplaceControls= addCombo(appearanceComposite, hoverReplace, hoverReplaceDomain, 20);
- createDependency(moveIntoHoverButton, hoverReplace, hoverReplaceControls);
-
+ addCombo(appearanceComposite, hoverReplace, hoverReplaceDomain, 0);
+
label= TextEditorMessages.TextEditorDefaultsPreferencePage_textDragAndDrop;
Preference textDragAndDrop= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null);
addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0);
-
+
label= TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived;
Preference warnIfDerived= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null);
addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0);
@@ -579,8 +574,8 @@
label= TextEditorMessages.TextEditorDefaultsPreferencePage_smartHomeEnd;
Preference smartHomeEnd= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END, label, null);
addCheckBox(appearanceComposite, smartHomeEnd, new BooleanDomain(), 0);
-
-
+
+
Label l= new Label(appearanceComposite, SWT.LEFT );
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 2;
@@ -592,7 +587,7 @@
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 2;
l.setLayoutData(gd);
-
+
Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
layout= new GridLayout();
layout.numColumns= 2;
@@ -602,12 +597,12 @@
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
gd.horizontalSpan= 2;
editorComposite.setLayoutData(gd);
-
+
fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.heightHint= fAppearanceColorList.getItemHeight() * 8;
fAppearanceColorList.setLayoutData(gd);
-
+
Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
layout= new GridLayout();
layout.marginHeight= 0;
@@ -615,35 +610,35 @@
layout.numColumns= 2;
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
l= new Label(stylesComposite, SWT.LEFT);
l.setText(TextEditorMessages.TextEditorPreferencePage_color);
gd= new GridData();
gd.horizontalAlignment= GridData.BEGINNING;
l.setLayoutData(gd);
-
+
fAppearanceColorEditor= new ColorSelector(stylesComposite);
Button foregroundColorButton= fAppearanceColorEditor.getButton();
gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment= GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
-
+
SelectionListener colorDefaultSelectionListener= new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
boolean systemDefault= fAppearanceColorDefault.getSelection();
fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
-
+
int i= fAppearanceColorList.getSelectionIndex();
if (i == -1)
return;
-
+
String key= fAppearanceColorListModel[i][2];
if (key != null)
fOverlayStore.setValue(key, systemDefault);
}
public void widgetDefaultSelected(SelectionEvent e) {}
};
-
+
fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
fAppearanceColorDefault.setText(TextEditorMessages.TextEditorPreferencePage_systemDefault);
gd= new GridData(GridData.FILL_HORIZONTAL);
@@ -652,7 +647,7 @@
fAppearanceColorDefault.setLayoutData(gd);
fAppearanceColorDefault.setVisible(false);
fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
-
+
fAppearanceColorList.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
@@ -669,7 +664,7 @@
int i= fAppearanceColorList.getSelectionIndex();
if (i == -1)
return;
-
+
String key= fAppearanceColorListModel[i][1];
PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
index e78ea40..20cc1ce 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
@@ -120,10 +120,10 @@
NLS.initializeMessages(BUNDLE_NAME, TextEditorMessages.class);
}
- public static String TextEditorDefaultsPreferencePage_moveIntoHover;
public static String TextEditorDefaultsPreferencePage_enrichHoverMode;
public static String TextEditorDefaultsPreferencePage_enrichHover_immediately;
public static String TextEditorDefaultsPreferencePage_enrichHover_afterDelay;
+ public static String TextEditorDefaultsPreferencePage_enrichHover_disabled;
public static String TextEditorDefaultsPreferencePage_enrichHover_onClick;
public static String TextEditorDefaultsPreferencePage_range_indicator;
public static String TextEditorDefaultsPreferencePage_smartHomeEnd;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
index 0aa1742..b50155e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
@@ -28,11 +28,11 @@
TextEditorPreferencePage_findScopeColor=Find scope
TextEditorPreferencePage_accessibility_disableCustomCarets= Use &custom caret
TextEditorPreferencePage_accessibility_wideCaret= &Enable thick caret
-TextEditorDefaultsPreferencePage_moveIntoHover=Allow to mo&ve mouse into hover
-TextEditorDefaultsPreferencePage_enrichHoverMode=&Enrich hover
-TextEditorDefaultsPreferencePage_enrichHover_afterDelay=After delay
-TextEditorDefaultsPreferencePage_enrichHover_immediately=Immediately
-TextEditorDefaultsPreferencePage_enrichHover_onClick=On click
+TextEditorDefaultsPreferencePage_enrichHoverMode=When mouse mo&ved into hover:
+TextEditorDefaultsPreferencePage_enrichHover_afterDelay=Enrich after delay
+TextEditorDefaultsPreferencePage_enrichHover_disabled=Close hover
+TextEditorDefaultsPreferencePage_enrichHover_immediately=Enrich immediately
+TextEditorDefaultsPreferencePage_enrichHover_onClick=Enrich on click
TextEditorDefaultsPreferencePage_range_indicator=Show &range indicator
TextEditorDefaultsPreferencePage_warn_if_derived= War&n before editing a derived file
TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
index 377c91e..0cacbaa 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
@@ -19,13 +19,11 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
-
import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
-import org.eclipse.ui.editors.text.EditorsUI;
-
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
import org.eclipse.ui.internal.texteditor.ITextEditorThemeConstants;
import org.eclipse.ui.texteditor.spelling.SpellingService;
@@ -455,26 +453,18 @@
public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "showTextHoverAffordance"; //$NON-NLS-1$
/**
- * A named preference that defines whether hovers should stay up when the mouse is moved into them.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- *
- * @since 3.4
- */
- public static final String EDITOR_MOVE_INTO_HOVER= AbstractTextEditor.PREFERENCE_MOVE_INTO_HOVER;
-
- /**
- * A named preference that controls when hovers should be enriched once the
- * mouse is moved into them.
+ * A named preference that controls if hovers should automatically be closed
+ * when the mouse is moved into them, or when they should be enriched.
* <p>
* Value is of type <code>Integer</code> and maps to the following
* {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode}:
- * <ul>
- * <li>0: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#AFTER_DELAY}:
- * <li>1: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#IMMEDIATELY}:
- * <li>2: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#ON_CLICK}:
* </p>
+ * <ul>
+ * <li>-1: <code>null</code> (don't allow moving the mouse into a hover),</li>
+ * <li>0: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#AFTER_DELAY},</li>
+ * <li>1: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#IMMEDIATELY},</li>
+ * <li>2: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#ON_CLICK}.</li>
+ * </ul>
*
* @since 3.4
*/
@@ -591,7 +581,6 @@
store.setDefault(EDITOR_SHOW_WHITESPACE_CHARACTERS, false);
store.setDefault(EDITOR_TEXT_DRAG_AND_DROP_ENABLED, true);
store.setDefault(EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
- store.setDefault(EDITOR_MOVE_INTO_HOVER, true);
store.setDefault(EDITOR_HOVER_ENRICH_MODE, 0);
MarkerAnnotationPreferences.initializeDefaultValues(store);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 2e8aefa..e689a36 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -123,7 +123,6 @@
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.ISelectionValidator;
import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextOperationTarget;
@@ -1907,16 +1906,11 @@
if (hoverRegion == null)
return false;
- Object hoverInfo;
+ String hoverInfo= textHover.getHoverInfo(sourceViewer, hoverRegion);
+
IInformationControlCreator controlCreator= null;
- if (textHover instanceof ITextHoverExtension2) {
- hoverInfo= ((ITextHoverExtension2)textHover).getHoverInfo2(sourceViewer, hoverRegion);
- controlCreator= ((ITextHoverExtension2)textHover).getInformationPresenterControlCreator();
- } else {
- hoverInfo= textHover.getHoverInfo(sourceViewer, hoverRegion);
- if (textHover instanceof IInformationProviderExtension2) // this is wrong, but left here for backwards compatibility
- controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator();
- }
+ if (textHover instanceof IInformationProviderExtension2) // this is conceptually wrong, but left here for backwards compatibility
+ controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator();
IInformationProvider informationProvider= new InformationProvider(hoverRegion, hoverInfo, controlCreator);
@@ -2156,26 +2150,18 @@
public static final String PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED= "textDragAndDropEnabled"; //$NON-NLS-1$
/**
- * A named preference that controls whether hovers should stay up when the mouse is moved into them.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- *
- * @since 3.4
- */
- public static final String PREFERENCE_MOVE_INTO_HOVER= "moveIntoHover"; //$NON-NLS-1$
-
- /**
- * A named preference that controls when hovers should be enriched once the
- * mouse is moved into them.
+ * A named preference that controls if hovers should automatically be closed
+ * when the mouse is moved into them, or when they should be enriched.
* <p>
* Value is of type <code>Integer</code> and maps to the following
* {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode}:
- * <ul>
- * <li>0: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#AFTER_DELAY}:
- * <li>1: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#IMMEDIATELY}:
- * <li>2: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#ON_CLICK}:
* </p>
+ * <ul>
+ * <li>-1: <code>null</code> (don't allow moving the mouse into a hover),</li>
+ * <li>0: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#AFTER_DELAY},</li>
+ * <li>1: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#IMMEDIATELY},</li>
+ * <li>2: {@link org.eclipse.jface.text.ITextViewerExtension8.EnrichMode#ON_CLICK}.</li>
+ * </ul>
*
* @since 3.4
*/
@@ -3845,7 +3831,6 @@
if (fSourceViewer instanceof ITextViewerExtension8) {
IPreferenceStore store= getPreferenceStore();
- ((ITextViewerExtension8)fSourceViewer).setAllowMoveIntoHover(store != null && store.getBoolean(PREFERENCE_MOVE_INTO_HOVER));
EnrichMode mode= store != null ? convertEnrichModePreference(store.getInt(PREFERENCE_HOVER_ENRICH_MODE)) : EnrichMode.AFTER_DELAY;
((ITextViewerExtension8)fSourceViewer).setHoverEnrichMode(mode);
}
@@ -3856,11 +3841,13 @@
* {@link ITextViewerExtension8.EnrichMode}.
*
* @param mode the preference value
- * @return the enrich mode
+ * @return the enrich mode, can be <code>null</code>
* @since 3.4
*/
private EnrichMode convertEnrichModePreference(int mode) {
switch (mode) {
+ case -1:
+ return null;
case 0:
return EnrichMode.AFTER_DELAY;
case 1:
@@ -4426,14 +4413,6 @@
return;
}
- if (PREFERENCE_MOVE_INTO_HOVER.equals(property)) {
- if (fSourceViewer instanceof ITextViewerExtension8) {
- IPreferenceStore store= getPreferenceStore();
- ((ITextViewerExtension8)fSourceViewer).setAllowMoveIntoHover(store != null && store.getBoolean(PREFERENCE_MOVE_INTO_HOVER));
- }
- return;
- }
-
if (PREFERENCE_HOVER_ENRICH_MODE.equals(property)) {
if (fSourceViewer instanceof ITextViewerExtension8) {
IPreferenceStore store= getPreferenceStore();