Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » special Jface dialog
special Jface dialog [message #329230] Mon, 16 June 2008 23:03 Go to next message
Lidder is currently offline LidderFriend
Messages: 46
Registered: July 2009
Member
Hello All,

Goal: Create a JFace dialog with a SWT text widget and the okay and cancel
buttons such that when the user types text, the dialog and the text area
expand/shrink according to the width and height of the text.

private Text textArea;

I am using a gridlayout:
textArea.setLayoutData(new GridData(GridData.FILL_BOTH));

I can get the textarea to expand/shrink using the following code:
textArea.setSize(textArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));

I have put this code in the modify event of the textarea. But I think
there might be a better place to put this. Any ideas?
I could not find a way to shrink/expand the dialog. The only place where I
can set the size of the dialog is in the configureShell(Shell shell)
function. But this sets the size only once when creating the dialog.

I also tried to do the following in the createContents(composite parent)
function:
getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));

this also sets the size once. How do I resize the dialog and keep it in
sync with the textarea. It is better in this case to use just a shell? and
not a JFace dialog?

Thanks.
Re: special Jface dialog [message #329251 is a reply to message #329230] Tue, 17 June 2008 13:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Upkar Lidder wrote:
> Hello All,
>
> Goal: Create a JFace dialog with a SWT text widget and the okay and
> cancel buttons such that when the user types text, the dialog and the
> text area expand/shrink according to the width and height of the text.
>
> private Text textArea;
>
> I am using a gridlayout:
> textArea.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> I can get the textarea to expand/shrink using the following code:
> textArea.setSize(textArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>
> I have put this code in the modify event of the textarea. But I think
> there might be a better place to put this. Any ideas?
> I could not find a way to shrink/expand the dialog. The only place where
> I can set the size of the dialog is in the configureShell(Shell shell)
> function. But this sets the size only once when creating the dialog.
> I also tried to do the following in the createContents(composite parent)
> function:
> getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
>
> this also sets the size once. How do I resize the dialog and keep it in
> sync with the textarea. It is better in this case to use just a shell?
> and not a JFace dialog?

Looking at the implementation of Window.getInitialSize() (which Dialog
inherits and uses), it looks like you can just call shell.computeSize()
as it does, whenever the Text size has changed.

Hope this helps,
Eric
Re: special Jface dialog [message #329269 is a reply to message #329251] Tue, 17 June 2008 18:27 Go to previous message
Lidder is currently offline LidderFriend
Messages: 46
Registered: July 2009
Member
Thanks for the response Eric.

I do shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT)); when the
text changes and it seems to be working.
Previous Topic:How to link multipage editor to source code file?
Next Topic:dispose menu and menu items
Goto Forum:
  


Current Time: Sat Jul 27 20:24:34 GMT 2024

Powered by FUDForum. Page generated in 0.03216 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top