1
0
Fork 0
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:
Anton Leherbauer 2008-05-09 11:41:44 +00:00
parent 3a389ae973
commit 73fe0cb572
8 changed files with 69 additions and 56 deletions

View file

@ -102,7 +102,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
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);
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())
setTitleText(""); //$NON-NLS-1$
setInfoText(""); // //$NON-NLS-1$
@ -452,10 +452,25 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
*/
public Rectangle computeTrim() {
Rectangle trim= getShell().computeTrim(0, 0, 0, 50);
Rectangle trim= getShell().computeTrim(0, 0, 0, 0);
addInternalTrim(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()
*/
@ -527,11 +542,4 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
return null;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
*/
public boolean allowMoveIntoControl() {
return false;
}
}

View file

@ -90,14 +90,16 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
* @param takeFocus flag indicating whether to take the focus
* @param showViewMenu flag indicating whether to show the "view" menu
* @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);
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())
setTitleText(""); //$NON-NLS-1$
setInfoText(""); // //$NON-NLS-1$
if (statusFieldText != null)
setInfoText(statusFieldText);
// Create all controls
create();
@ -554,11 +556,4 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
return null;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
*/
public boolean allowMoveIntoControl() {
return false;
}
}

View file

@ -31,6 +31,7 @@ public final class CHoverMessages extends NLS {
public static String CMacroExpansionControl_title_expansion;
public static String CMacroExpansionControl_title_fullyExpanded;
public static String CMacroExpansionControl_title_macroExpansion;
public static String CMacroExpansionControl_title_macroExpansionExploration;
public static String CMacroExpansionControl_title_original;
public static String CMacroExpansionInput_jobTitle;

View file

@ -19,6 +19,7 @@ CMacroExpansionControl_statusText=Press {0} or {1} to step through macro expansi
CMacroExpansionControl_title_expansion=Expansion \#{0} of {1}
CMacroExpansionControl_title_fullyExpanded=Fully Expanded
CMacroExpansionControl_title_macroExpansion=Macro Expansion
CMacroExpansionControl_title_macroExpansionExploration=Explore Macro Expansion ({0} steps)
CMacroExpansionControl_title_original=Original
CMacroExpansionInput_jobTitle= Computing Macro Expansion

View file

@ -8,7 +8,6 @@
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.c.hover;
import org.eclipse.jface.dialogs.PopupDialog;
@ -26,6 +25,8 @@ import org.eclipse.cdt.internal.ui.text.AbstractSourceViewerInformationControl;
*/
public class CMacroExpansionControl extends AbstractSourceViewerInformationControl {
private CMacroExpansionInput fInput;
/**
* 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>
*/
public CMacroExpansionControl(Shell parent, String statusFieldText) {
super(parent, PopupDialog.HOVER_SHELLSTYLE, SWT.NONE, false, false, false);
if (statusFieldText != null) {
setInfoText(statusFieldText);
}
super(parent, PopupDialog.HOVER_SHELLSTYLE, SWT.NONE, false, false, false, statusFieldText);
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
}
/**
* 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);
}
@ -64,6 +73,7 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
if (input instanceof CMacroExpansionInput) {
CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
fInput= macroExpansionInput;
} else {
super.setInput(input);
}
@ -76,16 +86,12 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
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;
}
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.c.hover;
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>.
*
* @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;
if (formattedBindingBack != null && formattedBindingForward != null) {
infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
}
return infoText;
}
@ -358,10 +357,24 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
@Override
public Rectangle computeTrim() {
Rectangle trim= super.computeTrim();
trim.height += fMacroText.getLineHeight();
addInternalTrim(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.
* @param input
@ -396,7 +409,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
final ITypedElement left= getContentForIndex(fIndex, true);
final ITypedElement right= getContentForIndex(fIndex, false);
setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
setTitleText(CHoverMessages.bind(CHoverMessages.CMacroExpansionControl_title_macroExpansionExploration, getStepCount()));
fMacroViewer.getDocument().set(getMacroText(fIndex));
setInput(createCompareInput(null, left, right));
}
@ -405,7 +418,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
if (index == 0) {
return CHoverMessages.CMacroExpansionControl_title_original;
} else if (index < getStepCount()) {
return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
String.valueOf(index), String.valueOf(getStepCount()));
} else {
return CHoverMessages.CMacroExpansionControl_title_fullyExpanded;

View file

@ -8,7 +8,6 @@
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.c.hover;
import java.lang.ref.Reference;

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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;
/**
* SourceViewerInformationControl
* Source viewer based implementation of <code>IInformationControl</code>.
* Displays information in a source viewer.
*
@ -109,15 +108,15 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
private boolean fIsSystemBackgroundColor= true;
/**
* Creates a default 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.
* Creates a source viewer information control with the given shell as parent. The given
* styles are applied to the created styled text widget. The status field will
* contain the given text or be hidden.
*
* @param parent the parent shell
* @param isResizable <code>true</code> if resizable
* @param orientation the orientation
* @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) {
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()
*/
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);
}
/*
* 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;
}
}