Fields Summary |
---|
ListDialog | listDlg |
AboutBox | aboutBox |
InEntry | entryDlg |
Search | searchDlg |
Hashtable | people |
Hashtable | families |
DataManagement.DMControl | dmControl |
int | listType |
FlatFile | fileType |
public TextArea | textArea |
private BorderLayout | borderLayout |
private MenuBar | menuBarMenu class instantations:
Main menu bar |
private Menu | menuFileMenu class instantations:
Main menu options: File |
private Menu | menuEditMenu class instantations:
Main menu options: Edit |
private Menu | menuViewMenu class instantations:
Main menu options: View |
private Menu | menuHelpMenu class instantations:
Main menu options: Help |
private MenuItem | menuOpenMenu class instantations:
Menu items: Open |
private MenuItem | menuSaveMenu class instantations:
Menu items: Open |
private MenuItem | menuCloseMenu class instantations:
Menu items: Close |
private MenuItem | menuExitMenu class instantations:
Menu items: Exit |
private MenuItem | menuNewIndividualMenu class instantations:
Menu items: New Individual |
private MenuItem | menuSearchMenu class instantations:
Menu items: Search |
private MenuItem | menuDescendentsMenu class instantations:
Menu items: Descendents |
private MenuItem | menuAncestorsMenu class instantations:
Menu items: Ancestors |
private MenuItem | menuAboutMenu class instantations:
Menu items: About |
private CheckboxMenuItem | checkShowSpouse |
Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent e)
String command = e.getActionCommand();
// System.out.println(command);
if(command.equals("Open")) openFile();
if(command.equals("Save as")) saveFile();
if(command.equals("Close")) close();
if(command.equals("Exit")) exit();
if(command.equals("About")) showAboutBox();
if(command.equals("New Individual")) newIndividual();
if(command.equals("Find")) find();
if(command.equals("Descendants")) getDescendants();
if(command.equals("Ancestors")) getAncestors();
|
void | close()
people = new Hashtable();
families = new Hashtable();
Individual temp1 = new Individual();
temp1.reset();
Family temp2 = new Family();
temp2.reset();
// baseFamily = new Family();
|
public void | exit()
System.exit(0);
|
void | find()
searchDlg = new Search();
searchDlg.setTarget(this);
searchDlg.setVisible(true);
|
void | getAncestors()
Vector buffer = null;
Enumeration pers;
Individual temp;
String name;
int count = 0;
listType = 2;
if(people != null) {
listDlg = new ListDialog(this);
listDlg.setTitle("List of Individuals...");
pers = people.keys();
while (pers.hasMoreElements()) {
temp = (Individual)people.get((Integer)pers.nextElement());
name = temp.getGivenNames() + " " + temp.getFamilyName();
if(buffer == null) buffer = new Vector();
buffer.addElement(temp);
count++;
}
listDlg.setData(buffer);
listDlg.setTarget(this);
Dimension frmSize = getSize();
Point loc = getLocation();
listDlg.setLocation((frmSize.width - 180)/ 2 + loc.x, (frmSize.height - 300) / 2 + loc.y);
listDlg.setVisible(true);
}
|
void | getDescendants()
Vector buffer = null;
Family t;
Individual temp;
Enumeration pers;
String name;
int count = 0;
listType = 1;
if(people != null) {
listDlg = new ListDialog(this);
listDlg.setTitle("List of Individuals...");
pers = people.keys();
while (pers.hasMoreElements()) {
temp = (Individual)people.get((Integer)pers.nextElement());
name = temp.getGivenNames() + " " + temp.getFamilyName();
if(buffer == null) buffer = new Vector();
buffer.addElement(temp);
count++;
}
listDlg.setData(buffer);
listDlg.setTarget(this);
Dimension frmSize = getSize();
Point loc = getLocation();
listDlg.setLocation((frmSize.width - 180)/ 2 + loc.x, (frmSize.height - 300) / 2 + loc.y);
listDlg.setVisible(true);
}
|
void | listClick()
Enumeration list;
String name;
Individual found;
Enumeration descendants;
Vector alist;
if(listType == 2) showAncestors();
else {
Individual person = listDlg.getIndividual();
if(person.isParent()) {
list = person.getSpouseInList();
while(list.hasMoreElements()) {
alist = ((Family)list.nextElement()).getDescendants(person.getName(),0,checkShowSpouse.getState());
if(alist != null) {
textArea.setText(" ");
descendants = alist.elements();
while(descendants.hasMoreElements()) {
name = (String)descendants.nextElement();
textArea.setText(textArea.getText() + name + "\n");
}
name = person.getGivenNames() + " " + person.getFamilyName().toLowerCase();
textArea.setText("The Descendants of: " + name + "\n\n" + textArea.getText());
}
}
}
else textArea.setText("No Descendants found.");
}
|
void | newIndividual()
Individual tempPerson;
Family tempFamily;
Hashtable test;
test = families;
entryDlg = new InEntry(this,true);
entryDlg.setList(families);
entryDlg.setInList(people);
entryDlg.setVisible(true);
tempPerson = entryDlg.getIndividual();
if(tempPerson != null && entryDlg.getCancel() != true) {
if(entryDlg.isNewIndividual()) {
people.put(new Integer(tempPerson.getReference()),tempPerson);
if(entryDlg.isParent()) {
entryDlg.getParentOf().setWife(tempPerson);
if(entryDlg.isChild()) {
entryDlg.getChild().addChild(tempPerson);
}
}
else {
if(entryDlg.isChild()) {
entryDlg.getChild().addChild(tempPerson);
}
else {
tempFamily = new Family();
tempFamily.setHusband(tempPerson);
int next = families.size() + 1;
families.put(new Integer(next),tempFamily);
}
}
}
else {
tempFamily = new Family();
tempFamily.setHusband(tempPerson);
int next = families.size() + 1;
families.put(new Integer(next),tempFamily);
}
}
|
void | openFile()
FileDialog fDialog = new FileDialog(this,"Open...",FileDialog.LOAD);
fDialog.setFile("*.ged");
fDialog.show();
if(fDialog.getFile() != null) {
close();
dmControl.readData(fDialog.getFile());
families = dmControl.getFamilies();
people = dmControl.getIndividuals();
}
|
public void | saveFile()
FileDialog fDialog = new FileDialog(this,"Save as...",FileDialog.SAVE);
fDialog.show();
if(fDialog.getFile() != null) {
/* try {
BufferedWriter out = new BufferedWriter(new FileWriter(fDialog.getFile()));
textArea.setText("Saving as " + fDialog.getFile());
Enumeration list = people.keys();
while(list.hasMoreElements()) {
out.write(((Individual)people.get(list.nextElement())).toString("0"));
}
list = families.keys();
while(list.hasMoreElements()) {
out.write(((Family)families.get(list.nextElement())).toString("0"));
}
out.write("0 TRLR");
out.close();
textArea.appendText("\nFinished saving file....");
}
catch(FileNotFoundException ex) {}
catch(IOException exe) {}*/
dmControl.saveData(fDialog.getFile());
}
|
public void | search()
Vector found = new Vector();
boolean flag;
Individual person;
if(searchDlg.getSearchName().length() > 0) {
String name = searchDlg.getSearchName().toLowerCase();
Enumeration list = people.keys();
while(list.hasMoreElements()) {
person = (Individual)people.get(list.nextElement());
if(person.getFamilyName().toLowerCase().equals(name) || person.getGivenNames().toLowerCase().equals(name))
found.addElement(person);
}
listDlg = new ListDialog(this);
listDlg.setTitle("List of Individuals...");
listDlg.setData(found);
listDlg.setTarget(this);
Dimension frmSize = getSize();
Point loc = getLocation();
listDlg.setLocation((frmSize.width - 180)/ 2 + loc.x, (frmSize.height - 300) / 2 + loc.y);
listDlg.setVisible(true);
}
|
public void | setup()
this.setLayout(borderLayout);
this.setSize(new Dimension(529, 327));
this.setTitle("Family Tree");
menuFile.setLabel("File");
menuOpen.setLabel("Open");
menuSave.setLabel("Save as");
menuClose.setLabel("Close");
menuExit.setLabel("Exit");
menuEdit.setLabel("Edit");
menuNewIndividual.setLabel("New Individual");
menuView.setLabel("View");
menuSearch.setLabel("Find");
menuDescendents.setLabel("Descendants");
menuAncestors.setLabel("Ancestors");
checkShowSpouse.setLabel("Show Spouse");
menuHelp.setLabel("Help");
menuAbout.setLabel("About");
menuAbout.addActionListener(this);
menuOpen.addActionListener(this);
menuSave.addActionListener(this);
menuClose.addActionListener(this);
menuExit.addActionListener(this);
menuNewIndividual.addActionListener(this);
menuSearch.addActionListener(this);
menuDescendents.addActionListener(this);
menuAncestors.addActionListener(this);
menuBar.add(menuFile);
menuBar.add(menuEdit);
menuBar.add(menuView);
menuBar.add(menuHelp);
menuFile.add(menuOpen);
menuFile.add(menuSave);
menuFile.add(menuClose);
menuFile.add(menuExit);
menuEdit.add(menuNewIndividual);
menuView.add(menuSearch);
menuView.add(menuDescendents);
menuView.add(menuAncestors);
menuView.add(checkShowSpouse);
menuHelp.add(menuAbout);
this.setMenuBar(menuBar);
this.addWindowListener(new windowEventHandler(this));
textArea.setEditable(false);
this.add(textArea, BorderLayout.CENTER);
testData();
|
public void | showAboutBox()
aboutBox = new AboutBox(this);
Dimension frmSize = getSize();
Point loc = getLocation();
aboutBox.setLocation((frmSize.width - 216)/ 2 + loc.x, (frmSize.height - 100) / 2 + loc.y);
aboutBox.setModal(true);
aboutBox.show();
|
void | showAncestors()
Vector list = null;
String name;
String test;
textArea.setText(" ");
Individual person = listDlg.getCurrent();
try {
list = person.getChildOf().getAncestors(0);
}catch(NullPointerException ex) {
textArea.setText(person.getName() + " has no Ancestors");
}
if(list != null) {
Enumeration loop = list.elements();
textArea.setText("The Ancestors of " + person.getName() + "\n");
while(loop.hasMoreElements()) {
name = (String)loop.nextElement();
textArea.setText(textArea.getText() + "\n" + name);
}
}
|
void | testData()
Family f;
people = new Hashtable();
families = new Hashtable();
people.put(new Integer(1),Individual.testObject());
people.put(new Integer(2),Individual.testObject2());
people.put(new Integer(3),Individual.testObject3());
people.put(new Integer(4),Individual.testObject4());
people.put(new Integer(5),Individual.testObject5());
people.put(new Integer(6),Individual.testObject6());
f = new Family(1,
(Individual)people.get(new Integer(1)), (Individual)people.get(new Integer(2)),
Marriage.testObject(), Divorce.testObject());
f.addChild((Individual)people.get(new Integer(3)));
f.addChild((Individual)people.get(new Integer(4)));
families.put(new Integer(1),f);
f = new Family(2,
(Individual)people.get(new Integer(3)), (Individual)people.get(new Integer(5)),
Marriage.testObject(), Divorce.testObject());
f.addChild((Individual)people.get(new Integer(6)));
families.put(new Integer(2),f);
dmControl.setUpRecords(families,people);
|
void | this_windowClosing(java.awt.event.WindowEvent e)
System.exit(0);
|
void | viewFamily()
Individual person;
Enumeration list;
Family family;
person = listDlg.getCurrent();
if(person != null) {
textArea.setText(" ");
family = person.getChildOf();
if(family != null) textArea.setText(family.getDetails());
if(person.isParent() == true) {
list = person.getSpouseInList();
if(list != null) {
while(list.hasMoreElements()) {
textArea.setText(textArea.getText() + "\n" + ((Family)list.nextElement()).getDetails());
}
}
}
}
|
void | viewIndividual()
Individual person;
person = listDlg.getCurrent();
if(person != null)
{
textArea.setText(person.getDetails());
}
else
textArea.setText("Please select an individual before choosing to view their details or family...");
|