### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.ui
Index: ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java,v
retrieving revision 1.30
diff -u -r1.30 AbstractJavaCompletionProposal.java
--- ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java 14 Feb 2008 11:00:52 -0000 1.30
+++ ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java 28 Feb 2008 01:04:27 -0000
@@ -103,7 +103,7 @@
* @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
*/
public IInformationControl doCreateInformationControl(Shell parent) {
- return new BrowserInformationControl(parent, SWT.NO_TRIM | SWT.TOOL, SWT.NONE);
+ return new BrowserInformationControl(parent, PreferenceConstants.APPEARANCE_JAVADOC_FONT, false);
}
}
Index: ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java,v
retrieving revision 1.57
diff -u -r1.57 JavadocHover.java
--- ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java 26 Feb 2008 18:12:25 -0000 1.57
+++ ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java 28 Feb 2008 01:04:28 -0000
@@ -240,12 +240,10 @@
* @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
*/
public IInformationControl doCreateInformationControl(Shell parent) {
- int shellStyle= SWT.RESIZE | SWT.TOOL;
- int style= SWT.V_SCROLL | SWT.H_SCROLL;
if (BrowserInformationControl.isAvailable(parent)) {
ToolBarManager tbm= new ToolBarManager(SWT.FLAT);
String font= PreferenceConstants.APPEARANCE_JAVADOC_FONT;
- BrowserInformationControl iControl= new BrowserInformationControl(parent, shellStyle, style, font, tbm);
+ BrowserInformationControl iControl= new BrowserInformationControl(parent, font, tbm);
final BackAction backAction= new BackAction(iControl);
backAction.setEnabled(false);
@@ -292,11 +290,9 @@
* @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
*/
public IInformationControl doCreateInformationControl(Shell parent) {
- int shellStyle= SWT.TOOL | SWT.NO_TRIM;
- int style= SWT.NONE;
if (BrowserInformationControl.isAvailable(parent)) {
String font= PreferenceConstants.APPEARANCE_JAVADOC_FONT;
- BrowserInformationControl iControl= new BrowserInformationControl(parent, shellStyle, style, font, EditorsUI.getTooltipAffordanceString());
+ BrowserInformationControl iControl= new BrowserInformationControl(parent, font, EditorsUI.getTooltipAffordanceString());
addLinkListener(iControl);
return iControl;
} else {
Index: ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java,v
retrieving revision 1.18
diff -u -r1.18 AbstractAnnotationHover.java
--- ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java 27 Feb 2008 09:50:18 -0000 1.18
+++ ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java 28 Feb 2008 01:04:27 -0000
@@ -182,10 +182,7 @@
* @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite)
*/
protected void createContent(Composite parent) {
- fParent= new Composite(parent, SWT.NONE);
- fParent.setForeground(parent.getForeground());
- fParent.setBackground(parent.getBackground());
- fParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ fParent= parent;
GridLayout layout= new GridLayout(1, false);
layout.verticalSpacing= 0;
fParent.setLayout(layout);
Index: ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaInformationProvider.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaInformationProvider.java,v
retrieving revision 1.20
diff -u -r1.20 JavaInformationProvider.java
--- ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaInformationProvider.java 26 Feb 2008 18:12:05 -0000 1.20
+++ ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaInformationProvider.java 28 Feb 2008 01:04:27 -0000
@@ -10,14 +10,6 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.java.hover;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.internal.text.html.BrowserInformationControl;
-
-import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHoverExtension2;
@@ -35,38 +27,8 @@
public class JavaInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
-
- /**
- * Control creator.
- *
- * @since 3.3
- */
- private static final class ControlCreator extends AbstractReusableInformationControlCreator {
- /*
- * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
- */
- public IInformationControl doCreateInformationControl(Shell parent) {
- int shellStyle= SWT.RESIZE | SWT.TOOL;
- int style= SWT.V_SCROLL | SWT.H_SCROLL;
- if (BrowserInformationControl.isAvailable(parent))
- return new BrowserInformationControl(parent, shellStyle, style);
- else
- return new DefaultInformationControl(parent, true);
- }
- }
-
-
protected IJavaEditorTextHover fImplementation;
- /**
- * The presentation control creator.
- *
- * @since 3.2
- */
- private IInformationControlCreator fPresenterControlCreator;
-
-
-
public JavaInformationProvider(IEditorPart editor) {
if (editor != null) {
fImplementation= new JavaTypeHover();
@@ -85,8 +47,9 @@
return null;
}
- /*
+ /**
* @see IInformationProvider#getInformation(ITextViewer, IRegion)
+ * @deprecated
*/
public String getInformation(ITextViewer textViewer, IRegion subject) {
if (fImplementation != null) {
@@ -122,8 +85,6 @@
ITextHoverExtension2 extension= (ITextHoverExtension2) fImplementation;
return extension.getInformationPresenterControlCreator();
}
- if (fPresenterControlCreator == null)
- fPresenterControlCreator= new ControlCreator();
- return fPresenterControlCreator;
+ return null;
}
}
#P org.eclipse.jface.text
Index: src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java,v
retrieving revision 1.19
diff -u -r1.19 BrowserInformationControl.java
--- src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java 26 Feb 2008 09:34:26 -0000 1.19
+++ src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java 28 Feb 2008 01:04:31 -0000
@@ -26,19 +26,9 @@
import org.eclipse.swt.browser.ProgressAdapter;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
@@ -46,29 +36,17 @@
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.TextLayout;
import org.eclipse.swt.graphics.TextStyle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Slider;
-import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.AbstractInformationControl;
import org.eclipse.jface.text.IDelayedInputChangeProvider;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
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.IInputChangedListener;
import org.eclipse.jface.text.TextPresentation;
@@ -93,7 +71,7 @@
*
* @since 3.2
*/
-public class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5, IDelayedInputChangeProvider, DisposeListener {
+public class BrowserInformationControl extends AbstractInformationControl implements IInformationControlExtension2, IDelayedInputChangeProvider {
/**
@@ -128,9 +106,6 @@
}
- /** Border thickness in pixels. */
- private static final int BORDER= 1;
-
/**
* Minimal size constraints.
* @since 3.2
@@ -151,31 +126,13 @@
*/
private static Point fgScrollBarSize;
- /** The control's shell */
- private Shell fShell;
/** The control's browser widget */
private Browser fBrowser;
/** Tells whether the browser has content */
private boolean fBrowserHasContent;
- /** The control width constraint */
- private int fMaxWidth= SWT.DEFAULT;
- /** The control height constraint */
- private int fMaxHeight= SWT.DEFAULT;
-
- private Label fSeparator;
- private Font fStatusTextFont;
- private Label fStatusTextField;
- private String fStatusFieldText;
-
- private ToolBarManager fToolBarManager;
- private Label fTBSeparator;
- private ToolBar fToolBar;
-
- private final int fBorderWidth;
- private boolean fHideScrollBars;
- private Listener fShellListener;
- private ListenerList fFocusListeners= new ListenerList(ListenerList.IDENTITY);
+ /** Text layout used to approximate size of content when rendered in browser */
private TextLayout fTextLayout;
+ /** Bold text style */
private TextStyle fBoldStyle;
private BrowserInformationControlInput fInput;
@@ -206,153 +163,62 @@
private final String fSymbolicFontName;
/**
- * Creates a browser 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 browser widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the browser widget
- */
- public BrowserInformationControl(Shell parent, int shellStyle, int style) {
- this(parent, shellStyle, style, null, null, null);
- }
-
- /**
- * Creates a browser 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 browser widget.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the browser widget
- * @param statusFieldText the text to be used in the optional status field
- * or null
if the status field should be hidden
- */
- public BrowserInformationControl(Shell parent, int shellStyle, int style, String statusFieldText) {
- this(parent, shellStyle, style, null, null, statusFieldText);
- }
-
- /**
- * Creates a browser 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 browser widget.
+ * Creates a browser information control with the given shell as parent.
*
* @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the browser widget
* @param symbolicFontName the symbolic name of the font used for size computations
- * @param statusFieldText the text to be used in the optional status field
- * or null
if the status field should be hidden
+ * @param resizable true
if the control should be resizable
* @since 3.4
*/
- public BrowserInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName, String statusFieldText) {
- this(parent, shellStyle, style, symbolicFontName, null, statusFieldText);
+ public BrowserInformationControl(Shell parent, String symbolicFontName, boolean resizable) {
+ super(parent, resizable);
+ fSymbolicFontName= symbolicFontName;
+ create();
}
/**
- * Creates a browser 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 browser widget.
+ * Creates a browser information control with the given shell as parent.
*
* @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the browser widget
* @param symbolicFontName the symbolic name of the font used for size computations
- * @param toolBarManager the tool bar manager or null
to hide the tool bar
+ * @param statusFieldText the text to be used in the optional status field
+ * or null
if the status field should be hidden
* @since 3.4
*/
- public BrowserInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName, ToolBarManager toolBarManager) {
- this(parent, shellStyle, style, symbolicFontName, toolBarManager, null);
+ public BrowserInformationControl(Shell parent, String symbolicFontName, String statusFieldText) {
+ super(parent, statusFieldText);
+ fSymbolicFontName= symbolicFontName;
+ create();
}
/**
- * Creates a browser 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 browser widget.
- *
- * At most one of toolBarManager
or statusFieldText
can be non-null.
- *
null
to hide the tool bar
- * @param statusFieldText the text to be used in the optional status field
- * or null
if the status field should be hidden
+ * @param toolBarManager the manager or null
if toolbar is not desired
* @since 3.4
*/
- private BrowserInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName, ToolBarManager toolBarManager, String statusFieldText) {
- Assert.isLegal(toolBarManager == null || statusFieldText == null);
+ public BrowserInformationControl(Shell parent, String symbolicFontName, ToolBarManager toolBarManager) {
+ super(parent, toolBarManager);
fSymbolicFontName= symbolicFontName;
- fToolBarManager= toolBarManager;
- fStatusFieldText= statusFieldText;
-
- fShell= new Shell(parent, SWT.ON_TOP | shellStyle);
- Display display= fShell.getDisplay();
-
- GridLayout layout= new GridLayout(1, false);
- if ((shellStyle & SWT.NO_TRIM) == 0) {
- fBorderWidth= 0;
- } else {
- fBorderWidth= BORDER;
- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
- }
- layout.marginHeight= fBorderWidth;
- layout.marginWidth= fBorderWidth;
- fShell.setLayout(layout);
- Composite composite= fShell;
-
- if (statusFieldText != null || toolBarManager != null) {
- composite= new Composite(composite, SWT.NONE);
- layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= 1;
- layout.horizontalSpacing= 1;
- composite.setLayout(layout);
-
- GridData gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
- }
- if (statusFieldText != null) {
- composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- createBrowser(composite, style);
-
- if (toolBarManager != null)
- createToolBar(composite, toolBarManager);
- if (statusFieldText != null)
- createStatusField(composite, statusFieldText);
-
- addDisposeListener(this);
- createTextLayout();
+ create();
}
-
- /**
- * Creates the browser control.
- *
- * @param composite the parent composite
- * @param style the additional styles for the browser widget
+
+ /*
+ * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite)
*/
- private void createBrowser(Composite composite, int style) {
- fBrowser= new Browser(composite, SWT.NONE);
- fHideScrollBars= (style & SWT.V_SCROLL) == 0 && (style & SWT.H_SCROLL) == 0;
-
- GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- fBrowser.setLayoutData(gd);
+ protected void createContent(Composite parent) {
+ fBrowser= new Browser(parent, SWT.NONE);
- Display display= fShell.getDisplay();
+ Display display= getShell().getDisplay();
fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fBrowser.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.character == 0x1B) // ESC
- fShell.dispose(); // XXX: Just hide? Would avoid constant recreations.
+ getShell().dispose(); // XXX: Just hide? Would avoid constant recreations.
}
public void keyReleased(KeyEvent e) {}
@@ -385,191 +251,9 @@
});
// Replace browser's built-in context menu with none
- fBrowser.setMenu(new Menu(fShell, SWT.NONE));
- }
-
- /**
- * Creates the tool bar.
- *
- * @param composite parent
- * @param toolBarManager manager
- */
- private void createToolBar(Composite composite, ToolBarManager toolBarManager) {
- fTBSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- fTBSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Composite bars= new Composite(composite, SWT.NONE);
- bars.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
- GridLayout layout= new GridLayout(3, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.horizontalSpacing= 0;
- layout.verticalSpacing= 0;
- bars.setLayout(layout);
-
- fToolBar= toolBarManager.createControl(bars);
- GridData gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
- fToolBar.setLayoutData(gd);
-
- Composite spacer= new Composite(bars, SWT.NONE);
- gd= new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint= 0;
- gd.heightHint= 0;
- spacer.setLayoutData(gd);
-
- addMoveSupport(spacer);
-
- // XXX: workaround for
- // - https://bugs.eclipse.org/bugs/show_bug.cgi?id=219139 : API to add resize grip / grow box in lower right corner of shell
- // - https://bugs.eclipse.org/bugs/show_bug.cgi?id=23980 : platform specific shell resize behavior
- String platform= SWT.getPlatform();
- final boolean isWin= platform.equals("win32"); //$NON-NLS-1$
- if (isWin || platform.equals("gtk")) { //$NON-NLS-1$
- final Canvas resizer= new Canvas(bars, SWT.NONE);
- gd= new GridData(SWT.END, SWT.END, false, true);
- gd.widthHint= fgScrollBarSize.x;
- gd.heightHint= fgScrollBarSize.x;
- resizer.setLayoutData(gd);
- resizer.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- Point s= resizer.getSize();
- int x= s.x - 2;
- int y= s.y - 2;
- int min= Math.min(x, y);
- if (isWin) {
- // draw dots
- e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- int end= min - 1;
- for (int i= 0; i <= 2; i++)
- for (int j= 0; j <= 2 - i; j++)
- e.gc.fillRectangle(end - 4*i, end - 4*j, 2, 2);
- end--;
- e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
- for (int i= 0; i <= 2; i++)
- for (int j= 0; j <= 2 - i; j++)
- e.gc.fillRectangle(end - 4*i, end - 4*j, 2, 2);
-
- } else {
- // draw diagonal lines
- e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
- for (int i= 1; i < min; i+= 4) {
- e.gc.drawLine(i, y, x, i);
- }
- e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
- for (int i= 2; i < min; i+= 4) {
- e.gc.drawLine(i, y, x, i);
- }
- }
- }
- });
- addResizeSupport(resizer);
- }
- }
-
- /**
- * Adds support to move the shell by dragging the given control.
- *
- * @param control the control that can be used to move the shell
- * @since 3.4
- */
- private void addMoveSupport(final Control control) {
- MouseAdapter moveSupport= new MouseAdapter() {
- private MouseMoveListener fMoveListener;
-
- public void mouseDown(MouseEvent e) {
- Point shellLoc= fShell.getLocation();
- final int shellX= shellLoc.x;
- final int shellY= shellLoc.y;
- Point mouseLoc= control.toDisplay(e.x, e.y);
- final int mouseX= mouseLoc.x;
- final int mouseY= mouseLoc.y;
- fMoveListener= new MouseMoveListener() {
- public void mouseMove(MouseEvent e2) {
- Point mouseLoc2= control.toDisplay(e2.x, e2.y);
- int dx= mouseLoc2.x - mouseX;
- int dy= mouseLoc2.y - mouseY;
- fShell.setLocation(shellX + dx, shellY + dy);
- }
- };
- control.addMouseMoveListener(fMoveListener);
- }
-
- public void mouseUp(MouseEvent e) {
- control.removeMouseMoveListener(fMoveListener);
- fMoveListener= null;
- }
- };
- control.addMouseListener(moveSupport);
- }
-
- /**
- * Adds support to resize the shell by dragging the given control.
- *
- * @param control the control that can be used to resize the shell
- * @since 3.4
- */
- private void addResizeSupport(final Control control) {
- control.setCursor(new Cursor(control.getDisplay(), SWT.CURSOR_SIZESE));
- MouseAdapter resizeSupport= new MouseAdapter() {
- private MouseMoveListener fResizeListener;
-
- public void mouseDown(MouseEvent e) {
- Point shellSize= fShell.getSize();
- final int shellX= shellSize.x;
- final int shellY= shellSize.y;
- Point mouseLoc= control.toDisplay(e.x, e.y);
- final int mouseX= mouseLoc.x;
- final int mouseY= mouseLoc.y;
- fResizeListener= new MouseMoveListener() {
- public void mouseMove(MouseEvent e2) {
- Point mouseLoc2= control.toDisplay(e2.x, e2.y);
- int dx= mouseLoc2.x - mouseX;
- int dy= mouseLoc2.y - mouseY;
- fBrowser.setRedraw(false);
- try {
- fShell.setSize(shellX + dx, shellY + dy);
- } finally {
- fBrowser.setRedraw(true);
- }
- }
- };
- control.addMouseMoveListener(fResizeListener);
- }
-
- public void mouseUp(MouseEvent e) {
- control.removeMouseMoveListener(fResizeListener);
- fResizeListener= null;
- }
- };
- control.addMouseListener(resizeSupport);
- }
-
- /**
- * Creates the status field.
- *
- * @param composite the parent composite
- * @param statusFieldText the text to show in the status field
- */
- private void createStatusField(Composite composite, String statusFieldText) {
- fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Status field label
- fStatusTextField= new Label(composite, SWT.RIGHT);
- fStatusTextField.setText(statusFieldText);
- Font font= fStatusTextField.getFont();
- FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
- fStatusTextFont= new Font(fStatusTextField.getDisplay(), fontDatas);
- fStatusTextField.setFont(fStatusTextFont);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- fStatusTextField.setLayoutData(gd);
-
- Display display= fShell.getDisplay();
- fStatusTextField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
- fStatusTextField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ fBrowser.setMenu(new Menu(getShell(), SWT.NONE));
+
+ createTextLayout();
}
/**
@@ -607,17 +291,17 @@
if (!fBrowserHasContent)
content= ""; //$NON-NLS-1$
- int shellStyle= fShell.getStyle();
- boolean RTL= (shellStyle & SWT.RIGHT_TO_LEFT) != 0;
+ boolean RTL= (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
+ boolean resizable= isResizable();
// The default "overflow:auto" would not result in a predictable width for the client area
// and the re-wrapping would cause visual noise
String[] styles= null;
- if (RTL && !fHideScrollBars)
+ if (RTL && resizable)
styles= new String[] { "direction:rtl;", "overflow:scroll;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else if (RTL && fHideScrollBars)
+ else if (RTL && !resizable)
styles= new String[] { "direction:rtl;", "overflow:hidden;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else if (fHideScrollBars)
+ else if (!resizable)
//XXX: In IE, "word-wrap: break-word;" causes bogus wrapping even in non-broken words :-(see e.g. Javadoc of String).
// Re-check whether we really still need this now that the Javadoc Hover header already sets this style.
styles= new String[] { "overflow:hidden;"/*, "word-wrap: break-word;"*/ }; //$NON-NLS-1$
@@ -643,32 +327,15 @@
}
/*
- * @see org.eclipse.jdt.internal.ui.text.IInformationControlExtension4#setStatusText(java.lang.String)
- * @since 3.2
- */
- public void setStatusText(String statusFieldText) {
- fStatusFieldText= statusFieldText;
- }
-
- /*
* @see IInformationControl#setVisible(boolean)
*/
public void setVisible(boolean visible) {
- if (fShell.isVisible() == visible)
+ Shell shell= getShell();
+ if (shell.isVisible() == visible)
return;
- if (visible) {
- if (fStatusTextField != null) {
- boolean state= fStatusFieldText != null;
- if (state)
- fStatusTextField.setText(fStatusFieldText);
- fStatusTextField.setVisible(state);
- fSeparator.setVisible(state);
- }
- }
-
if (!visible) {
- fShell.setVisible(false);
+ super.setVisible(false);
setInput(null);
return;
}
@@ -678,7 +345,7 @@
* The fix is to delay the call to setVisible until either loading is completed
* (see ProgressListener in constructor), or a timeout has been reached.
*/
- final Display display= fShell.getDisplay();
+ final Display display= shell.getDisplay();
// Make sure the display wakes from sleep after timeout:
display.timerExec(100, new Runnable() {
@@ -694,7 +361,8 @@
}
}
- if (fShell == null || fShell.isDisposed())
+ shell= getShell();
+ if (shell == null || shell.isDisposed())
return;
/*
@@ -702,9 +370,9 @@
* Causes flickering on GTK. Carbon does not care.
*/
if ("win32".equals(SWT.getPlatform())) //$NON-NLS-1$
- fShell.moveAbove(null);
+ shell.moveAbove(null);
- fShell.setVisible(true);
+ super.setVisible(true);
}
/**
@@ -723,7 +391,7 @@
FontData[] fontData= font.getFontData();
for (int i= 0; i < fontData.length; i++)
fontData[i].setStyle(SWT.BOLD);
- font= new Font(fShell.getDisplay(), fontData);
+ font= new Font(getShell().getDisplay(), fontData);
fBoldStyle= new TextStyle(font, null, null);
// Compute and set tab width
@@ -738,58 +406,21 @@
* @see IInformationControl#dispose()
*/
public void dispose() {
+ super.dispose();
if (fTextLayout != null)
fTextLayout.dispose();
fTextLayout= null;
if (fBoldStyle != null)
fBoldStyle.font.dispose();
fBoldStyle= null;
- if (fToolBarManager != null)
- fToolBarManager.dispose();
- if (fShell != null && !fShell.isDisposed())
- fShell.dispose();
- else
- widgetDisposed(null);
- }
-
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent event) {
- if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
- fStatusTextFont.dispose();
-
- fShell= null;
fBrowser= null;
- fStatusTextFont= null;
- }
-
- /*
- * @see IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
- fShell.setSize(width, height);
- }
-
- /*
- * @see IInformationControl#setLocation(Point)
- */
- public void setLocation(Point location) {
- fShell.setLocation(location);
- }
-
- /*
- * @see IInformationControl#setSizeConstraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- fMaxWidth= maxWidth;
- fMaxHeight= maxHeight;
}
/*
* @see IInformationControl#computeSizeHint()
*/
public Point computeSizeHint() {
+ Point sizeConstraints= getSizeConstraints();
Rectangle trim= computeTrim();
int height= trim.height;
@@ -806,7 +437,7 @@
}
fTextLayout.setText(text);
- fTextLayout.setWidth(fMaxWidth - trim.width);
+ fTextLayout.setWidth(sizeConstraints == null ? SWT.DEFAULT : sizeConstraints.x - trim.width);
Iterator iter= presentation.getAllStyleRangeIterator();
while (iter.hasNext()) {
StyleRange sr= (StyleRange)iter.next();
@@ -834,21 +465,14 @@
minWidth+= 15;
height+= 15;
- // Consider width of text field and toolbar (height is already in trim)
- if (fStatusFieldText != null && fSeparator != null) {
- Point statusTextSize= fStatusTextField.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- minWidth= Math.max(minWidth, statusTextSize.x);
- }
- if (fToolBar != null && fTBSeparator != null) {
- Point toolBarSize= fToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- minWidth= Math.max(minWidth, toolBarSize.x);
- }
// Apply max size constraints
- if (fMaxWidth != SWT.DEFAULT)
- minWidth= Math.min(fMaxWidth, minWidth + trim.width);
- if (fMaxHeight != SWT.DEFAULT)
- height= Math.min(fMaxHeight, height);
+ if (sizeConstraints != null) {
+ if (sizeConstraints.x != SWT.DEFAULT)
+ minWidth= Math.min(sizeConstraints.x, minWidth + trim.width);
+ if (sizeConstraints.y != SWT.DEFAULT)
+ height= Math.min(sizeConstraints.y, height);
+ }
// Ensure minimal size
int width= Math.max(MIN_WIDTH, minWidth);
@@ -861,78 +485,16 @@
* @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
*/
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 3.4
- */
- private void addInternalTrim(Rectangle trim) {
- trim.x-= fBorderWidth;
- trim.y-= fBorderWidth;
- trim.width+= 2 * fBorderWidth;
- trim.height+= 2 * fBorderWidth;
-
- if (! fHideScrollBars) {
- boolean RTL= (fShell.getStyle() & SWT.RIGHT_TO_LEFT) != 0;
+ Rectangle trim= super.computeTrim();
+ if (isResizable()) {
+ boolean RTL= (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
if (RTL) {
trim.x-= fgScrollBarSize.x;
}
trim.width+= fgScrollBarSize.x;
trim.height+= fgScrollBarSize.y;
}
-
- if (fStatusTextField != null) {
- trim.height+= 2; // from the layout's verticalSpacing
- trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- trim.height+= fStatusTextField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- }
-
- if (fToolBar != null) {
- trim.height+= 2; // from the layout's verticalSpacing
- trim.height+= fTBSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- trim.height+= fToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
- */
- public Rectangle getBounds() {
- return fShell.getBounds();
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
- */
- public boolean restoresLocation() {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
- */
- public boolean restoresSize() {
- return false;
- }
-
- /*
- * @see IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
+ return trim;
}
/**
@@ -950,6 +512,7 @@
* @see IInformationControl#setForegroundColor(Color)
*/
public void setForegroundColor(Color foreground) {
+ super.setForegroundColor(foreground);
fBrowser.setForeground(foreground);
}
@@ -957,82 +520,17 @@
* @see IInformationControl#setBackgroundColor(Color)
*/
public void setBackgroundColor(Color background) {
+ super.setBackgroundColor(background);
fBrowser.setBackground(background);
}
/*
- * @see IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- return fShell.getDisplay().getActiveShell() == fShell;
- }
-
- /*
- * @see IInformationControl#setFocus()
- */
- public void setFocus() {
- fShell.forceFocus();
- fBrowser.setFocus();
- }
-
- /*
- * @see IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(final FocusListener listener) {
- if (fFocusListeners.isEmpty()) {
- fShellListener= new Listener() {
- public void handleEvent(Event event) {
- Object[] listeners= fFocusListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- FocusListener focusListener= (FocusListener)listeners[i];
- if (event.type == SWT.Activate) {
- focusListener.focusGained(new FocusEvent(event));
- } else {
- focusListener.focusLost(new FocusEvent(event));
- }
- }
- }
- };
- fBrowser.getShell().addListener(SWT.Deactivate, fShellListener);
- fBrowser.getShell().addListener(SWT.Activate, fShellListener);
- }
- fFocusListeners.add(listener);
- }
-
- /*
- * @see IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- fFocusListeners.remove(listener);
- if (fFocusListeners.isEmpty()) {
- fBrowser.getShell().removeListener(SWT.Activate, fShellListener);
- fBrowser.getShell().removeListener(SWT.Deactivate, fShellListener);
- fShellListener= null;
- }
- }
-
- /*
* @see IInformationControlExtension#hasContents()
*/
public boolean hasContents() {
return fBrowserHasContent;
}
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
- * @since 3.4
- */
- 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;
- }
-
/**
* Adds a listener for input changes to this input change provider.
* Has no effect if an identical listener is already registered.
@@ -1087,27 +585,11 @@
}
/*
- * @see org.eclipse.jface.text.IInformationControlExtension5#isVisible()
- * @since 3.4
- */
- public boolean isVisible() {
- return fShell != null && ! fShell.isDisposed() && fShell.isVisible();
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension5#allowMoveIntoControl()
- * @since 3.4
- */
- public boolean allowMoveIntoControl() {
- return true;
- }
-
- /*
* @see java.lang.Object#toString()
* @since 3.4
*/
public String toString() {
- String style= (fShell.getStyle() & SWT.RESIZE) == 0 ? "fixed" : "resizeable"; //$NON-NLS-1$ //$NON-NLS-2$
+ String style= (getShell().getStyle() & SWT.RESIZE) == 0 ? "fixed" : "resizeable"; //$NON-NLS-1$ //$NON-NLS-2$
return super.toString() + " - style: " + style; //$NON-NLS-1$
}
@@ -1129,10 +611,10 @@
Font font= fSymbolicFontName == null ? JFaceResources.getDialogFont() : JFaceResources.getFont(fSymbolicFontName);
gc.setFont(font);
int width= gc.getFontMetrics().getAverageCharWidth();
- int height = gc.getFontMetrics().getHeight();
+ int height= gc.getFontMetrics().getHeight();
gc.dispose();
-
- return new Point (widthInChars * width, heightInChars * height);
+
+ return new Point(widthInChars * width, heightInChars * height);
}
}
Index: src/org/eclipse/jface/text/AbstractInformationControl.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java,v
retrieving revision 1.2
diff -u -r1.2 AbstractInformationControl.java
--- src/org/eclipse/jface/text/AbstractInformationControl.java 26 Feb 2008 18:05:34 -0000 1.2
+++ src/org/eclipse/jface/text/AbstractInformationControl.java 28 Feb 2008 01:04:33 -0000
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.jface.text;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.ListenerList;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusEvent;
@@ -26,6 +29,7 @@
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
@@ -39,11 +43,7 @@
import org.eclipse.swt.widgets.Slider;
import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ListenerList;
-
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.internal.text.html.BrowserInformationControl;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.Geometry;
@@ -58,40 +58,39 @@
* Additionally it can present either a status line containing a status text or
* a toolbar containing toolbar buttons.
* - * Clients must implement {@link #createContent(Composite)}, {@link #hasContents()} and - * {@link IInformationControl#setInformation(String)} and should - * extend {@link #computeTrim()} if they create a content area + * Clients must implement {@link #createContent(Composite)} and {@link #hasContents()}, and + * either override {@link IInformationControl#setInformation(String)} or implement {@link IInformationControlExtension2}. + * They should also extend {@link #computeTrim()} if they create a content area * with additional trim (e.g. scrollbars). *
- *- * FIXME: Work in progress. Will be modified in order to serve as super class - * for the {@link BrowserInformationControl} as well, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=219596. - *
* * @since 3.4 */ -public abstract class AbstractInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5 { +public abstract class AbstractInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5 { /** The information control's shell. */ private final Shell fShell; /** Composite containing the content created by subclasses. */ private final Composite fContentComposite; + /** Composite containing the status line content ornull
if none. */
private Composite fStatusComposite;
/** Separator between content and status line or null
if none. */
private Label fSeparator;
/** Label in the status line or null
if none. */
private Label fStatusLabel;
+ /** The toolbar manager used by the toolbar or null
if none. */
+ private final ToolBarManager fToolBarManager;
/** Status line toolbar or null
if none. */
private ToolBar fToolBar;
+
/** Listener for shell activation and deactivation. */
private Listener fShellListener;
/** All focus listeners registered to this information control. */
private ListenerList fFocusListeners= new ListenerList(ListenerList.IDENTITY);
- /** Size constrains, x is the maxWidth and y is the maxHeight, if any. */
+
+ /** Size constraints, x is the maxWidth and y is the maxHeight, or null
if not set. */
private Point fSizeConstraints;
- /** The toolbar manager used by the toolbar or null
if none. */
- private final ToolBarManager fToolBarManager;
/** The size of the resize handle if already set, -1 otherwise */
private int fResizeHandleSize;
@@ -178,10 +177,7 @@
fContentComposite= new Composite(fShell, SWT.NONE);
fContentComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- GridLayout contentLayout= new GridLayout(1, false);
- contentLayout.marginHeight= 0;
- contentLayout.marginWidth= 0;
- fContentComposite.setLayout(contentLayout);
+ fContentComposite.setLayout(new FillLayout());
setColor(fContentComposite, foreground, background);
createStatusComposite(statusFieldText, toolBarManager, foreground, background);
@@ -416,7 +412,7 @@
* Creates the content of this information control. Subclasses must call
* this method at the end of their constructor(s).
*/
- public final void create() {
+ protected final void create() {
createContent(fContentComposite);
}
@@ -432,12 +428,30 @@
* exceed the size of the information control. If false
,
* they should never show scrollbars.
*
+ *
+ * The given parent
comes with a {@link FillLayout}.
+ * Implementors can set a new layout.
+ *
+ * The default implementation does nothing. Subclasses must either override this method
+ * or implement {@link IInformationControlExtension2}.
+ *
+ * @param information the information to be presented
+ *
+ * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
+ */
+ public void setInformation(String information) {
+
+ }
+
+ /**
* Returns whether the information control is resizable.
*
* @return true
if the information control is resizable,
@@ -500,6 +514,7 @@
* @see IInformationControl#computeSizeHint()
*/
public Point computeSizeHint() {
+ //FIXME: Verify whether this is a good default implementation. If yes, document it.
Point constrains= getSizeConstraints();
if (constrains == null)
return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
@@ -530,14 +545,22 @@
return fShell.getBounds();
}
- /*
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation always returns false
.
+ *
+ * The default implementation always returns false
.
+ *
+ * The default implementation currently only updates the status field when + * the popup shell is not visible. The status field can currently only be + * shown if the information control has been created with a non-null status + * field text. + *
+ * + * @param statusFieldText the text to be used in the optional status field + * ornull
if the status field should be hidden
+ *
+ * @see org.eclipse.jface.text.IInformationControlExtension4#setStatusText(java.lang.String)
+ */
+ public void setStatusText(String statusFieldText) {
+ if (fStatusLabel != null && ! getShell().isVisible()) {
+ if (statusFieldText == null ) {
+ fStatusComposite.setVisible(false);
+ } else {
+ fStatusLabel.setText(statusFieldText);
+ fStatusComposite.setVisible(true);
+ }
+ }
+ }
+
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
*/
Index: src/org/eclipse/jface/text/IInformationControl.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControl.java,v
retrieving revision 1.17
diff -u -r1.17 IInformationControl.java
--- src/org/eclipse/jface/text/IInformationControl.java 4 Feb 2008 15:28:54 -0000 1.17
+++ src/org/eclipse/jface/text/IInformationControl.java 28 Feb 2008 01:04:34 -0000
@@ -12,6 +12,7 @@
package org.eclipse.jface.text;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Color;
@@ -53,14 +54,17 @@
* and to allow the mouse to move into this information control.
*
*
- * Clients can implement that interface and its extension interfaces or use the
- * provided default implementation {@link org.eclipse.jface.text.DefaultInformationControl}.
+ * Clients can implement this interface and its extension interfaces,
+ * subclass {@link AbstractInformationControl}, or use the (text-based)
+ * default implementation {@link DefaultInformationControl}.
*
* @see org.eclipse.jface.text.IInformationControlExtension
* @see org.eclipse.jface.text.IInformationControlExtension2
* @see org.eclipse.jface.text.IInformationControlExtension3
* @see org.eclipse.jface.text.IInformationControlExtension4
* @see org.eclipse.jface.text.IInformationControlExtension5
+ * @see AbstractInformationControl
+ * @see DefaultInformationControl
* @since 2.0
*/
public interface IInformationControl {
@@ -76,14 +80,14 @@
/**
* Sets the information control's size constraints. A constraint value of
- * -1
indicates no constraint. This method must be called before
- * computeSizeHint
is called.
+ * {@link SWT#DEFAULT} indicates no constraint. This method must be called before
+ * {@link #computeSizeHint()} is called.
*
* Note: An information control which implements {@link IInformationControlExtension3} * may ignore this method or use it as hint for its very first appearance. *
- * @param maxWidth the maximal width of the control to present the information, or-1
for not constraint
- * @param maxHeight the maximal height of the control to present the information, or -1
for not constraint
+ * @param maxWidth the maximal width of the control to present the information, or {@link SWT#DEFAULT} for not constraint
+ * @param maxHeight the maximal height of the control to present the information, or {@link SWT#DEFAULT} for not constraint
*/
void setSizeConstraints(int maxWidth, int maxHeight);
Index: src/org/eclipse/jface/text/IInformationControlExtension.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlExtension.java,v
retrieving revision 1.8
diff -u -r1.8 IInformationControlExtension.java
--- src/org/eclipse/jface/text/IInformationControlExtension.java 17 Jun 2005 15:49:07 -0000 1.8
+++ src/org/eclipse/jface/text/IInformationControlExtension.java 28 Feb 2008 01:04:34 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -15,8 +15,8 @@
* Extension interface {@link org.eclipse.jface.text.IInformationControl}.
* * As it is the responsibility of the implementer of - * {@link org.eclipse.jface.text.IInformationControl}and - * {@link org.eclipse.jface.text.IInformationControlExtension2}to specify the + * {@link org.eclipse.jface.text.IInformationControl} and + * {@link org.eclipse.jface.text.IInformationControlExtension2} to specify the * concrete nature of the information control's input, only the implementer can * know whether it has something to show or not. * Index: src/org/eclipse/jface/text/DefaultInformationControl.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java,v retrieving revision 1.44 diff -u -r1.44 DefaultInformationControl.java --- src/org/eclipse/jface/text/DefaultInformationControl.java 27 Feb 2008 12:46:29 -0000 1.44 +++ src/org/eclipse/jface/text/DefaultInformationControl.java 28 Feb 2008 01:04:34 -0000 @@ -18,7 +18,7 @@ import org.eclipse.swt.graphics.Drawable; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -295,10 +295,9 @@ fText.setForeground(parent.getForeground()); fText.setBackground(parent.getBackground()); fText.setFont(JFaceResources.getDialogFont()); - GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); - gd.horizontalIndent= INNER_BORDER; - gd.verticalIndent= INNER_BORDER; - fText.setLayoutData(gd); + FillLayout layout= (FillLayout) parent.getLayout(); + layout.marginHeight= INNER_BORDER; + layout.marginWidth= INNER_BORDER; } /* Index: src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java,v retrieving revision 1.40 diff -u -r1.40 RevisionPainter.java --- src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java 26 Feb 2008 18:06:34 -0000 1.40 +++ src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java 28 Feb 2008 01:04:33 -0000 @@ -20,6 +20,10 @@ import java.util.Map; import java.util.Map.Entry; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.core.runtime.Platform; + import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DisposeEvent; @@ -41,13 +45,9 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Platform; - import org.eclipse.jface.internal.text.html.BrowserInformationControl; import org.eclipse.jface.internal.text.html.HTMLPrinter; - +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.AbstractReusableInformationControlCreator; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultInformationControl; @@ -370,7 +370,14 @@ if (BrowserInformationControl.isAvailable(parent)) { final int shellStyle= SWT.TOOL | (fIsFocusable ? SWT.RESIZE : SWT.NO_TRIM); - return new BrowserInformationControl(parent, shellStyle, style) { + class RevisionInformationControl extends BrowserInformationControl { + public RevisionInformationControl(Shell parent2, String statusFieldText) { + super(parent2, JFaceResources.DIALOG_FONT, statusFieldText); + } + public RevisionInformationControl(Shell parent2) { + super(parent2, JFaceResources.DIALOG_FONT, true); + } + /* * @see org.eclipse.jface.internal.text.html.BrowserInformationControl#setInformation(java.lang.String) * @since 3.3 @@ -400,7 +407,10 @@ return info.toString(); } - }; + } + if (fIsFocusable) + return new RevisionInformationControl(parent); + return new RevisionInformationControl(parent, null); } return new DefaultInformationControl(parent, fIsFocusable); } @@ -1288,6 +1298,9 @@ */ private void installWheelHandler() { if (fFocusRevision != null && !fWheelHandlerInstalled) { + //FIXME: does not work on Windows, because Canvas cannot get focus and therefore does not send out mouse wheel events: + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=81189 + //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=75766 fControl.addListener(SWT.MouseWheel, fMouseHandler); fWheelHandlerInstalled= true; } #P org.eclipse.ui.editors Index: src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java,v retrieving revision 1.122 diff -u -r1.122 AbstractDecoratedTextEditor.java --- src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java 14 Dec 2007 12:26:25 -0000 1.122 +++ src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java 28 Feb 2008 01:04:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation 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 @@ -10,31 +10,12 @@ *******************************************************************************/ package org.eclipse.ui.texteditor; +import com.ibm.icu.text.MessageFormat; + import java.io.File; import java.util.Iterator; import java.util.List; -import com.ibm.icu.text.MessageFormat; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledTextPrintOptions; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.core.commands.operations.IOperationApprover; -import org.eclipse.core.commands.operations.IUndoContext; -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.filesystem.URIUtil; - import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -49,8 +30,26 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.commands.operations.IOperationApprover; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.IFileBufferStatusCodes; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.URIUtil; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledTextPrintOptions; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; @@ -64,11 +63,6 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.window.Window; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewerExtension6; @@ -100,12 +94,10 @@ import org.eclipse.jface.text.source.LineNumberRulerColumn; import org.eclipse.jface.text.source.OverviewRuler; import org.eclipse.jface.text.source.SourceViewer; - -import org.eclipse.ui.editors.text.DefaultEncodingSupport; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.editors.text.ForwardingDocumentProvider; -import org.eclipse.ui.editors.text.IEncodingSupport; -import org.eclipse.ui.editors.text.ITextEditorHelpContextIds; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.window.Window; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; @@ -116,6 +108,11 @@ import org.eclipse.ui.actions.ContributionItemFactory; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.dialogs.SaveAsDialog; +import org.eclipse.ui.editors.text.DefaultEncodingSupport; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.editors.text.ForwardingDocumentProvider; +import org.eclipse.ui.editors.text.IEncodingSupport; +import org.eclipse.ui.editors.text.ITextEditorHelpContextIds; import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.IDEActionFactory; import org.eclipse.ui.ide.IGotoMarker; @@ -562,6 +559,8 @@ public void showRevisionInformation(RevisionInformation info, String quickDiffProviderId) { if (info.getHoverControlCreator() == null) info.setHoverControlCreator(new RevisionHoverInformationControlCreator(false)); + if (info.getInformationPresenterControlCreator() == null) + info.setInformationPresenterControlCreator(new RevisionHoverInformationControlCreator(true)); showChangeInformation(true); if (fLineColumn != null) Index: src/org/eclipse/ui/texteditor/RevisionHoverInformationControlCreator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/RevisionHoverInformationControlCreator.java,v retrieving revision 1.3 diff -u -r1.3 RevisionHoverInformationControlCreator.java --- src/org/eclipse/ui/texteditor/RevisionHoverInformationControlCreator.java 26 Feb 2008 18:07:35 -0000 1.3 +++ src/org/eclipse/ui/texteditor/RevisionHoverInformationControlCreator.java 28 Feb 2008 01:04:41 -0000 @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.ui.texteditor; -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.internal.text.html.BrowserInformationControl; import org.eclipse.jface.internal.text.html.HTMLPrinter; - +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.AbstractReusableInformationControlCreator; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.IInformationControl; @@ -28,6 +27,10 @@ * The revision information control creator * that can show the tool tip affordance. * + * FIXME: + * - stylesheet manipulations should not be done here + * - focusable mode is not used anywhere + * * @since 3.3 */ class RevisionHoverInformationControlCreator extends AbstractReusableInformationControlCreator { @@ -88,13 +91,17 @@ * @see org.eclipse.jface.internal.text.revisions.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell) */ protected IInformationControl doCreateInformationControl(Shell parent) { - int style= fIsFocusable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE; - if (BrowserInformationControl.isAvailable(parent)) { - final int shellStyle= SWT.TOOL | (fIsFocusable ? SWT.RESIZE : SWT.NO_TRIM); - return new BrowserInformationControl(parent, shellStyle, style, EditorsUI.getTooltipAffordanceString()) { - - /* + + class RevisionInformationControl extends BrowserInformationControl { + public RevisionInformationControl(Shell parent2, String statusFieldText) { + super(parent2, JFaceResources.DIALOG_FONT, statusFieldText); + } + public RevisionInformationControl(Shell parent2) { + super(parent2, JFaceResources.DIALOG_FONT, true); + } + + /* * @see org.eclipse.jface.internal.text.html.BrowserInformationControl#setInformation(java.lang.String) */ public void setInformation(String content) { @@ -121,7 +128,10 @@ HTMLPrinter.addPageEpilog(info); return info.toString(); } - }; + } + if (fIsFocusable) + return new RevisionInformationControl(parent); + return new RevisionInformationControl(parent, EditorsUI.getTooltipAffordanceString()); } if (fIsFocusable) return new DefaultInformationControl(parent, true);