Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Replace the Content of a Composite on the fly.
Replace the Content of a Composite on the fly. [message #460932] Mon, 12 September 2005 11:49 Go to next message
Eclipse UserFriend
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 #460933 is a reply to message #460932] Mon, 12 September 2005 12:36 Go to previous messageGo to next message
arne anka is currently offline arne ankaFriend
Messages: 133
Registered: July 2009
Senior Member
redraw?
Re: Replace the Content of a Composite on the fly. [message #460938 is a reply to message #460932] Mon, 12 September 2005 14:18 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #460972 is a reply to message #460952] Tue, 13 September 2005 13:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Wudong Liu" <wudongs@gmail.com> wrote in message
news:4326354B.5010601@gmail.com...
> Sunil Kamath д
Re: Replace the Content of a Composite on the fly. [message #461029 is a reply to message #460972] Thu, 15 September 2005 01:56 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Examples
Next Topic:Table.select() doesn't call SelectionListener
Goto Forum:
  


Current Time: Fri Sep 20 07:29:17 GMT 2019

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

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

Back to the top