Skip to content

Commit

Permalink
Fixed text
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit10696 committed Nov 22, 2024
1 parent 538680c commit 8d32434
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 50 deletions.
51 changes: 12 additions & 39 deletions src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand All @@ -53,26 +51,19 @@
public class MedicalTypeBrowser extends ModalJFrame implements MedicalTypeListener {

private static final long serialVersionUID = 1L;

private static final String STR_ALL = MessageBundle.getMessage("angal.common.all.txt");
private static final String STR_ACTIVE_ONLY = MessageBundle.getMessage("angal.medicals.activeonly.txt");
private static final String STR_DISABLED_ONLY = MessageBundle.getMessage("angal.medicals.disabledonly.txt");

private String pSelection;
private String activeSelection = STR_ACTIVE_ONLY;
private List<MedicalType> pMedicalType;
private String[] pColumns = {
MessageBundle.getMessage("angal.common.code.txt").toUpperCase(),
MessageBundle.getMessage("angal.common.description.txt").toUpperCase()
MessageBundle.getMessage("angal.common.description.txt").toUpperCase(),
MessageBundle.getMessage("angal.common.deleted.label").toUpperCase()
};
private int[] pColumnWidth = {80, 200};
private final int[] pColumnWidth = { 20, 200, 20 };
private JPanel jContainPanel;
private JPanel jButtonPanel;
private JButton jNewButton;
private JButton jEditButton;
private JButton jCloseButton;
private JButton jDeleteButton;
private JComboBox activeComboBox;
private JTable jTable;
private MedicalTypeBrowserModel model;
private int selectedrow;
Expand Down Expand Up @@ -111,7 +102,6 @@ private JPanel getJContainPanel() {
private JPanel getJButtonPanel() {
if (jButtonPanel == null) {
jButtonPanel = new JPanel();
jButtonPanel.add(getComboBoxActive());
jButtonPanel.add(getJNewButton(), null);
jButtonPanel.add(getJEditButton(), null);
jButtonPanel.add(getJDeleteButton(), null);
Expand All @@ -134,24 +124,6 @@ private JButton getJNewButton() {
return jNewButton;
}

private JComboBox getComboBoxActive() {
if (activeComboBox == null) {
activeComboBox = new JComboBox();
activeComboBox.addItem(STR_ACTIVE_ONLY);
activeComboBox.addItem(STR_ALL);
activeComboBox.addItem(STR_DISABLED_ONLY);
activeSelection = STR_ACTIVE_ONLY;
}
activeComboBox.addActionListener(actionEvent -> {
activeSelection = activeComboBox.getSelectedItem().toString();
model = new MedicalTypeBrowserModel();
jTable.setModel(model);
model.fireTableDataChanged();
jTable.updateUI();
});
return activeComboBox;
}

/**
* This method initializes jEditButton
*
Expand Down Expand Up @@ -227,6 +199,7 @@ private JTable getJTable() {
jTable = new JTable(model);
jTable.getColumnModel().getColumn(0).setMinWidth(pColumnWidth[0]);
jTable.getColumnModel().getColumn(1).setMinWidth(pColumnWidth[1]);
jTable.getColumnModel().getColumn(2).setMinWidth(pColumnWidth[2]);
}
return jTable;
}
Expand All @@ -239,11 +212,6 @@ class MedicalTypeBrowserModel extends DefaultTableModel {
public MedicalTypeBrowserModel() {
try {
pMedicalType = medicalTypeBrowserManager.getMedicalType();
if (activeSelection.equals(STR_ACTIVE_ONLY)) {
pMedicalType = new ArrayList<>(pMedicalType.stream().filter(med -> med.getDeleted() == 'N').toList());
} else if (activeSelection.equals(STR_DISABLED_ONLY)) {
pMedicalType = new ArrayList<>(pMedicalType.stream().filter(med -> med.getDeleted() == 'Y').toList());
}
} catch (OHServiceException e) {
pMedicalType = null;
OHServiceExceptionUtil.showMessages(e);
Expand Down Expand Up @@ -277,6 +245,8 @@ public Object getValueAt(int r, int c) {
return medType.getCode();
} else if (c == 1) {
return medType.getDescription();
} else if (c == 2) {
return medType.getDeleted() == 'Y';
}
return null;
}
Expand All @@ -285,17 +255,21 @@ public Object getValueAt(int r, int c) {
public boolean isCellEditable(int arg0, int arg1) {
return false;
}

@Override
public Class getColumnClass(int column) {
return (column == 2) ? Boolean.class : String.class;
}
}

@Override
public void medicalTypeUpdated(AWTEvent e) {
pMedicalType.set(selectedrow, medicalType);
((MedicalTypeBrowserModel) jTable.getModel()).fireTableDataChanged();
jTable.updateUI();
if (jTable.getRowCount() > 0 && selectedrow > -1) {
jTable.setRowSelectionInterval(selectedrow, selectedrow);
}
model = new MedicalTypeBrowserModel();
jTable.updateUI();
}


Expand All @@ -306,6 +280,5 @@ public void medicalTypeInserted(AWTEvent e) {
if (jTable.getRowCount() > 0) {
jTable.setRowSelectionInterval(0, 0);
}
model = new MedicalTypeBrowserModel();
}
}
21 changes: 10 additions & 11 deletions src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void fireMedicalUpdated() {
private JButton cancelButton;
private JButton okButton;
private JTextField descriptionTextField;
private JCheckBox activeCheckbox;
private JCheckBox deletedCheckbox;
private VoLimitedTextField codeTextField;
private String lastdescription;
private char isLastDeleted;
Expand Down Expand Up @@ -128,11 +128,10 @@ private void initialize() {
this.setTitle(MessageBundle.getMessage("angal.medtype.editmedicaltype.title"));
}
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.getActiveField();
this.getDeletedField();
this.pack();
this.setLocationRelativeTo(null);
}


/**
* This method initializes jContentPane
Expand Down Expand Up @@ -203,7 +202,7 @@ private JButton getOkButton() {

medicalType.setDescription(descriptionTextField.getText());
medicalType.setCode(codeTextField.getText());
medicalType.setDeleted(activeCheckbox.isSelected() ? 'N' : 'Y');
medicalType.setDeleted(deletedCheckbox.isSelected() ? 'Y' : 'N');

if (insert) { // inserting
try {
Expand Down Expand Up @@ -271,12 +270,12 @@ private JTextField getCodeTextField() {
return codeTextField;
}

private JCheckBox getActiveField() {
if (activeCheckbox == null) {
activeCheckbox = new JCheckBox("Active");
activeCheckbox.setSelected(medicalType.getDeleted() == 'N');
private JCheckBox getDeletedField() {
if (deletedCheckbox == null) {
deletedCheckbox = new JCheckBox(MessageBundle.getMessage("angal.common.deleted.label"));
deletedCheckbox.setSelected(medicalType.getDeleted() == 'Y');
}
return activeCheckbox;
return deletedCheckbox;
}

/**
Expand All @@ -291,8 +290,8 @@ private JPanel getJDataPanel() {
jDataPanel.add(getCodeTextField());
jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.description.txt") + ':'));
jDataPanel.add(getDescriptionTextField());
jDataPanel.add(new JLabel(MessageBundle.getMessage("Active") + ':'));
jDataPanel.add(getActiveField());
jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label") + ':'));
jDataPanel.add(getDeletedField());
SpringUtilities.makeCompactGrid(jDataPanel, 3, 2, 5, 5, 5, 5);
}
return jDataPanel;
Expand Down

0 comments on commit 8d32434

Please sign in to comment.