Saturday, October 30, 2010

GWT-maps - How to ensure paint-based calls appear in a desired sequence?

Hi - Using GWT 2.0 and GWT-MAPS 1.1.. and am scratching my head
trying to figure how to implement a consistent 'Please wait'
dialog popup to appear *just before* i ask the Map to make many
(hundreds) of markers.setVisible(true). i.e.:

- PopupPanel P defined to say 'Please Wait' and is hidden
- button B onclick() method:
1. invoke P.show();
2. for each marker X in set, call X.setVisible(false) // set is large
3. hide P

Surprisingly in some ways, since steps 1 and 2 are both paint-
based they are interleaving and my popup P is not showing
consistently! Sometimes only after several seconds.. or near the
end of all the .setVisible calls!
How can i ENSURE that the panel (or ANYTHING 'paint-based')
appears before something else that is paint-based happens??

This would seem to be a common issue across Apps (Maps and
otherwise!) (e.g., a "Please Wait" dialog pattern in which the dialog
appears before the 'work' and disappears 'after')

Code snippet below:

WAIT_DIALOG = new DialogBox(false);
WAIT_DIALOG.setStyleName("gwt-PopupPanel");
HTML message4 = new HTML(".. html here ");
WAIT_DIALOG.setPixelSize(280, 100);//w,h
WAIT_DIALOG.setAnimationEnabled(true);
WAIT_DIALOG.setPopupPosition(400,250);
WAIT_DIALOG.setWidget(message4);
WAIT_DIALOG.hide();
...
key_ok_button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
//show the 'Please wait' dialog
/* THIS SEEMS TO LAG AND THE DIALOG DOES NOT SHOW PROMPTLY! */
WAIT_DIALOG.show();

for(int i=0;i<LS.size();i++){ //THERE ARE MANY MARKERS/POLYLINES IN
THIS SET
((Marker)LS.elementAt(i)).setVisible(true);
}//for
//now hide the dialog after a timeout
/* NO PROBLEMS WITH HIDING IT */
timeoutTimer = new Timer() {
public void run() {
WAIT_DIALOG.hide(); //hide the 'please wait' dialog
timeoutTimer = null;
}//run
};
timeoutTimer.schedule(3 * 1000); // timeout is in milliseconds
return;
}//onclick
}...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment