/**
*
*/
package systole.view.crud.medicine;
import systole.exceptions.ExceptionDAO;
import systole.utils.ImageUtils;
import systole.view.crud.controller.ControllerEntityView;
import systole.view.crud.tableModels.MedicinesTableModel;
import systole.view.utils.ErrorDialog;
/**
* @author jmj
*
*/
public class ControllerMedicineView extends ControllerEntityView {
/**
*
* @throws ExceptionDAO
*/
@SuppressWarnings("unchecked")
public ControllerMedicineView() throws ExceptionDAO {
super();
this.entityList = this.facadeDB.getMedicineBroker().getAllMedicines();
this.tableModel = new MedicinesTableModel(this.entityList);
this.entityName = "Medicamento";
this.pluralEntity = "Medicamentos";
this.controllerEntityEdition = new ControllerMedicineEdition();
}
@Override
public void refreshList() {
try {
this.entityList = this.facadeDB.getMedicineBroker().getAllMedicines();
this.tableModel.refreshList(this.entityList);
this.entities.getjTableEntities().setModel(this.tableModel);
} catch (ExceptionDAO ex) {
this.facadeDB.refreshSession();
ErrorDialog.showError(this.entities,ex.getMessage());
}
this.entities.getjTableEntities().revalidate();
}
@Override
protected boolean canDeleteEntity() {
return false;
}
@Override
protected void loadIconOnForm() {
this.entities.setIconImage(ImageUtils.buildImage("resources/icons/medic/medicine16.png"));
this.entities.getJXEntityHeader().setIcon(ImageUtils.buildIcon("resources/icons/medic/medicine32.png"));
}
}