Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » swapping composites
swapping composites [message #449129] Tue, 18 January 2005 15:43 Go to next message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
I'm writing a pocket pc application. I have a class which creates a GUI with
two panels (Composites). The top composite is for displaying the pages from
a form, the bottom is for next / previous buttons to swap between the pages
of that form.

I have worked out a procedure for swapping the form in the top panel. I got
the idea from Snippet98, "Create and dispose of children of a composite.".

when the "next" button is pressed...

1. The next form page (composite) is created and attached to the shell
2. This new page is passed into an object of the GUI class which:
2.1. Disposes of the existing "previous" form
2.2. Attaches new form to the GUI (by calling Composite.setParent)
2.3. Refreshes the display as required

My question is ... say I want to cache the pages of the form. Is it possible
to have several Composites ready to drop in, but not visible or attached to
anything? Say the user presses "previous" button - I can swap in the
previous page and its state, including any data that was already typed in.

Is this a useful thing to do anyway? I could keep a cache of a certain size
so as not to use too many resources?

Any comments would be appreciated. I am new to SWT and Java in general, so I
am experimenting with ideas like this for my application. I did read that it
is better to have one shell in a pocket pc app and to swap composites around
(but maybe not like this!).

thanks,
Andy
Re: swapping composites [message #449142 is a reply to message #449129] Tue, 18 January 2005 18:57 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You can do the same thing that StackLayout does.
org.eclipse.swt.custom.StackLayout is not included in the pocket pc jar but
you can just copy the idea.

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt/Ecl ipse%20SWT%20Custom%20Widgets/common/org/eclipse/swt/custom/ StackLayout.java?rev=HEAD&content-type=text/vnd.viewcvs- markup

"Andy Harrison" <andyh@agaricus.co.uk> wrote in message
news:csjb1o$4vk$1@www.eclipse.org...
> I'm writing a pocket pc application. I have a class which creates a GUI
> with
> two panels (Composites). The top composite is for displaying the pages
> from
> a form, the bottom is for next / previous buttons to swap between the
> pages
> of that form.
>
> I have worked out a procedure for swapping the form in the top panel. I
> got
> the idea from Snippet98, "Create and dispose of children of a composite.".
>
> when the "next" button is pressed...
>
> 1. The next form page (composite) is created and attached to the shell
> 2. This new page is passed into an object of the GUI class which:
> 2.1. Disposes of the existing "previous" form
> 2.2. Attaches new form to the GUI (by calling Composite.setParent)
> 2.3. Refreshes the display as required
>
> My question is ... say I want to cache the pages of the form. Is it
> possible
> to have several Composites ready to drop in, but not visible or attached
> to
> anything? Say the user presses "previous" button - I can swap in the
> previous page and its state, including any data that was already typed in.
>
> Is this a useful thing to do anyway? I could keep a cache of a certain
> size
> so as not to use too many resources?
>
> Any comments would be appreciated. I am new to SWT and Java in general, so
> I
> am experimenting with ideas like this for my application. I did read that
> it
> is better to have one shell in a pocket pc app and to swap composites
> around
> (but maybe not like this!).
>
> thanks,
> Andy
>
>
Re: swapping composites [message #449209 is a reply to message #449142] Wed, 19 January 2005 15:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: betan.us.ibm.com

This is a multipart message in MIME format.
--=_alternative 00536C1D85256F8E_=
Content-Type: text/plain; charset="US-ASCII"

A simpler answer... just use compositeName.setVisibile(false) when you
want to "move" the composite to the "back" and
compositeName2.setVisible(true) to "move" the other composite to the
"front."
--=_alternative 00536C1D85256F8E_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">A simpler answer... just use compositeName.setVisibile(false)
when you want to &quot;move&quot; the composite to the &quot;back&quot;
and compositeName2.setVisible(true) to &quot;move&quot; the other composite
to the &quot;front.&quot;</font>
--=_alternative 00536C1D85256F8E_=--
Re: swapping composites [message #449210 is a reply to message #449209] Wed, 19 January 2005 15:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

It's even easier. Use a StackLayout on the outer composite, and then set
the layout's topControl field to the control to be on top and then call
layout() on the outer composite.

That is exactly what StackLayout is for, switching in composited.


--
Thanks,
Rich Kulp
Re: swapping composites [message #449213 is a reply to message #449210] Wed, 19 January 2005 15:36 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
thanks for the responses... I'm working in PocketPC so StackLayout is not
included. I took Veronika's advice and had a look at the source for
StackLayout and I have got my own version working now. All you need is an
array of Composites so you can loop and manage the setVisible() for each. I
didn't know that, but I do now!

cheers,
Andy


"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:csltrv$qud$1@www.eclipse.org...
> It's even easier. Use a StackLayout on the outer composite, and then set
> the layout's topControl field to the control to be on top and then call
> layout() on the outer composite.
>
> That is exactly what StackLayout is for, switching in composited.
>
>
> --
> Thanks,
> Rich Kulp
Re: swapping composites [message #449306 is a reply to message #449129] Thu, 20 January 2005 19:53 Go to previous message
Eclipse UserFriend
Originally posted by: wiz.vball.net

Look at StackLayout

it allows you to create multiple controls that sit on top of each
other and using

stack.topControl = composite1;
or
stack.topControl = composite2;

you can switch between different composites and keep them in memory
(cache)...

you can keep an array of children composites and keep this as your
cache holder with the StackLayout set on the parent component...
then in your next or previous handlers you can check to see where you
are currently in the array and if the cache is full and you need a new
composite then simply remove one from the array (either from beginning
or end of array depending on whether going forward or backward) and
replace it with your new composite.


On Tue, 18 Jan 2005 15:43:58 -0000, "Andy Harrison"
<andyh@agaricus.co.uk> wrote:

>I'm writing a pocket pc application. I have a class which creates a GUI with
>two panels (Composites). The top composite is for displaying the pages from
>a form, the bottom is for next / previous buttons to swap between the pages
>of that form.
>
>I have worked out a procedure for swapping the form in the top panel. I got
>the idea from Snippet98, "Create and dispose of children of a composite.".
>
>when the "next" button is pressed...
>
>1. The next form page (composite) is created and attached to the shell
>2. This new page is passed into an object of the GUI class which:
>2.1. Disposes of the existing "previous" form
>2.2. Attaches new form to the GUI (by calling Composite.setParent)
>2.3. Refreshes the display as required
>
>My question is ... say I want to cache the pages of the form. Is it possible
>to have several Composites ready to drop in, but not visible or attached to
>anything? Say the user presses "previous" button - I can swap in the
>previous page and its state, including any data that was already typed in.
>
>Is this a useful thing to do anyway? I could keep a cache of a certain size
>so as not to use too many resources?
>
>Any comments would be appreciated. I am new to SWT and Java in general, so I
>am experimenting with ideas like this for my application. I did read that it
>is better to have one shell in a pocket pc app and to swap composites around
>(but maybe not like this!).
>
>thanks,
>Andy
>
Previous Topic:Drag and drop with link
Next Topic:Easy way to get API info
Goto Forum:
  


Current Time: Tue Apr 16 23:40:27 GMT 2024

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

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

Back to the top