RootPanel.get().add(vp);
}
private Widget buildControlPanel() {
VerticalPanel outerPanel = new VerticalPanel();
DecoratorPanel tableWrapper = new DecoratorPanel();
FlexTable resultTable = new FlexTable();
numDigitsListBox.addItem("1,000", "1000");
numDigitsListBox.addItem("5,000", "5000");
numDigitsListBox.addItem("10,000", "10000");
numDigitsListBox.addItem("20,000", "20000");
numDigitsListBox.addItem("100,000", "100000");
buildControlPanelRow(resultTable, "Number of Digits to compute: ",
numDigitsListBox);
buildControlPanelRow(resultTable, "Execute calculation using:", syncCalc);
syncCalc.setValue(true);
buildControlPanelRow(resultTable, "", asyncCalc);
startStopButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (calculationInProgress) {
statusLabel.setText(statusLabel.getText() + "...Cancelled");
stopCalculation();
return;
}
htmlResults.setText("");
statusLabel.setText("Starting calculation");
calculationInProgress = true;
startStopButton.setEnabled(false);
startStopButton.setText("Working...");
startTime = System.currentTimeMillis();
final int numDigits = Integer.valueOf(numDigitsListBox.getValue(numDigitsListBox.getSelectedIndex()));
if (syncCalc.getValue()) {
/*
* A DeferredCommand is used here so that the previous updates to the
* user interface will appear. The synchronous computation will block
* until the calculation is complete, freezing the user interface.
*/
DeferredCommand.addCommand(new Command() {
public void execute() {
doSyncCalculation(numDigits);
}
});
} else {
doAsyncCalculation(numDigits);
}
}
});
buildControlPanelRow(resultTable, "", startStopButton);
tableWrapper.setWidget(resultTable);
// Position the Animation so that it looks centered.
Widget toy = new AnimationToy();
AbsolutePanel toyWrapper = new AbsolutePanel();
toyWrapper.setSize("450px", "210px");