Hi,
I have a function that is used to process a set of data that is
returned from a server. This routine gets the date range for the data
returned and pops up a window for the used to enter the range that
they are interested in. The code will then go through the data and
draw a polyline on a map for the relevant set of data. This is a long
process and I wanted to display a progress bar on teh dialog to show
that the processing is happening. I am unable to get the progress bar
to update whilst the code is looping through the data.
Can anyone suggest a solution.
protected static void showTrackHistory(final Node item) {
//Ask the User to specify a range of data to view for the
specified
track
Panel timePanel = new Panel();
timePanel.setBorder(false);
timePanel.setPaddings(15);
VerticalPanel startTimePanel = new VerticalPanel();
startTimePanel.setSpacing(15);
Date startDate = new Date(Long.valueOf(((Element)
firstReport).getAttribute("TOF")).longValue() * 1000);
final TextField startTextField = new TextField("Date");
startTextField.setWidth(180);
startTextField.setHideLabel(true);
startTextField.setValue(startDate.toString());
DatePicker datePicker = new DatePicker();
datePicker.setValue(startDate);
datePicker.setTodayText("Now");
datePicker.addListener(new DatePickerListenerAdapter() {
public void onSelect(DatePicker dataPicker, Date date) {
startTextField.setValue(date.toString());
}
});
FieldSet startFS = new FieldSet();
startFS.setPaddings(5);
startFS.setCheckboxToggle(false);
startFS.setFrame(true);
startFS.setTitle("Start");
startFS.setCollapsed(false);
startFS.add(datePicker);
startFS.add(startTextField);
startTimePanel.add(startFS);
VerticalPanel endTimePanel = new VerticalPanel();
endTimePanel.setSpacing(15);
Date endDate = new Date(Long.valueOf(((Element)
lastReport).getAttribute("TOF")).longValue() * 1000);
final TextField endTextField = new TextField("Date");
endTextField.setWidth(180);
endTextField.setHideLabel(true);
endTextField.setValue(endDate.toString());
DatePicker endDatePicker = new DatePicker();
endDatePicker.setValue(endDate);
endDatePicker.setTodayText("Now");
endDatePicker.addListener(new DatePickerListenerAdapter() {
public void onSelect(DatePicker dataPicker, Date date) {
endTextField.setValue(date.toString());
}
});
FieldSet endFS = new FieldSet();
endFS.setPaddings(5);
endFS.setCheckboxToggle(false);
endFS.setFrame(true);
endFS.setTitle("End");
endFS.setCollapsed(false);
endFS.add(endDatePicker);
endFS.add(endTextField);
endTimePanel.add(endFS);
HorizontalPanel startEndPanel = new HorizontalPanel();
startEndPanel.add(startTimePanel);
startEndPanel.add(endTimePanel);
Button btnOK = new Button("OK");
btnOK.setWidth("200px");
pBar = new ProgressBar();
pBar.setWidth(250);
pBar.setText("Ready");
pBar.enable();
pBar.setAutoShow(true);
//pBar.reset();
//pBar.disable();
HorizontalPanel btnPanel = new HorizontalPanel();
btnPanel.setSpacing(5);
btnPanel.add(btnOK);
btnPanel.add(pBar);
timePanel.add(startEndPanel);
timePanel.add(btnPanel);
timePeriod = new Window();
timePeriod.setTitle("History Period Selection for Track : " +
trackName);
timePeriod.setClosable(true);
timePeriod.setWidth(520);
timePeriod.setHeight(400);
timePeriod.setPlain(true);
timePeriod.setCloseAction(Window.HIDE);
timePeriod.add(timePanel);
timePeriod.setModal(false);
timePeriod.setButtonAlign(Position.CENTER);
btnOK.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
((Button)sender).setEnabled(false);
pBar.enable();
pBar.updateText("Processing Data...");
long historyStartTime = new
Date(startTextField.getValueAsString
()).getTime();
long historyEndTime = new
Date(endTextField.getValueAsString
()).getTime();
NodeList historyItems = item.getChildNodes();
LatLng[] pointList = new
LatLng[historyItems.getLength()];
for (int i = 0; i < historyItems.getLength();
i++) {
Node point = historyItems.item(i);
{Extract location data}
final LatLng historyPoint =
LatLng.newInstance(lat, longit);
pointList[i] = historyPoint;
iconManager.CreateHistoryIcon(Integer.valueOf(i+1).toString(),
hdop, id);
MarkerOptions options =
MarkerOptions.newInstance
(iconManager.getIcon(id));
options.setClickable(true);
options.setDraggable(false);
Marker marker = new
Marker(historyPoint, options);
marker.addMarkerClickHandler(new MarkerClickHandler() {
public void
onClick(MarkerClickEvent event) {
Marker marker =
(Marker)event.getSource();
infoWindow.open(historyPoint, content1);
}
});
}
});
map.addOverlay(marker);
}
float pBarValue =
Integer.valueOf(i).floatValue() /
Integer.valueOf(historyItems.getLength()).floatValue();
pBar.setValue(pBarValue);
}
PolylineOptions options =
PolylineOptions.newInstance(true,
false);
Polyline polyline = new Polyline(pointList,
"#0000FF", 3, 0.7,
options);
polyline.addPolylineClickHandler(new
PolylineClickHandler () {
public void onClick(PolylineClickEvent
event) {
LatLng clickPos =
event.getLatLng();
InfoWindow infoWindow =
map.getInfoWindow();
InfoWindowContent content = new
InfoWindowContent("<br/>" +
trackName);
infoWindow.open(clickPos,
content);
}
});
map.addOverlay(polyline);
map.setZoomLevel(map.getBoundsZoomLevel(polyline.getBounds()));
map.panTo(polyline.getBounds().getCenter());
timePeriod.getUpdateManager().stopAutoRefresh();
timePeriod.hide();
}
});
timePeriod.show();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---