/** Sets up the login widget. */ private void setup() { setText(LocaleText.get("saveFormToBrowserTitle")); statusLabel = new Label(); // first see if the user is logged in. String user = UserInfo.getCurrentUser(); if (user == null) { statusLabel.setText(LocaleText.get("mustLoginFirst")); DOM.setStyleAttribute(statusLabel.getElement(), "color", "red"); } else { Label label = new Label(LocaleText.get("formName")); table.setWidget(1, 0, label); txtFormName = new TextBox(); txtFormName.setText(formDisplayText); // check and see if this form has already been saved String currentForm = UserInfo.getCurrentForm(); if (currentForm != null) { txtFormName.setText(currentForm); } txtFormName.setWidth("50%"); table.setWidget(1, 1, txtFormName); FormUtil.maximizeWidget(txtFormName); txtFormName.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) save(); } }); Button btnSave = new Button( LocaleText.get("save"), new ClickHandler() { public void onClick(ClickEvent event) { save(); } }); table.setWidget(3, 0, btnSave); } Button btnCancel = new Button( LocaleText.get("cancel"), new ClickHandler() { public void onClick(ClickEvent event) { cancel(); } }); table.setWidget(2, 0, statusLabel); table.setWidget(3, 1, btnCancel); FlexCellFormatter formatter = table.getFlexCellFormatter(); formatter.setColSpan(2, 0, 3); formatter.setColSpan(3, 0, 3); formatter.setColSpan(4, 0, 2); formatter.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER); formatter.setWidth(1, 1, "50%"); VerticalPanel panel = new VerticalPanel(); FormUtil.maximizeWidget(panel); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.add(table); setWidget(panel); setWidth("300px"); Scheduler.get() .scheduleDeferred( new Command() { public void execute() { if (txtFormName != null) { txtFormName.setFocus(true); } } }); }