final HTML responseField = new HTML();
final FlexCellFormatter cellFormatter = flexTable.getFlexCellFormatter();
final TextBox usernameField = new TextBox();
final PasswordTextBox passwordField = new PasswordTextBox();
final Button loginButton = new Button("Login");
final ScrollPanel scrollPanel = new ScrollPanel();
submitButton.addStyleName("sendButton");
submitButton.setEnabled(false);
monitorButton.setEnabled(true);
goHomeButton.setEnabled(true);
idField.setWidth("400px");
responseField.setWidth("640px");
responseField.setVisible(false);
scrollPanel.add(flexTable);
scrollPanel.setSize("800px", "600px");
scrollPanel.addStyleName("cw-ScollPanel");
flexTable.addStyleName("cw-FlexTable");
flexTable.setCellSpacing(2);
flexTable.setCellPadding(3);
// Add the fields to the RootPanel
if (RootPanel.get("nameFieldContainer") != null) {
//main page
RootPanel.get("nameFieldContainer").add(fileField);
RootPanel.get("idFieldContainer").add(idField);
RootPanel.get("sendButtonContainer").add(submitButton);
RootPanel.get("responseContainer").add(responseField);
RootPanel.get("monitorButtonContainer").add(monitorButton);
}
else if (RootPanel.get("usernameFieldContainer") != null) {
//login page
RootPanel.get("usernameFieldContainer").add(usernameField);
RootPanel.get("passwordFieldContainer").add(passwordField);
RootPanel.get("loginButtonContainer").add(loginButton);
}
else {
//results page
RootPanel.get("homeButtonContainer").add(goHomeButton);
RootPanel.get("tableContainer").add(scrollPanel);
cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
//cellFormatter.setColSpan(0, 0, 0);
//we no longer use timer scheduling, just run it once
timer.run();
// Program a Timer to execute this every N seconds
//no more auto-refresh: user will refresh manually
//timer.scheduleRepeating(UPDATE_INTERVAL*1000);
}
// Create a handler for the loginButtonButton
class LoginButtonHandler implements ClickHandler {
public void onClick(ClickEvent event) {
String username = usernameField.getText();
String password = passwordField.getText();
RootPanel.get().clear();
Window.Location.assign("/sampleapp?username=" + username + "&password=" + password);
}
}
loginButton.addClickHandler(new LoginButtonHandler());