Replace the Content of a Composite on the fly. [message #460932] |
Mon, 12 September 2005 11:49 |
Eclipse User |
|
|
|
Originally posted by: wudongs.gmail.com
Hi, everyone:
I have the following problem:
I want to change the content (compositeContent) of a Composite
(compositeContainer) accoridng to the selection event of a combox.
I do the following thing:
1. check if compositeContent is null or displosed. if it's not null and
not disposed, disposed it.
2. create a new Compoiste with the parent of compositeContainer,
assigning that to the compositeContent.
3. layout() on the compositeContainer.
It works for the replacing of the content. but the content isn't
displayed only after i drag to change the size of the compositeContainer.
Why the step 3 doesn't work? i'm assumed it will re-layout the content
of compositeContainer and display the content.
Thank you.
|
|
|
|
Re: Replace the Content of a Composite on the fly. [message #460938 is a reply to message #460932] |
Mon, 12 September 2005 14:18 |
Eclipse User |
|
|
|
Originally posted by: sunil_kamath.nohotspammail.com
"Wudong Liu" <wudongs@gmail.com> wrote in message
news:dg3q0f$ncn$1@news.eclipse.org...
> Hi, everyone:
> I have the following problem:
> I want to change the content (compositeContent) of a Composite
> (compositeContainer) accoridng to the selection event of a combox.
> I do the following thing:
> 1. check if compositeContent is null or displosed. if it's not null and
> not disposed, disposed it.
> 2. create a new Compoiste with the parent of compositeContainer,
> assigning that to the compositeContent.
> 3. layout() on the compositeContainer.
>
> It works for the replacing of the content. but the content isn't
> displayed only after i drag to change the size of the compositeContainer.
>
> Why the step 3 doesn't work? i'm assumed it will re-layout the content
> of compositeContainer and display the content.
>
Code snippet?
---
Sunil
|
|
|
Re: Replace the Content of a Composite on the fly. [message #460952 is a reply to message #460938] |
Tue, 13 September 2005 02:11 |
Eclipse User |
|
|
|
Originally posted by: wudongs.gmail.com
Sunil Kamath 写道:
> "Wudong Liu" <wudongs@gmail.com> wrote in message
> news:dg3q0f$ncn$1@news.eclipse.org...
>
>>Hi, everyone:
>>I have the following problem:
>>I want to change the content (compositeContent) of a Composite
>>(compositeContainer) accoridng to the selection event of a combox.
>>I do the following thing:
>>1. check if compositeContent is null or displosed. if it's not null and
>>not disposed, disposed it.
>>2. create a new Compoiste with the parent of compositeContainer,
>>assigning that to the compositeContent.
>>3. layout() on the compositeContainer.
>>
>>It works for the replacing of the content. but the content isn't
>>displayed only after i drag to change the size of the compositeContainer.
>>
>>Why the step 3 doesn't work? i'm assumed it will re-layout the content
>>of compositeContainer and display the content.
>>
>
> Code snippet?
> ---
> Sunil
>
>
Here is the code snippet:
combo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String text = combo.getText();
SearchType type = SearchType.getSearchTypeByName(text);
if (searchControl!=null&&!searchControl.isDisposed()) {
searchControl.dispose();
}
//Create the New content control
//on the parent searchpane.
searchControl = type.createComposite(searchpane);
((Composite)searchControl).layout();
searchpane.layout();
parent.layout();
}
);
|
|
|
|
Re: Replace the Content of a Composite on the fly. [message #461029 is a reply to message #460972] |
Thu, 15 September 2005 01:56 |
Eclipse User |
|
|
|
Originally posted by: wudongs.gmail.com
Sunil Kamath 写道:
> "Wudong Liu" <wudongs@gmail.com> wrote in message
> news:4326354B.5010601@gmail.com...
>
>>Sunil Kamath 写道:
>>
>>>"Wudong Liu" <wudongs@gmail.com> wrote in message
>>>news:dg3q0f$ncn$1@news.eclipse.org...
>>>
>
> [snip]
>
>>>>Why the step 3 doesn't work? i'm assumed it will re-layout the content
>>>>of compositeContainer and display the content.
>>>>
>>>
>>>Code snippet?
>>>---
>>>Sunil
>>>
>>>
>>
>>Here is the code snippet:
>>
>>combo.addSelectionListener(new SelectionListener() {
>>public void widgetSelected(SelectionEvent e) {
>>String text = combo.getText();
>>SearchType type = SearchType.getSearchTypeByName(text);
>>if (searchControl!=null&&!searchControl.isDisposed()) {
>>searchControl.dispose();
>>}
>>//Create the New content control
>>//on the parent searchpane.
>>searchControl = type.createComposite(searchpane);
>>((Composite)searchControl).layout();
>>searchpane.layout();
>>parent.layout();
>>}
>>);
>
>
> Hmmm... looks fine. What layout manager are you using?
> Did you try debugging to see what is going on?
> ---
> Sunil
>
>
The searchpane compoiste uses FillLayout, and the parent composite uses
gridlayout. I assume nomatter what layout i use, it should work when
the layout() method is invoked.
I do debug, but found nothing.
|
|
|
Re: Replace the Content of a Composite on the fly. [message #461045 is a reply to message #461029] |
Thu, 15 September 2005 08:37 |
Eclipse User |
|
|
|
Originally posted by: stefan.renz.web.de
May be this snippet will help you:
// determine top level shell
Composite comp = this;
while ( ! ((comp = comp.getParent()) instanceof Shell ))
{
}
Shell shell = (Shell)comp;
// fetch current size of shell
Point oldSize = shell.getSize();
// compute size of shell with the given current width (only the
height should change)
Point newSize = shell.computeSize(oldSize.x, SWT.DEFAULT, true);
// set the new size of the shell
shell.setSize(oldSize.x, newSize.y);
Wudong Liu wrote:
> Sunil Kamath ÐŽµÀ:
>> "Wudong Liu" <wudongs@gmail.com> wrote in message
>> news:4326354B.5010601@gmail.com...
>>
>>>Sunil Kamath ÐŽµÀ:
>>>
>>>>"Wudong Liu" <wudongs@gmail.com> wrote in message
>>>>news:dg3q0f$ncn$1@news.eclipse.org...
>>>>
>>
>> [snip]
>>
>>>>>Why the step 3 doesn't work? i'm assumed it will re-layout the content
>>>>>of compositeContainer and display the content.
>>>>>
>>>>
>>>>Code snippet?
>>>>---
>>>>Sunil
>>>>
>>>>
>>>
>>>Here is the code snippet:
>>>
>>>combo.addSelectionListener(new SelectionListener() {
>>>public void widgetSelected(SelectionEvent e) {
>>>String text = combo.getText();
>>>SearchType type = SearchType.getSearchTypeByName(text);
>>>if (searchControl!=null&&!searchControl.isDisposed()) {
>>>searchControl.dispose();
>>>}
>>>//Create the New content control
>>>//on the parent searchpane.
>>>searchControl = type.createComposite(searchpane);
>>>((Composite)searchControl).layout();
>>>searchpane.layout();
>>>parent.layout();
>>>}
>>>);
>>
>>
>> Hmmm... looks fine. What layout manager are you using?
>> Did you try debugging to see what is going on?
>> ---
>> Sunil
>>
>>
> The searchpane compoiste uses FillLayout, and the parent composite uses
> gridlayout. I assume nomatter what layout i use, it should work when
> the layout() method is invoked.
> I do debug, but found nothing.
|
|
|
Powered by
FUDForum. Page generated in 0.04320 seconds