1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 223987: CDT doesn't build with SDK 3.4 M6

This commit is contained in:
Anton Leherbauer 2008-03-26 16:19:44 +00:00
parent 212e5595fb
commit 486ed39667
15 changed files with 437 additions and 147 deletions

View file

@ -2515,7 +2515,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.search.results"); //$NON-NLS-1$ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.search.results"); //$NON-NLS-1$
fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell shell) { public IInformationControl createInformationControl(Shell shell) {
return new SourceViewerInformationControl(shell, SWT.TOOL | SWT.NO_TRIM | getOrientation(), SWT.NONE); return new SourceViewerInformationControl(shell, false, getOrientation(), null);
} }
}); });
fProjectionSupport.install(); fProjectionSupport.install();

View file

@ -18,9 +18,14 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IInformationControlExtension; import org.eclipse.jface.text.IInformationControlExtension;
import org.eclipse.jface.text.IInformationControlExtension2; import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.IInformationControlExtension3;
import org.eclipse.jface.text.IInformationControlExtension4;
import org.eclipse.jface.text.IInformationControlExtension5;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ViewForm; import org.eclipse.swt.custom.ViewForm;
@ -30,6 +35,8 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
@ -45,7 +52,7 @@ import org.eclipse.cdt.ui.PreferenceConstants;
* *
* @since 5.0 * @since 5.0
*/ */
public abstract class AbstractCompareViewerInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener { public abstract class AbstractCompareViewerInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5, DisposeListener {
protected class CompareViewerControl extends ViewForm { protected class CompareViewerControl extends ViewForm {
private CompareConfiguration fCompareConfiguration; private CompareConfiguration fCompareConfiguration;
@ -281,7 +288,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
} }
protected Point getInitialLocation(Point initialSize) { protected Point getInitialLocation(Point initialSize) {
if (!getPersistBounds()) { if (!restoresSize()) {
Point size = new Point(400, 400); Point size = new Point(400, 400);
Rectangle parentBounds = getParentShell().getBounds(); Rectangle parentBounds = getParentShell().getBounds();
int x = parentBounds.x + parentBounds.width / 2 - size.x / 2; int x = parentBounds.x + parentBounds.width / 2 - size.x / 2;
@ -341,7 +348,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
* {@inheritDoc} * {@inheritDoc}
*/ */
public void setLocation(Point location) { public void setLocation(Point location) {
if (!getPersistBounds() || getDialogSettings() == null || fUseDefaultBounds) if (!restoresLocation() || getDialogSettings() == null || fUseDefaultBounds)
getShell().setLocation(location); getShell().setLocation(location);
} }
@ -349,7 +356,7 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
* {@inheritDoc} * {@inheritDoc}
*/ */
public void setSize(int width, int height) { public void setSize(int width, int height) {
if (!getPersistBounds() || getDialogSettings() == null || fUseDefaultBounds) { if (!restoresSize() || getDialogSettings() == null || fUseDefaultBounds) {
getShell().setSize(width, height); getShell().setSize(width, height);
} }
} }
@ -433,4 +440,93 @@ public abstract class AbstractCompareViewerInformationControl extends PopupDialo
} }
return settings; return settings;
} }
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
*/
public Rectangle computeTrim() {
Rectangle trim= getShell().computeTrim(0, 0, 0, 50);
return trim;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
*/
public Rectangle getBounds() {
return getShell().getBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
*/
public boolean restoresLocation() {
// return getPersistLocation();
return getPersistBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
*/
public boolean restoresSize() {
// return getPersistSize();
return getPersistBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension4#setStatusText(java.lang.String)
*/
public void setStatusText(String statusFieldText) {
setInfoText(statusFieldText);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int)
*/
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
GC gc= new GC(fCompareViewerControl);
gc.setFont(font);
int width= gc.getFontMetrics().getAverageCharWidth();
int height= gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
*/
public boolean containsControl(Control control) {
do {
if (control == getShell())
return true;
if (control instanceof Shell)
return false;
control= control.getParent();
} while (control != null);
return false;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#isVisible()
*/
public boolean isVisible() {
Shell shell= getShell();
return shell != null && !shell.isDisposed() && shell.isVisible();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return null;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
*/
public boolean allowMoveIntoControl() {
return false;
}
} }

View file

@ -23,8 +23,12 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IInformationControlExtension; import org.eclipse.jface.text.IInformationControlExtension;
import org.eclipse.jface.text.IInformationControlExtension2; import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.IInformationControlExtension3;
import org.eclipse.jface.text.IInformationControlExtension4;
import org.eclipse.jface.text.IInformationControlExtension5;
import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
@ -37,6 +41,7 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
@ -56,7 +61,7 @@ import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
* *
* @since 5.0 * @since 5.0
*/ */
public abstract class AbstractSourceViewerInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener { public abstract class AbstractSourceViewerInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5, DisposeListener {
private int fTextStyle; private int fTextStyle;
@ -70,7 +75,11 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
private int fMaxHeight; private int fMaxHeight;
private List fColorExclusionControls= new ArrayList(); private List<Control> fColorExclusionControls= new ArrayList<Control>();
private Font fTextFont;
private StyledText fText;
/** /**
* Creates a source viewer information control with the given shell as parent. The given * Creates a source viewer information control with the given shell as parent. The given
@ -118,8 +127,8 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
*/ */
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
Control contents= super.createContents(parent); Control contents= super.createContents(parent);
for (Iterator it= fColorExclusionControls.iterator(); it.hasNext(); ) { for (Iterator<Control> it= fColorExclusionControls.iterator(); it.hasNext(); ) {
Control ctrl = (Control) it.next(); Control ctrl = it.next();
ctrl.setBackground(fBackgroundColor); ctrl.setBackground(fBackgroundColor);
} }
return contents; return contents;
@ -150,23 +159,23 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
return ((Viewer)fSourceViewer).getControl(); return ((Viewer)fSourceViewer).getControl();
} }
protected ISourceViewer createSourceViewer(Composite parent, int style) { protected final ISourceViewer createSourceViewer(Composite parent, int style) {
IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store); SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store);
CTextTools tools= CUIPlugin.getDefault().getTextTools(); CTextTools tools= CUIPlugin.getDefault().getTextTools();
sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false)); sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
sourceViewer.setEditable(false); sourceViewer.setEditable(false);
StyledText styledText= sourceViewer.getTextWidget(); fText= sourceViewer.getTextWidget();
GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
styledText.setLayoutData(gd); fText.setLayoutData(gd);
initializeColors(); initializeColors();
styledText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
styledText.setBackground(fBackgroundColor); fText.setBackground(fBackgroundColor);
fColorExclusionControls.add(styledText); fColorExclusionControls.add(fText);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
styledText.setFont(font); fText.setFont(fTextFont);
return sourceViewer; return sourceViewer;
} }
@ -192,8 +201,8 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
/* /*
* @see org.eclipse.jface.dialogs.PopupDialog#getBackgroundColorExclusions() * @see org.eclipse.jface.dialogs.PopupDialog#getBackgroundColorExclusions()
*/ */
protected List getBackgroundColorExclusions() { protected List<Control> getBackgroundColorExclusions() {
List exclusions= super.getBackgroundColorExclusions(); List<Control> exclusions= super.getBackgroundColorExclusions();
exclusions.addAll(fColorExclusionControls); exclusions.addAll(fColorExclusionControls);
return exclusions; return exclusions;
} }
@ -201,8 +210,8 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
/* /*
* @see org.eclipse.jface.dialogs.PopupDialog#getForegroundColorExclusions() * @see org.eclipse.jface.dialogs.PopupDialog#getForegroundColorExclusions()
*/ */
protected List getForegroundColorExclusions() { protected List<Control> getForegroundColorExclusions() {
List exclusions= super.getForegroundColorExclusions(); List<Control> exclusions= super.getForegroundColorExclusions();
exclusions.addAll(fColorExclusionControls); exclusions.addAll(fColorExclusionControls);
return exclusions; return exclusions;
} }
@ -305,7 +314,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
} }
protected Point getInitialLocation(Point initialSize) { protected Point getInitialLocation(Point initialSize) {
if (!getPersistBounds()) { if (!restoresLocation()) {
Point size = new Point(400, 400); Point size = new Point(400, 400);
Rectangle parentBounds = getParentShell().getBounds(); Rectangle parentBounds = getParentShell().getBounds();
int x = parentBounds.x + parentBounds.width / 2 - size.x / 2; int x = parentBounds.x + parentBounds.width / 2 - size.x / 2;
@ -366,7 +375,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
* {@inheritDoc} * {@inheritDoc}
*/ */
public void setLocation(Point location) { public void setLocation(Point location) {
if (!getPersistBounds() || getDialogSettings() == null) if (!restoresLocation() || getDialogSettings() == null)
getShell().setLocation(location); getShell().setLocation(location);
} }
@ -374,7 +383,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
* {@inheritDoc} * {@inheritDoc}
*/ */
public void setSize(int width, int height) { public void setSize(int width, int height) {
if (!getPersistBounds() || getDialogSettings() == null) { if (!restoresSize() || getDialogSettings() == null) {
getShell().setSize(width, height); getShell().setSize(width, height);
} }
} }
@ -457,4 +466,91 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
return settings; return settings;
} }
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
*/
public Rectangle computeTrim() {
return getShell().computeTrim(0, 0, 0, 0);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
*/
public Rectangle getBounds() {
return getShell().getBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
*/
public boolean restoresLocation() {
// return getPersistLocation();
return getPersistBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
*/
public boolean restoresSize() {
// return getPersistSize();
return getPersistBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension4#setStatusText(java.lang.String)
*/
public void setStatusText(String statusFieldText) {
setInfoText(statusFieldText);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int)
*/
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
GC gc= new GC(fText);
gc.setFont(fTextFont);
int width= gc.getFontMetrics().getAverageCharWidth();
int height= gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
*/
public boolean containsControl(Control control) {
do {
if (control == getShell())
return true;
if (control instanceof Shell)
return false;
control= control.getParent();
} while (control != null);
return false;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#isVisible()
*/
public boolean isVisible() {
Shell shell= getShell();
return shell != null && !shell.isDisposed() && shell.isVisible();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return null;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
*/
public boolean allowMoveIntoControl() {
return false;
}
} }

View file

@ -929,9 +929,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
private IInformationControlCreator getMacroExplorationControlCreator() { private IInformationControlCreator getMacroExplorationControlCreator() {
final IInformationControlCreator conrolCreator = new IInformationControlCreator() { final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) { public IInformationControl createInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE; return new CMacroExpansionExplorationControl(parent);
int textStyle= SWT.V_SCROLL | SWT.H_SCROLL;
return new CMacroExpansionExplorationControl(parent, shellStyle, textStyle);
} }
}; };
return conrolCreator; return conrolCreator;

View file

@ -21,6 +21,7 @@ import org.eclipse.jface.text.ITextHoverExtension;
import org.eclipse.jface.text.ITextHoverExtension2; import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region; import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -37,7 +38,7 @@ import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
* elements. * elements.
* *
*/ */
public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2 { public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
private IEditorPart fEditor; private IEditorPart fEditor;

View file

@ -157,8 +157,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
* @since 3.0 * @since 3.0
*/ */
public IInformationControlCreator getInformationPresenterControlCreator() { public IInformationControlCreator getInformationPresenterControlCreator() {
if (fBestHover instanceof ITextHoverExtension2) // this is wrong, but left here for backwards compatibility
return ((ITextHoverExtension2)fBestHover).getInformationPresenterControlCreator();
if (fBestHover instanceof IInformationProviderExtension2) if (fBestHover instanceof IInformationProviderExtension2)
return ((IInformationProviderExtension2)fBestHover).getInformationPresenterControlCreator(); return ((IInformationProviderExtension2)fBestHover).getInformationPresenterControlCreator();

View file

@ -118,9 +118,8 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
*/ */
public IInformationControlCreator getInformationPresenterControlCreator() { public IInformationControlCreator getInformationPresenterControlCreator() {
if (ensureHoverCreated()) { if (ensureHoverCreated()) {
if (fHover instanceof ITextHoverExtension2) // this is wrong, but left here for backwards compatibility
return ((ITextHoverExtension2) fHover).getInformationPresenterControlCreator(); if (fHover instanceof IInformationProviderExtension2)
if (fHover instanceof IInformationProviderExtension2) // this is wrong, but left here for backwards compatibility
return ((IInformationProviderExtension2) fHover).getInformationPresenterControlCreator(); return ((IInformationProviderExtension2) fHover).getInformationPresenterControlCreator();
} }
return null; return null;

View file

@ -16,11 +16,9 @@ import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.information.IInformationProvider; import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension2; import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPartListener;
@ -29,8 +27,6 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
/** /**
* Provides information for the current word under the cursor based on the documentation hover. * Provides information for the current word under the cursor based on the documentation hover.
@ -45,9 +41,7 @@ public class CInformationProvider implements IInformationProvider, IInformationP
*/ */
private static final class ControlCreator extends AbstractReusableInformationControlCreator { private static final class ControlCreator extends AbstractReusableInformationControlCreator {
public IInformationControl doCreateInformationControl(Shell parent) { public IInformationControl doCreateInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE | SWT.TOOL; return new DefaultInformationControl(parent);
int style= SWT.V_SCROLL | SWT.H_SCROLL;
return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
} }
} }
@ -123,10 +117,6 @@ public class CInformationProvider implements IInformationProvider, IInformationP
* @see IInformationProviderExtension2#getInformationPresenterControlCreator() * @see IInformationProviderExtension2#getInformationPresenterControlCreator()
*/ */
public IInformationControlCreator getInformationPresenterControlCreator() { public IInformationControlCreator getInformationPresenterControlCreator() {
if (fImplementation instanceof ITextHoverExtension2) {
ITextHoverExtension2 ext2= (ITextHoverExtension2) fImplementation;
return ext2.getInformationPresenterControlCreator();
}
if (fPresenterControlCreator == null) if (fPresenterControlCreator == null)
fPresenterControlCreator= new ControlCreator(); fPresenterControlCreator= new ControlCreator();
return fPresenterControlCreator; return fPresenterControlCreator;

View file

@ -12,6 +12,8 @@
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;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -58,9 +60,29 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
@Override @Override
public void setInput(Object input) { public void setInput(Object input) {
if (input instanceof CMacroExpansionInput) { if (input instanceof CMacroExpansionInput) {
setInformation(((CMacroExpansionInput) input).fExplorer.getFullExpansion().getCodeAfterStep()); CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
} else { } else {
super.setInput(input); super.setInput(input);
} }
} }
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new CMacroExpansionExplorationControl(parent);
}
};
}
/*
* @see org.eclipse.cdt.internal.ui.text.AbstractSourceViewerInformationControl#allowMoveIntoControl()
*/
@Override
public boolean allowMoveIntoControl() {
return true;
}
} }

View file

@ -40,6 +40,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
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.Event;
@ -110,17 +111,16 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
private CMacroExpansionInput fInput; private CMacroExpansionInput fInput;
private CMacroCompareViewer fMacroCompareViewer; private CMacroCompareViewer fMacroCompareViewer;
private ISourceViewer fMacroViewer; private ISourceViewer fMacroViewer;
private StyledText fMacroText;
/** /**
* Creates a new control for use as a "quick view" where the control immediately takes the focus. * Creates a new control for use as a "quick view" where the control immediately takes the focus.
* *
* @param parent parent shell * @param parent parent shell
* @param shellStyle shell style bits
* @param style text viewer style bits
* @param input the input object, may be <code>null</code> * @param input the input object, may be <code>null</code>
*/ */
public CMacroExpansionExplorationControl(Shell parent, int shellStyle, int style, CMacroExpansionInput input) { public CMacroExpansionExplorationControl(Shell parent, CMacroExpansionInput input) {
super(parent, shellStyle, style, true, true, true); super(parent, SWT.RESIZE, SWT.NONE, true, true, true);
setMacroExpansionInput(input); setMacroExpansionInput(input);
} }
@ -128,11 +128,9 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
* Creates a new control for use as a "quick view" where the control immediately takes the focus. * Creates a new control for use as a "quick view" where the control immediately takes the focus.
* *
* @param parent parent shell * @param parent parent shell
* @param shellStyle shell style bits
* @param textStyle text viewer style bits
*/ */
public CMacroExpansionExplorationControl(Shell parent, int shellStyle, int textStyle) { public CMacroExpansionExplorationControl(Shell parent) {
this(parent, shellStyle, textStyle, null); this(parent, null);
} }
/* /*
@ -173,15 +171,15 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false)); sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
sourceViewer.setEditable(false); sourceViewer.setEditable(false);
StyledText styledText= sourceViewer.getTextWidget(); fMacroText= sourceViewer.getTextWidget();
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
styledText.setFont(font); fMacroText.setFont(font);
GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
gd.heightHint= styledText.getLineHeight() * 2; gd.heightHint= fMacroText.getLineHeight() * 2;
styledText.setLayoutData(gd); fMacroText.setLayoutData(gd);
styledText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); fMacroText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
final Document doc= new Document(); final Document doc= new Document();
CUIPlugin.getDefault().getTextTools().setupCDocument(doc); CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
@ -347,6 +345,16 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
} }
} }
/*
* @see org.eclipse.cdt.internal.ui.text.AbstractCompareViewerInformationControl#computeTrim()
*/
@Override
public Rectangle computeTrim() {
Rectangle trim= super.computeTrim();
trim.height += fMacroText.getLineHeight();
return trim;
}
/** /**
* Set the input for this information control. * Set the input for this information control.
* @param input * @param input

View file

@ -21,7 +21,6 @@ import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region; import org.eclipse.jface.text.Region;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
@ -64,9 +63,7 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
public IInformationControlCreator getInformationPresenterControlCreator() { public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() { return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) { public IInformationControl createInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE; return new CMacroExpansionExplorationControl(parent, getCachedMacroExpansionInput());
int style= SWT.V_SCROLL | SWT.H_SCROLL;
return new CMacroExpansionExplorationControl(parent, shellStyle, style, getCachedMacroExpansionInput());
} }
}; };
} }

View file

@ -8,15 +8,18 @@
* 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.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region; import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.information.IInformationProvider; import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension; import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;
@ -25,7 +28,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
* *
* @since 5.0 * @since 5.0
*/ */
public class CMacroExpansionInformationProvider implements IInformationProvider, IInformationProviderExtension { public class CMacroExpansionInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
private final ITextEditor fEditor; private final ITextEditor fEditor;
@ -55,4 +58,15 @@ public class CMacroExpansionInformationProvider implements IInformationProvider,
return CMacroExpansionInput.create(fEditor, subject, true); return CMacroExpansionInput.create(fEditor, subject, true);
} }
/*
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new CMacroExpansionExplorationControl(parent);
}
};
}
} }

View file

@ -43,6 +43,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.part.IWorkbenchPartOrientation;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IPositionConverter; import org.eclipse.cdt.core.IPositionConverter;
@ -841,7 +842,11 @@ public class CSourceHover extends AbstractCEditorTextHover {
public IInformationControlCreator getHoverControlCreator() { public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() { return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) { public IInformationControl createInformationControl(Shell parent) {
return new SourceViewerInformationControl(parent, getTooltipAffordanceString()); IEditorPart editor= getEditor();
int orientation= SWT.NONE;
if (editor instanceof IWorkbenchPartOrientation)
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
return new SourceViewerInformationControl(parent, false, orientation, getTooltipAffordanceString());
} }
}; };
} }
@ -853,9 +858,11 @@ public class CSourceHover extends AbstractCEditorTextHover {
public IInformationControlCreator getInformationPresenterControlCreator() { public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() { return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) { public IInformationControl createInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE; IEditorPart editor= getEditor();
int style= SWT.V_SCROLL | SWT.H_SCROLL; int orientation= SWT.NONE;
return new SourceViewerInformationControl(parent, shellStyle, style); if (editor instanceof IWorkbenchPartOrientation)
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
return new SourceViewerInformationControl(parent, true, orientation, getTooltipAffordanceString());
} }
}; };
} }

View file

@ -12,13 +12,17 @@
package org.eclipse.cdt.internal.ui.text.c.hover; package org.eclipse.cdt.internal.ui.text.c.hover;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IInformationControlExtension; import org.eclipse.jface.text.IInformationControlExtension;
import org.eclipse.jface.text.IInformationControlExtension3;
import org.eclipse.jface.text.IInformationControlExtension5;
import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -31,11 +35,14 @@ import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -54,7 +61,7 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
* Displays information in a source viewer. * Displays information in a source viewer.
* *
*/ */
public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener { public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5, DisposeListener {
/** Border thickness in pixels. */ /** Border thickness in pixels. */
private static final int BORDER= 1; private static final int BORDER= 1;
@ -64,6 +71,8 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
private StyledText fText; private StyledText fText;
/** The control's source viewer */ /** The control's source viewer */
private SourceViewer fViewer; private SourceViewer fViewer;
/** The text font (do not dispose!) */
private Font fTextFont;
/** /**
* The optional status field. * The optional status field.
* *
@ -92,6 +101,11 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* @since 4.0 * @since 4.0
*/ */
private int fMaxHeight= SWT.DEFAULT; private int fMaxHeight= SWT.DEFAULT;
/**
* The orientation of the shell
* @since 3.4
*/
private final int fOrientation;
private Color fBackgroundColor; private Color fBackgroundColor;
private boolean fIsSystemBackgroundColor= true; private boolean fIsSystemBackgroundColor= true;
@ -102,29 +116,21 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
* styles are applied to the created styled text widget. * styles are applied to the created styled text widget.
* *
* @param parent the parent shell * @param parent the parent shell
* @param shellStyle the additional styles for the shell * @param isResizable <code>true</code> if resizable
* @param style the additional styles for the styled text widget * @param orientation the orientation
*/
public SourceViewerInformationControl(Shell parent, int shellStyle, int style) {
this(parent, shellStyle, style, null);
}
/**
* 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.
*
* @param parent the parent shell
* @param shellStyle the additional styles for the shell
* @param style the additional styles for the styled text widget
* @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
* @since 3.0
*/ */
public SourceViewerInformationControl(Shell parent, int shellStyle, int style, 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);
fOrientation= orientation;
GridLayout layout; GridLayout layout;
GridData gd; GridData gd;
int shellStyle= SWT.TOOL | SWT.ON_TOP | orientation | (isResizable ? SWT.RESIZE : 0);
int textStyle= isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;
fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
Display display= fShell.getDisplay(); Display display= fShell.getDisplay();
fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
@ -154,7 +160,7 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
// Source viewer // Source viewer
IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
fViewer= new CSourceViewer(composite, null, null, false, style, store); fViewer= new CSourceViewer(composite, null, null, false, textStyle, store);
CTextTools tools= CUIPlugin.getDefault().getTextTools(); CTextTools tools= CUIPlugin.getDefault().getTextTools();
fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false)); fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
fViewer.setEditable(false); fViewer.setEditable(false);
@ -222,67 +228,15 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
: PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
} }
/**
* 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.
*
* @param parent the parent shell
* @param style the additional styles for the styled text widget
*/
public SourceViewerInformationControl(Shell parent,int style) {
this(parent, SWT.NO_TRIM | SWT.TOOL, style);
}
/**
* 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.
*
* @param parent the parent shell
* @param style the additional styles for the styled text widget
* @param statusFieldText the text to be used in the optional status field
* or <code>null</code> if the status field should be hidden
* @since 3.0
*/
public SourceViewerInformationControl(Shell parent, int style, String statusFieldText) {
this(parent, SWT.NO_TRIM | SWT.TOOL, style, statusFieldText);
}
/**
* Creates a default information control with the given shell as parent.
* No information presenter is used to process the information
* to be displayed. No additional styles are applied to the styled text widget.
*
* @param parent the parent shell
*/
public SourceViewerInformationControl(Shell parent) {
this(parent, SWT.NONE);
}
/**
* Creates a default information control with the given shell as parent.
* No information presenter is used to process the information
* to be displayed. No additional styles are applied to the styled text widget.
*
* @param parent the parent shell
* @param statusFieldText the text to be used in the optional status field
* or <code>null</code> if the status field should be hidden
* @since 3.0
*/
public SourceViewerInformationControl(Shell parent, String statusFieldText) {
this(parent, SWT.NONE, statusFieldText);
}
/** /**
* Initialize the font to the editor font. * Initialize the font to the editor font.
* *
* @since 4.0 * @since 4.0
*/ */
private void initializeFont() { private void initializeFont() {
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
StyledText styledText= getViewer().getTextWidget(); StyledText styledText= getViewer().getTextWidget();
styledText.setFont(font); styledText.setFont(fTextFont);
} }
/* /*
@ -461,4 +415,113 @@ public class SourceViewerInformationControl implements IInformationControl, IInf
return fViewer; return fViewer;
} }
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
* @since 5.0
*/
public Rectangle computeTrim() {
Rectangle trim= fShell.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= fText.computeTrim(0, 0, 0, 0);
trim.x+= textTrim.x;
trim.y+= textTrim.y;
trim.width+= textTrim.width;
trim.height+= textTrim.height;
if (fStatusField != null) {
trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
trim.height+= 1; // verticalSpacing
}
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
* @since 5.0
*/
public Rectangle getBounds() {
return fShell.getBounds();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
* @since 5.0
*/
public boolean restoresLocation() {
return false;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
* @since 5.0
*/
public boolean restoresSize() {
return false;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
* @since 5.0
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new SourceViewerInformationControl(parent, true, fOrientation, null);
}
};
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
* @since 5.0
*/
public boolean containsControl(Control control) {
do {
if (control == fShell)
return true;
if (control instanceof Shell)
return false;
control= control.getParent();
} while (control != null);
return false;
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#isVisible()
* @since 5.0
*/
public boolean isVisible() {
return fShell != null && !fShell.isDisposed() && fShell.isVisible();
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int)
*/
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
GC gc= new GC(fText);
gc.setFont(fTextFont);
int width= gc.getFontMetrics().getAverageCharWidth();
int height= gc.getFontMetrics().getHeight();
gc.dispose();
return new Point(widthInChars * width, heightInChars * height);
}
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
*/
public boolean allowMoveIntoControl() {
return true;
}
} }

View file

@ -64,15 +64,14 @@ public class TemplateEngine {
public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal { public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
/* (non-Javadoc) /*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator() * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
*/ */
public IInformationControlCreator getInformationControlCreator() { public IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() { return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) { public IInformationControl createInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE; int orientation = SWT.LEFT_TO_RIGHT;
int style= SWT.V_SCROLL | SWT.H_SCROLL; return new SourceViewerInformationControl(parent, false, orientation, null);
return new SourceViewerInformationControl(parent, shellStyle, style);
} }
}; };
} }
@ -178,10 +177,11 @@ public class TemplateEngine {
Template[] templates= CUIPlugin.getDefault().getTemplateStore().getTemplates(); Template[] templates= CUIPlugin.getDefault().getTemplateStore().getTemplates();
Image image= CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE);
if (selection.y == 0) { if (selection.y == 0) {
for (int i= 0; i != templates.length; i++) for (int i= 0; i != templates.length; i++)
if (context.canEvaluate(templates[i])) if (context.canEvaluate(templates[i]))
fProposals.add(new CTemplateProposal(templates[i], context, region, CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE))); fProposals.add(new CTemplateProposal(templates[i], context, region, image));
} else { } else {
@ -194,7 +194,7 @@ public class TemplateEngine {
template.getContextTypeId().equals(context.getContextType().getId()) && template.getContextTypeId().equals(context.getContextType().getId()) &&
(!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1))) (!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1)))
{ {
fProposals.add(new CTemplateProposal(templates[i], context, region, CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE))); fProposals.add(new CTemplateProposal(templates[i], context, region, image));
} }
} }
} }