PageRenderTime 32ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/code/UDPEditor.java

http://silkin.googlecode.com/
Java | 1011 lines | 946 code | 38 blank | 27 comment | 275 complexity | 02a63b33c196303ee47a59f850cd2c57 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 UDPEditor is a window that displays a {@link UserDefinedProperty}'s fields for editing.
  9. It is an extension of KSJInternalFrame because I want this to appear in the View menu.
  10. @author Gary Morris, Northern Virginia Community College garymorris2245@verizon.net
  11. */
  12. public class UDPEditor extends KSJInternalFrame {
  13. public Context ctxt;
  14. public KSJInternalFrame ctxtEd;
  15. public boolean newUDP, newSingleValue, validValsChanged = false, defaultValExists = false;
  16. public UserDefinedProperty theUDP; // The various newxxx fields are holders for the
  17. public String newStarName, newType; // new values entered into this editor.
  18. public ArrayList<Object> newValidEntries; // After validation, they'll be stored on theUDP.
  19. Number newMinVal, newMaxVal;
  20. Object newDefaultValue;
  21. UDPListener listener;
  22. JComboBox typePick;
  23. JRadioButton nocertain, yescertain, yesdefault, nodefault, nomulti;
  24. JTextField name_1, certainText, defaultText, minText, maxText;
  25. JLabel certainEditLabel, defeditLabel;
  26. JButton udpCheckSave;
  27. JProgressBar progressBar; // These 2 elements of the editor GUI are accessed
  28. JPanel progBox; // by the Listener
  29. public UDPEditor(Context cntxt, KSJInternalFrame ctEd, String title, boolean newUDPee,
  30. UserDefinedProperty theUDPee) {
  31. super(title);
  32. ctxt = cntxt;
  33. ctxtEd = ctEd;
  34. newUDP = newUDPee;
  35. theUDP = theUDPee;
  36. if (newUDP) windowNum = "Add a UDP";
  37. else windowNum = "UDP Editor: " + theUDP.starName;
  38. setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  39. addInternalFrameListener(this); // allows View Menu to work
  40. listener = new UDPListener(this);
  41. JPanel editor = new JPanel();
  42. editor.setLayout(new BoxLayout(editor, BoxLayout.PAGE_AXIS));
  43. // NAME BOX
  44. JPanel nameBox = new JPanel();
  45. nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS));
  46. name_1 = new JTextField("*", 28);
  47. if (! newUDP) name_1.setText(theUDP.starName);
  48. name_1.setMaximumSize(new Dimension(225, 22));
  49. name_1.addActionListener(listener);
  50. name_1.setActionCommand("name edit");
  51. JLabel nameLabel = new JLabel("UDP Name: ");
  52. nameBox.add(nameLabel);
  53. nameBox.add(name_1);
  54. JPanel nameEdBox = new JPanel();
  55. nameEdBox.setLayout(new BoxLayout(nameEdBox, BoxLayout.PAGE_AXIS));
  56. nameBox.setAlignmentX(0.5f);
  57. String lab;
  58. if (newUDP) lab = "Enter name (starting with '*'), hit 'Enter' key.";
  59. else lab = "Edit name, then press 'Enter' key.";
  60. JLabel nameEdLabel = new JLabel(lab);
  61. nameEdLabel.setAlignmentX(0.5f);
  62. nameEdLabel.setMaximumSize(new Dimension(300, 22));
  63. nameEdBox.add(nameBox);
  64. nameEdBox.add(nameEdLabel);
  65. nameEdBox.setAlignmentX(0.5f);
  66. editor.add(nameEdBox);
  67. // DATA TYPE
  68. JPanel dTypeBox = new JPanel();
  69. dTypeBox.setLayout(new BoxLayout(dTypeBox, BoxLayout.LINE_AXIS));
  70. JLabel typeLabel = new JLabel("Data Type: ");
  71. Dimension sizer = new Dimension(150, 50);
  72. String[] typeMenu = {"String", "Integer", "Real Number", "Boolean", "Person"};
  73. typePick = new JComboBox(typeMenu);
  74. if (newUDP) {
  75. typePick.setSelectedIndex(0);
  76. newType = "string";
  77. }
  78. else {
  79. if (theUDP.typ.equals("integer")) typePick.setSelectedIndex(1);
  80. else if (theUDP.typ.equals("float")) typePick.setSelectedIndex(2);
  81. else if (theUDP.typ.equals("string")) typePick.setSelectedIndex(0);
  82. else if (theUDP.typ.equals("boolean")) typePick.setSelectedIndex(3);
  83. else typePick.setSelectedIndex(4);
  84. newType = theUDP.typ;
  85. } // end of setting the current data type
  86. typePick.addActionListener(listener);
  87. typePick.setActionCommand("data type");
  88. typePick.setMinimumSize(sizer);
  89. typePick.setMaximumSize(sizer);
  90. dTypeBox.add(typeLabel);
  91. dTypeBox.add(typePick);
  92. editor.add(Box.createRigidArea(new Dimension(0,4)));
  93. editor.add(dTypeBox);
  94. // MULTIPLE VALUES?
  95. JPanel multiBox = new JPanel();
  96. multiBox.setLayout(new BoxLayout(multiBox, BoxLayout.LINE_AXIS));
  97. JLabel multiLabel = new JLabel("Multiple Values?");
  98. JRadioButton yesmulti = new JRadioButton("Yes");
  99. yesmulti.setActionCommand("multiVal yes");
  100. yesmulti.addActionListener(listener);
  101. nomulti = new JRadioButton("No");
  102. nomulti.setActionCommand("multiVal no");
  103. nomulti.addActionListener(listener);
  104. if (theUDP.singleValue) nomulti.setSelected(true);
  105. else yesmulti.setSelected(true);
  106. newSingleValue = theUDP.singleValue;
  107. ButtonGroup multiBtns = new ButtonGroup();
  108. multiBtns.add(yesmulti);
  109. multiBtns.add(nomulti);
  110. multiBox.add(multiLabel);
  111. multiBox.add(yesmulti);
  112. multiBox.add(nomulti);
  113. editor.add(Box.createRigidArea(new Dimension(0,4)));
  114. editor.add(multiBox);
  115. // RESTRICTED TO CERTAIN VALUES?
  116. JPanel certainBox = new JPanel();
  117. certainBox.setLayout(new BoxLayout(certainBox, BoxLayout.LINE_AXIS));
  118. JLabel certainLabel = new JLabel("Restricted to Certain Values?");
  119. yescertain = new JRadioButton("Yes");
  120. yescertain.setActionCommand("certainVal yes");
  121. yescertain.addActionListener(listener);
  122. nocertain = new JRadioButton("No");
  123. nocertain.setActionCommand("certainVal no");
  124. nocertain.addActionListener(listener);
  125. if (newUDP || (theUDP.validEntries == null)
  126. || (theUDP.validEntries.isEmpty()) || (newType.equals("individual")))
  127. nocertain.setSelected(true);
  128. else yescertain.setSelected(true);
  129. newValidEntries = theUDP.validEntries;
  130. ButtonGroup certainBtns = new ButtonGroup();
  131. certainBtns.add(yescertain);
  132. certainBtns.add(nocertain);
  133. certainBox.add(certainLabel);
  134. certainBox.add(yescertain);
  135. certainBox.add(nocertain);
  136. certainText = new JTextField();
  137. certainText.setMinimumSize(new Dimension(400, 30));
  138. certainText.setMaximumSize(new Dimension(400, 30));
  139. certainText.setAlignmentX(0.5f);
  140. certainEditLabel = new JLabel();
  141. certainEditLabel.setAlignmentX(0.5f);
  142. if (newUDP || (theUDP.validEntries == null) || (theUDP.validEntries.isEmpty())) {
  143. certainText.setText("");
  144. certainEditLabel.setText("");
  145. certainText.setEditable(false);
  146. }else {
  147. certainText.setEditable(true);
  148. certainEditLabel.setText("Edit list of values, then hit 'Enter'.");
  149. newValidEntries = theUDP.validEntries;
  150. certainText.setText(theUDP.getValidEntriesString());
  151. certainText.addActionListener(listener);
  152. certainText.setActionCommand("certainText edit");
  153. } // end of it's restricted
  154. editor.add(Box.createRigidArea(new Dimension(0,4)));
  155. editor.add(certainBox);
  156. editor.add(Box.createRigidArea(new Dimension(0,4)));
  157. editor.add(certainEditLabel);
  158. editor.add(certainText);
  159. // DEFAULT VALUE
  160. JPanel defaultBox = new JPanel();
  161. defaultBox.setLayout(new BoxLayout(defaultBox, BoxLayout.LINE_AXIS));
  162. JLabel defaultLabel = new JLabel("Is There A Default Value?");
  163. yesdefault = new JRadioButton("Yes");
  164. yesdefault.setActionCommand("defaultVal yes");
  165. yesdefault.addActionListener(listener);
  166. nodefault = new JRadioButton("No");
  167. nodefault.setActionCommand("defaultVal no");
  168. nodefault.addActionListener(listener);
  169. nodefault.setSelected(true);
  170. ButtonGroup defaultBtns = new ButtonGroup();
  171. defaultBtns.add(yesdefault);
  172. defaultBtns.add(nodefault);
  173. defaultBox.add(defaultLabel);
  174. defaultBox.add(yesdefault);
  175. defaultBox.add(nodefault);
  176. defaultText = new JTextField();
  177. defaultText.setMinimumSize(new Dimension(400, 30));
  178. defaultText.setMaximumSize(new Dimension(400, 30));
  179. defaultText.setAlignmentX(0.5f);
  180. defeditLabel = new JLabel();
  181. defeditLabel.setAlignmentX(0.5f);
  182. if (newUDP || (theUDP.defaultValue == null)) {
  183. defaultText.setText("");
  184. defeditLabel.setText("");
  185. defaultText.setEditable(false);
  186. defaultValExists = false;
  187. }else {
  188. defaultText.setEditable(true);
  189. defeditLabel.setText("Edit the default value, then hit 'Enter'.");
  190. newDefaultValue = theUDP.defaultValue;
  191. yesdefault.setSelected(true);
  192. defaultText.setText(theUDP.defaultValue.toString());
  193. defaultText.addActionListener(listener);
  194. defaultText.setActionCommand("defaultText edit");
  195. defaultValExists = true;
  196. } // end of there is a default value
  197. editor.add(Box.createRigidArea(new Dimension(0,4)));
  198. editor.add(defaultBox);
  199. editor.add(Box.createRigidArea(new Dimension(0,4)));
  200. editor.add(defeditLabel);
  201. editor.add(defaultText);
  202. // MIN AND MAX VALUES
  203. JPanel minMaxBox = new JPanel();
  204. minMaxBox.setLayout(new BoxLayout(minMaxBox, BoxLayout.LINE_AXIS));
  205. JLabel minLabel = new JLabel("Minimum Value: ");
  206. minText = new JTextField();
  207. minText.setMinimumSize(new Dimension(50, 30));
  208. minText.setMaximumSize(new Dimension(50, 30));
  209. if (theUDP.minVal == null) minText.setText("");
  210. else minText.setText(theUDP.minVal.toString());
  211. minText.addActionListener(listener);
  212. minText.setActionCommand("minText edit");
  213. minMaxBox.add(minLabel);
  214. minMaxBox.add(minText);
  215. JPanel maxBox = new JPanel();
  216. maxBox.setLayout(new BoxLayout(maxBox, BoxLayout.PAGE_AXIS));
  217. JLabel maxLabel = new JLabel("Maximum Value: ");
  218. maxText = new JTextField();
  219. maxText.setMinimumSize(new Dimension(50, 30));
  220. maxText.setMaximumSize(new Dimension(50, 30));
  221. if (theUDP.maxVal == null) maxText.setText("");
  222. else maxText.setText(theUDP.maxVal.toString());
  223. maxText.addActionListener(listener);
  224. maxText.setActionCommand("maxText edit");
  225. if (((String)typePick.getSelectedItem()).equals("Integer") || ((String)typePick.getSelectedItem()).equals("Real Number")) {
  226. minText.setEditable(true);
  227. maxText.setEditable(true);
  228. }else {
  229. minText.setEditable(false);
  230. maxText.setEditable(false);
  231. }
  232. minMaxBox.add(Box.createRigidArea(new Dimension(50, 0)));
  233. minMaxBox.add(maxLabel);
  234. minMaxBox.add(maxText);
  235. editor.add(Box.createRigidArea(new Dimension(0,4)));
  236. editor.add(minMaxBox);
  237. // BUTTONS AT THE BOTTOM
  238. JPanel bottomBtns = new JPanel();
  239. bottomBtns.setLayout(new BoxLayout(bottomBtns, BoxLayout.LINE_AXIS));
  240. JButton udpCancel = new JButton("Cancel");
  241. udpCancel.setActionCommand("cancel");
  242. udpCancel.addActionListener(listener);
  243. bottomBtns.add(udpCancel);
  244. if (! newUDP) { // no need to delete a UDP being created -- just cancel
  245. JButton udpDelete = new JButton("Delete UDP");
  246. udpDelete.setActionCommand("delete");
  247. udpDelete.addActionListener(listener);
  248. bottomBtns.add(udpDelete);
  249. }
  250. udpCheckSave = new JButton("Check for Errors");
  251. udpCheckSave.setActionCommand("check");
  252. udpCheckSave.addActionListener(listener);
  253. bottomBtns.add(udpCheckSave);
  254. editor.add(Box.createRigidArea(new Dimension(0,6)));
  255. editor.add(bottomBtns);
  256. progBox = new JPanel();
  257. progBox.setLayout(new BoxLayout(progBox, BoxLayout.PAGE_AXIS));
  258. String progMod = " revised UDP.";
  259. if (newUDP) progMod = " new UDP.";
  260. JLabel progLabel = new JLabel("Updating " + ctxt.indSerNumGen + " persons with the" + progMod);
  261. progressBar = new JProgressBar(0, ctxt.indSerNumGen);
  262. progressBar.setValue(0);
  263. progressBar.setStringPainted(true);
  264. progBox.add(progLabel);
  265. progBox.add(progressBar);
  266. // progBox.setVisible(false);
  267. editor.add(Box.createRigidArea(new Dimension(0,6)));
  268. editor.add(progBox);
  269. JPanel sideFrame = new JPanel();
  270. sideFrame.setLayout(new BoxLayout(sideFrame, BoxLayout.LINE_AXIS));
  271. sideFrame.add(Box.createRigidArea(new Dimension(10,0)));
  272. sideFrame.add(editor);
  273. sideFrame.add(Box.createRigidArea(new Dimension(10,0)));
  274. getContentPane().add(sideFrame);
  275. addInternalFrameListener(this);
  276. setSize(420, 400);
  277. setVisible(true);
  278. } // end of UDPEditor constructor
  279. public class UDPListener implements ActionListener {
  280. KSJInternalFrame ed;
  281. boolean reName = false;
  282. public UDPListener(KSJInternalFrame uded) {
  283. ed = uded;
  284. } // end of constructor
  285. public void actionPerformed(ActionEvent e) {
  286. if (e.getActionCommand().equals("name edit")) {
  287. String newName = name_1.getText(), msg;
  288. if (! Library.validateFileName(newName, true)) {
  289. msg = "The name '" + newName + "' violates the rules for names:\n"
  290. + "The name MUST start with a star ('*') and a letter.\n" +
  291. "Use up to 28 LETTERS, NUMBERS, or DASHES (-) but NO SPACES.";
  292. JOptionPane.showMessageDialog(ed, msg, "Violation of Naming Rules",
  293. JOptionPane.WARNING_MESSAGE);
  294. flipFinalBtn("check");
  295. return;
  296. }
  297. // Once past activity-check, we can safely record the new starName
  298. newStarName = newName;
  299. if ((! newUDP) && (! newStarName.equals(theUDP.starName))) { // name change
  300. int numWithProp = 0, numWithVals = 0;
  301. Iterator indIter = ctxt.individualCensus.iterator();
  302. UserDefinedProperty udp;
  303. while (indIter.hasNext()) {
  304. udp = (UserDefinedProperty)((Individual)indIter.next()).userDefinedProperties.get(theUDP.starName);
  305. if (udp != null) {
  306. numWithProp++;
  307. if (udp.value.size() > 0) numWithVals++;
  308. }
  309. } // end of loop thru persons on this context
  310. int choice = JOptionPane.YES_OPTION;
  311. if (numWithProp > 0) {
  312. msg = "There are " + numWithProp + " persons with this property defined.\n" +
  313. "There are " + numWithVals + " with a value for this property.\n" +
  314. "Do you want to change the name of this UDP for every person?";
  315. choice = JOptionPane.showConfirmDialog(ed, msg, "Confirm", JOptionPane.YES_NO_OPTION);
  316. } // end of confirmed-delete-of-the UDPs-from-individuals
  317. if (choice == JOptionPane.YES_OPTION) reName = true;
  318. // end of User-chose-to-delete-UDP-from-all-persons
  319. } // end of name-change
  320. flipFinalBtn("check");
  321. return;
  322. } // end of "name edit"
  323. if (e.getActionCommand().equals("data type")) {
  324. String priorType = newType; // prior value
  325. String typ = (String)typePick.getSelectedItem();
  326. if (typ.equals("String")) {
  327. newType = "string";
  328. if (priorType.equals(newType)) return; // Nothing changed
  329. minText.setText("");
  330. minText.setEditable(false);
  331. maxText.setText("");
  332. maxText.setEditable(false);
  333. if (yescertain.isSelected()) {
  334. certainEditLabel.setText("Edit list of values, then hit 'Enter'.");
  335. certainText.setEditable(true);
  336. }else {
  337. certainEditLabel.setText("");
  338. certainText.setEditable(false);
  339. }
  340. if (yesdefault.isSelected()) {
  341. defaultText.setEditable(true);
  342. defeditLabel.setText("Edit the default value, then hit 'Enter'.");
  343. }else {
  344. defaultText.setEditable(false);
  345. defeditLabel.setText("");
  346. }
  347. }
  348. else if (typ.equals("Integer")) {
  349. newType = "integer";
  350. if (priorType.equals(newType)) return; // Nothing changed
  351. minText.setEditable(true);
  352. maxText.setEditable(true);
  353. if (yescertain.isSelected()) {
  354. certainEditLabel.setText("Edit list of values, then hit 'Enter'.");
  355. certainText.setEditable(true);
  356. }else {
  357. certainEditLabel.setText("");
  358. certainText.setEditable(false);
  359. }
  360. if (yesdefault.isSelected()) {
  361. defaultText.setEditable(true);
  362. defeditLabel.setText("Edit the default value, then hit 'Enter'.");
  363. }else {
  364. defaultText.setEditable(false);
  365. defeditLabel.setText("");
  366. }
  367. }
  368. else if (typ.equals("Real Number")) {
  369. newType = "float";
  370. if (priorType.equals(newType)) return; // Nothing changed
  371. minText.setEditable(true);
  372. maxText.setEditable(true);
  373. if (yescertain.isSelected()) {
  374. certainEditLabel.setText("Edit list of values, then hit 'Enter'.");
  375. certainText.setEditable(true);
  376. }else {
  377. certainEditLabel.setText("");
  378. certainText.setEditable(false);
  379. }
  380. if (yesdefault.isSelected()) {
  381. defaultText.setEditable(true);
  382. defeditLabel.setText("Edit the default value, then hit 'Enter'.");
  383. }else {
  384. defaultText.setEditable(false);
  385. defeditLabel.setText("");
  386. }
  387. }
  388. else if (typ.equals("Boolean")) {
  389. newType = "boolean";
  390. if (priorType.equals(newType)) return; // Nothing changed
  391. minText.setText("");
  392. minText.setEditable(false);
  393. maxText.setText("");
  394. maxText.setEditable(false);
  395. nomulti.setSelected(true);
  396. newSingleValue = true;
  397. nocertain.setSelected(true);
  398. certainText.setText("");
  399. certainEditLabel.setText("");
  400. certainText.setEditable(false);
  401. newValidEntries = null;
  402. }
  403. else if (typ.equals("Person")) {
  404. newType = "individual";
  405. if (priorType.equals(newType)) return; // Nothing changed
  406. minText.setText("");
  407. minText.setEditable(false);
  408. maxText.setText("");
  409. maxText.setEditable(false);
  410. nocertain.setSelected(true);
  411. certainText.setText("");
  412. certainEditLabel.setText("");
  413. certainText.setEditable(false);
  414. newValidEntries = null;
  415. nodefault.setSelected(true);
  416. defaultText.setEditable(false);
  417. defeditLabel.setText("");
  418. }
  419. if ((newValidEntries != null) && (newValidEntries.size() > 0)) {
  420. // Changed type after specifying valid entries
  421. newValidEntries = null;
  422. certainText.setText("");
  423. certainEditLabel.setText("");
  424. nocertain.setSelected(true);
  425. }
  426. flipFinalBtn("check");
  427. return;
  428. }
  429. if (e.getActionCommand().equals("multiVal yes")) {
  430. if (newType.equals("boolean")) {
  431. newSingleValue = true;
  432. nomulti.setSelected(true);
  433. JOptionPane.showMessageDialog(ed, "Sorry. When Data Type is 'Boolean'\n" +
  434. "you cannot allow Multiple Values.",
  435. "Illegal Combination",
  436. JOptionPane.INFORMATION_MESSAGE);
  437. }
  438. else newSingleValue = false;
  439. return;
  440. }
  441. if (e.getActionCommand().equals("multiVal no")) {
  442. newSingleValue = true;
  443. return;
  444. }
  445. if (e.getActionCommand().equals("certainVal yes")) {
  446. if (newType.equals("individual")) {
  447. JOptionPane.showMessageDialog(ed, "Sorry. When Data Type is 'Person' you\n" +
  448. "cannot Restrict to Certain Values",
  449. "Illegal Combination",
  450. JOptionPane.INFORMATION_MESSAGE);
  451. nocertain.setSelected(true);
  452. return;
  453. } // end of type = indiv
  454. else if (newType.equals("boolean")) {
  455. JOptionPane.showMessageDialog(ed, "Sorry. When Data Type is 'Boolean' you\n" +
  456. "cannot Restrict to Certain Values",
  457. "Illegal Combination",
  458. JOptionPane.INFORMATION_MESSAGE);
  459. nocertain.setSelected(true);
  460. return;
  461. } // end of type = boolean
  462. else if ((newUDP) || (theUDP.validEntries == null)) {
  463. newValidEntries = new ArrayList<Object>();
  464. certainText.setText("");
  465. certainEditLabel.setText("Enter values separated by commas, then hit 'Enter'.");
  466. }else {
  467. newValidEntries = theUDP.validEntries;
  468. certainText.setText(theUDP.getValidEntriesString());
  469. certainEditLabel.setText("Edit list of values, separated by commas, then hit 'Enter'.");
  470. }
  471. certainText.setEditable(true);
  472. certainText.addActionListener(listener);
  473. certainText.setActionCommand("certainText edit");
  474. flipFinalBtn("check");
  475. return;
  476. }
  477. if (e.getActionCommand().equals("certainVal no")) {
  478. newValidEntries = null;
  479. certainText.setText("");
  480. certainEditLabel.setText("");
  481. certainText.setEditable(false);
  482. flipFinalBtn("check");
  483. return;
  484. }
  485. if (e.getActionCommand().equals("certainText edit")) {
  486. validateCertainVals();
  487. return;
  488. }
  489. if (e.getActionCommand().equals("defaultVal yes")) {
  490. if (newType.equals("individual")) {
  491. JOptionPane.showMessageDialog(ed, "Sorry. When Data Type is 'Person' you\n" +
  492. "cannot have a Default Value",
  493. "Illegal Combination",
  494. JOptionPane.INFORMATION_MESSAGE);
  495. nodefault.setSelected(true);
  496. return;
  497. } // end of type = indiv
  498. if (theUDP.defaultValue != null) {
  499. newDefaultValue = theUDP.defaultValue;
  500. defaultText.setText(theUDP.defaultValue.toString());
  501. }
  502. defaultText.setEditable(true);
  503. defaultText.addActionListener(listener);
  504. defaultText.setActionCommand("defaultText edit");
  505. defeditLabel.setText("Edit the default value, then hit 'Enter'.");
  506. defaultValExists = true;
  507. flipFinalBtn("check");
  508. return;
  509. }
  510. if (e.getActionCommand().equals("defaultVal no")) {
  511. newDefaultValue = null;
  512. defaultText.setText("");
  513. defeditLabel.setText("");
  514. defaultText.setEditable(false);
  515. defaultValExists = false;
  516. flipFinalBtn("check");
  517. return;
  518. }
  519. if (e.getActionCommand().equals("defaultText edit")) {
  520. validateDefaultVal();
  521. return;
  522. }
  523. if (e.getActionCommand().equals("minText edit")) {
  524. validateMinText();
  525. return;
  526. }
  527. if (e.getActionCommand().equals("maxText edit")) {
  528. validateMaxText();
  529. return;
  530. }
  531. if (e.getActionCommand().equals("cancel")) {
  532. theUDP = null;
  533. try { ed.setClosed(true); // by not writing & saving, we cancel
  534. }catch(PropertyVetoException pve) {
  535. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  536. MainPane.activity.log.append("In UDPEditor:\n" + pve);
  537. System.out.println("In UDPEditor:\n" + pve); }
  538. return;
  539. }
  540. if (e.getActionCommand().equals("delete")) {
  541. int choice = JOptionPane.showConfirmDialog(ed,
  542. "Are you sure you want to delete this UDP?",
  543. "Confirm", JOptionPane.YES_NO_OPTION);
  544. if (choice == JOptionPane.YES_OPTION) {
  545. ctxt.userDefinedProperties.remove(theUDP.starName);
  546. int numWithProp = 0, numWithVals = 0;
  547. Iterator indIter = ctxt.individualCensus.iterator();
  548. UserDefinedProperty udp;
  549. while (indIter.hasNext()) {
  550. udp = (UserDefinedProperty)((Individual)indIter.next()).userDefinedProperties.get(theUDP.starName);
  551. if (udp != null) {
  552. numWithProp++;
  553. if (udp.value.size() > 0) numWithVals++;
  554. }
  555. } // end of loop thru persons on this context
  556. choice = JOptionPane.YES_OPTION;
  557. if (numWithVals > 0) {
  558. String msg = "There are " + numWithProp + " persons with this property defined.\n" +
  559. "There are " + numWithVals + " with a value for this property.\n" +
  560. "Do you want to delete this UDP from every person?";
  561. choice = JOptionPane.showConfirmDialog(ed, msg, "Confirm", JOptionPane.YES_NO_OPTION);
  562. } // end of confirmed-delete-of-the UDPs-from-individuals
  563. if (choice == JOptionPane.YES_OPTION) {
  564. indIter = ctxt.individualCensus.iterator();
  565. while (indIter.hasNext())
  566. ((Individual)indIter.next()).userDefinedProperties.remove(theUDP.starName);
  567. } // end of User-chose-to-delete-UDP-from-all-persons
  568. } // end of confirmed-delete-request
  569. try { ed.setClosed(true);
  570. ContextEditor newCtxtEd = new ContextEditor(ctxt);
  571. newCtxtEd.setLocation(ctxtEd.getLocation()); // put new one where old was
  572. ctxtEd.setClosed(true);
  573. newCtxtEd.desktop = desktop;
  574. desktop.add(newCtxtEd);
  575. newCtxtEd.show();
  576. newCtxtEd.moveToFront();
  577. newCtxtEd.setSelected(true);
  578. newCtxtEd.miViewMe = menuView.add(newCtxtEd.windowNum);
  579. newCtxtEd.miViewMe.addActionListener(newCtxtEd);
  580. newCtxtEd.menuView = menuView;
  581. }catch(PropertyVetoException pve) {
  582. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  583. MainPane.activity.log.append("In UDPEditor:\n" + pve);
  584. System.out.println("In UDPEditor:\n" + pve); }
  585. return;
  586. }
  587. if (e.getActionCommand().equals("check")) {
  588. // Run consistency checks again, just to be sure.
  589. boolean errorFlag = false;
  590. String newName = name_1.getText(), msg;
  591. if (! Library.validateFileName(newName, true)) {
  592. msg = "The name '" + newName + "' violates the rules for names:\n"
  593. + "The name MUST start with a star ('*') and a letter.\n" +
  594. "Use up to 28 LETTERS, NUMBERS, or DASHES (-) but NO SPACES.";
  595. JOptionPane.showMessageDialog(ed, msg, "Violation of Naming Rules",
  596. JOptionPane.WARNING_MESSAGE);
  597. flipFinalBtn("check");
  598. return;
  599. }
  600. // Once past activity-check, we can safely record the new starName
  601. newStarName = newName;
  602. if ((! newUDP) && (! reName) && (! newStarName.equals(theUDP.starName))) { // name change
  603. int numWithProp = 0, numWithVals = 0;
  604. Iterator indIter = ctxt.individualCensus.iterator();
  605. UserDefinedProperty udp;
  606. while (indIter.hasNext()) {
  607. udp = (UserDefinedProperty)((Individual)indIter.next()).userDefinedProperties.get(theUDP.starName);
  608. if (udp != null) {
  609. numWithProp++;
  610. if (udp.value.size() > 0) numWithVals++;
  611. }
  612. } // end of loop thru persons on this context
  613. int choice = JOptionPane.YES_OPTION;
  614. if (numWithProp > 0) {
  615. msg = "There are " + numWithProp + " persons with this property defined.\n" +
  616. "There are " + numWithVals + " with a value for this property.\n" +
  617. "Do you want to change the name of this UDP for every person?";
  618. choice = JOptionPane.showConfirmDialog(ed, msg, "Confirm", JOptionPane.YES_NO_OPTION);
  619. } // end of confirmed-delete-of-the UDPs-from-individuals
  620. if (choice == JOptionPane.YES_OPTION) reName = true;
  621. // end of User-chose-to-delete-UDP-from-all-persons
  622. } // end of name-change
  623. if (((newType.equals("boolean")) || (newType.equals("individual"))) && (newValidEntries != null)) {
  624. JOptionPane.showMessageDialog(ed, "Sorry. When Data Type is '" + newType + "' you\n" +
  625. "cannot Restrict to Certain Values",
  626. "Illegal Combination",
  627. JOptionPane.INFORMATION_MESSAGE);
  628. nocertain.setSelected(true);
  629. newValidEntries = null;
  630. errorFlag = true;
  631. } // re-checked consistency
  632. if ((newValidEntries != null) && (newValidEntries.size() < 1)) {
  633. JOptionPane.showMessageDialog(ed, "Error -- You chose to Restrict to Certain Values\n" +
  634. "but did not provide a valid list of allowable values.\n" +
  635. "Either provide a list or remove the restriction.",
  636. "Inconsistent Information",
  637. JOptionPane.WARNING_MESSAGE);
  638. errorFlag = true;
  639. } // end of check for Value Restriction with no list of legal values
  640. if ((newType.equals("individual")) && (newDefaultValue != null)) {
  641. JOptionPane.showMessageDialog(ed, "Error -- You may not have a Default Value\n" +
  642. "when the data type is 'Person'.",
  643. "Inconsistent Information",
  644. JOptionPane.WARNING_MESSAGE);
  645. errorFlag = true;
  646. } // end of check for a default individual
  647. if (((newType.equals("individual")) || (newType.equals("boolean")) || (newType.equals("string")))
  648. && ((newMaxVal != null) || (newMinVal != null))) {
  649. JOptionPane.showMessageDialog(ed, "Error -- You may not have a Maximum or Minimum Value\n" +
  650. "when the data type is 'Person' 'Boolean' or 'String'.",
  651. "Inconsistent Information",
  652. JOptionPane.WARNING_MESSAGE);
  653. errorFlag = true;
  654. } // end of check for min/max val of non-numeric data
  655. if (! validateDefaultVal()) errorFlag = true; // re-check consistency: default value & data type
  656. if (! validateMinText()) errorFlag = true;
  657. if (! validateMaxText()) errorFlag = true;
  658. if (! errorFlag) flipFinalBtn("save");
  659. return;
  660. }
  661. if (e.getActionCommand().equals("save")) {
  662. ctxt.saveState = true;
  663. String oldName = theUDP.starName, oldType = theUDP.typ;
  664. theUDP.starName = newStarName;
  665. theUDP.typ = newType;
  666. theUDP.validEntries = newValidEntries;
  667. theUDP.singleValue = newSingleValue;
  668. theUDP.defaultValue = newDefaultValue;
  669. theUDP.minVal = newMinVal;
  670. theUDP.maxVal = newMaxVal;
  671. if (newUDP || reName) {
  672. if (ctxt.userDefinedProperties == null) ctxt.userDefinedProperties = new TreeMap();
  673. ctxt.userDefinedProperties.put(newStarName, theUDP);
  674. }
  675. if ((reName) && (oldName != null)) ctxt.userDefinedProperties.remove(oldName);
  676. progBox.setVisible(true);
  677. progressBar.setStringPainted(true);
  678. UserDefinedProperty oldudp, newInstance;
  679. Individual ind;
  680. Iterator indIter = ctxt.individualCensus.iterator();
  681. if (newUDP) { // no possible clashes: just make one for each person
  682. while (indIter.hasNext()) {
  683. ind = (Individual)indIter.next();
  684. newInstance = new UserDefinedProperty(theUDP, true); // clone the new template
  685. if (ind.userDefinedProperties == null)
  686. ind.userDefinedProperties = new TreeMap();
  687. ind.userDefinedProperties.put(newStarName, newInstance);
  688. progressBar.setValue(ind.serialNmbr);
  689. } // end of loop thru individuals
  690. }else { // revised UDP could be inconsistent with some existing instances of old definition
  691. if (! oldType.equals(newType)) { // type clash, instance 'value' fields must be empty
  692. while (indIter.hasNext()) {
  693. ind = (Individual)indIter.next();
  694. if (reName) ind.userDefinedProperties.remove(oldName);
  695. newInstance = new UserDefinedProperty(theUDP, false); // clone the new template
  696. ind.userDefinedProperties.put(newStarName, newInstance);
  697. progressBar.setValue(ind.serialNmbr);
  698. } // end of loop thru individuals
  699. }else if (newSingleValue && (! theUDP.singleValue)) { // no type clash but arity clash
  700. while (indIter.hasNext()) {
  701. ind = (Individual)indIter.next();
  702. oldudp = (UserDefinedProperty)ind.userDefinedProperties.get(oldName);
  703. if (reName) ind.userDefinedProperties.remove(oldName);
  704. newInstance = new UserDefinedProperty(theUDP, false); // clone the new template
  705. if (validValsChanged) { // check for change in valid entries
  706. for (int i=0; i < oldudp.value.size(); i++)
  707. if (newValidEntries.contains(oldudp.value.get(i))) {
  708. newInstance.value.add(oldudp.value.get(i));
  709. i = 10000000; // only add first conforming value
  710. }
  711. }else if (oldudp.value.size() > 0)
  712. newInstance.value.add(oldudp.value.get(0)); // add first value from old value list
  713. ind.userDefinedProperties.put(newStarName, newInstance);
  714. progressBar.setValue(ind.serialNmbr);
  715. } // end of loop thru individuals
  716. }else { // no type clash, no arity clash
  717. while (indIter.hasNext()) {
  718. ind = (Individual)indIter.next();
  719. oldudp = (UserDefinedProperty)ind.userDefinedProperties.get(oldName);
  720. if (reName) ind.userDefinedProperties.remove(oldName);
  721. newInstance = new UserDefinedProperty(theUDP, false); // clone the new template
  722. if (validValsChanged) { // check for change in valid entries
  723. for (int i=0; i < oldudp.value.size(); i++)
  724. if (newValidEntries.contains(oldudp.value.get(i)))
  725. newInstance.value.add(oldudp.value.get(i));
  726. }else newInstance.value = oldudp.value; // copy the entire old value list
  727. if ((newInstance.value.size() < 1) && (newDefaultValue != null))
  728. // there was no prior value, but now there's a default
  729. newInstance.value.add(newDefaultValue);
  730. ind.userDefinedProperties.put(newStarName, newInstance);
  731. progressBar.setValue(ind.serialNmbr);
  732. } // end of loop thru individuals
  733. }
  734. }
  735. try { ed.setClosed(true);
  736. ContextEditor newCtxtEd = new ContextEditor(ctxt);
  737. newCtxtEd.setLocation(ctxtEd.getLocation()); // put new one where old was
  738. ctxtEd.setClosed(true);
  739. newCtxtEd.desktop = desktop;
  740. desktop.add(newCtxtEd);
  741. newCtxtEd.show();
  742. newCtxtEd.moveToFront();
  743. newCtxtEd.setSelected(true);
  744. newCtxtEd.miViewMe = menuView.add(newCtxtEd.windowNum);
  745. newCtxtEd.miViewMe.addActionListener(newCtxtEd);
  746. newCtxtEd.menuView = menuView;
  747. }catch (Exception ex) {
  748. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  749. MainPane.activity.log.append("While closing UDP editor & re-building a context editor, " + ex + "\n\n"); }
  750. } // end of action = save
  751. if (e.getActionCommand().equals("delete")) {
  752. String msg = "Are you sure you want to DELETE this UDP?";
  753. int choice = JOptionPane.showConfirmDialog(ed, msg, "Confirm", JOptionPane.YES_NO_OPTION);
  754. if (choice == JOptionPane.YES_OPTION) {
  755. ctxt.saveState = true;
  756. ctxt.userDefinedProperties.remove(theUDP.starName);
  757. try { ed.setClosed(true);
  758. ContextEditor newCtxtEd = new ContextEditor(ctxt);
  759. newCtxtEd.setLocation(ctxtEd.getLocation()); // put new one where old was
  760. ctxtEd.setClosed(true);
  761. newCtxtEd.desktop = desktop;
  762. desktop.add(newCtxtEd);
  763. newCtxtEd.show();
  764. newCtxtEd.moveToFront();
  765. newCtxtEd.setSelected(true);
  766. newCtxtEd.miViewMe = menuView.add(newCtxtEd.windowNum);
  767. newCtxtEd.miViewMe.addActionListener(newCtxtEd);
  768. newCtxtEd.menuView = menuView;
  769. }catch (Exception ex) {
  770. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  771. MainPane.activity.log.append("While closing UDP editor & re-building a context editor, " + ex + "\n\n"); }
  772. } // end of confirmed deletion
  773. } // end of action = delete
  774. } // end of ActionListerner method actionPerformed
  775. } // end of inner class UDPListener
  776. public void flipFinalBtn(String saveORnot) {
  777. if (saveORnot.equals("save")) {
  778. udpCheckSave.setActionCommand("save");
  779. udpCheckSave.setText("Save");
  780. } // end of flip to SAVE
  781. else {
  782. udpCheckSave.setActionCommand("check");
  783. udpCheckSave.setText("Check for Errors");
  784. } // end of flip to CHECK
  785. } // end of method flipFinalBtn
  786. public void validateCertainVals() {
  787. // Can't get here if typ = indiv or boolean
  788. validValsChanged = true;
  789. String theVals = certainText.getText();
  790. ArrayList<Object> safetyNet = new ArrayList<Object>(newValidEntries); // in case the edits were bad
  791. newValidEntries.clear();
  792. int start = 0, nextComma = 0, length = theVals.length();
  793. // In effect, we reverse the logic of getValidEntriesString
  794. try {
  795. if (newType.equals("string"))
  796. while (nextComma < length) {
  797. nextComma = theVals.substring(start).indexOf(",");
  798. if (nextComma == -1) nextComma = length;
  799. else nextComma += start;
  800. newValidEntries.add(theVals.substring(start, nextComma).trim());
  801. start = nextComma + 1;
  802. } // end of typ = string
  803. else if (newType.equals("integer")) {
  804. while (nextComma < length) {
  805. nextComma = theVals.substring(start).indexOf(",");
  806. if (nextComma == -1) nextComma = length;
  807. else nextComma += start;
  808. newValidEntries.add(new Integer(theVals.substring(start, nextComma).trim()));
  809. start = nextComma + 1;
  810. }
  811. } // // end of typ = int
  812. else if (newType.equals("float")) {
  813. while (nextComma < length) {
  814. nextComma = theVals.substring(start).indexOf(",");
  815. if (nextComma == -1) nextComma = length;
  816. else nextComma += start;
  817. newValidEntries.add(new Float(theVals.substring(start, nextComma).trim()));
  818. start = nextComma + 1;
  819. }
  820. } // end of typ = float
  821. }catch(NumberFormatException nfe) {
  822. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  823. String eMsg = "The Data Type you chose is '" + newType + ".'\n" +
  824. "Your entries can't be accepted as that type.\nPlease try again.";
  825. MainPane.activity.log.append("While parsing 'int' Valid Entries:\n" + nfe + "\n" + eMsg);
  826. JOptionPane.showMessageDialog(this, eMsg, "Type Violation", JOptionPane.INFORMATION_MESSAGE);
  827. return;
  828. }catch(Exception exc) {
  829. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  830. String eMsg = "Error while parsing " + newType + "s in the UDP Editor.\n" + exc + "\n"
  831. + "Your entries can't be accepted as that type.\nPlease try again.";
  832. MainPane.activity.log.append(eMsg + "\n" + exc);
  833. JOptionPane.showMessageDialog(this, eMsg, "Type Violation", JOptionPane.INFORMATION_MESSAGE);
  834. return;
  835. } // end of catch blocks
  836. flipFinalBtn("check");
  837. return;
  838. } // end of method validateCertainVals()
  839. public boolean validateDefaultVal() {
  840. // Can't get here if typ = indiv
  841. if (! defaultValExists) return true; // Nothing to validate
  842. String defVal = defaultText.getText();
  843. Object safetyNet = newDefaultValue;
  844. if (defVal.length() > 0) {
  845. try {
  846. if (newType.equals("string")) newDefaultValue = defVal;
  847. else if (newType.equals("integer")) newDefaultValue = new Integer(defVal);
  848. else if (newType.equals("float")) newDefaultValue = new Float(defVal);
  849. else if (newType.equals("boolean")) {
  850. if (! ((defVal.equals("true")) || (defVal.equals("false"))))
  851. throw new KinshipSystemException("Did not enter 'true' or 'false'.");
  852. else newDefaultValue = new Boolean(defVal);
  853. } // end of type=boolean
  854. }catch(Exception exc) {
  855. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  856. String eMsg = "Error while parsing " + newType + "s in the UDP Editor.\n" + exc + "\n"
  857. + "Your 'Default Value' can't be accepted as that type.\nPlease try again.";
  858. MainPane.activity.log.append(eMsg + "\n" + exc);
  859. JOptionPane.showMessageDialog(this, eMsg, "Type Violation", JOptionPane.INFORMATION_MESSAGE);
  860. newDefaultValue = safetyNet;
  861. return false;
  862. } // end of catch block
  863. // Check for consistency with Restricted Values
  864. if ((newValidEntries != null) && (newValidEntries.size() > 0) && (! newValidEntries.contains(newDefaultValue))) {
  865. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  866. String eMsg = "Sorry. Your default value of " + defVal + " is not valid.\n"
  867. + "You have Restricted Values for this UDP.\nPlease try again.";
  868. MainPane.activity.log.append(eMsg);
  869. JOptionPane.showMessageDialog(this, eMsg, "Restricted Value Violation", JOptionPane.INFORMATION_MESSAGE);
  870. newDefaultValue = safetyNet;
  871. return false;
  872. } // end of inconsistent-with-Valid-Entries
  873. flipFinalBtn("check");
  874. return true;
  875. }else { // default required but none entered
  876. JOptionPane.showMessageDialog(this, "You have not entered a Default Value.\n" +
  877. "Either enter one or click 'No' default.",
  878. "None Entered", JOptionPane.INFORMATION_MESSAGE);
  879. return false;
  880. } // end of none entered
  881. } // end of method validateDefaultVal()
  882. public boolean validateMinText() {
  883. // The Min field is only valid for data types of integer and float (Real Number)
  884. Number newVal;
  885. if (minText.getText().equals("")) return true;
  886. try {
  887. if (newType.equals("float")) newVal = new Float(minText.getText());
  888. else newVal = new Integer(minText.getText());
  889. }catch(NumberFormatException nfe) {
  890. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  891. String eMsg = "Sorry. Your Minimum Value of '" + minText.getText() + "' is not a valid "
  892. + newType + ".\nPlease try again.";
  893. MainPane.activity.log.append(eMsg);
  894. JOptionPane.showMessageDialog(this, eMsg, "Invalid Minimum Value", JOptionPane.INFORMATION_MESSAGE);
  895. return false;
  896. } // end of catch block
  897. if ((newValidEntries != null) && (newValidEntries.size() > 0) && (newValidEntries.get(0) instanceof Number))
  898. for (int i=0; i < newValidEntries.size(); i++)
  899. if (((Number)newValidEntries.get(i)).floatValue() < newVal.floatValue()) {
  900. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  901. String eMsg = "Sorry. Your Minimum Value of '" + newVal + "' is greater than "
  902. + newValidEntries.get(i) + ", one of your 'Certain Values.'\nPlease try again.";
  903. MainPane.activity.log.append(eMsg);
  904. JOptionPane.showMessageDialog(this, eMsg, "Invalid Minimum Value", JOptionPane.INFORMATION_MESSAGE);
  905. return false;
  906. } // end of activity-found
  907. if ((newDefaultValue != null) && (newDefaultValue instanceof Number)
  908. && (((Number)newDefaultValue).floatValue() < newVal.floatValue())) {
  909. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  910. String eMsg = "Sorry. Your Minimum Value of '" + newVal + "' is greater than "
  911. + newDefaultValue + ", your Default Value.\nPlease try again.";
  912. MainPane.activity.log.append(eMsg);
  913. JOptionPane.showMessageDialog(this, eMsg, "Invalid Minimum Value", JOptionPane.INFORMATION_MESSAGE);
  914. return false;
  915. }
  916. if ((newMaxVal != null) && (newMaxVal.floatValue() < newVal.floatValue())) {
  917. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  918. String eMsg = "Sorry. Your Minimum Value of '" + newVal + "' is greater than "
  919. + newMaxVal + ", your Maximum Value.\nPlease try again.";
  920. MainPane.activity.log.append(eMsg);
  921. JOptionPane.showMessageDialog(this, eMsg, "Invalid Minimum Value", JOptionPane.INFORMATION_MESSAGE);
  922. return false;
  923. }
  924. newMinVal = newVal;
  925. return true;
  926. } // end of method validateMinText
  927. public boolean validateMaxText() {
  928. // The Max field is only valid for data types of integer and float (Real Number)
  929. Number newVal;
  930. if (maxText.getText().equals("")) return true;
  931. try {
  932. if (newType.equals("float")) newVal = new Float(maxText.getText());
  933. else newVal = new Integer(maxText.getText());
  934. }catch(NumberFormatException nfe) {
  935. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  936. String eMsg = "Sorry. Your Maximum Value of '" + maxText.getText() + "' is not a valid "
  937. + newType + ".\nPlease try again.";
  938. MainPane.activity.log.append(eMsg);
  939. JOptionPane.showMessageDialog(this, eMsg, "Invalid Maximum Value", JOptionPane.INFORMATION_MESSAGE);
  940. return false;
  941. } // end of catch block
  942. if ((newValidEntries != null) && (newValidEntries.size() > 0) && (newValidEntries.get(0) instanceof Number))
  943. for (int i=0; i < newValidEntries.size(); i++)
  944. if (((Number)newValidEntries.get(i)).floatValue() > newVal.floatValue()) {
  945. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  946. String eMsg = "Sorry. Your Maximum Value of '" + newVal + "' is less than "
  947. + newValidEntries.get(i) + ", one of your 'Certain Values.'\nPlease try again.";
  948. MainPane.activity.log.append(eMsg);
  949. JOptionPane.showMessageDialog(this, eMsg, "Invalid Maximum Value", JOptionPane.INFORMATION_MESSAGE);
  950. return false;
  951. } // end of activity-found
  952. if ((newDefaultValue != null) && (newDefaultValue instanceof Number)
  953. && (((Number)newDefaultValue).floatValue() > newVal.floatValue())) {
  954. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  955. String eMsg = "Sorry. Your Maximum Value of '" + newVal + "' is less than "
  956. + newDefaultValue + ", your Default Value.\nPlease try again.";
  957. MainPane.activity.log.append(eMsg);
  958. JOptionPane.showMessageDialog(this, eMsg, "Invalid Maximum Value", JOptionPane.INFORMATION_MESSAGE);
  959. return false;
  960. }
  961. if ((newMinVal != null) && (newMinVal.floatValue() > newVal.floatValue())) {
  962. if (MainPane.activity == null) MainPane.createActivityLog(desktop, menuView);
  963. String eMsg = "Sorry. Your Maximum Value of '" + newVal + "' is less than "
  964. + newMinVal + ", your Minimum Value.\nPlease try again.";
  965. MainPane.activity.log.append(eMsg);
  966. JOptionPane.showMessageDialog(this, eMsg, "Invalid Maximum Value", JOptionPane.INFORMATION_MESSAGE);
  967. return false;
  968. }
  969. newMaxVal = newVal;
  970. return true;
  971. } // end of method validateMinText
  972. } // end of class UDPEditor