Index: DefaultInformationControl.java =================================================================== RCS file: /home/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java,v retrieving revision 1.16 diff -u -r1.16 DefaultInformationControl.java --- DefaultInformationControl.java 24 Jun 2004 15:48:50 -0000 1.16 +++ DefaultInformationControl.java 6 Dec 2004 18:18:19 -0000 @@ -20,16 +20,16 @@ import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.jface.dialogs.PopupDialog; + /** * Default implementation of {@link org.eclipse.jface.text.IInformationControl}. @@ -41,7 +41,39 @@ * @since 2.0 */ public class DefaultInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener { - + + class MyPopup extends PopupDialog { + + StyledText st; + int style; + + MyPopup(Shell parent, int shellStyle, int style) { + super(parent, shellStyle); + this.style= style; + } + + protected void createDialogContent(Composite composite) { + st= new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | style); + GridData gd2= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); + st.setLayoutData(gd2); + st.setForeground(composite.getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + st.setBackground(composite.getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + st.addKeyListener(new KeyListener() { + + public void keyPressed(KeyEvent e) { + if (e.character == 0x1B) // ESC + st.getShell().dispose(); + } + + public void keyReleased(KeyEvent e) {} + }); + + } + public StyledText getText() { + return st; + } + } + /** * An information presenter determines the style presentation * of information displayed in the default information control. @@ -88,6 +120,8 @@ */ private Font fStatusTextFont; + private MyPopup fPopup; + /** * 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 @@ -102,92 +136,96 @@ this(parent, shellStyle, style, presenter, 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 presenter the presenter to be used - * @param statusFieldText the text to be used in the optional status field - * or null if the status field should be hidden - * @since 3.0 - */ - public DefaultInformationControl(Shell parent, int shellStyle, int style, IInformationPresenter presenter, String statusFieldText) { - GridLayout layout; - GridData gd; - - fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); - Display display= fShell.getDisplay(); - fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); - - Composite composite= fShell; - layout= new GridLayout(1, false); - int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER; - layout.marginHeight= border; - layout.marginWidth= border; - composite.setLayout(layout); - gd= new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - - if (statusFieldText != null) { - composite= new Composite(composite, SWT.NONE); - layout= new GridLayout(1, false); - layout.marginHeight= 0; - layout.marginWidth= 0; - composite.setLayout(layout); - gd= new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - } - - // Text field - fText= new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | style); - gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); - fText.setLayoutData(gd); - fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - fText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - fText.addKeyListener(new KeyListener() { + /** + * 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 presenter the presenter to be used + * @param statusFieldText the text to be used in the optional status field + * or null if the status field should be hidden + * @since 3.0 + */ + public DefaultInformationControl(final Shell parent, int shellStyle, final int style, IInformationPresenter presenter, String statusFieldText) { + GridLayout layout; + GridData gd; + + fPopup= new MyPopup(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle, style); + fPopup.setBackGroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + fPopup.setBorderColor(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK)); + fPopup.setCloseCondition(PopupDialog.closeDialogOnDeactivate); + fPopup.create(); + fText= fPopup.getText(); + fShell= fText.getShell(); - public void keyPressed(KeyEvent e) { - if (e.character == 0x1B) // ESC - fShell.dispose(); - } + // Composite composite= fShell; + // layout= new GridLayout(1, false); + // int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER; + // layout.marginHeight= border; + // layout.marginWidth= border; + // composite.setLayout(layout); + // gd= new GridData(GridData.FILL_BOTH); + // composite.setLayoutData(gd); + // + // if (statusFieldText != null) { + // composite= new Composite(composite, SWT.NONE); + // layout= new GridLayout(1, false); + // layout.marginHeight= 0; + // layout.marginWidth= 0; + // composite.setLayout(layout); + // gd= new GridData(GridData.FILL_BOTH); + // composite.setLayoutData(gd); + // composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + // composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + // } + // + // // Text field + // fText= new StyledText(composite, SWT.MULTI | SWT.READ_ONLY | style); + // gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); + // fText.setLayoutData(gd); + // fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + // fText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + // fText.addKeyListener(new KeyListener() { + // + // public void keyPressed(KeyEvent e) { + // if (e.character == 0x1B) // ESC + // fShell.dispose(); + // } + // + // public void keyReleased(KeyEvent e) {} + // }); + // + fPresenter= presenter; + + // // Status field + // if (statusFieldText != null) { + // + // // Horizontal separator line + // Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); + // separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // + // // Status field label + // Label statusField= new Label(composite, SWT.RIGHT); + // statusField.setText(statusFieldText); + // Font font= statusField.getFont(); + // FontData[] fontDatas= font.getFontData(); + // for (int i= 0; i < fontDatas.length; i++) + // fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); + // fStatusTextFont= new Font(statusField.getDisplay(), fontDatas); + // statusField.setFont(fStatusTextFont); + // gd= new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + // statusField.setLayoutData(gd); + // + // statusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); + // + // statusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + // } - public void keyReleased(KeyEvent e) {} - }); - - fPresenter= presenter; - - // Status field - if (statusFieldText != null) { - - // Horizontal separator line - Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); - separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // Status field label - Label statusField= new Label(composite, SWT.RIGHT); - statusField.setText(statusFieldText); - Font font= statusField.getFont(); - FontData[] fontDatas= font.getFontData(); - for (int i= 0; i < fontDatas.length; i++) - fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); - fStatusTextFont= new Font(statusField.getDisplay(), fontDatas); - statusField.setFont(fStatusTextFont); - gd= new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); - statusField.setLayoutData(gd); - - statusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); - - statusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + addDisposeListener(this); } - - addDisposeListener(this); - } /** * Creates a default information control with the given shell as parent. The given