Example #1
0
  /** Called when one selects the save button. */
  private void save() {
    try {
      // 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");
        return;
      }

      // check and see if this form already exists
      String form = UserInfo.getForm(user, txtFormName.getText());

      if (form != null) {
        // Window.alert("This form already exists and will be over written");
        if (!Window.confirm(
            "A form by this name is already saved in this browser. Do you want to overwrite it?")) {
          return;
        }
      }

      UserInfo.setForm(user, txtFormName.getText(), formXmlStr);
      // clear dirty flags
      FormDesignerController.clearIsDirty();

      hide();
    } catch (Exception e) // in case there's an error with storage
    {
      statusLabel.setText(e.getMessage());
      DOM.setStyleAttribute(statusLabel.getElement(), "color", "red");
    }
  }