Could you use an AccordionSelectionListener which would intercept any panel
selection change requests via the previewSelectedIndexChange() method?
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/AccordionSelectionListener.html#previewSelectedIndexChange(org.apache.pivot.wtk.Accordion,
int)

It could keep track of the panels that have been initialized, and Veto the
selection change until the panel is ready to be displayed.  (Disable the
panel / show a busy cursor / show an ActivityIndicator / etc)
http://pivot.apache.org/tutorials/activity-indicators.html

If you don't want to actually Veto the change, you could just use the event
as a notification to start initializing the panel.

If you want to show an ActivityIndicator while the panel loads, you could
use a StackPane as per the iTunes search demo
http://pivot.apache.org/demos/itunes-search.html
http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/

Chris

On 12 June 2011 15:59, Edvin Syse <[email protected]> wrote:

> My Pivot App uses JDK ServiceLoader to load "modules" for an Accordion.
> Some of the modules will pull data from a remote server and do some
> initialization when created so I want to do it when each panel is shown for
> the first time.
>
> I want to check if my approach is viable: Most Panels are ScrollPanes, and
> they are ofcourse unexpensive to create. I then override the layout() method
> and to something like:
>
>    protected void layout() {
>        if (!initialized) {
>            setColumnHeader(createColumnHeader());
>            setView(createView());
>            initialized = true;
>        }
>        super.layout();
>    }
>
> This seems to work, but is it an OK approach?
>
> -- Edvin
>

Reply via email to