/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OpenEMRConnect.
*
* The Initial Developer of the Original Code is International Training &
* Education Center for Health (I-TECH) <http://www.go2itech.org/>
*
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
/*
* HouseholdMembersDialog.java
*
* Created on Jul 13, 2011, 11:14:37 AM
*/
package ke.go.moh.oec.reception.gui;
import java.util.ArrayList;
import java.util.List;
import ke.go.moh.oec.Person;
import ke.go.moh.oec.reception.controller.OECReception;
import ke.go.moh.oec.reception.gui.helper.DialogEscaper;
import org.jdesktop.application.Action;
import org.jdesktop.beansbinding.Binding;
/**
*
* @author jGitau
*/
public class HouseholdMembersDialog extends javax.swing.JDialog {
/** Creates new form HouseholdMembersDialog */
public HouseholdMembersDialog(java.awt.Frame parent, boolean modal, List<Person> householdMemberList) {
super(parent, modal);
initComponents();
displayHouseholdMembers(householdMemberList);
this.setIconImage(OECReception.applicationIcon());
this.getRootPane().setDefaultButton(closeButton);
addEscapeListener();
}
private void addEscapeListener() {
DialogEscaper.addEscapeListener(this);
}
private void displayHouseholdMembers(List<Person> householdMemberList) {
Binding binding = bindingGroup.getBinding("householdMembersBinding");
binding.unbind();
this.householdMemberList.clear();
this.householdMemberList.addAll(householdMemberList);
binding.bind();
householdMembersTable.repaint();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
householdMemberList = new ArrayList<Person>();
householdMembersPanel = new javax.swing.JPanel();
householdMembersScrollPane = new javax.swing.JScrollPane();
householdMembersTable = new javax.swing.JTable();
closeButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setName("Form"); // NOI18N
householdMembersPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
householdMembersPanel.setName("householdMembersPanel"); // NOI18N
householdMembersScrollPane.setName("householdMembersScrollPane"); // NOI18N
householdMembersTable.setName("householdMembersTable"); // NOI18N
org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, householdMemberList, householdMembersTable, "householdMembersBinding");
org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${firstName}"));
columnBinding.setColumnName("First Name");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${middleName}"));
columnBinding.setColumnName("Middle Name");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${lastName}"));
columnBinding.setColumnName("Last Name");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${otherName}"));
columnBinding.setColumnName("Other Name");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${birthdate}"));
columnBinding.setColumnName("Birthdate");
columnBinding.setColumnClass(java.util.Date.class);
bindingGroup.addBinding(jTableBinding);
jTableBinding.bind();
householdMembersScrollPane.setViewportView(householdMembersTable);
javax.swing.GroupLayout householdMembersPanelLayout = new javax.swing.GroupLayout(householdMembersPanel);
householdMembersPanel.setLayout(householdMembersPanelLayout);
householdMembersPanelLayout.setHorizontalGroup(
householdMembersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(householdMembersPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(householdMembersScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
.addContainerGap())
);
householdMembersPanelLayout.setVerticalGroup(
householdMembersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, householdMembersPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(householdMembersScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
.addContainerGap())
);
javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(ke.go.moh.oec.reception.gui.App.class).getContext().getActionMap(HouseholdMembersDialog.class, this);
closeButton.setAction(actionMap.get("close")); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ke.go.moh.oec.reception.gui.App.class).getContext().getResourceMap(HouseholdMembersDialog.class);
closeButton.setText(resourceMap.getString("closeButton.text")); // NOI18N
closeButton.setName("closeButton"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(householdMembersPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(closeButton))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(householdMembersPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(closeButton)
.addContainerGap())
);
bindingGroup.bind();
pack();
}// </editor-fold>//GEN-END:initComponents
@Action
public void close() {
dispose();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton closeButton;
private java.util.List<Person> householdMemberList;
private javax.swing.JPanel householdMembersPanel;
private javax.swing.JScrollPane householdMembersScrollPane;
private javax.swing.JTable householdMembersTable;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables
}