Replace the Content of a Composite on the fly. [message #460932] |
Mon, 12 September 2005 07: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 #461045 is a reply to message #461029] |
Thu, 15 September 2005 04: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.04963 seconds