@Override
protected Widget createMainWidget()
{
// create progress container
final SimplePanelWithProgress panel = new SimplePanelWithProgress(
ProgressImages.createLargeGray());
panel.setStylePrimaryName(RESOURCES.styles().mainWidget());
// show progress (with delay)
panel.showProgress(200);
// query data source for packages
mirrorSource_.requestData(new SimpleRequestCallback<JsArray<T>>() {
@Override
public void onResponseReceived(JsArray<T> mirrors)
{
// keep internal list of mirrors
mirrors_ = new ArrayList<T>(mirrors.length());
// create list box and select default item
listBox_ = new ListBox(false);
listBox_.setVisibleItemCount(18); // all
listBox_.setWidth("100%");
if (mirrors.length() > 0)
{
for(int i=0; i<mirrors.length(); i++)
{
T mirror = mirrors.get(i);
mirrors_.add(mirror);
String item = mirrorSource_.getLabel(mirror);
String value = mirrorSource_.getURL(mirror);
listBox_.addItem(item, value);
}
listBox_.setSelectedIndex(0);
enableOkButton(true);
}
// set it into the panel
panel.setWidget(listBox_);
// update ok button on changed
listBox_.addDoubleClickHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(DoubleClickEvent event)
{
clickOkButton();
}
});
// if the list box is larger than the space we initially allocated
// then increase the panel height
final int kDefaultPanelHeight = 285;
if (listBox_.getOffsetHeight() > kDefaultPanelHeight)
panel.setHeight(listBox_.getOffsetHeight() + "px");
// set focus
FocusHelper.setFocusDeferred(listBox_);
}