public void updateDetails() {
    Record selectedRecord = userListGrid.getSelectedRecord();

    if (selectedRecord == null) {
      return;
    }

    int selectedTab = getSelectedTabNumber();
    if (selectedTab == 0) {
      // view tab : show empty message
      userViewer.setData(new Record[] {selectedRecord});
    } else if (selectedTab == 1) {
      // edit tab : show record editor
      editorForm.editRecord(selectedRecord);
    } else {
      // insertForm.clearValues();
    }
  }
  public void findUsers() {
    Criteria findValues;

    String condition = searchForm.getValueAsString("searchCondition");
    String keyword = searchForm.getValueAsString("searchWord");

    /*
    System.out.println("condition ======> " + condition);
    System.out.println("keyword ======> " + keyword);
    */

    if ("User ID".equals(condition)) {
      findValues = searchForm.getValuesAsCriteria();
      findValues.addCriteria("userId", keyword);
    } else if ("User Name".equals(condition)) {
      findValues = searchForm.getValuesAsCriteria();
      findValues.addCriteria("userName", keyword);
    } else {
      findValues = searchForm.getValuesAsCriteria();
    }

    userList.filterData(findValues);
    userDetailTabPane.clearDetails();
  }
  public UserManagement() {
    setWidth100();
    setHeight100();
    setLayoutMargin(20);

    UserDataSource userDS = UserDataSource.getInstance();

    searchForm = new SearchForm(userDS);

    // final ComboBoxItem searchConditions = searchForm.getSearchConditionField();

    setupContextMenu();

    userList = new ItemListGrid(userDS);
    userList.addRecordClickHandler(
        new RecordClickHandler() {
          public void onRecordClick(RecordClickEvent event) {
            userDetailTabPane.updateDetails();
          }
        });

    userList.addCellSavedHandler(
        new CellSavedHandler() {
          public void onCellSaved(CellSavedEvent event) {
            userDetailTabPane.updateDetails();
          }
        });

    userList.addCellContextClickHandler(
        new CellContextClickHandler() {
          public void onCellContextClick(CellContextClickEvent event) {
            userListMenu.showContextMenu();
            event.cancel();
          }
        });

    SectionStack sessionLayout = new SectionStack();
    sessionLayout.setVisibilityMode(VisibilityMode.MULTIPLE);
    sessionLayout.setAnimateSections(true);

    searchForm.setHeight(60);
    searchForm.addFindListener(
        new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
          public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
            findUsers();
          }
        });

    SectionStackSection findSection = new SectionStackSection("Find Users");
    findSection.setItems(searchForm);
    findSection.setExpanded(true);

    SectionStackSection usersSection = new SectionStackSection("User List");
    usersSection.setItems(userList);
    usersSection.setExpanded(true);

    userDetailTabPane = new UserDetailTabPane(userDS, userList);
    SectionStackSection userDetailsSection = new SectionStackSection("User Details");
    userDetailsSection.setItems(userDetailTabPane);
    userDetailsSection.setExpanded(true);

    sessionLayout.setSections(findSection, usersSection, userDetailsSection);

    addMember(sessionLayout);
  }