1 6 7 274 275 276 277 package com.quikj.client.beans; 278 279 import java.awt.*; 280 import net.n3.nanoxml.*; 281 import java.util.*; 282 283 292 293 public class XMLForm extends java.awt.Frame 294 { 295 private XMLFormListenerInterface listener = null; 296 private ParentFrameInterface parent; 297 298 private Object parm = null; 299 300 private static final String [] nodes = 301 { "form", "frame", "panel", "textfield", 302 "textarea", "list", "checkbox", "submitbutton", 303 "resetbutton", "label", "choice", "layout", 304 "element", "value", "radiobuttongroup" }; 305 public static final int NODEINDEX_FORM = 0, 306 NODEINDEX_FRAME = NODEINDEX_FORM + 1, 307 NODEINDEX_PANEL = NODEINDEX_FRAME + 1, 308 NODEINDEX_TEXTFIELD = NODEINDEX_PANEL + 1, 309 NODEINDEX_TEXTAREA = NODEINDEX_TEXTFIELD + 1, 310 NODEINDEX_LIST = NODEINDEX_TEXTAREA + 1, 311 NODEINDEX_CHECKBOX = NODEINDEX_LIST + 1, 312 NODEINDEX_SUBMITBUTTON = NODEINDEX_CHECKBOX + 1, 313 NODEINDEX_RESETBUTTON = NODEINDEX_SUBMITBUTTON + 1, 314 NODEINDEX_LABEL = NODEINDEX_RESETBUTTON + 1, 315 NODEINDEX_CHOICE = NODEINDEX_LABEL + 1, 316 NODEINDEX_LAYOUT = NODEINDEX_CHOICE + 1, 317 NODEINDEX_ELEMENT = NODEINDEX_LAYOUT + 1, 318 NODEINDEX_VALUE = NODEINDEX_ELEMENT + 1, 319 NODEINDEX_RADIOBUTTONGROUP = NODEINDEX_VALUE + 1, 320 NODEINDEXES = nodes.length; 321 322 private Vector valueField, elementField; 323 private int elementSelected, frameLocationX, frameLocationY, frameSizeW, frameSizeH; 324 325 private Stack XMLconstraints; 326 private boolean layoutFound; 327 328 private Hashtable rbgTable; 329 private XMLArrayList awtItems; 330 public String formName; 331 332 private Locale locale = Locale.US; 333 334 335 public XMLForm(IXMLElement node, 336 XMLFormListenerInterface listener, 337 Object parm, 338 Locale locale, 339 ParentFrameInterface parent) 340 throws XMLFormException 341 { 342 super(); 343 344 this.parent = parent; 345 if (parent != null) 346 { 347 parent.addToFrameList(this); 348 } 349 350 if (locale != null) 351 { 352 this.locale = locale; 353 } 354 355 this.listener = listener; 356 this.parm = parm; 357 layoutFound = false; 358 valueField = new Vector(); 359 elementField = new Vector(); 360 elementSelected = 0; 361 rbgTable = new Hashtable(); 362 awtItems = new XMLArrayList(); 363 frameLocationX = 200; 364 frameLocationY = 200; 365 frameSizeW = 300; 366 frameSizeH = 400; 367 beginForm(node); 368 } 369 370 public XMLForm(IXMLElement node, 371 XMLFormListenerInterface listener, 372 Locale locale) 373 throws XMLFormException 374 { 375 this(node, listener, null, locale, null); 376 } 377 378 390 void beginForm(IXMLElement node) 391 throws XMLFormException 392 { 393 394 String elementName; 395 elementName = node.getName(); 396 397 setLayout(new GridBagLayout()); 398 setBackground(Color.white); 399 setTitle("XML Form"); 400 addWindowListener(new java.awt.event.WindowAdapter () 401 { 402 public void windowClosing(java.awt.event.WindowEvent evt) 403 { 404 closeDialog(evt); 405 } 406 }); 407 408 if ( elementName.equals("form") ) 409 handleForm(node, this); 410 else 411 throw new XMLFormException("First element found in XML Form is not <form>"); 412 413 show(); 414 toFront(); 415 416 } 417 418 419 420 438 void handleForm(IXMLElement node, Container parent) 439 throws XMLFormException 440 { 441 XMLconstraints = new Stack(); 442 Vector enumChildren = node.getChildren(); 443 IXMLElement childNode; 444 int childCount, childIndex; 445 XMLAttributes formAttrs = new XMLAttributes(); 446 447 formAttrs.parseAttributes(node, NODEINDEX_FORM); 449 450 if ( formAttrs.nameFound == true ) 451 formName = formAttrs.attrName; 452 else 453 formName = ""; 454 455 if ( formAttrs.typeFound == true ) 457 { 458 if ( formAttrs.attrType.equals("request") ) 459 { 460 childCount = node.getChildrenCount(); 462 childIndex = 0; 463 while ( childCount > 0 ) 464 { 465 childNode = (IXMLElement)enumChildren.elementAt(childIndex); 466 processChild(childNode.getName(), childNode, parent); 467 childIndex++; 468 childCount--; 469 } 470 } 471 else 472 throw new XMLFormException("Form type is not \"request\": " + formAttrs.attrType); 473 } 474 else 475 throw new XMLFormException("Form type not found."); 476 477 return; 478 } 479 480 481 494 void processChild(String childName, IXMLElement childNode, Container parent) 495 throws XMLFormException 496 { 497 int childIndex = -1; 498 499 509 510 if ( childName == null ) 511 valueField.addElement(childNode.getContent()); 512 else 513 { 514 for ( int i=0; i<nodes.length; i++ ) 516 { 517 if ( nodes[i].equals(childName) ) 518 { 519 childIndex = i; 520 break; 521 } 522 } 523 switch ( childIndex ) 524 { 525 case NODEINDEX_FRAME: 526 handleFrame(childNode, parent); 527 break; 528 case NODEINDEX_PANEL: 529 handlePanel(childNode, parent); 530 break; 531 case NODEINDEX_TEXTFIELD: 532 handleTextfield(childNode, parent); 533 break; 534 case NODEINDEX_TEXTAREA: 535 handleTextarea(childNode, parent); 536 break; 537 case NODEINDEX_LIST: 538 handleList(childNode, parent); 539 break; 540 case NODEINDEX_CHECKBOX: 541 handleCheckbox(childNode, parent); 542 break; 543 case NODEINDEX_SUBMITBUTTON: 544 handleSubmitbutton(childNode, parent); 545 break; 546 case NODEINDEX_RESETBUTTON: 547 handleResetbutton(childNode, parent); 548 break; 549 case NODEINDEX_CHOICE: 550 handleChoice(childNode, parent); 551 break; 552 case NODEINDEX_LABEL: 553 handleLabel(childNode, parent); 554 break; 555 case NODEINDEX_LAYOUT: 556 handleLayout(childNode, parent); 557 break; 558 case NODEINDEX_ELEMENT: 559 handleElement(childNode, parent); 560 break; 561 case NODEINDEX_VALUE: 562 handleValue(childNode, parent); 563 break; 564 case NODEINDEX_RADIOBUTTONGROUP: 565 handleRadiobuttongroup(childNode, parent); 566 break; 567 default: 568 throw new XMLFormException("Unknown child found: " + childName); 569 } 570 } 571 } 572 573 574 594 void handleFrame(IXMLElement node, Container parent) 595 throws XMLFormException 596 { 597 Vector enumChildren = node.getChildren(); 598 IXMLElement childNode; 599 int attrIndex, childCount, childIndex; 600 XMLAttributes frameAttrs = new XMLAttributes(); 601 602 frameAttrs.parseAttributes(node, NODEINDEX_FRAME); 604 605 609 setBackground(new Color(frameAttrs.attrBackgroundR, 610 frameAttrs.attrBackgroundG, 611 frameAttrs.attrBackgroundB)); 612 setForeground(new Color(frameAttrs.attrForegroundR, 613 frameAttrs.attrForegroundG, 614 frameAttrs.attrForegroundB)); 615 setEnabled(frameAttrs.attrEnabled); 616 setFont(new Font(frameAttrs.attrFontname, 617 frameAttrs.attrFontstyle, 618 frameAttrs.attrFontsize)); 619 setResizable(frameAttrs.attrResizable); 620 621 if ( frameAttrs.nameFound == true ) 622 setName(frameAttrs.attrName); 623 if ( frameAttrs.titleFound == true ) 624 setTitle(frameAttrs.attrTitle); 625 626 setLocation(frameAttrs.attrPositionX, frameAttrs.attrPositionY); 627 frameLocationX = frameAttrs.attrPositionX; 628 frameLocationY = frameAttrs.attrPositionY; 629 630 setSize(frameAttrs.attrSizeW, frameAttrs.attrSizeH); 631 frameSizeW = frameAttrs.attrSizeW; 632 frameSizeH = frameAttrs.attrSizeH; 633 634 GridBagConstraints dummy = parseChildren(parent, node); 635 636 return; 637 } 638 639 640 641 642 662 void handlePanel(IXMLElement node, Container parent) 663 throws XMLFormException 664 { 665 Panel p = new Panel( new GridBagLayout()); 666 GridBagConstraints pConstraints; 667 XMLAttributes panelAttrs = new XMLAttributes(); 668 669 panelAttrs.parseAttributes(node, NODEINDEX_PANEL); 671 672 p.setBackground(new Color(panelAttrs.attrBackgroundR, 673 panelAttrs.attrBackgroundG, 674 panelAttrs.attrBackgroundB)); 675 p.setForeground(new Color(panelAttrs.attrForegroundR, 676 panelAttrs.attrForegroundG, 677 panelAttrs.attrForegroundB)); 678 p.setEnabled(panelAttrs.attrEnabled); 679 p.setFont(new Font(panelAttrs.attrFontname, 680 panelAttrs.attrFontstyle, 681 panelAttrs.attrFontsize)); 682 p.setVisible(panelAttrs.attrVisible); 683 684 if ( panelAttrs.nameFound == true ) 685 p.setName(panelAttrs.attrName); 686 687 pConstraints = parseChildren(p, node); 688 parent.add(p, pConstraints); 689 690 } 691 692 693 694 714 void handleTextfield(IXMLElement node, Container parent) 715 throws XMLFormException 716 { 717 GridBagConstraints tfConstraints; 718 TextField tf = new TextField(); 719 XMLAttributes tfAttrs = new XMLAttributes(); 720 721 tfAttrs.parseAttributes(node, NODEINDEX_TEXTFIELD); 723 724 tf.setBackground(new Color(tfAttrs.attrBackgroundR, 725 tfAttrs.attrBackgroundG, 726 tfAttrs.attrBackgroundB)); 727 tf.setForeground(new Color(tfAttrs.attrForegroundR, 728 tfAttrs.attrForegroundG, 729 tfAttrs.attrForegroundB)); 730 tf.setEnabled(tfAttrs.attrEnabled); 731 tf.setFont(new Font(tfAttrs.attrFontname, 732 tfAttrs.attrFontstyle, 733 tfAttrs.attrFontsize)); 734 tf.setEditable(tfAttrs.attrEditable); 735 tf.setVisible(tfAttrs.attrVisible); 736 tf.setColumns(tfAttrs.attrColumns); 737 738 if ( tfAttrs.echoFound == true ) 739 tf.setEchoChar(tfAttrs.attrEchochar); 740 if ( tfAttrs.nameFound == true ) 741 tf.setName(tfAttrs.attrName); 742 743 tfConstraints = parseChildren(parent, node); 744 745 if ( valueField.size() > 0 ) 746 { 747 tf.setText((String )valueField.elementAt(0)); 748 valueField.removeAllElements(); 749 } 750 751 parent.add(tf, tfConstraints); 752 registerItem(tf, tfAttrs.attrRequired); 753 } 754 755 756 776 void handleTextarea(IXMLElement node, Container parent) 777 throws XMLFormException 778 { 779 GridBagConstraints taConstraints; 780 XMLAttributes taAttrs = new XMLAttributes(); 781 782 taAttrs.parseAttributes(node, NODEINDEX_TEXTAREA); 784 785 TextArea ta = new TextArea(null, 0, 0, taAttrs.attrScrollbar); 786 ta.setBackground(new Color(taAttrs.attrBackgroundR, 787 taAttrs.attrBackgroundG, 788 taAttrs.attrBackgroundB)); 789 ta.setForeground(new Color(taAttrs.attrForegroundR, 790 taAttrs.attrForegroundG, 791 taAttrs.attrForegroundB)); 792 ta.setEnabled(taAttrs.attrEnabled); 793 ta.setFont(new Font(taAttrs.attrFontname, 794 taAttrs.attrFontstyle, 795 taAttrs.attrFontsize)); 796 ta.setEditable(taAttrs.attrEditable); 797 ta.setVisible(taAttrs.attrVisible); 798 ta.setColumns(taAttrs.attrColumns); 799 800 if ( taAttrs.attrRows != -1 ) 801 ta.setRows(taAttrs.attrRows); 802 else 803 ta.setRows(3); 804 805 if ( taAttrs.nameFound == true ) 806 ta.setName(taAttrs.attrName); 807 808 taConstraints = parseChildren(parent, node); 810 if ( valueField.size() > 0 ) 811 { 812 ta.setText((String )valueField.elementAt(0)); 813 valueField.removeAllElements(); 814 } 815 816 parent.add(ta, taConstraints); 817 registerItem(ta, taAttrs.attrRequired); 818 } 819 820 821 822 844 void handleList(IXMLElement node, Container parent) 845 throws XMLFormException 846 { 847 int rows = 1; 848 GridBagConstraints lConstraints; 849 XMLAttributes lAttrs = new XMLAttributes(); 850 851 853 lAttrs.parseAttributes(node, NODEINDEX_LIST); 854 if ( lAttrs.attrRows != -1 ) 855 rows = lAttrs.attrRows; 856 857 java.awt.List l = new java.awt.List (rows); 858 l.setBackground(new Color(lAttrs.attrBackgroundR, 859 lAttrs.attrBackgroundG, 860 lAttrs.attrBackgroundB)); 861 l.setForeground(new Color(lAttrs.attrForegroundR, 862 lAttrs.attrForegroundG, 863 lAttrs.attrForegroundB)); 864 l.setEnabled(lAttrs.attrEnabled); 865 l.setFont(new Font(lAttrs.attrFontname, 866 lAttrs.attrFontstyle, 867 lAttrs.attrFontsize)); 868 l.setVisible(lAttrs.attrVisible); 869 l.setMultipleMode(lAttrs.attrMultiplemode); 870 if ( lAttrs.nameFound == true ) 871 l.setName(lAttrs.attrName); 872 873 lConstraints = parseChildren(this, node); 875 876 for (int i = 0; i < elementField.size(); i++) 877 l.add((String )elementField.elementAt(i)); 878 879 elementField.removeAllElements(); 880 l.select(elementSelected); 881 elementSelected = 0; 882 parent.add(l, lConstraints); 883 registerItem(l, false); 884 } 885 886 887 888 907 void handleCheckbox(IXMLElement node, Container parent) 908 throws XMLFormException 909 { 910 GridBagConstraints cbConstraints; 911 Checkbox cb = new Checkbox(); 912 XMLAttributes cbAttrs = new XMLAttributes(); 913 914 cbAttrs.parseAttributes(node, NODEINDEX_CHECKBOX); 916 917 cb.setBackground(new Color(cbAttrs.attrBackgroundR, 918 cbAttrs.attrBackgroundG, 919 cbAttrs.attrBackgroundB)); 920 cb.setForeground(new Color(cbAttrs.attrForegroundR, 921 cbAttrs.attrForegroundG, 922 cbAttrs.attrForegroundB)); 923 cb.setEnabled(cbAttrs.attrEnabled); 924 cb.setFont(new Font(cbAttrs.attrFontname, 925 cbAttrs.attrFontstyle, 926 cbAttrs.attrFontsize)); 927 cb.setVisible(cbAttrs.attrVisible); 928 929 930 if ( cbAttrs.nameFound == true ) 931 cb.setName(cbAttrs.attrName); 932 if ( cbAttrs.labelFound == true ) 933 cb.setLabel(cbAttrs.attrLabel); 934 if ( cbAttrs.radioGroupFound == true ) 935 { 936 CheckboxGroup chkboxgrp; 937 chkboxgrp = (CheckboxGroup)rbgTable.get(cbAttrs.attrRadiogroup); 938 cb.setCheckboxGroup(chkboxgrp); 939 if (cbAttrs.attrSelected == true ) 940 chkboxgrp.setSelectedCheckbox(cb); 941 } 942 else 943 cb.setState(cbAttrs.attrSelected); 944 945 cbConstraints = parseChildren(this, node); 947 parent.add(cb, cbConstraints); 948 registerItem(cb, false); 949 } 950 951 952 953 971 void handleSubmitbutton(IXMLElement node, Container parent) 972 throws XMLFormException 973 { 974 GridBagConstraints sbConstraints; 975 Button sb = new Button(); 976 XMLAttributes sbAttrs = new XMLAttributes(); 977 978 sbAttrs.parseAttributes(node, NODEINDEX_SUBMITBUTTON); 980 981 sb.setBackground(new Color(sbAttrs.attrBackgroundR, 982 sbAttrs.attrBackgroundG, 983 sbAttrs.attrBackgroundB)); 984 sb.setForeground(new Color(sbAttrs.attrForegroundR, 985 sbAttrs.attrForegroundG, 986 sbAttrs.attrForegroundB)); 987 sb.setEnabled(sbAttrs.attrEnabled); 988 sb.setFont(new Font(sbAttrs.attrFontname, 989 sbAttrs.attrFontstyle, 990 sbAttrs.attrFontsize)); 991 sb.setVisible(sbAttrs.attrVisible); 992 sb.addActionListener(new java.awt.event.ActionListener () 993 { 994 public void actionPerformed(java.awt.event.ActionEvent evt) 995 { 996 XMLsubmitAction(evt); 997 } 998 }); 999 1000 if ( sbAttrs.nameFound == true ) 1001 sb.setName(sbAttrs.attrName); 1002 if ( sbAttrs.labelFound == true ) 1003 sb.setLabel(sbAttrs.attrLabel); 1004 else 1005 sb.setLabel("Submit"); 1006 1007 sbConstraints = parseChildren(this, node); 1009 parent.add(sb, sbConstraints); 1010 1011 } 1012 1013 1014 1015 1033 void handleResetbutton(IXMLElement node, Container parent) 1034 throws XMLFormException 1035 { 1036 GridBagConstraints rbConstraints; 1037 Button rb = new Button(); 1038 XMLAttributes rbAttrs = new XMLAttributes(); 1039 1040 rbAttrs.parseAttributes(node, NODEINDEX_RESETBUTTON); 1042 1043 rb.setBackground(new Color(rbAttrs.attrBackgroundR, 1044 rbAttrs.attrBackgroundG, 1045 rbAttrs.attrBackgroundB)); 1046 rb.setForeground(new Color(rbAttrs.attrForegroundR, 1047 rbAttrs.attrForegroundG, 1048 rbAttrs.attrForegroundB)); 1049 rb.setEnabled(rbAttrs.attrEnabled); 1050 rb.setFont(new Font(rbAttrs.attrFontname, 1051 rbAttrs.attrFontstyle, 1052 rbAttrs.attrFontsize)); 1053 rb.setVisible(rbAttrs.attrVisible); 1054 rb.addActionListener(new java.awt.event.ActionListener () 1055 { 1056 public void actionPerformed(java.awt.event.ActionEvent evt) 1057 { 1058 listener.resetActionPerformed(evt, awtItems); } 1059 }); 1060 1061 if ( rbAttrs.nameFound == true ) 1062 rb.setName(rbAttrs.attrName); 1063 if ( rbAttrs.labelFound == true ) 1064 rb.setLabel(rbAttrs.attrLabel); 1065 else 1066 rb.setLabel("Reset"); 1067 1068 rbConstraints = parseChildren(this, node); 1070 parent.add(rb, rbConstraints); 1071 1072 } 1073 1074 1075 1076 1097 void handleChoice(IXMLElement node, Container parent) 1098 throws XMLFormException 1099 { 1100 GridBagConstraints cConstraints; 1101 Choice c = new Choice(); 1102 XMLAttributes cAttrs = new XMLAttributes(); 1103 1104 cAttrs.parseAttributes(node, NODEINDEX_CHOICE); 1106 1107 c.setBackground(new Color(cAttrs.attrBackgroundR, 1108 cAttrs.attrBackgroundG, 1109 cAttrs.attrBackgroundB)); 1110 c.setForeground(new Color(cAttrs.attrForegroundR, 1111 cAttrs.attrForegroundG, 1112 cAttrs.attrForegroundB)); 1113 c.setEnabled(cAttrs.attrEnabled); 1114 c.setFont(new Font(cAttrs.attrFontname, 1115 cAttrs.attrFontstyle, 1116 cAttrs.attrFontsize)); 1117 if ( cAttrs.nameFound == true) 1118 c.setName(cAttrs.attrName); 1119 1120 cConstraints = parseChildren(this, node); 1122 1123 for (int i = 0; i < elementField.size(); i++) 1124 c.add((String )elementField.elementAt(i)); 1125 1126 elementField.removeAllElements(); 1127 c.select(elementSelected); 1128 elementSelected = 0; 1129 parent.add(c, cConstraints); 1130 registerItem(c, false); 1131 1132 } 1133 1134 1135 1136 1156 void handleLabel(IXMLElement node, Container parent) 1157 throws XMLFormException 1158 { 1159 Label fl = new Label(); 1160 GridBagConstraints flConstraints; 1161 XMLAttributes flAttrs = new XMLAttributes(); 1162 1163 1165 flAttrs.parseAttributes(node, NODEINDEX_LABEL); 1166 1167 fl.setBackground(new Color(flAttrs.attrBackgroundR, 1168 flAttrs.attrBackgroundG, 1169 flAttrs.attrBackgroundB)); 1170 fl.setForeground(new Color(flAttrs.attrForegroundR, 1171 flAttrs.attrForegroundG, 1172 flAttrs.attrForegroundB)); 1173 fl.setEnabled(flAttrs.attrEnabled); 1174 fl.setFont(new Font(flAttrs.attrFontname, 1175 flAttrs.attrFontstyle, 1176 flAttrs.attrFontsize)); 1177 fl.setVisible(flAttrs.attrVisible); 1178 1179 if ( flAttrs.nameFound == true ) 1180 fl.setName(flAttrs.attrName); 1181 if ( flAttrs.attrAlignment != -1 ) 1182 fl.setAlignment(flAttrs.attrAlignment); 1183 1184 flConstraints = parseChildren(this, node); 1186 if ( valueField.size() > 0 ) 1187 { 1188 fl.setText((String )valueField.elementAt(0)); 1189 valueField.removeAllElements(); 1190 } 1191 parent.add(fl, flConstraints); 1192 } 1193 1194 1195 1196 1216 void handleLayout(IXMLElement node, Container parent) 1217 throws XMLFormException 1218 { 1219 1220 XMLFormLayout layoutConstraints = new XMLFormLayout(); 1221 1222 try 1223 { 1224 layoutConstraints.parseLayout(node); 1225 layoutFound = true; 1226 XMLconstraints.push(layoutConstraints); 1227 } 1228 catch (XMLFormException exc) 1229 { 1230 throw new XMLFormException("Error parsing Layout element."); 1231 } 1232 1233 } 1234 1235 1236 1247 void handleRadiobuttongroup(IXMLElement node, Container parent) 1248 throws XMLFormException 1249 { 1250 XMLAttributes rbgrpAttrs = new XMLAttributes(); 1251 1252 if ( node.getChildrenCount() == 0 ) 1254 { 1255 rbgrpAttrs.parseAttributes(node, NODEINDEX_RADIOBUTTONGROUP); 1256 if ( rbgrpAttrs.nameFound == true) 1257 { 1258 CheckboxGroup rbgrp = new CheckboxGroup(); 1259 rbgTable.put(rbgrpAttrs.attrName, rbgrp); 1260 } 1261 1262 } 1263 else 1264 throw new XMLFormException("Children found in Radiogroup element."); 1265 1266 } 1267 1268 1269 1286 void handleElement(IXMLElement node, Container parent) 1287 throws XMLFormException 1288 { 1289 XMLAttributes eAttrs = new XMLAttributes(); 1290 1291 eAttrs.parseAttributes(node, NODEINDEX_ELEMENT); 1293 if ( node.getChildrenCount() == 0 ) 1294 { 1295 elementField.addElement(node.getContent()); 1296 if (eAttrs.attrSelected == true) 1297 elementSelected = elementField.size() - 1; 1298 } 1299 else 1300 throw new XMLFormException("Children found in <element>"); 1301 1302 } 1303 1304 1305 1323 void handleValue(IXMLElement node, Container parent) 1324 throws XMLFormException 1325 { 1326 if ( node.getAttributeCount() == 0) 1327 if ( node.getChildrenCount() == 0 ) 1328 valueField.addElement(node.getContent()); 1329 else 1330 throw new XMLFormException("Children found in <value>"); 1331 else 1332 throw new XMLFormException("Attributes found in <value>"); 1333 } 1334 1335 1336 1344 GridBagConstraints parseChildren(Container parent, IXMLElement node) 1345 throws XMLFormException 1346 { 1347 int childCount, childIndex; 1348 boolean defaultConstraints = true; 1349 GridBagConstraints itemConstraints; 1350 Vector enumChildren = node.getChildren(); 1351 IXMLElement childNode; 1352 1353 childCount = node.getChildrenCount(); 1354 childIndex = 0; 1355 while ( childCount > 0 ) 1356 { 1357 childNode = (IXMLElement)enumChildren.elementAt(childIndex); 1358 processChild(childNode.getName(), childNode, parent); 1359 childIndex++; 1360 childCount--; 1361 if ( layoutFound ) 1364 { 1365 layoutFound = false; 1366 defaultConstraints = false; 1367 } 1368 } 1369 1370 if ( defaultConstraints == true ) 1371 { 1372 itemConstraints = new GridBagConstraints(); 1373 itemConstraints.gridx = 0; 1374 itemConstraints.gridy = 0; 1375 itemConstraints.fill = GridBagConstraints.HORIZONTAL; 1376 } 1377 else 1378 { 1379 XMLFormLayout layoutConstraints; 1380 layoutConstraints = (XMLFormLayout)XMLconstraints.pop(); 1381 itemConstraints = layoutConstraints.getXMLGridBagConstraints(); 1382 } 1383 1384 return (itemConstraints); 1385 } 1386 1387 1388 1400 void registerItem(Object obj, boolean flag) 1401 { 1402 awtItems.add(obj, flag); 1403 } 1404 1405 public void XMLsubmitAction(java.awt.event.ActionEvent evt) 1406 { 1407 listener.submitActionPerformed(evt, awtItems, formName); 1408 1409 if ( listener.submitSuccessful() == true ) 1410 { 1411 setVisible(false); 1412 1413 if (parent != null) 1414 { 1415 parent.removeFromFrameList(XMLForm.this); 1416 } 1417 1418 dispose(); 1419 } 1420 else 1421 { 1422 new InformationDialog(this, 1423 java.util.ResourceBundle.getBundle("com.quikj.client.beans.language", 1424 locale).getString("Invalid_Data"), 1425 listener.getMsgString(), 1426 java.util.ResourceBundle.getBundle("com.quikj.client.beans.language", 1427 locale).getString("_Close_"), 1428 true); 1429 listener.clearMsgString(); 1430 } 1431 } 1432 1433 private void closeDialog(java.awt.event.WindowEvent evt) 1434 { 1435 setVisible(false); 1436 dispose(); 1437 } 1438} 1439 1440 | Popular Tags |