From 8d32434b6fa825de053e2ead586875a41d0ca310 Mon Sep 17 00:00:00 2001 From: Mohit Rajeshkumar Sojitra Date: Fri, 22 Nov 2024 19:38:01 -0400 Subject: [PATCH] Fixed text --- .../isf/medtype/gui/MedicalTypeBrowser.java | 51 +++++-------------- .../medtype/gui/MedicalTypeBrowserEdit.java | 21 ++++---- 2 files changed, 22 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java index 7c8c55af3f..7e173e9744 100644 --- a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java +++ b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java @@ -23,11 +23,9 @@ import java.awt.AWTEvent; import java.awt.BorderLayout; -import java.util.ArrayList; import java.util.List; import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -53,26 +51,19 @@ public class MedicalTypeBrowser extends ModalJFrame implements MedicalTypeListener { private static final long serialVersionUID = 1L; - - private static final String STR_ALL = MessageBundle.getMessage("angal.common.all.txt"); - private static final String STR_ACTIVE_ONLY = MessageBundle.getMessage("angal.medicals.activeonly.txt"); - private static final String STR_DISABLED_ONLY = MessageBundle.getMessage("angal.medicals.disabledonly.txt"); - - private String pSelection; - private String activeSelection = STR_ACTIVE_ONLY; 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; private JButton jEditButton; private JButton jCloseButton; private JButton jDeleteButton; - private JComboBox activeComboBox; private JTable jTable; private MedicalTypeBrowserModel model; private int selectedrow; @@ -111,7 +102,6 @@ private JPanel getJContainPanel() { private JPanel getJButtonPanel() { if (jButtonPanel == null) { jButtonPanel = new JPanel(); - jButtonPanel.add(getComboBoxActive()); jButtonPanel.add(getJNewButton(), null); jButtonPanel.add(getJEditButton(), null); jButtonPanel.add(getJDeleteButton(), null); @@ -134,24 +124,6 @@ private JButton getJNewButton() { return jNewButton; } - private JComboBox getComboBoxActive() { - if (activeComboBox == null) { - activeComboBox = new JComboBox(); - activeComboBox.addItem(STR_ACTIVE_ONLY); - activeComboBox.addItem(STR_ALL); - activeComboBox.addItem(STR_DISABLED_ONLY); - activeSelection = STR_ACTIVE_ONLY; - } - activeComboBox.addActionListener(actionEvent -> { - activeSelection = activeComboBox.getSelectedItem().toString(); - model = new MedicalTypeBrowserModel(); - jTable.setModel(model); - model.fireTableDataChanged(); - jTable.updateUI(); - }); - return activeComboBox; - } - /** * This method initializes jEditButton * @@ -227,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; } @@ -239,11 +212,6 @@ class MedicalTypeBrowserModel extends DefaultTableModel { public MedicalTypeBrowserModel() { try { pMedicalType = medicalTypeBrowserManager.getMedicalType(); - if (activeSelection.equals(STR_ACTIVE_ONLY)) { - pMedicalType = new ArrayList<>(pMedicalType.stream().filter(med -> med.getDeleted() == 'N').toList()); - } else if (activeSelection.equals(STR_DISABLED_ONLY)) { - pMedicalType = new ArrayList<>(pMedicalType.stream().filter(med -> med.getDeleted() == 'Y').toList()); - } } catch (OHServiceException e) { pMedicalType = null; OHServiceExceptionUtil.showMessages(e); @@ -277,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; } @@ -285,17 +255,21 @@ 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 public void medicalTypeUpdated(AWTEvent e) { pMedicalType.set(selectedrow, medicalType); ((MedicalTypeBrowserModel) jTable.getModel()).fireTableDataChanged(); + jTable.updateUI(); if (jTable.getRowCount() > 0 && selectedrow > -1) { jTable.setRowSelectionInterval(selectedrow, selectedrow); } - model = new MedicalTypeBrowserModel(); - jTable.updateUI(); } @@ -306,6 +280,5 @@ public void medicalTypeInserted(AWTEvent e) { if (jTable.getRowCount() > 0) { jTable.setRowSelectionInterval(0, 0); } - model = new MedicalTypeBrowserModel(); } } diff --git a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java index 71476bbd81..36e4613717 100644 --- a/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java +++ b/src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java @@ -96,7 +96,7 @@ private void fireMedicalUpdated() { private JButton cancelButton; private JButton okButton; private JTextField descriptionTextField; - private JCheckBox activeCheckbox; + private JCheckBox deletedCheckbox; private VoLimitedTextField codeTextField; private String lastdescription; private char isLastDeleted; @@ -128,11 +128,10 @@ private void initialize() { this.setTitle(MessageBundle.getMessage("angal.medtype.editmedicaltype.title")); } this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - this.getActiveField(); + this.getDeletedField(); this.pack(); this.setLocationRelativeTo(null); } - /** * This method initializes jContentPane @@ -203,7 +202,7 @@ private JButton getOkButton() { medicalType.setDescription(descriptionTextField.getText()); medicalType.setCode(codeTextField.getText()); - medicalType.setDeleted(activeCheckbox.isSelected() ? 'N' : 'Y'); + medicalType.setDeleted(deletedCheckbox.isSelected() ? 'Y' : 'N'); if (insert) { // inserting try { @@ -271,12 +270,12 @@ private JTextField getCodeTextField() { return codeTextField; } - private JCheckBox getActiveField() { - if (activeCheckbox == null) { - activeCheckbox = new JCheckBox("Active"); - activeCheckbox.setSelected(medicalType.getDeleted() == 'N'); + private JCheckBox getDeletedField() { + if (deletedCheckbox == null) { + deletedCheckbox = new JCheckBox(MessageBundle.getMessage("angal.common.deleted.label")); + deletedCheckbox.setSelected(medicalType.getDeleted() == 'Y'); } - return activeCheckbox; + return deletedCheckbox; } /** @@ -291,8 +290,8 @@ private JPanel getJDataPanel() { jDataPanel.add(getCodeTextField()); jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.description.txt") + ':')); jDataPanel.add(getDescriptionTextField()); - jDataPanel.add(new JLabel(MessageBundle.getMessage("Active") + ':')); - jDataPanel.add(getActiveField()); + jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label") + ':')); + jDataPanel.add(getDeletedField()); SpringUtilities.makeCompactGrid(jDataPanel, 3, 2, 5, 5, 5, 5); } return jDataPanel;