mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix hover move-into behaviour
This commit is contained in:
parent
3a389ae973
commit
73fe0cb572
8 changed files with 69 additions and 56 deletions
|
@ -102,7 +102,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
|
||||||
public AbstractCompareViewerInformationControl(Shell parent, int shellStyle, int textStyle, boolean takeFocus, boolean showViewMenu, boolean persistBounds) {
|
public AbstractCompareViewerInformationControl(Shell parent, int shellStyle, int textStyle, boolean takeFocus, boolean showViewMenu, boolean persistBounds) {
|
||||||
super(parent, shellStyle | SWT.ON_TOP, takeFocus, persistBounds, persistBounds, showViewMenu, false, null, null);
|
super(parent, shellStyle | SWT.ON_TOP, takeFocus, persistBounds, persistBounds, showViewMenu, false, null, null);
|
||||||
fStyle= textStyle & ~(SWT.V_SCROLL | SWT.H_SCROLL);
|
fStyle= textStyle & ~(SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
// Title and status text must be set to get the title label created, so force empty values here.
|
// Title and status text must be set to get the title label created, so force empty values here.
|
||||||
if (hasHeader())
|
if (hasHeader())
|
||||||
setTitleText(""); //$NON-NLS-1$
|
setTitleText(""); //$NON-NLS-1$
|
||||||
setInfoText(""); // //$NON-NLS-1$
|
setInfoText(""); // //$NON-NLS-1$
|
||||||
|
@ -452,10 +452,25 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
|
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
|
||||||
*/
|
*/
|
||||||
public Rectangle computeTrim() {
|
public Rectangle computeTrim() {
|
||||||
Rectangle trim= getShell().computeTrim(0, 0, 0, 50);
|
Rectangle trim= getShell().computeTrim(0, 0, 0, 0);
|
||||||
|
addInternalTrim(trim);
|
||||||
return trim;
|
return trim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the internal trimmings to the given trim of the shell.
|
||||||
|
*
|
||||||
|
* @param trim the shell's trim, will be updated
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
private void addInternalTrim(Rectangle trim) {
|
||||||
|
Rectangle textTrim= fCompareViewerControl.computeTrim(0, 0, 0, 0);
|
||||||
|
trim.x+= textTrim.x;
|
||||||
|
trim.y+= textTrim.y;
|
||||||
|
trim.width+= textTrim.width;
|
||||||
|
trim.height+= textTrim.height;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
|
* @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
|
||||||
*/
|
*/
|
||||||
|
@ -527,11 +542,4 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
|
|
||||||
*/
|
|
||||||
public boolean allowMoveIntoControl() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,14 +90,16 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
|
||||||
* @param takeFocus flag indicating whether to take the focus
|
* @param takeFocus flag indicating whether to take the focus
|
||||||
* @param showViewMenu flag indicating whether to show the "view" menu
|
* @param showViewMenu flag indicating whether to show the "view" menu
|
||||||
* @param persistBounds flag indicating whether control size and location should be persisted
|
* @param persistBounds flag indicating whether control size and location should be persisted
|
||||||
|
* @param statusFieldText
|
||||||
*/
|
*/
|
||||||
public AbstractSourceViewerInformationControl(Shell parent, int shellStyle, int textStyle, boolean takeFocus, boolean showViewMenu, boolean persistBounds) {
|
public AbstractSourceViewerInformationControl(Shell parent, int shellStyle, int textStyle, boolean takeFocus, boolean showViewMenu, boolean persistBounds, String statusFieldText) {
|
||||||
super(parent, shellStyle, takeFocus, persistBounds, persistBounds, showViewMenu, false, null, null);
|
super(parent, shellStyle, takeFocus, persistBounds, persistBounds, showViewMenu, false, null, null);
|
||||||
fTextStyle= textStyle;
|
fTextStyle= textStyle;
|
||||||
// Title and status text must be set to get the title label created, so force empty values here.
|
// Title and status text must be set to get the title label created, so force empty values here.
|
||||||
if (hasHeader())
|
if (hasHeader())
|
||||||
setTitleText(""); //$NON-NLS-1$
|
setTitleText(""); //$NON-NLS-1$
|
||||||
setInfoText(""); // //$NON-NLS-1$
|
if (statusFieldText != null)
|
||||||
|
setInfoText(statusFieldText);
|
||||||
|
|
||||||
// Create all controls
|
// Create all controls
|
||||||
create();
|
create();
|
||||||
|
@ -554,11 +556,4 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
|
|
||||||
*/
|
|
||||||
public boolean allowMoveIntoControl() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public final class CHoverMessages extends NLS {
|
||||||
public static String CMacroExpansionControl_title_expansion;
|
public static String CMacroExpansionControl_title_expansion;
|
||||||
public static String CMacroExpansionControl_title_fullyExpanded;
|
public static String CMacroExpansionControl_title_fullyExpanded;
|
||||||
public static String CMacroExpansionControl_title_macroExpansion;
|
public static String CMacroExpansionControl_title_macroExpansion;
|
||||||
|
public static String CMacroExpansionControl_title_macroExpansionExploration;
|
||||||
public static String CMacroExpansionControl_title_original;
|
public static String CMacroExpansionControl_title_original;
|
||||||
|
|
||||||
public static String CMacroExpansionInput_jobTitle;
|
public static String CMacroExpansionInput_jobTitle;
|
||||||
|
|
|
@ -19,6 +19,7 @@ CMacroExpansionControl_statusText=Press {0} or {1} to step through macro expansi
|
||||||
CMacroExpansionControl_title_expansion=Expansion \#{0} of {1}
|
CMacroExpansionControl_title_expansion=Expansion \#{0} of {1}
|
||||||
CMacroExpansionControl_title_fullyExpanded=Fully Expanded
|
CMacroExpansionControl_title_fullyExpanded=Fully Expanded
|
||||||
CMacroExpansionControl_title_macroExpansion=Macro Expansion
|
CMacroExpansionControl_title_macroExpansion=Macro Expansion
|
||||||
|
CMacroExpansionControl_title_macroExpansionExploration=Explore Macro Expansion ({0} steps)
|
||||||
CMacroExpansionControl_title_original=Original
|
CMacroExpansionControl_title_original=Original
|
||||||
|
|
||||||
CMacroExpansionInput_jobTitle= Computing Macro Expansion
|
CMacroExpansionInput_jobTitle= Computing Macro Expansion
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.PopupDialog;
|
import org.eclipse.jface.dialogs.PopupDialog;
|
||||||
|
@ -26,6 +25,8 @@ import org.eclipse.cdt.internal.ui.text.AbstractSourceViewerInformationControl;
|
||||||
*/
|
*/
|
||||||
public class CMacroExpansionControl extends AbstractSourceViewerInformationControl {
|
public class CMacroExpansionControl extends AbstractSourceViewerInformationControl {
|
||||||
|
|
||||||
|
private CMacroExpansionInput fInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new control for use as a hover which does not take the focus.
|
* Creates a new control for use as a hover which does not take the focus.
|
||||||
*
|
*
|
||||||
|
@ -33,10 +34,18 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
|
||||||
* @param statusFieldText text to be displayed in the status field, may be <code>null</code>
|
* @param statusFieldText text to be displayed in the status field, may be <code>null</code>
|
||||||
*/
|
*/
|
||||||
public CMacroExpansionControl(Shell parent, String statusFieldText) {
|
public CMacroExpansionControl(Shell parent, String statusFieldText) {
|
||||||
super(parent, PopupDialog.HOVER_SHELLSTYLE, SWT.NONE, false, false, false);
|
super(parent, PopupDialog.HOVER_SHELLSTYLE, SWT.NONE, false, false, false, statusFieldText);
|
||||||
if (statusFieldText != null) {
|
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
|
||||||
setInfoText(statusFieldText);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Creates a new control for use as a hover which optionally takes the focus.
|
||||||
|
*
|
||||||
|
* @param parent parent shell
|
||||||
|
* @param takeFocus whether this control should take the focus
|
||||||
|
*/
|
||||||
|
public CMacroExpansionControl(Shell parent, boolean takeFocus) {
|
||||||
|
super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, SWT.NONE, takeFocus, false, false, null);
|
||||||
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
|
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +73,7 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
|
||||||
if (input instanceof CMacroExpansionInput) {
|
if (input instanceof CMacroExpansionInput) {
|
||||||
CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
|
CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
|
||||||
setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
|
setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
|
||||||
|
fInput= macroExpansionInput;
|
||||||
} else {
|
} else {
|
||||||
super.setInput(input);
|
super.setInput(input);
|
||||||
}
|
}
|
||||||
|
@ -76,16 +86,12 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
return new IInformationControlCreator() {
|
return new IInformationControlCreator() {
|
||||||
public IInformationControl createInformationControl(Shell parent) {
|
public IInformationControl createInformationControl(Shell parent) {
|
||||||
return new CMacroExpansionExplorationControl(parent);
|
if (fInput != null && fInput.fExplorer.getExpansionStepCount() > 1) {
|
||||||
|
return new CMacroExpansionExplorationControl(parent);
|
||||||
|
} else {
|
||||||
|
return new CMacroExpansionControl(parent, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.ui.text.AbstractSourceViewerInformationControl#allowMoveIntoControl()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean allowMoveIntoControl() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -302,7 +301,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the text to be shown in the popups's information area.
|
* Returns the text to be shown in the popups's information area.
|
||||||
* May return <code>null</code>.
|
* May return <code>null</code>.
|
||||||
*
|
*
|
||||||
* @return The text to be shown in the popup's information area or <code>null</code>
|
* @return The text to be shown in the popup's information area or <code>null</code>
|
||||||
|
@ -315,7 +314,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
|
|
||||||
String infoText= null;
|
String infoText= null;
|
||||||
if (formattedBindingBack != null && formattedBindingForward != null) {
|
if (formattedBindingBack != null && formattedBindingForward != null) {
|
||||||
infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
|
infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
|
||||||
}
|
}
|
||||||
return infoText;
|
return infoText;
|
||||||
}
|
}
|
||||||
|
@ -358,10 +357,24 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
@Override
|
@Override
|
||||||
public Rectangle computeTrim() {
|
public Rectangle computeTrim() {
|
||||||
Rectangle trim= super.computeTrim();
|
Rectangle trim= super.computeTrim();
|
||||||
trim.height += fMacroText.getLineHeight();
|
addInternalTrim(trim);
|
||||||
return trim;
|
return trim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the internal trimmings to the given trim of the shell.
|
||||||
|
*
|
||||||
|
* @param trim the shell's trim, will be updated
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
private void addInternalTrim(Rectangle trim) {
|
||||||
|
Rectangle textTrim= fMacroText.computeTrim(0, 0, 0, 0);
|
||||||
|
trim.x+= textTrim.x;
|
||||||
|
trim.y+= textTrim.y;
|
||||||
|
trim.width+= textTrim.width;
|
||||||
|
trim.height+= textTrim.height;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the input for this information control.
|
* Set the input for this information control.
|
||||||
* @param input
|
* @param input
|
||||||
|
@ -396,7 +409,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
final ITypedElement left= getContentForIndex(fIndex, true);
|
final ITypedElement left= getContentForIndex(fIndex, true);
|
||||||
final ITypedElement right= getContentForIndex(fIndex, false);
|
final ITypedElement right= getContentForIndex(fIndex, false);
|
||||||
|
|
||||||
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
|
setTitleText(CHoverMessages.bind(CHoverMessages.CMacroExpansionControl_title_macroExpansionExploration, getStepCount()));
|
||||||
fMacroViewer.getDocument().set(getMacroText(fIndex));
|
fMacroViewer.getDocument().set(getMacroText(fIndex));
|
||||||
setInput(createCompareInput(null, left, right));
|
setInput(createCompareInput(null, left, right));
|
||||||
}
|
}
|
||||||
|
@ -405,7 +418,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return CHoverMessages.CMacroExpansionControl_title_original;
|
return CHoverMessages.CMacroExpansionControl_title_original;
|
||||||
} else if (index < getStepCount()) {
|
} else if (index < getStepCount()) {
|
||||||
return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
|
return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
|
||||||
String.valueOf(index), String.valueOf(getStepCount()));
|
String.valueOf(index), String.valueOf(getStepCount()));
|
||||||
} else {
|
} else {
|
||||||
return CHoverMessages.CMacroExpansionControl_title_fullyExpanded;
|
return CHoverMessages.CMacroExpansionControl_title_fullyExpanded;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 QNX Software Systems and others.
|
* Copyright (c) 2002, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -56,7 +56,6 @@ import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||||
import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
|
import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SourceViewerInformationControl
|
|
||||||
* Source viewer based implementation of <code>IInformationControl</code>.
|
* Source viewer based implementation of <code>IInformationControl</code>.
|
||||||
* Displays information in a source viewer.
|
* Displays information in a source viewer.
|
||||||
*
|
*
|
||||||
|
@ -109,15 +108,15 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
||||||
private boolean fIsSystemBackgroundColor= true;
|
private boolean fIsSystemBackgroundColor= true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default information control with the given shell as parent. The given
|
* Creates a source viewer information control with the given shell as parent. The given
|
||||||
* information presenter is used to process the information to be displayed. The given
|
* styles are applied to the created styled text widget. The status field will
|
||||||
* styles are applied to the created styled text widget.
|
* contain the given text or be hidden.
|
||||||
*
|
*
|
||||||
* @param parent the parent shell
|
* @param parent the parent shell
|
||||||
* @param isResizable <code>true</code> if resizable
|
* @param isResizable <code>true</code> if resizable
|
||||||
* @param orientation the orientation
|
* @param orientation the orientation
|
||||||
* @param statusFieldText the text to be used in the optional status field
|
* @param statusFieldText the text to be used in the optional status field
|
||||||
* or <code>null</code> if the status field should be hidden
|
* or <code>null</code> if the status field should be hidden
|
||||||
*/
|
*/
|
||||||
public SourceViewerInformationControl(Shell parent, boolean isResizable, int orientation, String statusFieldText) {
|
public SourceViewerInformationControl(Shell parent, boolean isResizable, int orientation, String statusFieldText) {
|
||||||
Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT || orientation == SWT.NONE);
|
Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT || orientation == SWT.NONE);
|
||||||
|
@ -367,7 +366,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
||||||
* @see IInformationControl#isFocusControl()
|
* @see IInformationControl#isFocusControl()
|
||||||
*/
|
*/
|
||||||
public boolean isFocusControl() {
|
public boolean isFocusControl() {
|
||||||
return fText.isFocusControl();
|
return fShell.getDisplay().getActiveShell() == fShell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -504,13 +503,4 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
|
||||||
|
|
||||||
return new Point(widthInChars * width, heightInChars * height);
|
return new Point(widthInChars * width, heightInChars * height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This method has been removed from IInformationControlExtension5 in 3.4 M6.
|
|
||||||
* TODO Remove this method. Just kept to stay compilable against 3.4 M5.
|
|
||||||
*/
|
|
||||||
public boolean allowMoveIntoControl() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue