mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 223250: Macro expansion hover only displays _very_ briefly
This commit is contained in:
parent
e2b4a4cf52
commit
e8c27d5cae
3 changed files with 65 additions and 52 deletions
|
@ -93,7 +93,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
|
||||||
* @param persistBounds flag indicating whether control size and location should be persisted
|
* @param persistBounds flag indicating whether control size and location should be persisted
|
||||||
*/
|
*/
|
||||||
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, takeFocus, persistBounds, showViewMenu, false, null, null);
|
super(parent, shellStyle | SWT.ON_TOP, takeFocus, 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())
|
||||||
|
@ -393,7 +393,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean isFocusControl() {
|
public boolean isFocusControl() {
|
||||||
return fCompareViewerControl.isFocusControl();
|
return fCompareViewerControl != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
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.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ 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, SWT.NO_TRIM | SWT.TOOL, SWT.NONE, false, false, false);
|
super(parent, PopupDialog.HOVER_SHELLSTYLE, SWT.NONE, false, false, false);
|
||||||
if (statusFieldText != null) {
|
if (statusFieldText != null) {
|
||||||
setInfoText(statusFieldText);
|
setInfoText(statusFieldText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.eclipse.swt.graphics.Font;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.text.edits.ReplaceEdit;
|
import org.eclipse.text.edits.ReplaceEdit;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
@ -50,6 +52,7 @@ import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.contexts.IContextActivation;
|
import org.eclipse.ui.contexts.IContextActivation;
|
||||||
import org.eclipse.ui.contexts.IContextService;
|
import org.eclipse.ui.contexts.IContextService;
|
||||||
|
import org.eclipse.ui.handlers.IHandlerActivation;
|
||||||
import org.eclipse.ui.handlers.IHandlerService;
|
import org.eclipse.ui.handlers.IHandlerService;
|
||||||
import org.eclipse.ui.keys.IBindingService;
|
import org.eclipse.ui.keys.IBindingService;
|
||||||
import org.eclipse.ui.menus.CommandContributionItem;
|
import org.eclipse.ui.menus.CommandContributionItem;
|
||||||
|
@ -100,7 +103,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
private IHandlerService fHandlerService;
|
private IHandlerService fHandlerService;
|
||||||
private Collection fHandlerActivations;
|
private Collection<IHandlerActivation> fHandlerActivations;
|
||||||
private IContextService fContextService;
|
private IContextService fContextService;
|
||||||
private IContextActivation fContextActivation;
|
private IContextActivation fContextActivation;
|
||||||
private int fIndex;
|
private int fIndex;
|
||||||
|
@ -186,13 +189,34 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
return sourceViewer;
|
return sourceViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.dialogs.PopupDialog#open()
|
|
||||||
*/
|
|
||||||
public int open() {
|
|
||||||
int result= super.open();
|
|
||||||
|
|
||||||
if (fInput != null) {
|
@Override
|
||||||
|
public int open() {
|
||||||
|
getShell().addListener(SWT.Activate, new Listener() {
|
||||||
|
public void handleEvent(Event arg0) {
|
||||||
|
registerCommandHandlers();
|
||||||
|
}});
|
||||||
|
getShell().addListener(SWT.Deactivate, new Listener() {
|
||||||
|
public void handleEvent(Event arg0) {
|
||||||
|
unregisterCommandHandlers();
|
||||||
|
}});
|
||||||
|
|
||||||
|
return super.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unregisterCommandHandlers() {
|
||||||
|
if (fHandlerService != null) {
|
||||||
|
fHandlerService.deactivateHandlers(fHandlerActivations);
|
||||||
|
fHandlerActivations.clear();
|
||||||
|
fHandlerService= null;
|
||||||
|
}
|
||||||
|
if (fContextActivation != null) {
|
||||||
|
fContextService.deactivateContext(fContextActivation);
|
||||||
|
fContextActivation= null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void registerCommandHandlers() {
|
||||||
IHandler backwardHandler= new AbstractHandler() {
|
IHandler backwardHandler= new AbstractHandler() {
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
backward();
|
backward();
|
||||||
|
@ -212,12 +236,11 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
IWorkbench workbench= PlatformUI.getWorkbench();
|
IWorkbench workbench= PlatformUI.getWorkbench();
|
||||||
fHandlerService= (IHandlerService) workbench.getService(IHandlerService.class);
|
fHandlerService= (IHandlerService) workbench.getService(IHandlerService.class);
|
||||||
fContextService= (IContextService) workbench.getService(IContextService.class);
|
fContextService= (IContextService) workbench.getService(IContextService.class);
|
||||||
fContextActivation= fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
|
fContextActivation= fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
|
||||||
fHandlerActivations= new ArrayList();
|
fHandlerActivations= new ArrayList<IHandlerActivation>();
|
||||||
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
|
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
|
||||||
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
|
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
|
||||||
fHandlerActivations.add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
|
fHandlerActivations.add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
|
||||||
|
@ -228,9 +251,6 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.AbstractCompareViewerInformationControl#fillViewMenu(org.eclipse.jface.action.IMenuManager)
|
* @see org.eclipse.cdt.internal.ui.text.AbstractCompareViewerInformationControl#fillViewMenu(org.eclipse.jface.action.IMenuManager)
|
||||||
*/
|
*/
|
||||||
|
@ -302,14 +322,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
* @see org.eclipse.jface.dialogs.PopupDialog#close()
|
* @see org.eclipse.jface.dialogs.PopupDialog#close()
|
||||||
*/
|
*/
|
||||||
public boolean close() {
|
public boolean close() {
|
||||||
if (fHandlerService != null) {
|
unregisterCommandHandlers();
|
||||||
fHandlerService.deactivateHandlers(fHandlerActivations);
|
|
||||||
fHandlerActivations.clear();
|
|
||||||
fHandlerService= null;
|
|
||||||
}
|
|
||||||
if (fContextActivation != null) {
|
|
||||||
fContextService.deactivateContext(fContextActivation);
|
|
||||||
}
|
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,5 +457,4 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue