/** 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(""); } }
/** Observer method to update the editPanel and it's contents */ public void updateEditPanel() { InsuranceCompany insuranceCompany = model.getCurrentInsuranceCompany(); if (insuranceCompany != null) { // If no currentInsuranceCompany is set (if the db is empty) // Update all text fields String id = (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0); companyIdTextField.setText(id); companyNameTextField.setText(insuranceCompany.getCompanyName()); urlTextField.setText(insuranceCompany.getUrl()); urlTextField.setCaretPosition(0); generalDescriptionTextField.setText(insuranceCompany.getGeneralDescription()); generalDescriptionTextField.setCaretPosition(0); insuranceTypesTextField.setText(insuranceCompany.getInsuranceTypes()); insuranceTypesTextField.setCaretPosition(0); telephoneTextField.setText(insuranceCompany.getTelephone()); percentageTextField.setText(Float.toString(insuranceCompany.getPercentage())); } }