PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/code/ContextEditor.java

http://silkin.googlecode.com/
Java | 662 lines | 551 code | 49 blank | 62 comment | 64 complexity | 1eb7aaba7d4df0aa2d6f5c697c924fd8 MD5 | raw file
  1. import java.util.* ;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import javax.swing.event.*;
  6. import java.beans.*;
  7. /**
  8. The ContextEditor is a window that displays some of a {@link Context}'s fields for user editing.
  9. It is an extension of KSJInternalFrame because I want this to appear in the View menu.
  10. <p>
  11. The ContextEditor can only display one context - the current <code>Library.contextUnderConstruction</code>.
  12. Often there will be only one; if there are more, the User must choose one to be his current focus, then edit it.</p>
  13. @author Gary Morris, Northern Virginia Community College garymorris2245@verizon.net
  14. */
  15. public class ContextEditor extends KSJInternalFrame implements ItemListener {
  16. public Context ctxt;
  17. public JTextField name, folder;
  18. public JComboBox UDPick, indPick, famPick;
  19. public boolean rebuilding, showDeleted = false;
  20. public JPanel populationBox = new JPanel();
  21. public ArrayList<Object> peopleList;
  22. public ArrayList<Family> famList;
  23. public JCheckBox delBox;
  24. public Rectangle bnds = new Rectangle();
  25. public JTextArea comments;
  26. public CEListener listener;
  27. public ContextEditor(Context cntxt) {
  28. super("Edit User Context: " + cntxt.languageName);
  29. ctxt = cntxt;
  30. windowNum = ctxt.languageName + " Context Editor";
  31. setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  32. listener = new CEListener(this);
  33. JLabel textEdLabel = new JLabel("After editing a field, press 'Enter' key.");
  34. textEdLabel.setAlignmentX(0.5f);
  35. textEdLabel.setMaximumSize(new Dimension(225, 22));
  36. JPanel nameBox = new JPanel();
  37. nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS));
  38. name = new JTextField(ctxt.languageName, 28);
  39. name.setMaximumSize(new Dimension(225, 22));
  40. name.addActionListener(listener);
  41. name.setActionCommand("name edit");
  42. JLabel nameLabel = new JLabel("Language Name: ");
  43. nameBox.add(nameLabel);
  44. nameBox.add(name);
  45. JPanel folderBox = new JPanel();
  46. folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS));
  47. folder = new JTextField(ctxt.editDirectory);
  48. folder.setMaximumSize(new Dimension(225, 22));
  49. folder.addActionListener(listener);
  50. folder.setActionCommand("folder edit");
  51. JLabel folderLabel = new JLabel("SILK file folder: ");
  52. folderBox.add(folderLabel);
  53. folderBox.add(folder);
  54. JPanel nameFolderBox = new JPanel();
  55. nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS));
  56. nameBox.setAlignmentX(0.5f);
  57. nameFolderBox.add(nameBox);
  58. nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4)));
  59. nameFolderBox.add(folderBox);
  60. nameFolderBox.setAlignmentX(0.5f);
  61. delBox = new JCheckBox("Show deleted records");
  62. delBox.setSelected(false);
  63. delBox.addItemListener(this);
  64. buildPopulationBox();
  65. JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel();
  66. btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS));
  67. subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS));
  68. int numUDPs = 0;
  69. if (ctxt.userDefinedProperties != null) {
  70. numUDPs = ctxt.userDefinedProperties.size();
  71. }
  72. String plur = "ies";
  73. if (numUDPs == 1) {
  74. plur = "y";
  75. }
  76. JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur);
  77. subBoxUDP.add(udpLabel);
  78. JButton addUDP = new JButton("Add UDP");
  79. addUDP.setActionCommand("add UDP");
  80. addUDP.addActionListener(listener);
  81. subBoxUDP.add(addUDP);
  82. btnBoxUDPs.add(subBoxUDP);
  83. if (numUDPs > 0) {
  84. Dimension sizer = new Dimension(250, 50);
  85. String[] udpMenu = genUDPMenu();
  86. UDPick = new JComboBox(udpMenu);
  87. UDPick.addActionListener(listener);
  88. UDPick.setActionCommand("view/edit UDP");
  89. UDPick.setMinimumSize(sizer);
  90. UDPick.setMaximumSize(sizer);
  91. UDPick.setBorder(BorderFactory.createTitledBorder(
  92. BorderFactory.createLineBorder(Color.blue),
  93. "View/Edit UDPs"));
  94. btnBoxUDPs.add(UDPick);
  95. } // end of if-any-UDPs-exist
  96. JPanel domThs = new JPanel();
  97. domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS));
  98. domThs.setBorder(BorderFactory.createTitledBorder(
  99. BorderFactory.createLineBorder(Color.blue),
  100. "Kinship System Domain Theories"));
  101. domThs.setAlignmentX(0.5f);
  102. JPanel dtRefBtnBox = new JPanel();
  103. dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS));
  104. dtRefBtnBox.setAlignmentX(0.0f);
  105. JLabel dtRefLabel = new JLabel("Terms of Reference ");
  106. dtRefBtnBox.add(dtRefLabel);
  107. if (ctxt.domTheoryRefExists()) {
  108. JButton dtRefEdit = new JButton("Edit Theory");
  109. dtRefEdit.setActionCommand("edit dtRef");
  110. dtRefEdit.addActionListener(listener);
  111. dtRefBtnBox.add(dtRefEdit);
  112. // JButton dtRefDelete = new JButton("Delete Theory");
  113. // dtRefDelete.setActionCommand("dtRef delete");
  114. // dtRefDelete.addActionListener(listener);
  115. // dtRefBtnBox.add(dtRefDelete);
  116. } // end of if-dt-exists
  117. else { // if does not exist
  118. JLabel dtRefNone = new JLabel("< None >");
  119. dtRefBtnBox.add(dtRefNone);
  120. // JButton dtRefAdd = new JButton("Add Theory");
  121. // dtRefAdd.setActionCommand("dtRef add");
  122. // dtRefAdd.addActionListener(listener);
  123. // dtRefBtnBox.add(dtRefAdd);
  124. } // end of does-not-exist
  125. domThs.add(dtRefBtnBox);
  126. JPanel dtAddrBtnBox = new JPanel();
  127. dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS));
  128. dtAddrBtnBox.setAlignmentX(0.0f);
  129. JLabel dtAddrLabel = new JLabel("Terms of Address ");
  130. dtAddrBtnBox.add(dtAddrLabel);
  131. if (ctxt.domTheoryAdrExists()) {
  132. JButton dtAddrEdit = new JButton("Edit Theory");
  133. dtAddrEdit.setActionCommand("edit dtAddr");
  134. dtAddrEdit.addActionListener(listener);
  135. dtAddrBtnBox.add(dtAddrEdit);
  136. // JButton dtAddrViewList = new JButton("Delete Theory");
  137. // dtAddrViewList.setActionCommand("dtAddr delete");
  138. // dtAddrViewList.addActionListener(listener);
  139. // dtAddrBtnBox.add(dtAddrViewList);
  140. } // end of if-dt-exists
  141. else { // if does not exist
  142. JLabel dtAddrNone = new JLabel("< None >");
  143. dtAddrBtnBox.add(dtAddrNone);
  144. // JButton dtAddrAdd = new JButton("Add Theory");
  145. // dtAddrAdd.setActionCommand("dtAddr add");
  146. // dtAddrAdd.addActionListener(listener);
  147. // dtAddrBtnBox.add(dtAddrAdd);
  148. } // end of does-not-exist
  149. domThs.add(dtAddrBtnBox);
  150. // End of the left hand portion
  151. // Right hand portion follows. it is narrower.
  152. JPanel polyBox = new JPanel();
  153. polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS));
  154. polyBox.setAlignmentX(0.5f);
  155. JLabel polyLabelA = new JLabel("Polygamy");
  156. JLabel polyLabelB = new JLabel("Permitted?");
  157. JRadioButton yesPoly = new JRadioButton("Yes");
  158. yesPoly.setActionCommand("polygamy yes");
  159. yesPoly.addActionListener(listener);
  160. JRadioButton noPoly = new JRadioButton("No");
  161. noPoly.setActionCommand("polygamy no");
  162. noPoly.addActionListener(listener);
  163. if (cntxt.polygamyPermit) {
  164. yesPoly.setSelected(true);
  165. } else {
  166. noPoly.setSelected(true);
  167. }
  168. ButtonGroup polyBtns = new ButtonGroup();
  169. polyBtns.add(yesPoly);
  170. polyBtns.add(noPoly);
  171. polyBox.add(polyLabelA);
  172. polyBox.add(polyLabelB);
  173. polyBox.add(yesPoly);
  174. polyBox.add(noPoly);
  175. JPanel matrixBox = new JPanel();
  176. matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS));
  177. matrixBox.setAlignmentX(0.5f);
  178. JLabel matrixLabelA = new JLabel("Kin Term Matrix");
  179. JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows");
  180. JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms");
  181. matrixLabelA.setAlignmentX(0.5f);
  182. matrixLabelC.setAlignmentX(0.5f);
  183. matrixLabelD.setAlignmentX(0.5f);
  184. JButton matrixEditBtn = new JButton("Edit Matrix");
  185. matrixEditBtn.setActionCommand("edit matrix");
  186. matrixEditBtn.addActionListener(listener);
  187. matrixEditBtn.setAlignmentX(0.5f);
  188. matrixBox.add(matrixLabelA);
  189. matrixBox.add(matrixLabelC);
  190. matrixBox.add(matrixLabelD);
  191. matrixBox.add(matrixEditBtn);
  192. JPanel distinctBox = new JPanel();
  193. distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS));
  194. distinctBox.setAlignmentX(0.5f);
  195. JLabel distinctLabelA = new JLabel("Distinct Terms");
  196. JLabel distinctLabelB = new JLabel("of Address");
  197. distinctLabelA.setAlignmentX(0.5f);
  198. distinctLabelB.setAlignmentX(0.5f);
  199. JRadioButton yesDistinct = new JRadioButton("Yes");
  200. yesDistinct.setActionCommand("distinct yes");
  201. yesDistinct.addActionListener(listener);
  202. JRadioButton noDistinct = new JRadioButton("No");
  203. noDistinct.setActionCommand("distinct no");
  204. noDistinct.addActionListener(listener);
  205. yesDistinct.setAlignmentX(0.5f);
  206. noDistinct.setAlignmentX(0.5f);
  207. if (ctxt.distinctAdrTerms) {
  208. yesDistinct.setSelected(true);
  209. } else {
  210. noDistinct.setSelected(true);
  211. }
  212. ButtonGroup distinctBtns = new ButtonGroup();
  213. distinctBtns.add(yesDistinct);
  214. distinctBtns.add(noDistinct);
  215. distinctBox.add(distinctLabelA);
  216. distinctBox.add(distinctLabelB);
  217. distinctBox.add(yesDistinct);
  218. distinctBox.add(noDistinct);
  219. /* NOTE: It should be possible to put all these elements directly into the ContentPane.
  220. But that doesn't work; the layout is truly ugly and stuff gets stacked on top of other stuff.
  221. What works is to put everything into a JPanel with BoxLayout. Then put the JPanel into ContentPane. */
  222. JPanel leftCol = new JPanel();
  223. leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS));
  224. leftCol.add(nameFolderBox);
  225. leftCol.add(Box.createRigidArea(new Dimension(0, 4)));
  226. leftCol.add(populationBox);
  227. leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
  228. leftCol.add(btnBoxUDPs);
  229. leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
  230. leftCol.add(domThs);
  231. leftCol.add(new JLabel(" "));
  232. JPanel rightCol = new JPanel();
  233. rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS));
  234. rightCol.setBorder(BorderFactory.createTitledBorder(
  235. BorderFactory.createLineBorder(Color.blue),
  236. "Options"));
  237. rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
  238. rightCol.add(polyBox);
  239. rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
  240. rightCol.add(matrixBox);
  241. int high = (numUDPs > 0 ? 120 : 20);
  242. rightCol.add(Box.createRigidArea(new Dimension(0, high)));
  243. rightCol.add(distinctBox);
  244. JPanel commentBox = new JPanel();
  245. commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS));
  246. commentBox.setBorder(BorderFactory.createTitledBorder(
  247. BorderFactory.createLineBorder(Color.blue), "Notes on this culture:"));
  248. JScrollPane commentsPane = new JScrollPane();
  249. comments = new JTextArea();
  250. comments.setColumns(20);
  251. comments.setEditable(true);
  252. comments.setRows(3);
  253. comments.getDocument().addDocumentListener(new CommentListener());
  254. commentsPane.setViewportView(comments);
  255. commentBox.add(commentsPane);
  256. JPanel guts = new JPanel(); // Holds the guts of this window
  257. guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS));
  258. guts.add(leftCol);
  259. guts.add(Box.createRigidArea(new Dimension(10, 4)));
  260. guts.add(rightCol);
  261. JPanel wholeThing = new JPanel();
  262. wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS));
  263. wholeThing.add(textEdLabel);
  264. wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));
  265. wholeThing.add(guts);
  266. wholeThing.add(Box.createRigidArea(new Dimension(0, 8)));
  267. wholeThing.add(commentBox);
  268. wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));
  269. getContentPane().add(wholeThing);
  270. addInternalFrameListener(this);
  271. setSize(600, 620);
  272. setVisible(true);
  273. } // end of ContextEditor constructor
  274. public void buildPopulationBox() {
  275. rebuilding = true;
  276. populationBox.removeAll();
  277. peopleList = new ArrayList<Object>();
  278. famList = new ArrayList<Family>();
  279. if (showDeleted) peopleList.addAll(ctxt.individualCensus);
  280. else { // must filter out the deleted records
  281. Individual psn;
  282. Iterator pplIter = ctxt.individualCensus.iterator();
  283. while (pplIter.hasNext()) {
  284. psn = (Individual)pplIter.next();
  285. if (! psn.deleted) peopleList.add(psn);
  286. }
  287. } // end of filtering deleted records
  288. String plur = "s";
  289. if (peopleList.size() == 1) plur = "";
  290. populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS));
  291. populationBox.setBorder(BorderFactory.createTitledBorder(
  292. BorderFactory.createLineBorder(Color.blue),
  293. "Current Population"));
  294. populationBox.setAlignmentX(0.5f);
  295. populationBox.add(delBox);
  296. populationBox.add(Box.createRigidArea(new Dimension(8,0)));
  297. JLabel indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur);
  298. indivLabel.setAlignmentX(0.5f);
  299. populationBox.add(indivLabel);
  300. if (peopleList.size() > 0) {
  301. JPanel indivBtnBox = new JPanel();
  302. indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS));
  303. Dimension sizer2 = new Dimension(350, 50);
  304. String[] indMenu = genIndMenu(peopleList);
  305. indPick = new JComboBox(indMenu);
  306. indPick.addActionListener(listener);
  307. indPick.setActionCommand("view/edit person");
  308. indPick.setMinimumSize(sizer2);
  309. indPick.setMaximumSize(sizer2);
  310. indPick.setBorder(BorderFactory.createTitledBorder(
  311. BorderFactory.createLineBorder(Color.blue),
  312. "View/Edit Person"));
  313. indivBtnBox.add(indPick);
  314. populationBox.add(indivBtnBox);
  315. } // end of if-any-people-exist
  316. if (showDeleted) famList.addAll(ctxt.familyCensus);
  317. else { // must filter out the deleted records
  318. Family fm;
  319. Iterator fmIter = ctxt.familyCensus.iterator();
  320. while (fmIter.hasNext()) {
  321. fm = (Family)fmIter.next();
  322. if (! fm.deleted) famList.add(fm);
  323. }
  324. } // end of filtering deleted records
  325. plur = "ies";
  326. if (famList.size() == 1) plur = "y";
  327. JLabel famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
  328. famLabel.setAlignmentX(0.5f);
  329. populationBox.add(Box.createRigidArea(new Dimension(0,4)));
  330. populationBox.add(famLabel);
  331. if (famList.size() > 0) {
  332. JPanel famBtnBox = new JPanel();
  333. famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
  334. Dimension sizer2 = new Dimension(350, 50);
  335. String[] famMenu = genFamMenu(famList);
  336. famPick = new JComboBox(famMenu);
  337. famPick.addActionListener(listener);
  338. famPick.setActionCommand("view/edit family");
  339. famPick.setMinimumSize(sizer2);
  340. famPick.setMaximumSize(sizer2);
  341. famPick.setBorder(BorderFactory.createTitledBorder(
  342. BorderFactory.createLineBorder(Color.blue),
  343. "View/Edit Family"));
  344. famBtnBox.add(famPick);
  345. populationBox.add(famBtnBox);
  346. } // end of if-any-families-exist
  347. rebuilding = false;
  348. } // end of method buildPopulationBox
  349. public static String[] genIndMenu(ArrayList<Object> source) {
  350. String[] menu = new String[source.size()];
  351. Iterator indIter = source.iterator();
  352. Individual ind;
  353. String item;
  354. int ndex = 0;
  355. while (indIter.hasNext()) {
  356. ind = (Individual)indIter.next();
  357. item = "<no name>";
  358. if ((ind.name != null) && (ind.name.length() > 0))
  359. item = ind.name;
  360. item += " (" + ind.serialNmbr + ")";
  361. menu[ndex++] = item;
  362. }
  363. return menu;
  364. } // end of method genIndMenu(source)
  365. public static String[] genFamMenu(ArrayList<Family> source) {
  366. String[] menu = new String[source.size()];
  367. Iterator famIter = source.iterator();
  368. String dad, mom;
  369. Family fam;
  370. int ndex = 0;
  371. while (famIter.hasNext()) {
  372. fam = (Family)famIter.next();
  373. dad = "Anonymous"; mom = "Anonymous";
  374. if (fam.husband != null) dad = fam.husband.name;
  375. if (fam.wife != null) mom = fam.wife.name;
  376. menu[ndex++] = dad + " & " + mom + " (" + fam.serialNmbr + ")";
  377. }
  378. return menu;
  379. } // end of method genFamMenu(source)
  380. public String[] genUDPMenu() {
  381. String[] menu = new String[ctxt.userDefinedProperties.size()];
  382. Iterator udpIter = ctxt.userDefinedProperties.keySet().iterator();
  383. String item;
  384. int ndex = 0;
  385. while (udpIter.hasNext()) {
  386. item = (String)udpIter.next();
  387. menu[ndex++] = item;
  388. }
  389. return menu;
  390. } // end of method genUDPMenu()
  391. public void itemStateChanged(ItemEvent e) { // the required method for an Item Listener
  392. if (e.getStateChange() == ItemEvent.DESELECTED) {
  393. showDeleted = false;
  394. } else {
  395. showDeleted = true;
  396. }
  397. populationBox.removeAll();
  398. buildPopulationBox();
  399. populationBox.getBounds(bnds);
  400. populationBox.repaint(bnds);
  401. } // end of method itemStateChanged
  402. /** This internal class is the ActionListener for a ContextEditor; it
  403. * contains all the code behind the buttons, combo boxes, etc. in the
  404. * editor.
  405. */
  406. public class CEListener implements ActionListener {
  407. KSJInternalFrame ed;
  408. public CEListener(KSJInternalFrame ctxted) {
  409. ed = ctxted;
  410. } // end of constructor
  411. public void actionPerformed(ActionEvent e) {
  412. if (rebuilding) {
  413. return;
  414. }
  415. if (e.getActionCommand().equals("name edit")) {
  416. ctxt.saveState = true;
  417. String newName = name.getText(), msg;
  418. while (!Library.validateFileName(newName, false)) {
  419. msg = "The name '" + newName + "' violates the rules for names:\n"
  420. + "The name MUST start with a letter.\n"
  421. + "Use up to 28 LETTERS, NUMBERS, or DASHES (-) but NO SPACES.";
  422. newName = JOptionPane.showInputDialog(msg);
  423. } // end of harrass-em-until-they-give-a-good-name
  424. name.setText(newName);
  425. if (!newName.equals(ctxt.languageName)) { // Made a change
  426. msg = "Change this context's language name\nto" + newName + "?";
  427. String[] options = {newName, ctxt.languageName};
  428. int choice = JOptionPane.showOptionDialog(ed, msg, "Confirm Changed Language Name",
  429. JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
  430. null, options, options[0]);
  431. if (choice == 0) { // Change is confirmed
  432. ctxt.languageName = newName;
  433. msg = "Normally, the file name for a context is the same as the language name "
  434. + "\nfor that context. Change this context's file name\n"
  435. + "to " + newName + "?";
  436. options[0] = "Change File Name";
  437. options[1] = "Do Not Change";
  438. choice = JOptionPane.showOptionDialog(ed, msg, "Confirm Correct File Name",
  439. JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
  440. null, options, options[0]);
  441. if (choice == 0) {
  442. Library.userContextName = newName;
  443. }
  444. } // end of Change-is-confirmed
  445. } // end of change-was-made
  446. } // end of "name edit"
  447. if (e.getActionCommand().equals("folder edit")) {
  448. ctxt.editDirectory = folder.getText();
  449. }
  450. if (e.getActionCommand().equals("polygamy yes")) {
  451. ctxt.saveState = true;
  452. ctxt.polygamyPermit = true;
  453. SIL_Edit.editWindow.chart.dirty = true;
  454. }
  455. if (e.getActionCommand().equals("polygamy no")) {
  456. ctxt.saveState = true;
  457. ctxt.polygamyPermit = false;
  458. SIL_Edit.editWindow.chart.dirty = true;
  459. }
  460. if (e.getActionCommand().equals("distinct yes")) {
  461. ctxt.saveState = true;
  462. ctxt.distinctAdrTerms = true;
  463. SIL_Edit.editWindow.setDistinctAdrMenuItemSelected(true);
  464. SIL_Edit.editWindow.distinctAdrItemActionPerformed(null);
  465. SIL_Edit.editWindow.chart.dirty = true;
  466. MainPane.topPane.setVisible(true);
  467. }
  468. if (e.getActionCommand().equals("distinct no")) {
  469. ctxt.saveState = true;
  470. ctxt.distinctAdrTerms = false;
  471. SIL_Edit.editWindow.setDistinctAdrMenuItemSelected(false);
  472. SIL_Edit.editWindow.distinctAdrItemActionPerformed(null);
  473. SIL_Edit.editWindow.chart.dirty = true;
  474. MainPane.topPane.setVisible(true);
  475. }
  476. if (e.getActionCommand().equals("edit matrix")) {
  477. // TODO Allow edit of KinTermMatrix
  478. }
  479. if (e.getActionCommand().equals("view/edit person")) {
  480. ctxt.saveState = true;
  481. int serial = indPick.getSelectedIndex();
  482. Individual edee = (Individual) peopleList.get(serial);
  483. PersonEditor pEd = new PersonEditor(ctxt, ed, "View or Edit a Person", edee, "census", 0);
  484. if (!pEd.dupEditor) {
  485. pEd.desktop = desktop;
  486. desktop.add(pEd);
  487. pEd.miViewMe = menuView.add(pEd.windowNum);
  488. pEd.miViewMe.addActionListener(pEd);
  489. pEd.menuView = menuView;
  490. pEd.show();
  491. pEd.moveToFront();
  492. try {
  493. pEd.setSelected(true);
  494. } catch (PropertyVetoException pv) {
  495. }
  496. } else {
  497. try {
  498. pEd.setClosed(true);
  499. } catch (PropertyVetoException pv) {
  500. }
  501. }
  502. }
  503. if (e.getActionCommand().equals("view/edit family")) {
  504. ctxt.saveState = true;
  505. int serial = famPick.getSelectedIndex();
  506. Family edee = (Family) famList.get(serial);
  507. FamilyEditor fEd = new FamilyEditor(ctxt, ed, "View or Edit a Family", edee, "census");
  508. if (!fEd.dupEditor) {
  509. fEd.desktop = desktop;
  510. fEd.setLocation(350, 100);
  511. desktop.add(fEd);
  512. fEd.miViewMe = menuView.add(fEd.windowNum);
  513. fEd.miViewMe.addActionListener(fEd);
  514. fEd.menuView = menuView;
  515. fEd.show();
  516. fEd.moveToFront();
  517. try {
  518. fEd.setSelected(true);
  519. } catch (PropertyVetoException pv) {
  520. }
  521. } else {
  522. try {
  523. fEd.setClosed(true);
  524. } catch (PropertyVetoException pv) {
  525. }
  526. }
  527. }
  528. if (e.getActionCommand().equals("add UDP")) {
  529. UserDefinedProperty newU = new UserDefinedProperty("*newUDP");
  530. UDPEditor eddy = new UDPEditor(ctxt, ed, "Create New UDP", true, newU);
  531. eddy.desktop = desktop;
  532. eddy.setLocation(250, 50);
  533. desktop.add(eddy);
  534. eddy.miViewMe = menuView.add(eddy.windowNum);
  535. eddy.miViewMe.addActionListener(eddy);
  536. eddy.menuView = menuView;
  537. eddy.show();
  538. eddy.moveToFront();
  539. try {
  540. eddy.setSelected(true);
  541. } catch (PropertyVetoException pv) {
  542. }
  543. }
  544. if (e.getActionCommand().equals("view/edit UDP")) {
  545. String victim = (String) UDPick.getSelectedItem();
  546. UserDefinedProperty theUDP = (UserDefinedProperty) ctxt.userDefinedProperties.get(victim);
  547. UDPEditor eddy = new UDPEditor(ctxt, ed, "Edit UDP " + victim, false, theUDP);
  548. eddy.desktop = desktop;
  549. eddy.setLocation(250, 50);
  550. desktop.add(eddy);
  551. eddy.miViewMe = menuView.add(eddy.windowNum);
  552. eddy.miViewMe.addActionListener(eddy);
  553. eddy.menuView = menuView;
  554. eddy.show();
  555. eddy.moveToFront();
  556. try {
  557. eddy.setSelected(true);
  558. } catch (PropertyVetoException pv) {
  559. }
  560. }
  561. // THE NEXT 6 COMMANDS ARE NOT IMPLEMENTED
  562. // They'll be done after learning methods have been implemented
  563. // if (e.getActionCommand().equals("dtRef add")) {
  564. // ctxt.saveState = true;
  565. // JOptionPane.showMessageDialog(ed, "The function 'Add Terms of Reference' is not yet available.",
  566. // "Action Not Availabe",
  567. // JOptionPane.INFORMATION_MESSAGE);
  568. // }
  569. if (e.getActionCommand().equals("edit dtRef")) {
  570. ctxt.saveState = true;
  571. JOptionPane.showMessageDialog(ed, "The function 'Edit Terms of Reference' is not yet available.",
  572. "Action Not Availabe",
  573. JOptionPane.INFORMATION_MESSAGE);
  574. }
  575. // if (e.getActionCommand().equals("dtRef delete")) {
  576. // ctxt.saveState = true;
  577. // JOptionPane.showMessageDialog(ed, "The function 'Delete Terms of Reference' is not yet available.",
  578. // "Action Not Availabe",
  579. // JOptionPane.INFORMATION_MESSAGE);
  580. // }
  581. // if (e.getActionCommand().equals("dtAddr add")) {
  582. // ctxt.saveState = true;
  583. // JOptionPane.showMessageDialog(ed, "The function 'Add Terms of Address' is not yet available.",
  584. // "Action Not Availabe",
  585. // JOptionPane.INFORMATION_MESSAGE);
  586. // }
  587. if (e.getActionCommand().equals("edit dtAddr")) {
  588. ctxt.saveState = true;
  589. JOptionPane.showMessageDialog(ed, "The function 'Edit Terms of Address' is not yet available.",
  590. "Action Not Availabe",
  591. JOptionPane.INFORMATION_MESSAGE);
  592. }
  593. // if (e.getActionCommand().equals("dtAddr delete")) {
  594. // ctxt.saveState = true;
  595. // JOptionPane.showMessageDialog(ed, "The function 'Delete Terms of Address' is not yet available.",
  596. // "Action Not Availabe",
  597. // JOptionPane.INFORMATION_MESSAGE);
  598. // }
  599. } // end of ActionListerner method actionPerformed
  600. } // end of inner class CEListener
  601. class CommentListener implements DocumentListener {
  602. public void insertUpdate(DocumentEvent e) {
  603. ctxt.comments = comments.getText();
  604. }
  605. public void removeUpdate(DocumentEvent e) {
  606. ctxt.comments = comments.getText();
  607. }
  608. public void changedUpdate(DocumentEvent e) {
  609. //Plain text components do not fire these events
  610. }
  611. } // end of inner class CommentListener
  612. } // end of class ContextEditor