/**
  * Searches for InsuranceCompanies. Calls the controller and updates the tableData to the
  * searchMap.
  */
 private void searchInsuranceCompany() {
   String query = searchTextField.getText();
   controller.searchInsuranceCompanies(query);
   tableData.update(
       model.getSearchMap(), model.getSortingStrategy()); // Updates tableData and sortingStrategy
   // Enable automatic selection while searching
   if (tableData.getRowCount() > 0) {
     selectRow();
     int selectedCompanyId =
         Integer.valueOf(
             (String)
                 insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
     controller.selectInsuranceCompany(selectedCompanyId);
   }
 }
  /** Makes sure that the right row is selected on adding a new record, or on editing a record. */
  private void selectRow() {

    int tableRows = tableData.getRowCount();
    int tabelCols = tableData.getColumnCount();
    int rowToSelect = 0;

    if (recordEdited != -1) {
      rowToSelect = recordEdited; // Select the edited record
    } else {
      for (int i = 0; i < tableRows; i++) {
        String companyName = (String) tableData.getValueAt(i, 1);
        if (companyName.equals("-")) {
          rowToSelect = i; // Select the new record
        }
      }
    }

    insuranceCompaniesTable.setRowSelectionInterval(rowToSelect, rowToSelect);
  }