diff --git a/src/main/java/org/isf/medicals/gui/MedicalBrowser.java b/src/main/java/org/isf/medicals/gui/MedicalBrowser.java index 231810640a..74b3f27d7f 100644 --- a/src/main/java/org/isf/medicals/gui/MedicalBrowser.java +++ b/src/main/java/org/isf/medicals/gui/MedicalBrowser.java @@ -595,7 +595,7 @@ private JComboBox getComboBoxMedicalType() { pbox.addItem(STR_ALL); List type; try { - type = medicalTypeManager.getMedicalType(); + type = medicalTypeManager.getAllActiveMedicalType(); for (MedicalType elem : type) { pbox.addItem(elem); } diff --git a/src/main/java/org/isf/medicals/gui/MedicalEdit.java b/src/main/java/org/isf/medicals/gui/MedicalEdit.java index 61825d0143..f953292a70 100644 --- a/src/main/java/org/isf/medicals/gui/MedicalEdit.java +++ b/src/main/java/org/isf/medicals/gui/MedicalEdit.java @@ -432,7 +432,7 @@ private JComboBox getTypeComboBox() { if (typeComboBox == null) { typeComboBox = new JComboBox<>(); try { - List types = medicalTypeManager.getMedicalType(); + List types = medicalTypeManager.getAllActiveMedicalType(); for (MedicalType elem : types) { typeComboBox.addItem(elem); } diff --git a/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java b/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java index 99ab7dc533..02b7a0c10c 100644 --- a/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java +++ b/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java @@ -618,7 +618,7 @@ private JComboBox getMedicalTypeBox() { medicalTypeBox.addItem(TEXT_ALL); try { - medical = medicalTypeBrowserManager.getMedicalType(); + medical = medicalTypeBrowserManager.getAllActiveMedicalType(); for (MedicalType aMedicalType : medical) { medicalTypeBox.addItem(aMedicalType); diff --git a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java index 6c9fdb9d49..7e173e9744 100644 --- a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java +++ b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java @@ -54,9 +54,10 @@ public class MedicalTypeBrowser extends ModalJFrame implements MedicalTypeListen private List pMedicalType; private String[] pColumns = { MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.description.txt").toUpperCase() + MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.deleted.label").toUpperCase() }; - private int[] pColumnWidth = {80, 200}; + private final int[] pColumnWidth = { 20, 200, 20 }; private JPanel jContainPanel; private JPanel jButtonPanel; private JButton jNewButton; @@ -198,6 +199,7 @@ private JTable getJTable() { jTable = new JTable(model); jTable.getColumnModel().getColumn(0).setMinWidth(pColumnWidth[0]); jTable.getColumnModel().getColumn(1).setMinWidth(pColumnWidth[1]); + jTable.getColumnModel().getColumn(2).setMinWidth(pColumnWidth[2]); } return jTable; } @@ -243,6 +245,8 @@ public Object getValueAt(int r, int c) { return medType.getCode(); } else if (c == 1) { return medType.getDescription(); + } else if (c == 2) { + return medType.getDeleted() == 'Y'; } return null; } @@ -251,6 +255,11 @@ public Object getValueAt(int r, int c) { public boolean isCellEditable(int arg0, int arg1) { return false; } + + @Override + public Class getColumnClass(int column) { + return (column == 2) ? Boolean.class : String.class; + } } @Override diff --git a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java index 82e8f69556..36e4613717 100644 --- a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java +++ b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java @@ -26,6 +26,7 @@ import java.util.EventListener; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; @@ -95,8 +96,10 @@ private void fireMedicalUpdated() { private JButton cancelButton; private JButton okButton; private JTextField descriptionTextField; + private JCheckBox deletedCheckbox; private VoLimitedTextField codeTextField; private String lastdescription; + private char isLastDeleted; private MedicalType medicalType; private boolean insert; private JPanel jDataPanel; @@ -110,6 +113,7 @@ public MedicalTypeBrowserEdit(JFrame owner, MedicalType old, boolean inserting) insert = inserting; medicalType = old; //medical type will be used for every operation lastdescription = medicalType.getDescription(); + isLastDeleted = medicalType.getDeleted(); initialize(); } @@ -124,6 +128,7 @@ private void initialize() { this.setTitle(MessageBundle.getMessage("angal.medtype.editmedicaltype.title")); } this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.getDeletedField(); this.pack(); this.setLocationRelativeTo(null); } @@ -197,7 +202,8 @@ private JButton getOkButton() { medicalType.setDescription(descriptionTextField.getText()); medicalType.setCode(codeTextField.getText()); - + medicalType.setDeleted(deletedCheckbox.isSelected() ? 'Y' : 'N'); + if (insert) { // inserting try { MedicalType insertedMedicalType = medicalTypeBrowserManager.newMedicalType(medicalType); @@ -211,7 +217,7 @@ private JButton getOkButton() { OHServiceExceptionUtil.showMessages(e1); } } else { // updating - if (descriptionTextField.getText().equals(lastdescription)) { + if (descriptionTextField.getText().equals(lastdescription) && medicalType.getDeleted() == isLastDeleted) { dispose(); } else { try { @@ -263,6 +269,14 @@ private JTextField getCodeTextField() { } return codeTextField; } + + private JCheckBox getDeletedField() { + if (deletedCheckbox == null) { + deletedCheckbox = new JCheckBox(MessageBundle.getMessage("angal.common.deleted.label")); + deletedCheckbox.setSelected(medicalType.getDeleted() == 'Y'); + } + return deletedCheckbox; + } /** * This method initializes jDataPanel @@ -276,7 +290,9 @@ private JPanel getJDataPanel() { jDataPanel.add(getCodeTextField()); jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.description.txt") + ':')); jDataPanel.add(getDescriptionTextField()); - SpringUtilities.makeCompactGrid(jDataPanel, 2, 2, 5, 5, 5, 5); + jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label") + ':')); + jDataPanel.add(getDeletedField()); + SpringUtilities.makeCompactGrid(jDataPanel, 3, 2, 5, 5, 5, 5); } return jDataPanel; }