コード例 #1
0
  /** Observer method to update the insuranceCompanyTable */
  public void updateTable() {

    tableData.update(
        model.getInsuranceCompanies(), model.getSortingStrategy()); // Populate the table

    // Check if InsuranceCompany map is empty
    if (model.getInsuranceCompanies().size() > 0) {
      selectRow();
      int selectedCompanyId =
          Integer.valueOf(
              (String)
                  insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
      controller.selectInsuranceCompany(selectedCompanyId);
      recordEdited = -1; // Reset the recordEdited field
    } else {
      // If all records are deleted, clear the edit panel
      companyIdTextField.setText("");
      companyNameTextField.setText("");
      urlTextField.setText("");
      generalDescriptionTextField.setText("");
      insuranceTypesTextField.setText("");
      telephoneTextField.setText("");
      percentageTextField.setText("");
    }
  }
コード例 #2
0
 /**
  * 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);
   }
 }