protected void onLogOutButtonClicked() {
   int result = Dialog.ask(Dialog.D_YES_NO, "Are you sure you want to Log Out ?");
   if (result == Dialog.YES) {
     settings.clearAuthenticationInfo();
     Dialog.alert("Successfully Logged Out");
   }
 }
 protected void onSynchronizeClicked() {
   if (ConnectionFactory.isNotConnected()) {
     Dialog.ask(
         Dialog.D_OK,
         "Could not establish connection with host because all connectors are offline");
   } else if (!settings.isUserLoggedIn()) {
     int result = Dialog.ask(Dialog.D_OK_CANCEL, "You are not logged in.\n Press ok to  login.");
     if (result == Dialog.OK) {
       onLoginButtonClicked();
     }
   } else {
     ((HomeController) controller).synchronize();
   }
 }
  private void layoutScreen() {

    Button loginButton;
    if (settings.isUserLoggedIn()) {
      loginButton = new Button("Log Out");
      loginButton.setChangeListener(
          new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
              onLogOutButtonClicked();
            }
          });
    } else {
      loginButton = new Button("Log In");
      loginButton.setChangeListener(
          new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
              onLoginButtonClicked();
            }
          });
    }

    Button newChildButton = new Button("Register Child");
    newChildButton.setChangeListener(
        new FieldChangeListener() {
          public void fieldChanged(Field field, int context) {
            onNewChildClicked();
          }
        });
    Button viewChildrenButton = new Button("View All Children");
    viewChildrenButton.setChangeListener(
        new FieldChangeListener() {
          public void fieldChanged(Field field, int context) {
            onViewChildrenClicked();
          }
        });

    searchButton = new Button("Search for a Child");
    searchButton.setChangeListener(
        new FieldChangeListener() {
          public void fieldChanged(Field field, int context) {
            onSearchClicked();
          }
        });

    Button synchronizeButton = new Button("Synchronize");
    synchronizeButton.setChangeListener(
        new FieldChangeListener() {
          public void fieldChanged(Field field, int context) {
            onSynchronizeClicked();
          }
        });

    Vector buttonGroup = new Vector();
    buttonGroup.addElement(loginButton);
    buttonGroup.addElement(newChildButton);
    buttonGroup.addElement(viewChildrenButton);
    buttonGroup.addElement(searchButton);

    buttonGroup.addElement(synchronizeButton);

    Button.setOptimimWidthForButtonGroup(buttonGroup);
    VerticalFieldManager manager = new VerticalFieldManager(FIELD_HCENTER);
    manager.setPadding(PADDING);
    loginButton.setPadding(PADDING);
    manager.add(loginButton);
    newChildButton.setPadding(PADDING);
    manager.add(newChildButton);
    viewChildrenButton.setPadding(PADDING);
    manager.add(viewChildrenButton);
    searchButton.setPadding(PADDING);
    manager.add(searchButton);

    synchronizeButton.setPadding(PADDING);
    manager.add(synchronizeButton);

    add(manager);
  }