Home » Eclipse Projects » Eclipse Platform » TextViewer and positioning it in the dialog
| TextViewer and positioning it in the dialog [message #304617] |
Mon, 12 June 2006 18:44  |
Eclipse User |
|
|
|
Hi,
I'm trying to set the position of TextViewer in the dialog
which has a GridLayout set.
protected Control createDialogArea(Composite parent)
{
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
composite.setLayout(layout);
Label codeLabel = new Label(composite, SWT.NONE);
codeLabel.setText("&Label:");
codeLabel.setLayoutData(new GridData(GridData.BEGINNING,
GridData.BEGINNING, false, false));
codeTextViewer = new TextViewer(getShell(), SWT.MULTI);
codeTextViewer.getControl().setLayoutData(new GridData(450, 100));
codeTextViewer.setInput(new Document());
}
I also have this method:
protected void createButtonsForButtonBar(Composite parent)
{
createButton(parent, IDialogConstants.OK_ID,
IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
}
The trouble is that TextViewer is always set on the bottom end of the
dialog - under the OK, CANCEL buttons! Label 'codeLabel' sits over
the buttons...
I've tried to move the code of the TextViewer around the
createDialogArea method but it had no effect.
It has expected dimensions, but the position is wrong.
Thanks for your replies.
Piotr Gorny
|
|
|
| Re: TextViewer and positioning it in the dialog [message #304629 is a reply to message #304617] |
Tue, 13 June 2006 03:35   |
Eclipse User |
|
|
|
Piotr Gorny schrieb:
> Hi,
> I'm trying to set the position of TextViewer in the dialog
> which has a GridLayout set.
>
> protected Control createDialogArea(Composite parent)
> {
> Composite composite = new Composite(parent, SWT.NONE);
> GridLayout layout = new GridLayout(1, false);
> composite.setLayout(layout);
>
> Label codeLabel = new Label(composite, SWT.NONE);
> codeLabel.setText("&Label:");
> codeLabel.setLayoutData(new GridData(GridData.BEGINNING,
> GridData.BEGINNING, false, false));
>
> codeTextViewer = new TextViewer(getShell(), SWT.MULTI);
^^^^^^^^^^
codeTextViewer = new TextViewer(composite, SWT.MULTI);
Tom
|
|
|
| Re: TextViewer and positioning it in the dialog [message #304630 is a reply to message #304629] |
Tue, 13 June 2006 04:22   |
Eclipse User |
|
|
|
Tom Schindl napisał(a):
> Piotr Gorny schrieb:
>> Hi,
>> I'm trying to set the position of TextViewer in the dialog
>> which has a GridLayout set.
>>
>> protected Control createDialogArea(Composite parent)
>> {
>> Composite composite = new Composite(parent, SWT.NONE);
>> GridLayout layout = new GridLayout(1, false);
>> composite.setLayout(layout);
>>
>> Label codeLabel = new Label(composite, SWT.NONE);
>> codeLabel.setText("&Label:");
>> codeLabel.setLayoutData(new GridData(GridData.BEGINNING,
>> GridData.BEGINNING, false, false));
>>
>> codeTextViewer = new TextViewer(getShell(), SWT.MULTI);
> ^^^^^^^^^^
> codeTextViewer = new TextViewer(composite, SWT.MULTI);
>
> Tom
Hello again Tom :-)
I'm afraid I've tried this solution earlier.
That's not the clue. I've left the composite and set getShell()
because the first one didn't work.
Piotr Gorny
|
|
|
| Re: TextViewer and positioning it in the dialog [message #304633 is a reply to message #304630] |
Tue, 13 June 2006 06:37   |
Eclipse User |
|
|
|
Piotr Gorny schrieb:
> Tom Schindl napisał(a):
>> Piotr Gorny schrieb:
>>> Hi,
>>> I'm trying to set the position of TextViewer in the dialog
>>> which has a GridLayout set.
>>>
>>> protected Control createDialogArea(Composite parent)
>>> {
>>> Composite composite = new Composite(parent, SWT.NONE);
>>> GridLayout layout = new GridLayout(1, false);
>>> composite.setLayout(layout);
>>>
>>> Label codeLabel = new Label(composite, SWT.NONE);
>>> codeLabel.setText("&Label:");
>>> codeLabel.setLayoutData(new GridData(GridData.BEGINNING,
>>> GridData.BEGINNING, false, false));
>>>
>>> codeTextViewer = new TextViewer(getShell(), SWT.MULTI);
>> ^^^^^^^^^^
>> codeTextViewer = new TextViewer(composite, SWT.MULTI);
>>
>> Tom
> Hello again Tom :-)
> I'm afraid I've tried this solution earlier.
> That's not the clue. I've left the composite and set getShell()
> because the first one didn't work.
>
> Piotr Gorny
This code works perfectly for me on Eclipse-3.2 RC6.
---------------8<---------------
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Dialog dia = new Dialog(shell) {
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite)super.createDialogArea(parent);
Label codeLabel = new Label(composite, SWT.NONE);
codeLabel.setText("&Label:");
codeLabel.setLayoutData(new
GridData(GridData.BEGINNING,GridData.BEGINNING, false, false));
TextViewer codeTextViewer = new TextViewer(composite, SWT.MULTI);
codeTextViewer.getControl().setLayoutData(new GridData(450, 100));
return composite;
}
};
dia.open();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
---------------8<---------------
|
|
| | |
| Re: TextViewer and positioning it in the dialog [message #304638 is a reply to message #304635] |
Tue, 13 June 2006 07:03  |
Eclipse User |
|
|
|
Piotr Gorny schrieb:
> Hi,
> thanks to your snippet I've found the reason:
>
> I had:
> //Composite composite = new Composite(parent, SWT.NONE);
>
> ..but should have:
> Composite composite = (Composite) super.createDialogArea(parent);
>
> Unfortunately i don't understand why should I use the latter version :-(
>
Well if I replace the super call with the lines below i get the same
result as I got when calling super.
-----------8<-----------
Composite composite = new Composite(parent,SWT.NONE);
composite.setLayout(new GridLayout(1,false));
-----------8<-----------
Tom
|
|
|
Goto Forum:
Current Time: Wed Nov 05 15:10:29 EST 2025
Powered by FUDForum. Page generated in 0.07136 seconds
|