From bb5810b7fead923035f670d268081d32df32a60e Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 30 Oct 2024 15:58:46 +0100 Subject: [PATCH 01/19] feature(OP-1043): Implement soft deletion --- bundle/language_am_ET.properties | 2 +- bundle/language_ar.properties | 2 +- bundle/language_ar_SA.properties | 2 +- bundle/language_de.properties | 2 +- bundle/language_en.properties | 2 +- bundle/language_es.properties | 2 +- bundle/language_fr.properties | 2 +- bundle/language_it.properties | 2 +- bundle/language_sq.properties | 2 +- bundle/language_zh_CN.properties | 2 +- .../java/org/isf/menu/gui/UserBrowsing.java | 100 +++++++++------- .../org/isf/menu/gui/UserGroupBrowsing.java | 111 +++++++++++------- .../org/isf/supplier/gui/SupplierBrowser.java | 2 +- 13 files changed, 139 insertions(+), 94 deletions(-) diff --git a/bundle/language_am_ET.properties b/bundle/language_am_ET.properties index d597245ec8..db5b22baf5 100644 --- a/bundle/language_am_ET.properties +++ b/bundle/language_am_ET.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - ሳምንታዊ ወረርሽኝ. ክትትል. ከ 5 ዓመት በታች angal.stat.year = አመት angal.supplier.deleted = ተሰርዟል። -angal.supplier.deleted.col = ተሰርዟል። +angal.common.deleted.txt = ተሰርዟል። angal.supplier.deletesupplier.fmt.msg = አቅራቢ ይሰረዝ፡ {0}? angal.supplier.editsupplier.title = አቅራቢን ያርትዑ angal.supplier.email = ኢ-ሜይል diff --git a/bundle/language_ar.properties b/bundle/language_ar.properties index 7c2a1b6a35..12eae02c94 100644 --- a/bundle/language_ar.properties +++ b/bundle/language_ar.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - المراقبة الوبائية الأسبوعية تحت سن 5 سنوات angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.supplier.deleted.col = محذوفة +angal.common.deleted.txt = محذوفة angal.supplier.deletesupplier.fmt.msg = حذف المورد: {0}؟ angal.supplier.editsupplier.title = تعديل المورد angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_ar_SA.properties b/bundle/language_ar_SA.properties index c80e935dfa..872ec149e8 100644 --- a/bundle/language_ar_SA.properties +++ b/bundle/language_ar_SA.properties @@ -1424,7 +1424,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33B - epidem أسبوعي. surveil. تحت 5 يو angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.supplier.deleted.col = محذوفة +angal.common.deleted.txt = محذوفة angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_de.properties b/bundle/language_de.properties index 9d0edac1d9..05f9ab6fd6 100644 --- a/bundle/language_de.properties +++ b/bundle/language_de.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b – Wöchentliche Epidemie. Überwachung. unter 5 Jahren angal.stat.year = Jahr angal.supplier.deleted = Gelöscht -angal.supplier.deleted.col = Gelöscht +angal.common.deleted.txt = Gelöscht angal.supplier.deletesupplier.fmt.msg = Lieferant löschen: {0}? angal.supplier.editsupplier.title = Zulieferer bearbeiten angal.supplier.email = E-mail diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 421d525dda..71e7694af1 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1601,7 +1601,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Weekly epidem. surveil. under 5 y.o. angal.stat.year = Year angal.supplier.deleted = Deleted -angal.supplier.deleted.col = Deleted +angal.common.deleted.txt = Deleted angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = E-mail diff --git a/bundle/language_es.properties b/bundle/language_es.properties index 6f7f9a84f7..25580cfa3b 100644 --- a/bundle/language_es.properties +++ b/bundle/language_es.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoreo Semanal Epidemiologico (<5) angal.stat.year = Año angal.supplier.deleted = Eliminado -angal.supplier.deleted.col = Eliminado +angal.common.deleted.txt = Eliminado angal.supplier.deletesupplier.fmt.msg = ¿Eliminar proveedor: {0}? angal.supplier.editsupplier.title = Editar Proveedor angal.supplier.email = E-mail diff --git a/bundle/language_fr.properties b/bundle/language_fr.properties index b096d8daeb..bcb1522328 100644 --- a/bundle/language_fr.properties +++ b/bundle/language_fr.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Surveillance Hebdomadaire épidémiologique <5 ans angal.stat.year = Année angal.supplier.deleted = Supprimé -angal.supplier.deleted.col = Supprimé +angal.common.deleted.txt = Supprimé angal.supplier.deletesupplier.fmt.msg = Supprimer fournisseur: {0}? angal.supplier.editsupplier.title = Modification Fournisseur angal.supplier.email = E-mail diff --git a/bundle/language_it.properties b/bundle/language_it.properties index 29c3906b00..ed4e622559 100644 --- a/bundle/language_it.properties +++ b/bundle/language_it.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoraggio Settimanale Edipemiologico (<5) angal.stat.year = Anno angal.supplier.deleted = Eliminato -angal.supplier.deleted.col = Eliminato +angal.common.deleted.txt = Eliminato angal.supplier.deletesupplier.fmt.msg = Elimina fornitore: {0}? angal.supplier.editsupplier.title = Modifica Fornitore angal.supplier.email = e-mail diff --git a/bundle/language_sq.properties b/bundle/language_sq.properties index 9e9c765051..ca2e96b0a2 100644 --- a/bundle/language_sq.properties +++ b/bundle/language_sq.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Epidemi javore. survejimi. nën 5 vjeç angal.stat.year = Viti angal.supplier.deleted = Fshirë -angal.supplier.deleted.col = Fshirë +angal.common.deleted.txt = Fshirë angal.supplier.deletesupplier.fmt.msg = Fshij furnitorin: {0}? angal.supplier.editsupplier.title = Redakto Furnitorin angal.supplier.email = E-mail diff --git a/bundle/language_zh_CN.properties b/bundle/language_zh_CN.properties index ff072be992..f79a4b3423 100644 --- a/bundle/language_zh_CN.properties +++ b/bundle/language_zh_CN.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - 每周流行病监测 小于5岁 angal.stat.year = 年 angal.supplier.deleted = 已删除 -angal.supplier.deleted.col = 已删除 +angal.common.deleted.txt = 已删除 angal.supplier.deletesupplier.fmt.msg = 删除供应商: {0}? angal.supplier.editsupplier.title = 修改供应商 angal.supplier.email = 电子邮件 diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index eb56b27671..da2d756bc9 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -36,6 +36,8 @@ import javax.swing.JTable; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.GeneralData; @@ -55,46 +57,23 @@ public class UserBrowsing extends ModalJFrame implements UserListener { private static final long serialVersionUID = 1L; private static final String ALL_STR = MessageBundle.getMessage("angal.common.all.txt").toUpperCase(); - - @Override - public void userInserted(AWTEvent e) { - User u = (User) e.getSource(); - userList.add(0, u); - ((UserBrowserModel) table.getModel()).fireTableDataChanged(); - table.updateUI(); - if (table.getRowCount() > 0) { - table.setRowSelectionInterval(0, 0); - } - } - - @Override - public void userUpdated(AWTEvent e) { - userList.set(selectedrow, user); - ((UserBrowserModel) table.getModel()).fireTableDataChanged(); - table.updateUI(); - if ((table.getRowCount() > 0) && (selectedrow > -1)) { - table.setRowSelectionInterval(selectedrow, selectedrow); - } - } - + private final JComboBox userGroupFilter; + private final String[] pColumns = { + MessageBundle.getMessage("angal.userbrowser.user.col").toUpperCase(), + MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), + MessageBundle.getMessage("angal.userbrowser.locked.col").toUpperCase(), + MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() }; + private final int[] pColumnWidth = { 70, 70, 150, 20, 20 }; + private final JTable table; + private final UserBrowsing myFrame; + private final UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); private int selectedrow; - private JComboBox userGroupFilter; private List userList; - private String[] pColumns = { - MessageBundle.getMessage("angal.userbrowser.user.col").toUpperCase(), - MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), - MessageBundle.getMessage("angal.userbrowser.locked.col").toUpperCase()}; - private int[] pColumnWidth = {70, 70, 150, 20}; private User user; private DefaultTableModel model; - private JTable table; - private String pSelection; - private UserBrowsing myFrame; - private UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); - public UserBrowsing() { setTitle(MessageBundle.getMessage("angal.userbrowser.title")); @@ -106,6 +85,7 @@ public UserBrowsing() { table.getColumnModel().getColumn(1).setPreferredWidth(pColumnWidth[1]); table.getColumnModel().getColumn(2).setPreferredWidth(pColumnWidth[2]); table.getColumnModel().getColumn(3).setPreferredWidth(pColumnWidth[3]); + table.getColumnModel().getColumn(4).setPreferredWidth(pColumnWidth[4]); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane, BorderLayout.CENTER); @@ -149,6 +129,7 @@ public UserBrowsing() { buttonPanel.add(buttonNew); JButton buttonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); + buttonEdit.setEnabled(false); buttonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); buttonEdit.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -162,6 +143,7 @@ public UserBrowsing() { buttonPanel.add(buttonEdit); JButton buttonResetPassword = new JButton(MessageBundle.getMessage("angal.userbrowser.resetpassword.btn")); + buttonResetPassword.setEnabled(false); buttonResetPassword.setMnemonic(MessageBundle.getMnemonic("angal.userbrowser.resetpassword.btn.key")); buttonResetPassword.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -190,7 +172,8 @@ public void ancestorAdded(AncestorEvent event) { String newPassword = ""; JPanel stepPanel = new JPanel(new GridLayout(2, 1, 5, 5)); if (GeneralData.STRONGLENGTH != 0) { - stepPanel.add(new JLabel(MessageBundle.formatMessage("angal.userbrowser.step1.pleaseinsertanew.password.fmt.msg", GeneralData.STRONGLENGTH))); + stepPanel.add( + new JLabel(MessageBundle.formatMessage("angal.userbrowser.step1.pleaseinsertanew.password.fmt.msg", GeneralData.STRONGLENGTH))); } else { stepPanel.add(new JLabel(MessageBundle.formatMessage("angal.userbrowser.step1.pleaseinsertanew.password.msg"))); } @@ -199,8 +182,8 @@ public void ancestorAdded(AncestorEvent event) { while (newPassword.isEmpty()) { int action = JOptionPane - .showConfirmDialog(this, stepPanel, MessageBundle.getMessage("angal.userbrowser.resetpassword.title"), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + .showConfirmDialog(this, stepPanel, MessageBundle.getMessage("angal.userbrowser.resetpassword.title"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (JOptionPane.CANCEL_OPTION == action) { return; } @@ -230,8 +213,8 @@ public void ancestorAdded(AncestorEvent event) { stepPanel.add(new JLabel(MessageBundle.getMessage("angal.userbrowser.step2.pleaserepeatthenewpassword.label"))); stepPanel.add(pwd); int action = JOptionPane - .showConfirmDialog(this, stepPanel, MessageBundle.getMessage("angal.userbrowser.resetpassword.title"), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + .showConfirmDialog(this, stepPanel, MessageBundle.getMessage("angal.userbrowser.resetpassword.title"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (JOptionPane.CANCEL_OPTION == action) { return; } @@ -269,6 +252,7 @@ public void ancestorAdded(AncestorEvent event) { buttonPanel.add(buttonResetPassword); JButton buttonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); + buttonDelete.setEnabled(false); buttonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); buttonDelete.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -290,6 +274,21 @@ public void ancestorAdded(AncestorEvent event) { }); buttonPanel.add(buttonDelete); + table.getSelectionModel().addListSelectionListener( + new ListSelectionListener() { + + public void valueChanged(ListSelectionEvent e) { + if(table.getSelectedRow() >= 0) { + User selected = (User) table.getValueAt(table.getSelectedRow(), -1); + buttonEdit.setEnabled(!selected.isDeleted()); + buttonDelete.setEnabled(!selected.isDeleted()); + buttonResetPassword.setEnabled(!selected.isDeleted()); + } + String selectedData = null; + } + } + ); + JButton buttonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); buttonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); buttonClose.addActionListener(actionEvent -> dispose()); @@ -301,6 +300,25 @@ public void ancestorAdded(AncestorEvent event) { setLocationRelativeTo(null); setVisible(true); } + @Override + public void userInserted(AWTEvent e) { + User u = (User) e.getSource(); + userList.add(0, u); + ((UserBrowserModel) table.getModel()).fireTableDataChanged(); + table.updateUI(); + if (table.getRowCount() > 0) { + table.setRowSelectionInterval(0, 0); + } + } + @Override + public void userUpdated(AWTEvent e) { + userList.set(selectedrow, user); + ((UserBrowserModel) table.getModel()).fireTableDataChanged(); + table.updateUI(); + if ((table.getRowCount() > 0) && (selectedrow > -1)) { + table.setRowSelectionInterval(selectedrow, selectedrow); + } + } class UserBrowserModel extends DefaultTableModel { @@ -324,7 +342,7 @@ public UserBrowserModel() { @Override public Class getColumnClass(int column) { - return (column == 3) ? Boolean.class : String.class; + return (column == 3 || column == 4) ? Boolean.class : String.class; } @Override @@ -357,6 +375,8 @@ public Object getValueAt(int r, int c) { return userList.get(r).getDesc(); } else if (c == 3) { return userList.get(r).isAccountLocked(); + } else if (c == 4) { + return userList.get(r).isDeleted(); } return null; } diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 62eb3d93be..6774cf2274 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -32,12 +32,15 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; import org.isf.menu.gui.GroupEdit.GroupListener; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; +import org.isf.menu.model.User; import org.isf.menu.model.UserGroup; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; @@ -47,60 +50,39 @@ public class UserGroupBrowsing extends ModalJFrame implements GroupListener { private static final long serialVersionUID = 1L; - - @Override - public void groupInserted(AWTEvent e) { - pGroup.add(0, group); - ((UserGroupBrowserModel) table.getModel()).fireTableDataChanged(); - table.updateUI(); - if (table.getRowCount() > 0) { - table.setRowSelectionInterval(0, 0); - } - } - - @Override - public void groupUpdated(AWTEvent e) { - pGroup.set(selectedrow, group); - ((UserGroupBrowserModel) table.getModel()).fireTableDataChanged(); - table.updateUI(); - if (table.getRowCount() > 0 && selectedrow > -1) { - table.setRowSelectionInterval(selectedrow, selectedrow); - } - } - private static final int DEFAULT_WIDTH = 200; private static final int DEFAULT_HEIGHT = 150; private int selectedrow; private List pGroup; - private String[] pColumns = { - MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.description.txt").toUpperCase() + private final String[] pColumns = { + MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() }; - private int[] pColumnWidth = {70, 100}; + private final int[] pColumnWidth = { 70, 100, 20 }; private UserGroup group; - private DefaultTableModel model; - private JTable table; - - private UserGroupBrowsing myFrame; - - private UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); + private final DefaultTableModel model; + private final JTable table; + private final UserGroupBrowsing myFrame; + private final UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); public UserGroupBrowsing() { myFrame = this; setTitle(MessageBundle.getMessage("angal.groupsbrowser.title")); - + setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screensize = kit.getScreenSize(); int pfrmWidth = screensize.width / 2; int pfrmHeight = screensize.height / 4; setBounds(screensize.width / 4, screensize.height / 4, pfrmWidth, pfrmHeight); - + model = new UserGroupBrowserModel(); table = new JTable(model); table.getColumnModel().getColumn(0).setPreferredWidth(pColumnWidth[0]); table.getColumnModel().getColumn(1).setPreferredWidth(pColumnWidth[1]); - + table.getColumnModel().getColumn(2).setPreferredWidth(pColumnWidth[2]); + add(new JScrollPane(table), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); @@ -114,6 +96,7 @@ public UserGroupBrowsing() { buttonPanel.add(buttonNew); JButton buttonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); + buttonEdit.setEnabled(false); buttonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); buttonEdit.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -127,6 +110,7 @@ public UserGroupBrowsing() { buttonPanel.add(buttonEdit); JButton buttonPrivilege = new JButton(MessageBundle.getMessage("angal.groupsbrowser.groupmenu.btn")); + buttonPrivilege.setEnabled(false); buttonPrivilege.setMnemonic(MessageBundle.getMnemonic("angal.groupsbrowser.groupmenu.btn.key")); buttonPrivilege.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -139,6 +123,7 @@ public UserGroupBrowsing() { buttonPanel.add(buttonPrivilege); JButton buttonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); + buttonDelete.setEnabled(false); buttonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); buttonDelete.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -160,6 +145,21 @@ public UserGroupBrowsing() { }); buttonPanel.add(buttonDelete); + table.getSelectionModel().addListSelectionListener( + new ListSelectionListener() { + + public void valueChanged(ListSelectionEvent e) { + if(table.getSelectedRow() >= 0) { + UserGroup selected = (UserGroup) table.getValueAt(table.getSelectedRow(), -1); + buttonEdit.setEnabled(!selected.isDeleted()); + buttonPrivilege.setEnabled(!selected.isDeleted()); + buttonDelete.setEnabled(!selected.isDeleted()); + } + String selectedData = null; + } + } + ); + JButton buttonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); buttonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); buttonClose.addActionListener(actionEvent -> dispose()); @@ -169,18 +169,36 @@ public UserGroupBrowsing() { setLocationRelativeTo(null); setVisible(true); } + @Override + public void groupInserted(AWTEvent e) { + pGroup.add(0, group); + ((UserGroupBrowserModel) table.getModel()).fireTableDataChanged(); + table.updateUI(); + if (table.getRowCount() > 0) { + table.setRowSelectionInterval(0, 0); + } + } + @Override + public void groupUpdated(AWTEvent e) { + pGroup.set(selectedrow, group); + ((UserGroupBrowserModel) table.getModel()).fireTableDataChanged(); + table.updateUI(); + if (table.getRowCount() > 0 && selectedrow > -1) { + table.setRowSelectionInterval(selectedrow, selectedrow); + } + } class UserGroupBrowserModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public UserGroupBrowserModel() { - try { - pGroup = userBrowsingManager.getUserGroup(); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } + try { + pGroup = userBrowsingManager.getUserGroup(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } @Override public int getRowCount() { @@ -189,7 +207,7 @@ public int getRowCount() { } return pGroup.size(); } - + @Override public String getColumnName(int c) { return pColumns[c]; @@ -208,10 +226,17 @@ public Object getValueAt(int r, int c) { return pGroup.get(r); } else if (c == 1) { return pGroup.get(r).getDesc(); - } + } else if (c == 2) { + return pGroup.get(r).isDeleted(); + } return null; } - + + @Override + public Class getColumnClass(int column) { + return (column == 2) ? Boolean.class : String.class; + } + @Override public boolean isCellEditable(int arg0, int arg1) { return false; diff --git a/src/main/java/org/isf/supplier/gui/SupplierBrowser.java b/src/main/java/org/isf/supplier/gui/SupplierBrowser.java index a3bfbb3c2e..2115e19f62 100644 --- a/src/main/java/org/isf/supplier/gui/SupplierBrowser.java +++ b/src/main/java/org/isf/supplier/gui/SupplierBrowser.java @@ -95,7 +95,7 @@ public void supplierUpdated(AWTEvent e) { MessageBundle.getMessage("angal.common.fax.txt").toUpperCase(), MessageBundle.getMessage("angal.common.email.txt").toUpperCase(), MessageBundle.getMessage("angal.common.note.txt").toUpperCase(), - MessageBundle.getMessage("angal.supplier.deleted.col").toUpperCase() + MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() }; private int[] pColumnWidth = {45, 80, 60, 60, 80, 30, 30, 30, 30}; private int selectedrow; From 5494bb3c57148a86e285a0cbf05b0199c2c13fca Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 30 Oct 2024 17:31:10 +0100 Subject: [PATCH 02/19] chore: Reformat code --- bundle/language_am_ET.properties | 2 +- bundle/language_ar.properties | 2 +- bundle/language_ar_SA.properties | 2 +- bundle/language_de.properties | 2 +- bundle/language_en.properties | 2 +- bundle/language_es.properties | 2 +- bundle/language_fr.properties | 2 +- bundle/language_it.properties | 2 +- bundle/language_sq.properties | 2 +- bundle/language_zh_CN.properties | 2 +- src/main/java/org/isf/menu/gui/UserBrowsing.java | 4 ++-- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 11 +++++------ .../java/org/isf/supplier/gui/SupplierBrowser.java | 2 +- 13 files changed, 18 insertions(+), 19 deletions(-) diff --git a/bundle/language_am_ET.properties b/bundle/language_am_ET.properties index db5b22baf5..8cad8b3749 100644 --- a/bundle/language_am_ET.properties +++ b/bundle/language_am_ET.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - ሳምንታዊ ወረርሽኝ. ክትትል. ከ 5 ዓመት በታች angal.stat.year = አመት angal.supplier.deleted = ተሰርዟል። -angal.common.deleted.txt = ተሰርዟል። +angal.common.deleted.col = ተሰርዟል። angal.supplier.deletesupplier.fmt.msg = አቅራቢ ይሰረዝ፡ {0}? angal.supplier.editsupplier.title = አቅራቢን ያርትዑ angal.supplier.email = ኢ-ሜይል diff --git a/bundle/language_ar.properties b/bundle/language_ar.properties index 12eae02c94..6f2b19889f 100644 --- a/bundle/language_ar.properties +++ b/bundle/language_ar.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - المراقبة الوبائية الأسبوعية تحت سن 5 سنوات angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.common.deleted.txt = محذوفة +angal.common.deleted.col = محذوفة angal.supplier.deletesupplier.fmt.msg = حذف المورد: {0}؟ angal.supplier.editsupplier.title = تعديل المورد angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_ar_SA.properties b/bundle/language_ar_SA.properties index 872ec149e8..802933a4f9 100644 --- a/bundle/language_ar_SA.properties +++ b/bundle/language_ar_SA.properties @@ -1424,7 +1424,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33B - epidem أسبوعي. surveil. تحت 5 يو angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.common.deleted.txt = محذوفة +angal.common.deleted.col = محذوفة angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_de.properties b/bundle/language_de.properties index 05f9ab6fd6..e262cd7ac4 100644 --- a/bundle/language_de.properties +++ b/bundle/language_de.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b – Wöchentliche Epidemie. Überwachung. unter 5 Jahren angal.stat.year = Jahr angal.supplier.deleted = Gelöscht -angal.common.deleted.txt = Gelöscht +angal.common.deleted.col = Gelöscht angal.supplier.deletesupplier.fmt.msg = Lieferant löschen: {0}? angal.supplier.editsupplier.title = Zulieferer bearbeiten angal.supplier.email = E-mail diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 71e7694af1..25ee5929fc 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1601,7 +1601,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Weekly epidem. surveil. under 5 y.o. angal.stat.year = Year angal.supplier.deleted = Deleted -angal.common.deleted.txt = Deleted +angal.common.deleted.col = Deleted angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = E-mail diff --git a/bundle/language_es.properties b/bundle/language_es.properties index 25580cfa3b..ca8756553f 100644 --- a/bundle/language_es.properties +++ b/bundle/language_es.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoreo Semanal Epidemiologico (<5) angal.stat.year = Año angal.supplier.deleted = Eliminado -angal.common.deleted.txt = Eliminado +angal.common.deleted.col = Eliminado angal.supplier.deletesupplier.fmt.msg = ¿Eliminar proveedor: {0}? angal.supplier.editsupplier.title = Editar Proveedor angal.supplier.email = E-mail diff --git a/bundle/language_fr.properties b/bundle/language_fr.properties index bcb1522328..6597eecee8 100644 --- a/bundle/language_fr.properties +++ b/bundle/language_fr.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Surveillance Hebdomadaire épidémiologique <5 ans angal.stat.year = Année angal.supplier.deleted = Supprimé -angal.common.deleted.txt = Supprimé +angal.common.deleted.col = Supprimé angal.supplier.deletesupplier.fmt.msg = Supprimer fournisseur: {0}? angal.supplier.editsupplier.title = Modification Fournisseur angal.supplier.email = E-mail diff --git a/bundle/language_it.properties b/bundle/language_it.properties index ed4e622559..022268d712 100644 --- a/bundle/language_it.properties +++ b/bundle/language_it.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoraggio Settimanale Edipemiologico (<5) angal.stat.year = Anno angal.supplier.deleted = Eliminato -angal.common.deleted.txt = Eliminato +angal.common.deleted.col = Eliminato angal.supplier.deletesupplier.fmt.msg = Elimina fornitore: {0}? angal.supplier.editsupplier.title = Modifica Fornitore angal.supplier.email = e-mail diff --git a/bundle/language_sq.properties b/bundle/language_sq.properties index ca2e96b0a2..6e17fdf24e 100644 --- a/bundle/language_sq.properties +++ b/bundle/language_sq.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Epidemi javore. survejimi. nën 5 vjeç angal.stat.year = Viti angal.supplier.deleted = Fshirë -angal.common.deleted.txt = Fshirë +angal.common.deleted.col = Fshirë angal.supplier.deletesupplier.fmt.msg = Fshij furnitorin: {0}? angal.supplier.editsupplier.title = Redakto Furnitorin angal.supplier.email = E-mail diff --git a/bundle/language_zh_CN.properties b/bundle/language_zh_CN.properties index f79a4b3423..9a6b8d7420 100644 --- a/bundle/language_zh_CN.properties +++ b/bundle/language_zh_CN.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - 每周流行病监测 小于5岁 angal.stat.year = 年 angal.supplier.deleted = 已删除 -angal.common.deleted.txt = 已删除 +angal.common.deleted.col = 已删除 angal.supplier.deletesupplier.fmt.msg = 删除供应商: {0}? angal.supplier.editsupplier.title = 修改供应商 angal.supplier.email = 电子邮件 diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index da2d756bc9..982056e782 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -63,7 +63,7 @@ public class UserBrowsing extends ModalJFrame implements UserListener { MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), MessageBundle.getMessage("angal.userbrowser.locked.col").toUpperCase(), - MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() }; + MessageBundle.getMessage("angal.common.deleted.col").toUpperCase() }; private final int[] pColumnWidth = { 70, 70, 150, 20, 20 }; private final JTable table; private final UserBrowsing myFrame; @@ -278,7 +278,7 @@ public void ancestorAdded(AncestorEvent event) { new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { - if(table.getSelectedRow() >= 0) { + if (table.getSelectedRow() >= 0) { User selected = (User) table.getValueAt(table.getSelectedRow(), -1); buttonEdit.setEnabled(!selected.isDeleted()); buttonDelete.setEnabled(!selected.isDeleted()); diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 6774cf2274..b1e6c1a218 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -40,7 +40,6 @@ import org.isf.menu.gui.GroupEdit.GroupListener; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; -import org.isf.menu.model.User; import org.isf.menu.model.UserGroup; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; @@ -52,19 +51,19 @@ public class UserGroupBrowsing extends ModalJFrame implements GroupListener { private static final long serialVersionUID = 1L; private static final int DEFAULT_WIDTH = 200; private static final int DEFAULT_HEIGHT = 150; - private int selectedrow; - private List pGroup; private final String[] pColumns = { MessageBundle.getMessage("angal.common.group.txt").toUpperCase(), MessageBundle.getMessage("angal.common.description.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() + MessageBundle.getMessage("angal.common.deleted.col").toUpperCase() }; private final int[] pColumnWidth = { 70, 100, 20 }; - private UserGroup group; private final DefaultTableModel model; private final JTable table; private final UserGroupBrowsing myFrame; private final UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); + private int selectedrow; + private List pGroup; + private UserGroup group; public UserGroupBrowsing() { myFrame = this; @@ -149,7 +148,7 @@ public UserGroupBrowsing() { new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { - if(table.getSelectedRow() >= 0) { + if (table.getSelectedRow() >= 0) { UserGroup selected = (UserGroup) table.getValueAt(table.getSelectedRow(), -1); buttonEdit.setEnabled(!selected.isDeleted()); buttonPrivilege.setEnabled(!selected.isDeleted()); diff --git a/src/main/java/org/isf/supplier/gui/SupplierBrowser.java b/src/main/java/org/isf/supplier/gui/SupplierBrowser.java index 2115e19f62..491e49ee56 100644 --- a/src/main/java/org/isf/supplier/gui/SupplierBrowser.java +++ b/src/main/java/org/isf/supplier/gui/SupplierBrowser.java @@ -95,7 +95,7 @@ public void supplierUpdated(AWTEvent e) { MessageBundle.getMessage("angal.common.fax.txt").toUpperCase(), MessageBundle.getMessage("angal.common.email.txt").toUpperCase(), MessageBundle.getMessage("angal.common.note.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.deleted.txt").toUpperCase() + MessageBundle.getMessage("angal.common.deleted.col").toUpperCase() }; private int[] pColumnWidth = {45, 80, 60, 60, 80, 30, 30, 30, 30}; private int selectedrow; From 0ce79cd80cfbfe9d1f2da8d60f8e8b1bda765a46 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Fri, 1 Nov 2024 09:30:18 +0100 Subject: [PATCH 03/19] update: Implement hard delete user --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 982056e782..2eaa31749c 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -262,10 +262,18 @@ public void ancestorAdded(AncestorEvent event) { int answer = MessageDialog.yesNo(null, "angal.userbrowser.deleteuser.fmt.msg", selectedUser.getUserName()); try { if (answer == JOptionPane.YES_OPTION) { - userBrowsingManager.deleteUser(selectedUser); - userList.remove(table.getSelectedRow()); - model.fireTableDataChanged(); - table.updateUI(); + try { + userBrowsingManager.deleteUser(selectedUser); + userList.remove(table.getSelectedRow()); + model.fireTableDataChanged(); + table.updateUI(); + } catch (OHServiceException ex) { + selectedUser.setDeleted(true); + userBrowsingManager.deleteUser(selectedUser); + userList.set(table.getSelectedRow(), selectedUser); + model.fireTableDataChanged(); + table.updateUI(); + } } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); From 6dcbe182c1838f7f3a1f416d35a575f406bdc63f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Mon, 4 Nov 2024 15:23:08 +0100 Subject: [PATCH 04/19] chore: Update resource bundle --- bundle/language_am_ET.properties | 2 +- bundle/language_ar.properties | 2 +- bundle/language_ar_SA.properties | 2 +- bundle/language_de.properties | 2 +- bundle/language_en.properties | 2 +- bundle/language_es.properties | 2 +- bundle/language_fr.properties | 2 +- bundle/language_it.properties | 2 +- bundle/language_sq.properties | 2 +- bundle/language_zh_CN.properties | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundle/language_am_ET.properties b/bundle/language_am_ET.properties index 8cad8b3749..d597245ec8 100644 --- a/bundle/language_am_ET.properties +++ b/bundle/language_am_ET.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - ሳምንታዊ ወረርሽኝ. ክትትል. ከ 5 ዓመት በታች angal.stat.year = አመት angal.supplier.deleted = ተሰርዟል። -angal.common.deleted.col = ተሰርዟል። +angal.supplier.deleted.col = ተሰርዟል። angal.supplier.deletesupplier.fmt.msg = አቅራቢ ይሰረዝ፡ {0}? angal.supplier.editsupplier.title = አቅራቢን ያርትዑ angal.supplier.email = ኢ-ሜይል diff --git a/bundle/language_ar.properties b/bundle/language_ar.properties index 6f2b19889f..7c2a1b6a35 100644 --- a/bundle/language_ar.properties +++ b/bundle/language_ar.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - المراقبة الوبائية الأسبوعية تحت سن 5 سنوات angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.common.deleted.col = محذوفة +angal.supplier.deleted.col = محذوفة angal.supplier.deletesupplier.fmt.msg = حذف المورد: {0}؟ angal.supplier.editsupplier.title = تعديل المورد angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_ar_SA.properties b/bundle/language_ar_SA.properties index 802933a4f9..c80e935dfa 100644 --- a/bundle/language_ar_SA.properties +++ b/bundle/language_ar_SA.properties @@ -1424,7 +1424,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33B - epidem أسبوعي. surveil. تحت 5 يو angal.stat.year = سنة angal.supplier.deleted = محذوفة -angal.common.deleted.col = محذوفة +angal.supplier.deleted.col = محذوفة angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = البريد الإلكتروني diff --git a/bundle/language_de.properties b/bundle/language_de.properties index e262cd7ac4..9d0edac1d9 100644 --- a/bundle/language_de.properties +++ b/bundle/language_de.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b – Wöchentliche Epidemie. Überwachung. unter 5 Jahren angal.stat.year = Jahr angal.supplier.deleted = Gelöscht -angal.common.deleted.col = Gelöscht +angal.supplier.deleted.col = Gelöscht angal.supplier.deletesupplier.fmt.msg = Lieferant löschen: {0}? angal.supplier.editsupplier.title = Zulieferer bearbeiten angal.supplier.email = E-mail diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 25ee5929fc..5b4cd21beb 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -372,6 +372,7 @@ angal.common.days.txt angal.common.delete = Delete angal.common.delete.btn = Delete angal.common.delete.btn.key = D +angal.common.deleted.col = Deleted angal.common.description.txt = Description angal.common.discharge.txt = Discharge angal.common.documenthasnopages.msg = The document has no pages. @@ -1601,7 +1602,6 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Weekly epidem. surveil. under 5 y.o. angal.stat.year = Year angal.supplier.deleted = Deleted -angal.common.deleted.col = Deleted angal.supplier.deletesupplier.fmt.msg = Delete supplier: {0}? angal.supplier.editsupplier.title = Edit Supplier angal.supplier.email = E-mail diff --git a/bundle/language_es.properties b/bundle/language_es.properties index ca8756553f..6f7f9a84f7 100644 --- a/bundle/language_es.properties +++ b/bundle/language_es.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoreo Semanal Epidemiologico (<5) angal.stat.year = Año angal.supplier.deleted = Eliminado -angal.common.deleted.col = Eliminado +angal.supplier.deleted.col = Eliminado angal.supplier.deletesupplier.fmt.msg = ¿Eliminar proveedor: {0}? angal.supplier.editsupplier.title = Editar Proveedor angal.supplier.email = E-mail diff --git a/bundle/language_fr.properties b/bundle/language_fr.properties index 6597eecee8..b096d8daeb 100644 --- a/bundle/language_fr.properties +++ b/bundle/language_fr.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Surveillance Hebdomadaire épidémiologique <5 ans angal.stat.year = Année angal.supplier.deleted = Supprimé -angal.common.deleted.col = Supprimé +angal.supplier.deleted.col = Supprimé angal.supplier.deletesupplier.fmt.msg = Supprimer fournisseur: {0}? angal.supplier.editsupplier.title = Modification Fournisseur angal.supplier.email = E-mail diff --git a/bundle/language_it.properties b/bundle/language_it.properties index 022268d712..29c3906b00 100644 --- a/bundle/language_it.properties +++ b/bundle/language_it.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Monitoraggio Settimanale Edipemiologico (<5) angal.stat.year = Anno angal.supplier.deleted = Eliminato -angal.common.deleted.col = Eliminato +angal.supplier.deleted.col = Eliminato angal.supplier.deletesupplier.fmt.msg = Elimina fornitore: {0}? angal.supplier.editsupplier.title = Modifica Fornitore angal.supplier.email = e-mail diff --git a/bundle/language_sq.properties b/bundle/language_sq.properties index 6e17fdf24e..9e9c765051 100644 --- a/bundle/language_sq.properties +++ b/bundle/language_sq.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - Epidemi javore. survejimi. nën 5 vjeç angal.stat.year = Viti angal.supplier.deleted = Fshirë -angal.common.deleted.col = Fshirë +angal.supplier.deleted.col = Fshirë angal.supplier.deletesupplier.fmt.msg = Fshij furnitorin: {0}? angal.supplier.editsupplier.title = Redakto Furnitorin angal.supplier.email = E-mail diff --git a/bundle/language_zh_CN.properties b/bundle/language_zh_CN.properties index 9a6b8d7420..ff072be992 100644 --- a/bundle/language_zh_CN.properties +++ b/bundle/language_zh_CN.properties @@ -1600,7 +1600,7 @@ angal.stat.weeklyepidemsurveilover5 angal.stat.weeklyepidemsurveilunder5 = HMIS 33b - 每周流行病监测 小于5岁 angal.stat.year = 年 angal.supplier.deleted = 已删除 -angal.common.deleted.col = 已删除 +angal.supplier.deleted.col = 已删除 angal.supplier.deletesupplier.fmt.msg = 删除供应商: {0}? angal.supplier.editsupplier.title = 修改供应商 angal.supplier.email = 电子邮件 From e2e30e8dba21db2b6005133d2782cb959a4220e0 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Mon, 4 Nov 2024 16:02:16 +0100 Subject: [PATCH 05/19] chore: Update error handling --- bundle/language_en.properties | 2 ++ .../java/org/isf/menu/gui/UserBrowsing.java | 18 ++++++++++++------ .../org/isf/menu/gui/UserGroupBrowsing.java | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 5b4cd21beb..55e9de6568 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -633,6 +633,7 @@ angal.exatype.examtypebrowser.title angal.exatype.newexamtype.title = New Exam Type angal.genericreportbill.doyouwanttoprintreceipt.msg = Do you want to print a receipt? angal.groupsbrowser.deletegroup.fmt.msg = Delete group: {0}? +angal.groupsbrowser.softdeletegroup.fmt.msg = Could not delete the group '{0}' because he is used somewhere. Do you want to mark it as deleted ? angal.groupsbrowser.description.label = Description: angal.groupsbrowser.editgroup.title = Edit Group angal.groupsbrowser.groupmenu.btn = GroupMenu @@ -1693,6 +1694,7 @@ angal.therapy.worksheet.btn angal.therapy.worksheet.btn.key = W angal.userbrowser.addnewuser.title = Add New User angal.userbrowser.deleteuser.fmt.msg = Delete user: {0}? +angal.userbrowser.softdeleteuser.fmt.msg = Could not delete the user '{0}' because he is used somewhere. Do you want to mark him as deleted ? angal.userbrowser.description.label = Description: angal.userbrowser.edituser.title = Edit User angal.userbrowser.group.label = Group: diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 2eaa31749c..804540a85a 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -48,6 +48,7 @@ import org.isf.menu.model.User; import org.isf.menu.model.UserGroup; import org.isf.utils.db.BCrypt; +import org.isf.utils.exception.OHDataIntegrityViolationException; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.MessageDialog; @@ -261,18 +262,23 @@ public void ancestorAdded(AncestorEvent event) { User selectedUser = (User) model.getValueAt(table.getSelectedRow(), -1); int answer = MessageDialog.yesNo(null, "angal.userbrowser.deleteuser.fmt.msg", selectedUser.getUserName()); try { + if (answer == JOptionPane.YES_OPTION) { + userBrowsingManager.deleteUser(selectedUser); + userList.remove(table.getSelectedRow()); + model.fireTableDataChanged(); + table.updateUI(); + } + } catch (OHDataIntegrityViolationException ex) { + answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); if (answer == JOptionPane.YES_OPTION) { try { + user.setDeleted(true); userBrowsingManager.deleteUser(selectedUser); userList.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); - } catch (OHServiceException ex) { - selectedUser.setDeleted(true); - userBrowsingManager.deleteUser(selectedUser); - userList.set(table.getSelectedRow(), selectedUser); - model.fireTableDataChanged(); - table.updateUI(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); } } } catch (OHServiceException e) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index b1e6c1a218..d4d1dd1c7a 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -41,6 +41,7 @@ import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; import org.isf.menu.model.UserGroup; +import org.isf.utils.exception.OHDataIntegrityViolationException; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.MessageDialog; @@ -137,6 +138,19 @@ public UserGroupBrowsing() { model.fireTableDataChanged(); table.updateUI(); } + } catch (OHDataIntegrityViolationException ex) { + answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeleteuser.fmt.msg", userGroup.getCode()); + if (answer == JOptionPane.YES_OPTION) { + try { + userGroup.setDeleted(true); + userBrowsingManager.deleteGroup(userGroup); + pGroup.remove(table.getSelectedRow()); + model.fireTableDataChanged(); + table.updateUI(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } From 24d7bda4b9ff7f26b861489dffa35b6a03a4553f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Nov 2024 09:20:10 +0100 Subject: [PATCH 06/19] fix: Fix soft user deletion --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 4 +--- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 804540a85a..f9565fdf2b 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -264,7 +264,6 @@ public void ancestorAdded(AncestorEvent event) { try { if (answer == JOptionPane.YES_OPTION) { userBrowsingManager.deleteUser(selectedUser); - userList.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } @@ -272,9 +271,8 @@ public void ancestorAdded(AncestorEvent event) { answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); if (answer == JOptionPane.YES_OPTION) { try { - user.setDeleted(true); + selectedUser.setDeleted(true); userBrowsingManager.deleteUser(selectedUser); - userList.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index d4d1dd1c7a..51d8250c95 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -134,7 +134,6 @@ public UserGroupBrowsing() { try { if (answer == JOptionPane.YES_OPTION) { userBrowsingManager.deleteGroup(userGroup); - pGroup.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } @@ -144,7 +143,6 @@ public UserGroupBrowsing() { try { userGroup.setDeleted(true); userBrowsingManager.deleteGroup(userGroup); - pGroup.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { From cb9bbc03fc847a5f5021784827d42a18f091756f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Nov 2024 10:09:09 +0100 Subject: [PATCH 07/19] fix: Fix soft deletion --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 2 +- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index f9565fdf2b..34afec3db9 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -272,7 +272,7 @@ public void ancestorAdded(AncestorEvent event) { if (answer == JOptionPane.YES_OPTION) { try { selectedUser.setDeleted(true); - userBrowsingManager.deleteUser(selectedUser); + userBrowsingManager.updateUser(selectedUser); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 51d8250c95..319debd15e 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -142,7 +142,7 @@ public UserGroupBrowsing() { if (answer == JOptionPane.YES_OPTION) { try { userGroup.setDeleted(true); - userBrowsingManager.deleteGroup(userGroup); + userBrowsingManager.updateUserGroup(userGroup); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { From e72cbc91c37d6e43b0dc3276a3df10368fefe1a4 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Nov 2024 10:18:35 +0100 Subject: [PATCH 08/19] fix: Fix label --- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 319debd15e..479dd71d24 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -138,7 +138,7 @@ public UserGroupBrowsing() { table.updateUI(); } } catch (OHDataIntegrityViolationException ex) { - answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeleteuser.fmt.msg", userGroup.getCode()); + answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeletegroup.fmt.msg", userGroup.getCode()); if (answer == JOptionPane.YES_OPTION) { try { userGroup.setDeleted(true); From 60836a73f26614cb093b0f3eecaed60e7d6f896f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Nov 2024 12:03:05 +0100 Subject: [PATCH 09/19] chore: Align with the core --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 34afec3db9..1eabd82815 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -242,7 +242,7 @@ public void ancestorAdded(AncestorEvent event) { newPassword2 = null; user.setPasswd(hashed); try { - if (userBrowsingManager.updatePassword(user)) { + if (userBrowsingManager.updatePassword(user) != null) { MessageDialog.info(this, "angal.userbrowser.thepasswordhasbeenchanged.msg"); } } catch (OHServiceException e) { From 10c705e1a37471b48382bb4a87d9f7694dbb0042 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 6 Nov 2024 08:36:58 +0100 Subject: [PATCH 10/19] fix: Remove user/user group from list after hard deletion --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 1 + src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 1eabd82815..75fdb46dc9 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -264,6 +264,7 @@ public void ancestorAdded(AncestorEvent event) { try { if (answer == JOptionPane.YES_OPTION) { userBrowsingManager.deleteUser(selectedUser); + userList.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 479dd71d24..0f7a6204a4 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -134,6 +134,7 @@ public UserGroupBrowsing() { try { if (answer == JOptionPane.YES_OPTION) { userBrowsingManager.deleteGroup(userGroup); + pGroup.remove(table.getSelectedRow()); model.fireTableDataChanged(); table.updateUI(); } From 4528efaff8aab4fc2a40ebacb502648ea3e22e4f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 6 Nov 2024 15:51:48 +0100 Subject: [PATCH 11/19] fix: Fix user and user group update --- bundle/language_en.properties | 6 +++-- src/main/java/org/isf/menu/gui/GroupEdit.java | 13 ++++++++++- .../java/org/isf/menu/gui/UserBrowsing.java | 20 ++--------------- src/main/java/org/isf/menu/gui/UserEdit.java | 10 +++++++++ .../org/isf/menu/gui/UserGroupBrowsing.java | 22 ++----------------- 5 files changed, 30 insertions(+), 41 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 55e9de6568..fa46adeff5 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -373,6 +373,8 @@ angal.common.delete angal.common.delete.btn = Delete angal.common.delete.btn.key = D angal.common.deleted.col = Deleted +angal.common.deleted.label = Deleted +angal.common.denied.msg = This operation is not allowed. angal.common.description.txt = Description angal.common.discharge.txt = Discharge angal.common.documenthasnopages.msg = The document has no pages. @@ -633,7 +635,7 @@ angal.exatype.examtypebrowser.title angal.exatype.newexamtype.title = New Exam Type angal.genericreportbill.doyouwanttoprintreceipt.msg = Do you want to print a receipt? angal.groupsbrowser.deletegroup.fmt.msg = Delete group: {0}? -angal.groupsbrowser.softdeletegroup.fmt.msg = Could not delete the group '{0}' because he is used somewhere. Do you want to mark it as deleted ? +angal.groupsbrowser.softdeletegroup.fmt.msg = Could not delete the group '{0}' because it is used somewhere. Do you want to mark it as deleted ? angal.groupsbrowser.description.label = Description: angal.groupsbrowser.editgroup.title = Edit Group angal.groupsbrowser.groupmenu.btn = GroupMenu @@ -1694,7 +1696,7 @@ angal.therapy.worksheet.btn angal.therapy.worksheet.btn.key = W angal.userbrowser.addnewuser.title = Add New User angal.userbrowser.deleteuser.fmt.msg = Delete user: {0}? -angal.userbrowser.softdeleteuser.fmt.msg = Could not delete the user '{0}' because he is used somewhere. Do you want to mark him as deleted ? +angal.userbrowser.softdeleteuser.fmt.msg = Could not delete the user '{0}' because it is used somewhere. Do you want to mark it as deleted ? angal.userbrowser.description.label = Description: angal.userbrowser.edituser.title = Edit User angal.userbrowser.group.label = Group: diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index dee1db1321..6ca9904476 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -25,6 +25,7 @@ import java.util.EventListener; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; @@ -93,6 +94,7 @@ private void fireGroupUpdated() { private JButton okButton; private JTextField descriptionTextField; private JTextField nameTextField; + private JCheckBox isDeletedCheck; private UserGroup group; private boolean insert; @@ -155,7 +157,15 @@ private JPanel getDataPanel() { dataPanel.add(descLabel); dataPanel.add(getDescriptionTextField()); - SpringUtilities.makeCompactGrid(dataPanel, 2, 2, 5, 5, 5, 5); + + if (!insert && group.isDeleted()) { + dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); + isDeletedCheck = new JCheckBox(); + isDeletedCheck.setSelected(true); + dataPanel.add(isDeletedCheck); + } + + SpringUtilities.makeCompactGrid(dataPanel, 3, 2, 5, 5, 5, 5); } return dataPanel; } @@ -217,6 +227,7 @@ private JButton getOkButton() { } } else { // updating try { + group.setDeleted(isDeletedCheck.isSelected()); userBrowsingManager.updateUserGroup(group); fireGroupUpdated(); dispose(); diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 75fdb46dc9..362f30772a 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -130,7 +130,6 @@ public UserBrowsing() { buttonPanel.add(buttonNew); JButton buttonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); - buttonEdit.setEnabled(false); buttonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); buttonEdit.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -144,7 +143,6 @@ public UserBrowsing() { buttonPanel.add(buttonEdit); JButton buttonResetPassword = new JButton(MessageBundle.getMessage("angal.userbrowser.resetpassword.btn")); - buttonResetPassword.setEnabled(false); buttonResetPassword.setMnemonic(MessageBundle.getMnemonic("angal.userbrowser.resetpassword.btn.key")); buttonResetPassword.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -253,7 +251,6 @@ public void ancestorAdded(AncestorEvent event) { buttonPanel.add(buttonResetPassword); JButton buttonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); - buttonDelete.setEnabled(false); buttonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); buttonDelete.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -287,21 +284,6 @@ public void ancestorAdded(AncestorEvent event) { }); buttonPanel.add(buttonDelete); - table.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - - public void valueChanged(ListSelectionEvent e) { - if (table.getSelectedRow() >= 0) { - User selected = (User) table.getValueAt(table.getSelectedRow(), -1); - buttonEdit.setEnabled(!selected.isDeleted()); - buttonDelete.setEnabled(!selected.isDeleted()); - buttonResetPassword.setEnabled(!selected.isDeleted()); - } - String selectedData = null; - } - } - ); - JButton buttonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); buttonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); buttonClose.addActionListener(actionEvent -> dispose()); @@ -313,6 +295,7 @@ public void valueChanged(ListSelectionEvent e) { setLocationRelativeTo(null); setVisible(true); } + @Override public void userInserted(AWTEvent e) { User u = (User) e.getSource(); @@ -323,6 +306,7 @@ public void userInserted(AWTEvent e) { table.setRowSelectionInterval(0, 0); } } + @Override public void userUpdated(AWTEvent e) { userList.set(selectedrow, user); diff --git a/src/main/java/org/isf/menu/gui/UserEdit.java b/src/main/java/org/isf/menu/gui/UserEdit.java index f9a2bb175a..e5ffffcb91 100644 --- a/src/main/java/org/isf/menu/gui/UserEdit.java +++ b/src/main/java/org/isf/menu/gui/UserEdit.java @@ -106,6 +106,8 @@ private void fireUserUpdated() { private JComboBox userGroupComboBox; private JCheckBox accountLocked; + private JCheckBox isDeletedCheck; + private User user; private boolean insert; @@ -180,6 +182,13 @@ private JPanel getDataPanel() { accountLocked = new JCheckBox(); accountLocked.setSelected(user.isAccountLocked()); dataPanel.add(accountLocked); + + if(user.isDeleted()) { + dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); + isDeletedCheck = new JCheckBox(); + isDeletedCheck.setSelected(true); + dataPanel.add(isDeletedCheck); + } } SpringUtilities.makeCompactGrid(dataPanel, insert ? 5 : 4, 2, @@ -292,6 +301,7 @@ private JButton getOkButton() { Arrays.fill(password, '0'); Arrays.fill(repeatPassword, '0'); } else { + user.setDeleted(isDeletedCheck.isSelected()); user.setUserGroupName((UserGroup) userGroupComboBox.getSelectedItem()); try { if (user.isAccountLocked() && !accountLocked.isSelected()) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 0f7a6204a4..031268339a 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -32,8 +32,6 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; @@ -96,7 +94,6 @@ public UserGroupBrowsing() { buttonPanel.add(buttonNew); JButton buttonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); - buttonEdit.setEnabled(false); buttonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); buttonEdit.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -110,7 +107,6 @@ public UserGroupBrowsing() { buttonPanel.add(buttonEdit); JButton buttonPrivilege = new JButton(MessageBundle.getMessage("angal.groupsbrowser.groupmenu.btn")); - buttonPrivilege.setEnabled(false); buttonPrivilege.setMnemonic(MessageBundle.getMnemonic("angal.groupsbrowser.groupmenu.btn.key")); buttonPrivilege.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -123,7 +119,6 @@ public UserGroupBrowsing() { buttonPanel.add(buttonPrivilege); JButton buttonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); - buttonDelete.setEnabled(false); buttonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); buttonDelete.addActionListener(actionEvent -> { if (table.getSelectedRow() < 0) { @@ -157,21 +152,6 @@ public UserGroupBrowsing() { }); buttonPanel.add(buttonDelete); - table.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - - public void valueChanged(ListSelectionEvent e) { - if (table.getSelectedRow() >= 0) { - UserGroup selected = (UserGroup) table.getValueAt(table.getSelectedRow(), -1); - buttonEdit.setEnabled(!selected.isDeleted()); - buttonPrivilege.setEnabled(!selected.isDeleted()); - buttonDelete.setEnabled(!selected.isDeleted()); - } - String selectedData = null; - } - } - ); - JButton buttonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); buttonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); buttonClose.addActionListener(actionEvent -> dispose()); @@ -181,6 +161,7 @@ public void valueChanged(ListSelectionEvent e) { setLocationRelativeTo(null); setVisible(true); } + @Override public void groupInserted(AWTEvent e) { pGroup.add(0, group); @@ -190,6 +171,7 @@ public void groupInserted(AWTEvent e) { table.setRowSelectionInterval(0, 0); } } + @Override public void groupUpdated(AWTEvent e) { pGroup.set(selectedrow, group); From 3b0688c7ed9b072007b7dbd21559fe3985af4fd7 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Thu, 7 Nov 2024 17:01:00 +0100 Subject: [PATCH 12/19] fix: Fix user / user group edit ui --- src/main/java/org/isf/menu/gui/GroupEdit.java | 2 +- src/main/java/org/isf/menu/gui/UserEdit.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index 6ca9904476..dde31e6657 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -165,7 +165,7 @@ private JPanel getDataPanel() { dataPanel.add(isDeletedCheck); } - SpringUtilities.makeCompactGrid(dataPanel, 3, 2, 5, 5, 5, 5); + SpringUtilities.makeCompactGrid(dataPanel, group.isDeleted() ? 3 : 2, 2, 5, 5, 5, 5); } return dataPanel; } diff --git a/src/main/java/org/isf/menu/gui/UserEdit.java b/src/main/java/org/isf/menu/gui/UserEdit.java index e5ffffcb91..f454ca1f57 100644 --- a/src/main/java/org/isf/menu/gui/UserEdit.java +++ b/src/main/java/org/isf/menu/gui/UserEdit.java @@ -191,7 +191,7 @@ private JPanel getDataPanel() { } } SpringUtilities.makeCompactGrid(dataPanel, - insert ? 5 : 4, 2, + (insert || user.isDeleted()) ? 5 : 4, 2, 5, 5, 5, 5); } From b9faed476b3018b65bc83ffe3cfe5ffdf7101729 Mon Sep 17 00:00:00 2001 From: David B Malkovsky Date: Thu, 7 Nov 2024 15:39:45 -0500 Subject: [PATCH 13/19] Chore: replace explicit type with <> (#2082) --- .../java/org/isf/medicalstock/gui/MovStockMultipleCharging.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java index 6fc884994c..90e5937876 100644 --- a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java +++ b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java @@ -140,7 +140,7 @@ public class MovStockMultipleCharging extends JDialog { }; private JComboBox comboBoxUnits = new JComboBox(qtyOption); private int optionSelected = UNITS; - private List updateLots = new ArrayList(); + private List updateLots = new ArrayList<>(); private final String[] lotSelectionColumnNames = { MessageBundle.getMessage("angal.medicalstock.lotid").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.prepdate.col").toUpperCase(), From a418810d74c1826b2cd622bfe1d9d44ba3b9e3b4 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Fri, 8 Nov 2024 09:38:10 +0100 Subject: [PATCH 14/19] fix: Fix User and UserGroup edit --- bundle/language_en.properties | 2 + src/main/java/org/isf/menu/gui/GroupEdit.java | 127 +++++++---------- .../java/org/isf/menu/gui/UserBrowsing.java | 25 ++-- src/main/java/org/isf/menu/gui/UserEdit.java | 132 +++++++----------- .../org/isf/menu/gui/UserGroupBrowsing.java | 23 +-- 5 files changed, 131 insertions(+), 178 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index fa46adeff5..0ac1c9f9de 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -645,6 +645,7 @@ angal.groupsbrowser.mainmenu.txt angal.groupsbrowser.menuitembrowser.title = Menu Item Browser angal.groupsbrowser.newgroup.title = New Group angal.groupsbrowser.pleaseinsertavalidusergroupname.msg = Please insert a valid user group name. +angal.groupsbrowser.alreadysoftdeleted.msg = The group is already set as deleted. angal.groupsbrowser.theadmingroupcannotbedeleted.msg = The "admin" group cannot be deleted. angal.groupsbrowser.thegroupalreadyexists.fmt.msg = The group "{0}" already exists. angal.groupsbrowser.thisgrouphasusersandcannotbedeleted.msg = This group has users and cannot be deleted. @@ -1719,6 +1720,7 @@ angal.userbrowser.resetpassword.btn.key angal.userbrowser.resetpassword.title = Reset Password angal.userbrowser.retype.password.label = Retype Password: angal.userbrowser.selectgroup.label = Select group: +angal.userbrowser.alreadysoftdeleted.msg = The user is already set as deleted. angal.userbrowser.step1.pleaseinsertanew.password.msg = Please insert a new password. angal.userbrowser.step1.pleaseinsertanew.password.fmt.msg = Please insert a new password (minimum of {0} characters). angal.userbrowser.step2.pleaserepeatthenewpassword.label = Please repeat the new password. diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index dde31e6657..4c2f641568 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -46,23 +46,37 @@ public class GroupEdit extends JDialog { private static final long serialVersionUID = 1L; - private EventListenerList groupListeners = new EventListenerList(); - - private UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); - - public interface GroupListener extends EventListener { - void groupUpdated(AWTEvent e); - void groupInserted(AWTEvent e); - } - - public void addGroupListener(GroupListener l) { - groupListeners.add(GroupListener.class, l); - } - - public void removeGroupListener(GroupListener listener) { - groupListeners.remove(GroupListener.class, listener); - } + private final EventListenerList groupListeners = new EventListenerList(); + private final UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); + private final UserGroup group; + private final boolean insert; + private JPanel jContentPane; + private JPanel dataPanel; + private JPanel buttonPanel; + private JButton cancelButton; + private JButton okButton; + private JTextField descriptionTextField; + private JTextField nameTextField; + private JCheckBox isDeletedCheck; + /** + * This is the default constructor; we pass the arraylist and the selectedrow because we need to update them + */ + public GroupEdit(UserGroupBrowsing parent, UserGroup old, boolean inserting) { + super(parent, inserting + ? MessageBundle.getMessage("angal.groupsbrowser.newgroup.title") + : MessageBundle.getMessage("angal.groupsbrowser.editgroup.title"), true); + addGroupListener(parent); + insert = inserting; + group = old; + initialize(); + } + public void addGroupListener(GroupListener l) { + groupListeners.add(GroupListener.class, l); + } + public void removeGroupListener(GroupListener listener) { + groupListeners.remove(GroupListener.class, listener); + } private void fireGroupInserted(UserGroup aGroup) { AWTEvent event = new AWTEvent(aGroup, AWTEvent.RESERVED_ID_MAX + 1) { @@ -74,7 +88,6 @@ private void fireGroupInserted(UserGroup aGroup) { ((GroupListener) listener).groupInserted(event); } } - private void fireGroupUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { @@ -86,33 +99,6 @@ private void fireGroupUpdated() { ((GroupListener) listener).groupUpdated(event); } } - - private JPanel jContentPane; - private JPanel dataPanel; - private JPanel buttonPanel; - private JButton cancelButton; - private JButton okButton; - private JTextField descriptionTextField; - private JTextField nameTextField; - private JCheckBox isDeletedCheck; - - private UserGroup group; - private boolean insert; - - /** - * This is the default constructor; we pass the arraylist and the selectedrow - * because we need to update them - */ - public GroupEdit(UserGroupBrowsing parent, UserGroup old, boolean inserting) { - super(parent, inserting - ? MessageBundle.getMessage("angal.groupsbrowser.newgroup.title") - : MessageBundle.getMessage("angal.groupsbrowser.editgroup.title"), true); - addGroupListener(parent); - insert = inserting; - group = old; - initialize(); - } - /** * This method initializes this */ @@ -126,10 +112,8 @@ private void initialize() { setLocationRelativeTo(null); setVisible(true); } - /** * This method initializes jContentPane - * * @return javax.swing.JPanel */ private JPanel getJContentPane() { @@ -141,10 +125,8 @@ private JPanel getJContentPane() { } return jContentPane; } - /** * This method initializes dataPanel - * * @return javax.swing.JPanel */ private JPanel getDataPanel() { @@ -154,40 +136,34 @@ private JPanel getDataPanel() { dataPanel = new JPanel(new SpringLayout()); dataPanel.add(nameLabel); dataPanel.add(getNameTextField()); - + dataPanel.add(descLabel); dataPanel.add(getDescriptionTextField()); - if (!insert && group.isDeleted()) { - dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); - isDeletedCheck = new JCheckBox(); - isDeletedCheck.setSelected(true); - dataPanel.add(isDeletedCheck); - } + dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); + isDeletedCheck = new JCheckBox(); + isDeletedCheck.setSelected(group.isDeleted()); + dataPanel.add(isDeletedCheck); - SpringUtilities.makeCompactGrid(dataPanel, group.isDeleted() ? 3 : 2, 2, 5, 5, 5, 5); + SpringUtilities.makeCompactGrid(dataPanel, 3, 2, 5, 5, 5, 5); } return dataPanel; } - /** - * This method initializes buttonPanel - * - * @return javax.swing.JPanel + * This method initializes buttonPanel + * @return javax.swing.JPanel */ private JPanel getButtonPanel() { if (buttonPanel == null) { buttonPanel = new JPanel(); - buttonPanel.add(getOkButton(), null); - buttonPanel.add(getCancelButton(), null); + buttonPanel.add(getOkButton(), null); + buttonPanel.add(getCancelButton(), null); } return buttonPanel; } - /** - * This method initializes cancelButton - * - * @return javax.swing.JButton + * This method initializes cancelButton + * @return javax.swing.JButton */ private JButton getCancelButton() { if (cancelButton == null) { @@ -197,11 +173,9 @@ private JButton getCancelButton() { } return cancelButton; } - /** - * This method initializes okButton - * - * @return javax.swing.JButton + * This method initializes okButton + * @return javax.swing.JButton */ private JButton getOkButton() { if (okButton == null) { @@ -240,11 +214,9 @@ private JButton getOkButton() { } return okButton; } - /** - * This method initializes descriptionTextField - * - * @return javax.swing.JTextField + * This method initializes descriptionTextField + * @return javax.swing.JTextField */ private JTextField getDescriptionTextField() { if (descriptionTextField == null) { @@ -256,7 +228,6 @@ private JTextField getDescriptionTextField() { } return descriptionTextField; } - private JTextField getNameTextField() { if (nameTextField == null) { if (insert) { @@ -269,4 +240,10 @@ private JTextField getNameTextField() { return nameTextField; } + public interface GroupListener extends EventListener { + + void groupUpdated(AWTEvent e); + void groupInserted(AWTEvent e); + } + } diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 362f30772a..cc5090e4cd 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -36,8 +36,6 @@ import javax.swing.JTable; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.GeneralData; @@ -266,16 +264,21 @@ public void ancestorAdded(AncestorEvent event) { table.updateUI(); } } catch (OHDataIntegrityViolationException ex) { - answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); - if (answer == JOptionPane.YES_OPTION) { - try { - selectedUser.setDeleted(true); - userBrowsingManager.updateUser(selectedUser); - model.fireTableDataChanged(); - table.updateUI(); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); + try { + User oldUser = userBrowsingManager.getUserByName(selectedUser.getUserName(), true); + if (oldUser.isDeleted()) { + MessageDialog.error(null, "angal.userbrowser.alreadysoftdeleted.msg"); + } else { + answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); + if (answer == JOptionPane.YES_OPTION) { + selectedUser.setDeleted(true); + userBrowsingManager.updateUser(selectedUser); + model.fireTableDataChanged(); + table.updateUI(); + } } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); diff --git a/src/main/java/org/isf/menu/gui/UserEdit.java b/src/main/java/org/isf/menu/gui/UserEdit.java index f454ca1f57..ed69ba5b44 100644 --- a/src/main/java/org/isf/menu/gui/UserEdit.java +++ b/src/main/java/org/isf/menu/gui/UserEdit.java @@ -55,45 +55,10 @@ public class UserEdit extends JDialog { private static final long serialVersionUID = 1L; - private EventListenerList userListeners = new EventListenerList(); - - public interface UserListener extends EventListener { - void userUpdated(AWTEvent e); - void userInserted(AWTEvent e); - } - - public void addUserListener(UserListener l) { - userListeners.add(UserListener.class, l); - } - - public void removeUserListener(UserListener listener) { - userListeners.remove(UserListener.class, listener); - } - - private void fireUserInserted(User aUser) { - AWTEvent event = new AWTEvent(aUser, AWTEvent.RESERVED_ID_MAX + 1) { - - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = userListeners.getListeners(UserListener.class); - for (EventListener listener : listeners) { - ((UserListener) listener).userInserted(event); - } - } - - private void fireUserUpdated() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = userListeners.getListeners(UserListener.class); - for (EventListener listener : listeners) { - ((UserListener) listener).userUpdated(event); - } - } - + private final EventListenerList userListeners = new EventListenerList(); + private final User user; + private final boolean insert; + private final UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); private JPanel jContentPane; private JPanel dataPanel; private JPanel buttonPanel; @@ -105,27 +70,46 @@ private void fireUserUpdated() { private JPasswordField pwd2TextField; private JComboBox userGroupComboBox; private JCheckBox accountLocked; - private JCheckBox isDeletedCheck; - - private User user; - private boolean insert; - - private UserBrowsingManager userBrowsingManager = Context.getApplicationContext().getBean(UserBrowsingManager.class); - /** - * This is the default constructor; we pass the arraylist and the selectedrow - * because we need to update them + * This is the default constructor; we pass the arraylist and the selectedrow because we need to update them */ public UserEdit(UserBrowsing parent, User old, boolean inserting) { super(parent, (inserting ? MessageBundle.getMessage("angal.userbrowser.addnewuser.title") - : MessageBundle.getMessage("angal.userbrowser.edituser.title")), true); + : MessageBundle.getMessage("angal.userbrowser.edituser.title")), true); addUserListener(parent); insert = inserting; user = old; initialize(); } + public void addUserListener(UserListener l) { + userListeners.add(UserListener.class, l); + } + public void removeUserListener(UserListener listener) { + userListeners.remove(UserListener.class, listener); + } + private void fireUserInserted(User aUser) { + AWTEvent event = new AWTEvent(aUser, AWTEvent.RESERVED_ID_MAX + 1) { + + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = userListeners.getListeners(UserListener.class); + for (EventListener listener : listeners) { + ((UserListener) listener).userInserted(event); + } + } + private void fireUserUpdated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = userListeners.getListeners(UserListener.class); + for (EventListener listener : listeners) { + ((UserListener) listener).userUpdated(event); + } + } /** * This method initializes this */ @@ -136,10 +120,8 @@ private void initialize() { setLocationRelativeTo(null); setVisible(true); } - /** * This method initializes jContentPane - * * @return javax.swing.JPanel */ private JPanel getJContentPane() { @@ -151,16 +133,9 @@ private JPanel getJContentPane() { } return jContentPane; } - /** * This method initializes dataPanel - * - * @return javax.swing.JPanel - * tipo combo - * nome text - * desc text - * pwd text - * pwd2 text + * @return javax.swing.JPanel tipo combo nome text desc text pwd text pwd2 text */ private JPanel getDataPanel() { if (dataPanel == null) { @@ -182,25 +157,22 @@ private JPanel getDataPanel() { accountLocked = new JCheckBox(); accountLocked.setSelected(user.isAccountLocked()); dataPanel.add(accountLocked); - - if(user.isDeleted()) { - dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); - isDeletedCheck = new JCheckBox(); - isDeletedCheck.setSelected(true); - dataPanel.add(isDeletedCheck); - } } + + dataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label"))); + isDeletedCheck = new JCheckBox(); + isDeletedCheck.setSelected(user.isDeleted()); + dataPanel.add(isDeletedCheck); + SpringUtilities.makeCompactGrid(dataPanel, - (insert || user.isDeleted()) ? 5 : 4, 2, - 5, 5, - 5, 5); + insert ? 6 : 5, 2, + 5, 5, + 5, 5); } return dataPanel; } - /** * This method initializes buttonPanel - * * @return javax.swing.JPanel */ private JPanel getButtonPanel() { @@ -211,10 +183,8 @@ private JPanel getButtonPanel() { } return buttonPanel; } - /** * This method initializes cancelButton - * * @return javax.swing.JButton */ private JButton getCancelButton() { @@ -225,10 +195,8 @@ private JButton getCancelButton() { } return cancelButton; } - /** * This method initializes okButton - * * @return javax.swing.JButton */ private JButton getOkButton() { @@ -321,10 +289,8 @@ private JButton getOkButton() { } return okButton; } - /** * This method initializes descriptionTextField - * * @return javax.swing.JTextField */ private JTextField getDescriptionTextField() { @@ -338,8 +304,6 @@ private JTextField getDescriptionTextField() { } return descriptionTextField; } - - private JTextField getNameTextField() { if (nameTextField == null) { if (insert) { @@ -352,24 +316,20 @@ private JTextField getNameTextField() { } return nameTextField; } - private JPasswordField getPwdTextField() { if (pwdTextField == null) { pwdTextField = new JPasswordField(15); } return pwdTextField; } - private JTextField getPwd2TextField() { if (pwd2TextField == null) { pwd2TextField = new JPasswordField(15); } return pwd2TextField; } - /** * This method initializes userGroupComboBox - * * @return javax.swing.JComboBox */ private JComboBox getUserGroupComboBox() { @@ -410,4 +370,10 @@ private JComboBox getUserGroupComboBox() { return userGroupComboBox; } + public interface UserListener extends EventListener { + + void userUpdated(AWTEvent e); + void userInserted(AWTEvent e); + } + } diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 031268339a..10abf0fc13 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -134,15 +134,20 @@ public UserGroupBrowsing() { table.updateUI(); } } catch (OHDataIntegrityViolationException ex) { - answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeletegroup.fmt.msg", userGroup.getCode()); - if (answer == JOptionPane.YES_OPTION) { - try { - userGroup.setDeleted(true); - userBrowsingManager.updateUserGroup(userGroup); - model.fireTableDataChanged(); - table.updateUI(); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); + UserGroup oldUserGroup = userBrowsingManager.findUserGroupByCode(userGroup.getCode(), true); + if (oldUserGroup.isDeleted()) { + MessageDialog.error(null, "angal.groupsbrowser.alreadysoftdeleted.msg"); + } else { + answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeletegroup.fmt.msg", userGroup.getCode()); + if (answer == JOptionPane.YES_OPTION) { + try { + userGroup.setDeleted(true); + userBrowsingManager.updateUserGroup(userGroup); + model.fireTableDataChanged(); + table.updateUI(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } } } } catch (OHServiceException e) { From a44ca1b707175d3bc77af2aba9f58a978c0659d3 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Fri, 8 Nov 2024 11:31:31 +0100 Subject: [PATCH 15/19] fix: Fix user group creation and update --- src/main/java/org/isf/menu/gui/GroupEdit.java | 4 ++-- src/main/java/org/isf/menu/gui/UserBrowsing.java | 6 ++++-- src/main/java/org/isf/menu/gui/UserEdit.java | 6 +++++- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 5 +++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index 4c2f641568..c2dd89a024 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -188,8 +188,9 @@ private JButton getOkButton() { } group.setCode(nameTextField.getText()); - group.setDesc(descriptionTextField.getText()); + group.setDeleted(isDeletedCheck.isSelected()); + if (insert) { // inserting try { userBrowsingManager.newUserGroup(group); @@ -201,7 +202,6 @@ private JButton getOkButton() { } } else { // updating try { - group.setDeleted(isDeletedCheck.isSelected()); userBrowsingManager.updateUserGroup(group); fireGroupUpdated(); dispose(); diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index cc5090e4cd..2f53c6f7fa 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -271,8 +271,10 @@ public void ancestorAdded(AncestorEvent event) { } else { answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); if (answer == JOptionPane.YES_OPTION) { - selectedUser.setDeleted(true); - userBrowsingManager.updateUser(selectedUser); + User update = new User(selectedUser.getUserName(), selectedUser.getUserGroupName(), selectedUser.getPasswd(), + selectedUser.getDesc()); + update.setDeleted(true); + userBrowsingManager.updateUser(update); model.fireTableDataChanged(); table.updateUI(); } diff --git a/src/main/java/org/isf/menu/gui/UserEdit.java b/src/main/java/org/isf/menu/gui/UserEdit.java index ed69ba5b44..2c444058bd 100644 --- a/src/main/java/org/isf/menu/gui/UserEdit.java +++ b/src/main/java/org/isf/menu/gui/UserEdit.java @@ -209,8 +209,11 @@ private JButton getOkButton() { MessageDialog.error(null, "angal.userbrowser.pleaseprovideavalidusername.msg"); return; } + user.setUserName(userName); user.setDesc(descriptionTextField.getText()); + user.setDeleted(isDeletedCheck.isSelected()); + if (insert) { char[] password = pwdTextField.getPassword(); char[] repeatPassword = pwd2TextField.getPassword(); @@ -255,9 +258,11 @@ private JButton getOkButton() { Arrays.fill(repeatPassword, '0'); return; } + String hashed = BCrypt.hashpw(new String(password), BCrypt.gensalt()); user.setPasswd(hashed); user.setUserGroupName((UserGroup) userGroupComboBox.getSelectedItem()); + try { userBrowsingManager.newUser(user); fireUserInserted(user); @@ -269,7 +274,6 @@ private JButton getOkButton() { Arrays.fill(password, '0'); Arrays.fill(repeatPassword, '0'); } else { - user.setDeleted(isDeletedCheck.isSelected()); user.setUserGroupName((UserGroup) userGroupComboBox.getSelectedItem()); try { if (user.isAccountLocked() && !accountLocked.isSelected()) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 10abf0fc13..201f1f08a7 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -141,8 +141,9 @@ public UserGroupBrowsing() { answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeletegroup.fmt.msg", userGroup.getCode()); if (answer == JOptionPane.YES_OPTION) { try { - userGroup.setDeleted(true); - userBrowsingManager.updateUserGroup(userGroup); + UserGroup update = new UserGroup(userGroup.getCode(), userGroup.getDesc()); + update.setDeleted(true); + userBrowsingManager.updateUserGroup(update); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { From 4642e990a26f0878197b69d51505ffdf02b7bfcc Mon Sep 17 00:00:00 2001 From: David B Malkovsky Date: Sat, 9 Nov 2024 05:36:28 -0500 Subject: [PATCH 16/19] OP-1157 use pattern matching for instanceof (JDK 16) (#2083) --- .../admission/gui/PatientFolderBrowser.java | 9 +++---- .../java/org/isf/opd/gui/OpdEditExtended.java | 3 +-- .../org/isf/session/LoginEventListener.java | 3 +-- .../java/org/isf/therapy/gui/TherapyEdit.java | 6 ++--- .../isf/utils/jobjects/OhTableDrugsModel.java | 3 +-- .../org/isf/utils/jobjects/OhTableModel.java | 24 +++++++------------ .../utils/jobjects/OhTableOperationModel.java | 6 ++--- .../java/org/isf/video/PhotoboothTester.java | 10 ++++---- .../video/gui/PhotoboothComponentImpl.java | 10 ++++---- 9 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java b/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java index ec84046472..6420b94444 100644 --- a/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java +++ b/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java @@ -452,19 +452,16 @@ public void mouseClicked(MouseEvent mouseEvent) { } } - if (selectedObject instanceof Admission) { + if (selectedObject instanceof Admission ad) { - Admission ad = (Admission) selectedObject; startDate = ad.getAdmDate(); endDate = ad.getDisDate(); - } else if (selectedObject instanceof Opd) { + } else if (selectedObject instanceof Opd opd) { - Opd opd = (Opd) selectedObject; startDate = opd.getDate(); - } else if (selectedObject instanceof PatientExamination) { - PatientExamination exam = (PatientExamination) selectedObject; + } else if (selectedObject instanceof PatientExamination exam) { startDate = exam.getPex_date(); } diff --git a/src/main/java/org/isf/opd/gui/OpdEditExtended.java b/src/main/java/org/isf/opd/gui/OpdEditExtended.java index 4602a078bd..3c44beac58 100644 --- a/src/main/java/org/isf/opd/gui/OpdEditExtended.java +++ b/src/main/java/org/isf/opd/gui/OpdEditExtended.java @@ -445,8 +445,7 @@ private void setAttendance() { return; } Object selectedObject = diseaseBox1.getSelectedItem(); - if (selectedObject instanceof Disease) { - Disease disease = (Disease) selectedObject; + if (selectedObject instanceof Disease disease) { if (lastOPDDisease1 != null && disease.getCode().equals(lastOPDDisease1.getCode())) { rePatientButton.setSelected(true); } else { diff --git a/src/main/java/org/isf/session/LoginEventListener.java b/src/main/java/org/isf/session/LoginEventListener.java index 54029aa21f..aec980cf45 100644 --- a/src/main/java/org/isf/session/LoginEventListener.java +++ b/src/main/java/org/isf/session/LoginEventListener.java @@ -30,8 +30,7 @@ public class LoginEventListener implements LoginListener { @Override public void loginInserted(AWTEvent e) { - if (e.getSource() instanceof User) { - User myUser = (User) e.getSource(); + if (e.getSource() instanceof User myUser) { RestartUserSession.setUser(myUser); RestartUserSession.getTimer().startTimer(); } diff --git a/src/main/java/org/isf/therapy/gui/TherapyEdit.java b/src/main/java/org/isf/therapy/gui/TherapyEdit.java index 1e6855e163..1c1b612976 100644 --- a/src/main/java/org/isf/therapy/gui/TherapyEdit.java +++ b/src/main/java/org/isf/therapy/gui/TherapyEdit.java @@ -1142,14 +1142,12 @@ public void mouseClicked(MouseEvent e) { model = list.getModel(); for (int i = 0; i < model.getSize(); i++) { Object iteratedItem = model.getElementAt(i); - if (iteratedItem instanceof Therapy) { - Therapy aTherapy = (Therapy) iteratedItem; + if (iteratedItem instanceof Therapy aTherapy) { if (therapyID != 0 && aTherapy.getTherapyID() == therapyID) { list.setSelectedIndex(i); } } - if (iteratedItem instanceof Visit) { - Visit aVisit = (Visit) iteratedItem; + if (iteratedItem instanceof Visit aVisit) { if (visitID != 0 && aVisit.getVisitID() == visitID) { list.setSelectedIndex(i); } diff --git a/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java b/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java index 4d1d50b63f..ebfe1b2b8f 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java @@ -97,8 +97,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof MovementWard) { - MovementWard drugObj = (MovementWard) obj; + if (obj instanceof MovementWard drugObj) { switch (columnIndex) { case 0: String dt; diff --git a/src/main/java/org/isf/utils/jobjects/OhTableModel.java b/src/main/java/org/isf/utils/jobjects/OhTableModel.java index d2780e654b..6ce43fc84c 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableModel.java @@ -67,8 +67,7 @@ public T filter(String searchQuery) throws OHException { for (T t : this.dataList) { Object object = t; - if (object instanceof Price) { - Price price = (Price) object; + if (object instanceof Price price) { String strItem = price.getItem() + price.getDesc(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(price.getItem())) { T resPbj = (T) object; @@ -83,8 +82,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof MedicalWard) { - MedicalWard mdw = (MedicalWard) object; + if (object instanceof MedicalWard mdw) { String strItem = mdw.getMedical().getProdCode() + mdw.getMedical().getDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(mdw.getMedical().getProdCode())) { @@ -101,8 +99,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof PricesOthers) { - PricesOthers priceO = (PricesOthers) object; + if (object instanceof PricesOthers priceO) { String strItem = priceO.getCode() + priceO.getDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getCode())) { @@ -119,8 +116,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof BillItems) { - BillItems priceO = (BillItems) object; + if (object instanceof BillItems priceO) { String strItem = priceO.getItemDisplayCode() + priceO.getItemDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getItemDisplayCode())) { @@ -188,24 +184,21 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof Price) { - Price priceObj = (Price) obj; + if (obj instanceof Price priceObj) { if (columnIndex == 0) { value = priceObj.getItem() != null ? priceObj.getItem() : String.valueOf(priceObj.getId()); } else { value = priceObj.getDesc(); } } - if (obj instanceof MedicalWard) { - MedicalWard mdwObj = (MedicalWard) obj; + if (obj instanceof MedicalWard mdwObj) { if (columnIndex == 0) { value = mdwObj.getMedical().getProdCode() != null ? mdwObj.getMedical().getProdCode() : String.valueOf(mdwObj.getMedical().getCode()); } else { value = mdwObj.getMedical().getDescription(); } } - if (obj instanceof PricesOthers) { - PricesOthers mdwObj = (PricesOthers) obj; + if (obj instanceof PricesOthers mdwObj) { if (columnIndex == 0) { value = mdwObj.getCode() != null ? mdwObj.getCode() : String.valueOf(mdwObj.getId()); } else { @@ -213,8 +206,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { } } - if (obj instanceof BillItems) { - BillItems mdwObj = (BillItems) obj; + if (obj instanceof BillItems mdwObj) { if (columnIndex == 0) { value = mdwObj.getItemDisplayCode() != null ? mdwObj.getItemDisplayCode() : String.valueOf(mdwObj.getId()); } else { diff --git a/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java b/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java index 812c360f46..6946646975 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java @@ -63,8 +63,7 @@ public int filter(String searchQuery) { for (T t : this.dataList) { Object object = t; - if (object instanceof OperationRow) { - OperationRow price = (OperationRow) object; + if (object instanceof OperationRow price) { String strItem = price.getOperation().getCode() + price.getOpResult(); strItem = strItem.toLowerCase(); searchQuery = searchQuery.toLowerCase(); @@ -126,8 +125,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof OperationRow) { - OperationRow opdObj = (OperationRow) obj; + if (obj instanceof OperationRow opdObj) { switch (columnIndex) { case -1: return opdObj; diff --git a/src/main/java/org/isf/video/PhotoboothTester.java b/src/main/java/org/isf/video/PhotoboothTester.java index 994f13453e..878383f5ed 100644 --- a/src/main/java/org/isf/video/PhotoboothTester.java +++ b/src/main/java/org/isf/video/PhotoboothTester.java @@ -46,16 +46,14 @@ public static void main(final String[] args) { final PhotoboothPanelPresentationModel presentationModel = new PhotoboothPanelPresentationModel(); presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_IMAGE, propertyChangeEvent -> { final Object newValue = propertyChangeEvent.getNewValue(); - if (newValue instanceof BufferedImage) { - final BufferedImage bufferedImage = (BufferedImage) newValue; - LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight()); + if (newValue instanceof BufferedImage bufferedImage) { + LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight()); } }); presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_RESOLUTION, propertyChangeEvent -> { Object newValue = propertyChangeEvent.getNewValue(); - if (newValue instanceof Dimension) { - final Dimension newDimension = (Dimension) newValue; - LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight()); + if (newValue instanceof Dimension newDimension) { + LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight()); } }); diff --git a/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java b/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java index 644e091074..25c71ad390 100644 --- a/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java +++ b/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java @@ -58,9 +58,8 @@ public Component getListCellRendererComponent(final JList list, final boolean isSelected, final boolean cellHasFocus) { final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Dimension) { - final Dimension valueAsDimension = (Dimension) value; - setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight())); + if (value instanceof Dimension valueAsDimension) { + setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight())); } return component; } @@ -73,9 +72,8 @@ public Component getListCellRendererComponent(final JList list, final boolean isSelected, final boolean cellHasFocus) { final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Webcam) { - final Webcam webcam = (Webcam) value; - setText(webcam.getName()); + if (value instanceof Webcam webcam) { + setText(webcam.getName()); } return component; } From f39d81ea77ed2da5d55581ef990e3e57cae1374e Mon Sep 17 00:00:00 2001 From: David B Malkovsky Date: Sat, 9 Nov 2024 05:36:53 -0500 Subject: [PATCH 17/19] OP-1157 use enhanced switch (JDK 14) (#2084) --- .../isf/accounting/gui/BillDataLoader.java | 19 +++++--------- .../admission/gui/AdmittedPatientBrowser.java | 14 ++++------ .../org/isf/patient/gui/PatientInsert.java | 26 +++++++------------ .../patient/gui/PatientInsertExtended.java | 13 ++++------ 4 files changed, 26 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/isf/accounting/gui/BillDataLoader.java b/src/main/java/org/isf/accounting/gui/BillDataLoader.java index 81b816e08f..05618b065c 100644 --- a/src/main/java/org/isf/accounting/gui/BillDataLoader.java +++ b/src/main/java/org/isf/accounting/gui/BillDataLoader.java @@ -47,19 +47,12 @@ public BillDataLoader(List billPeriod, List billFromPayments, Patien } public List loadBills(String status, String username) throws OHServiceException { - List tableArray = new ArrayList<>(); - - switch (status) { - case "O": - tableArray = getPendingBills(status, username); - break; - case "ALL": - tableArray = getAllBills(username); - break; - case "C": - tableArray = getClosedBills(status, username); - break; - } + List tableArray = switch (status) { + case "O" -> getPendingBills(status, username); + case "ALL" -> getAllBills(username); + case "C" -> getClosedBills(status, username); + default -> new ArrayList<>(); + }; tableArray.sort(Collections.reverseOrder()); return tableArray; diff --git a/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java b/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java index 0e2aa065c8..fb611a04cf 100644 --- a/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java +++ b/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java @@ -1206,15 +1206,11 @@ else if (patientClassBox.getSelectedItem().equals(patientClassItems[1])) { } // sex patient type - Character sex = null; - switch (patientSexBox.getSelectedIndex()) { - case 1: - sex = 'M'; - break; - case 2: - sex = 'F'; - break; - } + Character sex = switch (patientSexBox.getSelectedIndex()) { + case 1 -> 'M'; + case 2 -> 'F'; + default -> null; + }; if (sex != null && !sex.equals(ap.getPatient().getSex())) { continue; diff --git a/src/main/java/org/isf/patient/gui/PatientInsert.java b/src/main/java/org/isf/patient/gui/PatientInsert.java index 28878c1e3a..cd0d1f8a71 100644 --- a/src/main/java/org/isf/patient/gui/PatientInsert.java +++ b/src/main/java/org/isf/patient/gui/PatientInsert.java @@ -263,14 +263,11 @@ private JButton getJOkButton() { String name = jFirstNameTextField.getText() + ' ' + jSecondNameTextField.getText(); try { if (patientBrowserManager.isNamePresent(name)) { - switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { - case JOptionPane.OK_OPTION: - ok = true; - break; - case JOptionPane.NO_OPTION: - ok = false; - break; - } + ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { + case JOptionPane.OK_OPTION -> true; + case JOptionPane.NO_OPTION -> false; + default -> ok; + }; } } catch (OHServiceException ex) { OHServiceExceptionUtil.showMessages(ex); @@ -320,14 +317,11 @@ private JButton getJOkButton() { if (!patient.getName().equals(name)) { try { if (patientBrowserManager.isNamePresent(name)) { - switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { - case JOptionPane.OK_OPTION: - ok = true; - break; - case JOptionPane.NO_OPTION: - ok = false; - break; - } + ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { + case JOptionPane.OK_OPTION -> true; + case JOptionPane.NO_OPTION -> false; + default -> ok; + }; } } catch (OHServiceException ex) { OHServiceExceptionUtil.showMessages(ex); diff --git a/src/main/java/org/isf/patient/gui/PatientInsertExtended.java b/src/main/java/org/isf/patient/gui/PatientInsertExtended.java index 53a8a9901c..da5a0829c5 100644 --- a/src/main/java/org/isf/patient/gui/PatientInsertExtended.java +++ b/src/main/java/org/isf/patient/gui/PatientInsertExtended.java @@ -444,14 +444,11 @@ private JButton getJOkButton() { String name = firstName + ' ' + secondName; try { if (patientBrowserManager.isNamePresent(name)) { - switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { - case JOptionPane.OK_OPTION: - ok = true; - break; - case JOptionPane.NO_OPTION: - ok = false; - break; - } + ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) { + case JOptionPane.OK_OPTION -> true; + case JOptionPane.NO_OPTION -> false; + default -> ok; + }; } } catch (OHServiceException ex) { OHServiceExceptionUtil.showMessages(ex); From c8a67af30825c08b9b32ec9a04d0558d6722d2b8 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Mon, 11 Nov 2024 14:47:24 +0100 Subject: [PATCH 18/19] fix: Fix group and user table not updating after soft delete operation --- src/main/java/org/isf/menu/gui/UserBrowsing.java | 7 +++---- src/main/java/org/isf/menu/gui/UserGroupBrowsing.java | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/UserBrowsing.java b/src/main/java/org/isf/menu/gui/UserBrowsing.java index 2f53c6f7fa..54f4937c73 100644 --- a/src/main/java/org/isf/menu/gui/UserBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserBrowsing.java @@ -271,15 +271,14 @@ public void ancestorAdded(AncestorEvent event) { } else { answer = MessageDialog.yesNo(null, "angal.userbrowser.softdeleteuser.fmt.msg", selectedUser.getUserName()); if (answer == JOptionPane.YES_OPTION) { - User update = new User(selectedUser.getUserName(), selectedUser.getUserGroupName(), selectedUser.getPasswd(), - selectedUser.getDesc()); - update.setDeleted(true); - userBrowsingManager.updateUser(update); + selectedUser.setDeleted(true); + userBrowsingManager.updateUser(selectedUser); model.fireTableDataChanged(); table.updateUI(); } } } catch (OHServiceException e) { + selectedUser.setDeleted(false); OHServiceExceptionUtil.showMessages(e); } } catch (OHServiceException e) { diff --git a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java index 201f1f08a7..8790512cdb 100644 --- a/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java +++ b/src/main/java/org/isf/menu/gui/UserGroupBrowsing.java @@ -141,12 +141,12 @@ public UserGroupBrowsing() { answer = MessageDialog.yesNo(null, "angal.groupsbrowser.softdeletegroup.fmt.msg", userGroup.getCode()); if (answer == JOptionPane.YES_OPTION) { try { - UserGroup update = new UserGroup(userGroup.getCode(), userGroup.getDesc()); - update.setDeleted(true); - userBrowsingManager.updateUserGroup(update); + userGroup.setDeleted(true); + userBrowsingManager.updateUserGroup(userGroup); model.fireTableDataChanged(); table.updateUI(); } catch (OHServiceException e) { + userGroup.setDeleted(false); OHServiceExceptionUtil.showMessages(e); } } From ce3abf9fc17f7e2a3c2757c6681a75177d30ebba Mon Sep 17 00:00:00 2001 From: mwithi Date: Mon, 11 Nov 2024 19:33:06 +0100 Subject: [PATCH 19/19] Fix Layout --- src/main/java/org/isf/menu/gui/GroupEdit.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index c2dd89a024..5e17a2098a 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -59,6 +59,7 @@ public class GroupEdit extends JDialog { private JTextField descriptionTextField; private JTextField nameTextField; private JCheckBox isDeletedCheck; + /** * This is the default constructor; we pass the arraylist and the selectedrow because we need to update them */ @@ -103,17 +104,16 @@ private void fireGroupUpdated() { * This method initializes this */ private void initialize() { - - this.setBounds(300, 300, 450, 150); this.setContentPane(getJContentPane()); - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); + pack(); setLocationRelativeTo(null); setVisible(true); } /** * This method initializes jContentPane + * * @return javax.swing.JPanel */ private JPanel getJContentPane() { @@ -127,6 +127,7 @@ private JPanel getJContentPane() { } /** * This method initializes dataPanel + * * @return javax.swing.JPanel */ private JPanel getDataPanel() { @@ -151,6 +152,7 @@ private JPanel getDataPanel() { } /** * This method initializes buttonPanel + * * @return javax.swing.JPanel */ private JPanel getButtonPanel() { @@ -163,6 +165,7 @@ private JPanel getButtonPanel() { } /** * This method initializes cancelButton + * * @return javax.swing.JButton */ private JButton getCancelButton() { @@ -175,6 +178,7 @@ private JButton getCancelButton() { } /** * This method initializes okButton + * * @return javax.swing.JButton */ private JButton getOkButton() { @@ -191,7 +195,7 @@ private JButton getOkButton() { group.setDesc(descriptionTextField.getText()); group.setDeleted(isDeletedCheck.isSelected()); - if (insert) { // inserting + if (insert) { // inserting try { userBrowsingManager.newUserGroup(group); fireGroupInserted(group); @@ -200,7 +204,7 @@ private JButton getOkButton() { MessageDialog.error(null, "angal.common.datacouldnotbesaved.msg"); OHServiceExceptionUtil.showMessages(e1); } - } else { // updating + } else { // updating try { userBrowsingManager.updateUserGroup(group); fireGroupUpdated(); @@ -216,12 +220,13 @@ private JButton getOkButton() { } /** * This method initializes descriptionTextField + * * @return javax.swing.JTextField */ private JTextField getDescriptionTextField() { if (descriptionTextField == null) { if (insert) { - descriptionTextField = new JTextField(); + descriptionTextField = new JTextField(15); } else { descriptionTextField = new JTextField(group.getDesc()); } @@ -231,7 +236,7 @@ private JTextField getDescriptionTextField() { private JTextField getNameTextField() { if (nameTextField == null) { if (insert) { - nameTextField = new JTextField(); + nameTextField = new JTextField(15); } else { nameTextField = new JTextField(group.getCode()); nameTextField.setEditable(false);