1 // https://bugs.openjdk.java.net/browse/INTJDK-7624138 2 /* 3 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 package test.fxmltests.app; 27 28 import javafx.fxml.LoadListener; 29 import com.sun.javafx.fxml.ParseTraceElement; 30 import java.io.File; 31 import java.io.IOException; 32 import java.io.InputStream; 33 import java.net.URL; 34 import java.nio.charset.Charset; 35 import java.util.ArrayList; 36 import java.util.HashMap; 37 import java.util.LinkedList; 38 import java.util.List; 39 import java.util.Locale; 40 import java.util.ResourceBundle; 41 import java.util.logging.Level; 42 import java.util.logging.Logger; 43 import javafx.collections.FXCollections; 44 import javafx.collections.ObservableList; 45 import javafx.css.CssMetaData; 46 import javafx.css.Styleable; 47 import javafx.event.ActionEvent; 48 import javafx.event.EventHandler; 49 import javafx.fxml.FXMLLoader; 50 import javafx.fxml.JavaFXBuilderFactory; 51 import javafx.fxml.LoadException; 52 import javafx.scene.Group; 53 54 55 import javafx.scene.Node; 56 import javafx.scene.Scene; 57 import javafx.scene.control.Button; 58 import javafx.scene.control.Label; 59 import javafx.scene.control.Labeled; 60 import javafx.scene.control.ListView; 61 import javafx.scene.control.Menu; 62 import javafx.scene.control.MenuBar; 63 import javafx.scene.control.MenuItem; 64 import javafx.scene.control.RadioButton; 65 import javafx.scene.control.TableColumn; 66 import javafx.scene.control.TableView; 67 import javafx.scene.control.ToggleGroup; 68 import javafx.scene.control.cell.PropertyValueFactory; 69 import javafx.scene.input.KeyCombination; 70 import javafx.scene.layout.*; 71 import javafx.scene.paint.Color; 72 import javafx.scene.shape.Rectangle; 73 import javafx.scene.text.Font; 74 import javafx.scene.text.Text; 75 import javafx.util.Callback; 76 import javafx.util.Pair; 77 78 import test.javaclient.shared.BasicButtonChooserApp; 79 import test.javaclient.shared.PageWithSlots; 80 import test.javaclient.shared.TestNode; 81 import test.javaclient.shared.Utils; 82 83 public class staticPropertyLoadApp extends BasicButtonChooserApp { 84 85 public static final String RESOURCE_BASE = "/test/fxmltests/resources/"; 86 public static final String staticPropertyResourcePath = RESOURCE_BASE + "static-property.fxml"; 87 public static final String hashmapResourcePath = RESOURCE_BASE + "hashmap.fxml"; 88 public static final String customClassLoadResourcePath = RESOURCE_BASE + "include.fxml"; 89 public static final String factoryResourcePath = RESOURCE_BASE + "factory.fxml"; 90 public static final String builderResourcePath = RESOURCE_BASE + "builder.fxml"; 91 public static final String propertyElementsResourcePath = RESOURCE_BASE + "propertyElements.fxml"; 92 public static final String referenceResourcePath = RESOURCE_BASE + "reference.fxml"; 93 public static final String copyResourcePath = RESOURCE_BASE + "fxcopy.fxml"; 94 public static final String propertySetterResourcePath = RESOURCE_BASE + "propertySetter.fxml"; 95 public static final String roListResourcePath = RESOURCE_BASE + "rolist.fxml"; 96 public static final String roMapResourcePath = RESOURCE_BASE + "romap.fxml"; 97 public static final String defaultPropertyResourcePath = RESOURCE_BASE + "defaultProperty.fxml"; 98 public static final String fxdefineResourcePath = RESOURCE_BASE + "fxdefine.fxml"; 99 public static final String fxdefine2ResourcePath = RESOURCE_BASE + "fxdefine2.fxml"; 100 public static final String namespaceBindingResourcePath = RESOURCE_BASE + "namespaceBinding.fxml"; 101 public static final String staticPropertiesResourcePath = RESOURCE_BASE + "static-properties.fxml"; 102 public static final String rootMethodEventHandlerResourcePath = RESOURCE_BASE + "rootMethodEventHandler.fxml"; 103 public static final String scriptEventHandlerResourcePath = RESOURCE_BASE + "scriptEventHandler.fxml"; 104 public static final String scriptResourcePath = RESOURCE_BASE + "script.fxml"; 105 public static final String menuitemResourcePath = RESOURCE_BASE + "menuitem.fxml"; 106 public static final String resourceResourcePath = RESOURCE_BASE + "resourcefxml.fxml"; 107 public static final String splitpanebugResourcePath = RESOURCE_BASE + "vt1.fxml"; 108 public static final String throw1ResourcePath = RESOURCE_BASE + "throw1.fxml"; 109 public static final String throw2ResourcePath = RESOURCE_BASE + "throw2.fxml"; 110 public static final String rt19133ResourcePath = RESOURCE_BASE + "rt19133.fxml"; 111 112 public static enum Pages { 113 staticProperty,HashMap,customClassAndInclude,factory,simple, 114 propertyElements,reference,copy,prSetter,roList,roMap, 115 defaultProperty,fxdefine,namespaceBinding,staticProperties,rootMethodEventHandler, 116 scriptEventHandler,script,menuItem,resources1,resources2,namespace, 117 splitpanebug,charset, loadExceptions, 118 slotDefaultLabeled, slotDefaultListview, slotDefaultMenu, slotDefaultMenuBar, 119 slotDefaultScrollpane, slotDefaultTabpane, slotDefaultTableView, 120 slotDefaultTextinput, slotDefaultTitledpane, slotDefaultTreeview, 121 slotDefaultImageview, slotDefaultPane, slotControllerFactory, 122 specificSignatureMethod, loadfontSlot, scenebuilderSlot, 123 scenebuilderNoRoot, references2, apConstraints, coerce, listviewItems, listenerNullArg, 124 gridapplet, csspath, errorFXML, colorValueOF, escapeCharacter, collectionEventsHandlers, 125 noArgControllerMethod, overloadedControllerMethod, customIDProperty, unknownCustomType, 126 baseControllerProperty, relativeStylesheet, FXMLLoaderAPI, fullyQualifiedNames, importPI, 127 beanInstantiation, valueOf, root, fxId, fxController, noDefaultController, lateRoot, 128 lateController, variableResolution, externalScript 129 130 } 131 132 public staticPropertyLoadApp() { 133 super(800, 600, "LoadFXML", false); 134 } 135 136 Rectangle retRec = new Rectangle(10,10){{setFill(Color.GREEN);}}; 137 Rectangle redRectangle = new Rectangle(10,10){{setFill(Color.RED);}}; 138 139 abstract private class TestNodeWithIOExceptionProcessing extends TestNode { 140 141 abstract protected Node impl_drawNode() throws IOException; 142 protected String impl_getPathToResource() { return null; }; 143 protected URL resource = null; 144 protected File f = null; 145 146 @Override 147 public Node drawNode() { 148 Node result = redRectangle; 149 150 VBox vb = null; 151 152 if (null != impl_getPathToResource()) { 153 resource = getClass().getResource(impl_getPathToResource()); 154 if (null != resource && null != (f = new File(resource.getFile()))) { 155 System.out.println("loading " + f.getPath()); 156 } else { 157 String tmpMsg = "resource file error. [" + impl_getPathToResource() + "]"; 158 System.out.println(tmpMsg); 159 reportGetterFailure(tmpMsg); 160 return result; 161 } 162 } 163 try { 164 result = impl_drawNode(); 165 } catch (IOException ex) { 166 reportGetterFailure("TestNodeWithIOExceptionProcessing: IOException"); 167 Logger.getLogger(staticPropertyLoadApp.class.getName()).log(Level.SEVERE, null, ex); 168 } catch (Exception ex) { 169 reportGetterFailure("TestNodeWithIOExceptionProcessing: Exception"); 170 Logger.getLogger(staticPropertyLoadApp.class.getName()).log(Level.SEVERE, null, ex); 171 } 172 return result; 173 } 174 } 175 176 private class slotStaticProperty extends TestNodeWithIOExceptionProcessing { 177 @Override 178 protected String impl_getPathToResource() { 179 return staticPropertyResourcePath; 180 } 181 @Override 182 public Node impl_drawNode() throws IOException { 183 Node uplevelNode = null; 184 try { 185 uplevelNode = FXMLLoader.load(resource); 186 } catch (Exception e) { 187 System.out.println("message: " + e.getMessage()); 188 reportGetterFailure("message: " + e.getMessage()); 189 } 190 return uplevelNode; 191 } 192 } 193 194 private class hashmaptest extends TestNodeWithIOExceptionProcessing { 195 196 HashMap hm = null; 197 String value1; 198 String value2; 199 200 @Override 201 protected String impl_getPathToResource() { 202 return hashmapResourcePath; 203 } 204 205 @Override 206 public Node impl_drawNode() throws IOException { 207 208 try { 209 hm = FXMLLoader.load(resource); 210 value1 = (String) hm.get("foo"); 211 value2 = (String) hm.get("bar"); 212 } catch (Exception e) { 213 System.out.println("message: " + e.getMessage()); 214 reportGetterFailure("exception thrown."); 215 } 216 if (value1.equals("123") && value2.equals("456")) { 217 return retRec; 218 } else { 219 reportGetterFailure("failed."); 220 return redRectangle; 221 } 222 } 223 } 224 225 CustomClass cc; 226 private class customClassLoadSlot extends TestNodeWithIOExceptionProcessing { 227 228 @Override 229 protected String impl_getPathToResource() { 230 return customClassLoadResourcePath; 231 } 232 233 @Override 234 public Node impl_drawNode() throws IOException { 235 FXMLLoader fxmlLoader = new FXMLLoader(); 236 237 InputStream is = null; 238 try { 239 fxmlLoader.setLocation(resource); 240 is = resource.openStream(); 241 cc = (CustomClass) fxmlLoader.load(is); 242 } catch (Exception e) { 243 System.out.println("message: " + e.getMessage()); 244 e.printStackTrace(); 245 reportGetterFailure("exception thrown."); 246 } finally { 247 is.close(); 248 } 249 250 // System.out.println(" includes: " + fxmlLoader.getIncludes()); 251 System.out.println("cc.getFld(): " + cc.getFld()); 252 253 if (cc.getFld().equals("fine!")) { 254 return retRec; 255 } else { 256 reportGetterFailure("failed."); 257 return redRectangle; 258 } 259 } 260 } 261 262 private class factorySlot extends TestNodeWithIOExceptionProcessing { 263 264 ObservableList<String> ss = FXCollections.observableArrayList(); 265 266 @Override 267 protected String impl_getPathToResource() { 268 return factoryResourcePath; 269 } 270 271 @Override 272 public Node impl_drawNode() throws IOException { 273 try { 274 ss = FXMLLoader.load(resource); 275 } catch (Exception e) { 276 System.out.println("message: " + e.getMessage()); 277 reportGetterFailure("exception thrown."); 278 } 279 if (ss.get(0).equals("A") && ss.get(1).equals("B") && ss.get(2).equals("C")) { 280 return retRec; 281 } else { 282 reportGetterFailure("failed."); 283 return redRectangle; 284 } 285 } 286 } 287 288 private class simpleSlot extends TestNodeWithIOExceptionProcessing { 289 290 Color color = Color.ALICEBLUE; 291 292 @Override 293 protected String impl_getPathToResource() { 294 return builderResourcePath; 295 } 296 297 @Override 298 public Node impl_drawNode() throws IOException { 299 InputStream is = null; 300 try { 301 FXMLLoader fxmlLoader2 = new FXMLLoader(); 302 is = resource.openStream(); 303 ClassLoader defaultClassLoader = fxmlLoader2.getClassLoader(); 304 305 fxmlLoader2.setBuilderFactory(new JavaFXBuilderFactory(defaultClassLoader)); 306 color = (Color) fxmlLoader2.load(is); // see RT-18091 307 } catch (Exception e) { 308 e.printStackTrace(); 309 System.out.println("message: " + e.getMessage()); 310 reportGetterFailure("exception thrown."); 311 } finally { 312 is.close(); 313 } 314 System.out.println("color: " + color); 315 if (color.equals(Color.color(1., 0., 0.))) { 316 return retRec; 317 } else { 318 reportGetterFailure("failed."); 319 return redRectangle; 320 } 321 } 322 } 323 324 private class propertyElementsSlot extends TestNodeWithIOExceptionProcessing { 325 326 Label label; 327 328 @Override 329 protected String impl_getPathToResource() { 330 return propertyElementsResourcePath; 331 } 332 333 @Override 334 public Node impl_drawNode() { 335 try { 336 label = FXMLLoader.load(resource); 337 } catch (Exception e) { 338 System.out.println("message: " + e.getMessage()); 339 reportGetterFailure("exception thrown."); 340 } 341 if (label.getText().equals("label")) { 342 return label; 343 } else { 344 reportGetterFailure("failed."); 345 return redRectangle; 346 } 347 } 348 } 349 350 private class referenceSlot extends TestNodeWithIOExceptionProcessing { 351 352 List<Label> lst = new ArrayList(); 353 354 @Override 355 protected String impl_getPathToResource() { 356 return referenceResourcePath; 357 } 358 359 @Override 360 public Node impl_drawNode() { 361 try { 362 lst = FXMLLoader.load(resource); // was: f.toURI().toURL(). does not work with jnlp http://javafx-jira.kenai.com/browse/RT-17736 363 } catch (Exception e) { 364 System.out.println("message: " + e.getMessage()); 365 reportGetterFailure("exception thrown."); 366 } 367 if (lst.get(0).getText().equals(lst.get(1).getText())) { 368 return retRec; 369 } else { 370 reportGetterFailure("failed."); 371 return redRectangle; 372 } 373 } 374 } 375 376 private class copySlot extends TestNodeWithIOExceptionProcessing { 377 378 List<Label> lst = new ArrayList(); 379 380 @Override 381 protected String impl_getPathToResource() { 382 return copyResourcePath; 383 } 384 385 @Override 386 public Node impl_drawNode() { 387 try { 388 lst = (List<Label>) FXMLLoader.load(resource); //inputStream 389 } catch (Exception e) { 390 System.out.println("message2: " + e.getMessage()); 391 e.printStackTrace(); 392 reportGetterFailure("exception thrown."); 393 } 394 if (3 == lst.size()) { 395 return retRec; 396 } else { 397 reportGetterFailure("failed."); 398 return redRectangle; 399 } 400 } 401 } 402 403 private class propertySetterSlot extends TestNodeWithIOExceptionProcessing { 404 405 Label label; 406 407 @Override 408 protected String impl_getPathToResource() { 409 return propertySetterResourcePath; 410 } 411 412 @Override 413 public Node impl_drawNode() { 414 try { 415 label = FXMLLoader.load(resource); 416 417 } catch (Exception e) { 418 System.out.println("message: " + e.getMessage()); 419 reportGetterFailure("exception thrown."); 420 } 421 if (label.getText().equals("txt")) { 422 return retRec; 423 } else { 424 reportGetterFailure("failed."); 425 return redRectangle; 426 } 427 } 428 } 429 430 private class roListSlot extends TestNodeWithIOExceptionProcessing { 431 432 Group gr; 433 434 @Override 435 protected String impl_getPathToResource() { 436 return roListResourcePath; 437 } 438 439 @Override 440 public Node impl_drawNode() { 441 try { 442 gr = FXMLLoader.load(resource); 443 } catch (Exception e) { 444 System.out.println("message: " + e.getMessage()); 445 e.printStackTrace(); 446 reportGetterFailure("exception thrown."); 447 } 448 Node n =((Rectangle) gr.getChildren().get(0)); 449 String strId = n.getId(); 450 if (strId.equals("rectangle1")) { 451 return retRec; 452 } else { 453 reportGetterFailure("failed."); 454 return redRectangle; 455 } 456 } 457 } 458 459 private class roMapSlot extends TestNodeWithIOExceptionProcessing { 460 461 JavaFXBuilderFactory builderFactory = new JavaFXBuilderFactory(); 462 FXMLLoader fxmlLoader = new FXMLLoader(); 463 Button btn; 464 465 @Override 466 protected String impl_getPathToResource() { 467 return roMapResourcePath; 468 } 469 470 @Override 471 public Node impl_drawNode() { 472 InputStream is = getClass().getResourceAsStream(impl_getPathToResource()); 473 474 try { 475 fxmlLoader.setBuilderFactory(builderFactory); 476 btn = (Button) fxmlLoader.load(is); 477 } catch (Exception e) { 478 System.out.println("message: " + e.getMessage()); 479 reportGetterFailure("exception thrown."); 480 } 481 if (builderFactory != fxmlLoader.getBuilderFactory()) { 482 reportGetterFailure("fxmlLoader.getBuilderFactory() failed."); 483 } 484 485 if (btn.getProperties().get("foo").equals("123")) { 486 return retRec; 487 } else { 488 reportGetterFailure("failed."); 489 return redRectangle; 490 } 491 } 492 } 493 494 private class defaultPropertySlot extends TestNodeWithIOExceptionProcessing { 495 496 Group gr; 497 498 @Override 499 protected String impl_getPathToResource() { 500 return defaultPropertyResourcePath; 501 } 502 503 @Override 504 public Node impl_drawNode() { 505 try { 506 gr = FXMLLoader.load(resource); 507 } catch (Exception e) { 508 System.out.println("message: " + e.getMessage()); 509 reportGetterFailure("exception thrown."); 510 } 511 if (((Rectangle) gr.getChildren().get(1)).getId().equals("rectangle2")) { 512 return retRec; 513 } else { 514 reportGetterFailure("failed."); 515 return redRectangle; 516 } 517 } 518 } 519 520 private class fxdefineSlot extends TestNodeWithIOExceptionProcessing { 521 522 VBox vb; 523 524 @Override 525 protected String impl_getPathToResource() { 526 return fxdefineResourcePath; 527 } 528 529 @Override 530 public Node impl_drawNode() { 531 try { 532 vb = FXMLLoader.load(resource); 533 } catch (Exception e) { 534 System.out.println("message: " + e.getMessage()); 535 reportGetterFailure("exception thrown."); 536 } 537 if (((RadioButton) vb.getChildren().get(0)).getText().equals("A")) { 538 return retRec; 539 } else { 540 reportGetterFailure("failed."); 541 return redRectangle; 542 } 543 } 544 } 545 546 private class namespaceBindingSlot extends TestNodeWithIOExceptionProcessing { 547 548 public VBox vb; 549 FXMLLoader fxmlLoader2 = new FXMLLoader(); 550 551 @Override 552 protected String impl_getPathToResource() { 553 return namespaceBindingResourcePath; 554 } 555 556 @Override 557 public Node impl_drawNode() throws IOException { 558 InputStream is = null; 559 try { 560 is = resource.openStream(); 561 vb = (VBox) fxmlLoader2.load(is); 562 } catch (Exception e) { 563 System.out.println("message: " + e.getMessage()); 564 reportGetterFailure("exception thrown."); 565 } finally { 566 is.close(); 567 } 568 if (null == vb) { 569 System.out.println("Custom class instance is null"); 570 reportGetterFailure("failed 1."); 571 } 572 573 Button b = (Button) vb.getChildren().get(0); 574 575 if (null == vb.getChildren().get(0)) { 576 System.out.println("button field is null"); 577 reportGetterFailure("failed 2."); 578 } 579 if (!(null != vb && null != b && null != b.getOnAction())) { 580 reportGetterFailure("failed."); 581 } 582 583 MyRootElement mr = (MyRootElement) fxmlLoader2.getController(); 584 System.out.println("mr: " + mr.toString()); 585 System.out.println("getController(): " + fxmlLoader2.getController()); 586 587 if ((null != mr) 588 && (mr.toString().contains("MyRootElement"))) { 589 return retRec; 590 } else { 591 reportGetterFailure("failed."); 592 return redRectangle; 593 } 594 } 595 } 596 597 private class staticPropertiesSlot extends TestNodeWithIOExceptionProcessing { 598 599 @Override 600 protected String impl_getPathToResource() { 601 return staticPropertiesResourcePath; 602 } 603 604 @Override 605 public Node impl_drawNode() { 606 607 try { 608 FXMLLoader.load(resource); 609 } catch (Exception e) { 610 System.out.println("message: " + e.getMessage()); 611 reportGetterFailure("exception thrown."); 612 return redRectangle; 613 } 614 615 return retRec; 616 } 617 } 618 619 private class rootMethodEventHandlerSlot extends TestNodeWithIOExceptionProcessing { 620 621 MyRootElement2 mr; 622 623 @Override 624 protected String impl_getPathToResource() { 625 return rootMethodEventHandlerResourcePath; 626 } 627 628 @Override 629 public Node impl_drawNode() { 630 try { 631 mr = FXMLLoader.load(resource); 632 } catch (Exception e) { 633 System.out.println("message: " + e.getMessage()); 634 e.printStackTrace(); 635 reportGetterFailure("exception thrown."); 636 } 637 638 Button bbb = (Button) mr.getChildren().get(0); 639 EventHandler<ActionEvent> hndlr = bbb.getOnAction(); 640 if (null != hndlr) { 641 return retRec; 642 } else { 643 reportGetterFailure("failed."); 644 return redRectangle; 645 } 646 } 647 } 648 649 private class scriptEventHandlerSlot extends TestNodeWithIOExceptionProcessing { 650 651 MyRootElement2 mr; 652 653 @Override 654 protected String impl_getPathToResource() { 655 return scriptEventHandlerResourcePath; 656 } 657 658 @Override 659 public Node impl_drawNode() { 660 661 try { 662 mr = FXMLLoader.load(resource); 663 } catch (Exception e) { 664 System.out.println("message: " + e.getMessage()); 665 reportGetterFailure("exception thrown."); 666 } 667 Button bbb = (Button) mr.getChildren().get(0); 668 EventHandler<ActionEvent> hndlr = bbb.getOnAction(); 669 if (null != hndlr) { 670 return mr;//retRec; 671 } else { 672 reportGetterFailure("failed."); 673 return redRectangle; 674 } 675 } 676 } 677 678 private class scriptSlot extends TestNodeWithIOExceptionProcessing { 679 680 VBox vb; 681 682 @Override 683 protected String impl_getPathToResource() { 684 return scriptResourcePath; 685 } 686 687 @Override 688 public Node impl_drawNode() { 689 690 try { 691 vb = FXMLLoader.load(resource); 692 } catch (Exception e) { 693 System.out.println("message: " + e.getMessage()); 694 reportGetterFailure("exception thrown."); 695 } 696 Button bbb = (Button) vb.getChildren().get(0); 697 EventHandler<ActionEvent> hndlr = bbb.getOnAction(); 698 if (null != hndlr) { 699 return vb;//retRec; 700 } else { 701 reportGetterFailure("failed."); 702 return redRectangle; 703 } 704 } 705 } 706 707 private class menuitemSlot extends TestNodeWithIOExceptionProcessing { 708 //http://javafx-jira.kenai.com/browse/RT-17715 709 710 MenuItem mi2; 711 712 @Override 713 protected String impl_getPathToResource() { 714 return menuitemResourcePath; 715 } 716 717 @Override 718 public Node impl_drawNode() { 719 /* 720 MenuItem mi = new MenuItem(); 721 mi.setText("open..."); 722 mi.setGraphic(new ImageView()); 723 mi.setAccelerator(KeyCombination.keyCombination("CTRL+N")); 724 */ 725 726 try { 727 mi2 = FXMLLoader.load(resource); 728 } catch (Exception e) { 729 System.out.println("message: " + e.getMessage()); 730 e.printStackTrace(); 731 reportGetterFailure("exception thrown."); 732 } 733 System.out.println("DEBUG: menuItem.getText()=" + ((null != mi2) ? mi2.getText() : "(null)")); 734 if ((null != mi2) 735 && (0 == "open...".compareTo(mi2.getText())) 736 && (KeyCombination.keyCombination("CTRL+N").equals(mi2.getAccelerator()))) { 737 return retRec; 738 } else { 739 reportGetterFailure("failed."); 740 return redRectangle; 741 } 742 } 743 } 744 745 746 /* 747 * localization using setResources() 748 */ 749 private class resource1Slot extends TestNodeWithIOExceptionProcessing { 750 751 MenuItem mi2; 752 753 @Override 754 public Node impl_drawNode() { 755 try { 756 URL resourceURL = getClass().getResource(resourceResourcePath); 757 Locale currentLocale = new Locale("en", "US"); 758 ResourceBundle resourceBundle = ResourceBundle.getBundle("test.fxmltests.resources.resource1", currentLocale); 759 FXMLLoader fxmlLoader2 = new FXMLLoader(); 760 761 fxmlLoader2.setResources(resourceBundle); 762 System.out.println("resources: " + fxmlLoader2.getResources()); 763 fxmlLoader2.setBuilderFactory(new JavaFXBuilderFactory()); 764 765 System.out.println("xxx loading " + resourceURL); 766 InputStream is = null; 767 try { 768 769 is = resourceURL.openStream(); 770 mi2 = (MenuItem) fxmlLoader2.load(is); 771 772 } catch (Exception e) { 773 System.out.println("message: " + e.getMessage()); 774 e.printStackTrace(); 775 reportGetterFailure("exception thrown."); 776 } finally { 777 is.close(); 778 } 779 780 System.out.println("resources: " + fxmlLoader2.getResources()); 781 System.out.println("charset: " + fxmlLoader2.getCharset()); 782 System.out.println("location: " + fxmlLoader2.getLocation()); 783 System.out.println("bf: " + fxmlLoader2.getBuilderFactory()); 784 System.out.println("namespace: " + fxmlLoader2.getNamespace()); 785 // System.out.println("includes: " + fxmlLoader2.getIncludes()); 786 787 788 System.out.println("DEBUG: menuItem.getText()=" + ((null != mi2) ? mi2.getText() : "(null)")); 789 if ((null != mi2) 790 && (0 == "close".compareTo(mi2.getText()))) { 791 boolean pass = true; 792 } else { 793 reportGetterFailure("failed."); 794 } 795 } catch (IOException ex) { 796 Logger.getLogger(staticPropertyLoadApp.class.getName()).log(Level.SEVERE, null, ex); 797 } 798 return retRec; 799 } 800 } 801 802 803 /* 804 * localization wirh resources mentioned in load() 805 */ 806 private class resource2Slot extends TestNodeWithIOExceptionProcessing { 807 808 MenuItem mi2; 809 810 @Override 811 public Node impl_drawNode() { 812 URL resourceURL = getClass().getResource(resourceResourcePath); 813 Locale currentLocale = new Locale("en", "US"); 814 ResourceBundle resourceBundle = ResourceBundle.getBundle("test.fxmltests.resources.resource1", currentLocale); 815 816 System.out.println("xxx loading " + resourceURL); 817 try { 818 819 mi2 = (MenuItem) FXMLLoader.load(resourceURL, resourceBundle); 820 821 } catch (Exception e) { 822 System.out.println("message: " + e.getMessage()); 823 e.printStackTrace(); 824 reportGetterFailure("exception thrown."); 825 } 826 827 System.out.println("DEBUG: menuItem.getText()=" + ((null != mi2) ? mi2.getText() : "(null)")); 828 if ((null != mi2) 829 && (0 == "close".compareTo(mi2.getText()))) { 830 boolean pass = true; 831 } else { 832 reportGetterFailure("failed."); 833 } 834 return retRec; 835 } 836 } 837 838 /* 839 * getNamespace test 840 */ 841 private class namespaceSlot extends TestNodeWithIOExceptionProcessing { 842 843 @Override 844 public Node impl_drawNode() throws IOException { 845 URL resourceURL = getClass().getResource(fxdefine2ResourcePath); 846 JavaFXBuilderFactory builderFactory = new JavaFXBuilderFactory(); 847 FXMLLoader fxmlLoader = new FXMLLoader(); 848 fxmlLoader.setBuilderFactory(builderFactory); 849 850 InputStream is = null; 851 System.out.println("xxx loading " + resourceURL); 852 try { 853 is = resourceURL.openStream(); 854 fxmlLoader.load(is); 855 } catch (Exception e) { 856 System.out.println("message: " + e.getMessage()); 857 e.printStackTrace(); 858 reportGetterFailure("exception thrown."); 859 } finally { 860 is.close(); 861 } 862 863 System.out.println("namespace: " + fxmlLoader.getNamespace()); 864 System.out.println("empty: " + fxmlLoader.getNamespace().isEmpty()); 865 System.out.println("nonexisting key vb5: " + fxmlLoader.getNamespace().get("vb5")); 866 867 Node n = (Node)fxmlLoader.getNamespace().get("vb1"); 868 String xxx = (null != n)?(n.getId()):""; 869 System.out.println("existing key vb1: " + fxmlLoader.getNamespace().get("vb1") + " / id=" + xxx); 870 System.out.println("getRoot: " + fxmlLoader.getRoot()); 871 872 if ((null != (fxmlLoader.getNamespace().get("vb1"))) 873 && (null == (fxmlLoader.getNamespace().get("vb5"))) 874 && (fxmlLoader.getRoot().toString().equals("VBox[id=vb1]"))) { 875 boolean pass = true; 876 } else { 877 reportGetterFailure("failed."); 878 } 879 return retRec; 880 } 881 } 882 883 884 private class splitpanebugSlot extends TestNodeWithIOExceptionProcessing { 885 // http://javafx-jira.kenai.com/browse/RT-16977 886 @Override 887 public Node impl_drawNode() throws IOException { 888 URL resourceURL = getClass().getResource(splitpanebugResourcePath); 889 JavaFXBuilderFactory builderFactory = new JavaFXBuilderFactory(); 890 FXMLLoader fxmlLoader = new FXMLLoader(); 891 fxmlLoader.setBuilderFactory(builderFactory); 892 893 InputStream is = null; 894 System.out.println("loading " + resourceURL); 895 try { 896 // fxmlLoader.setLocation(new URL(RESOURCE_BASE)); 897 // ResourceBundle rb = new ResourceBundle(); 898 // fxmlLoader.setResources(rb); 899 is = resourceURL.openStream(); 900 fxmlLoader.load(is); 901 } catch (Exception e) { 902 System.out.println("message: " + e.getMessage()); 903 e.printStackTrace(); 904 reportGetterFailure("exception thrown."); 905 } catch (Throwable e) { 906 System.out.println("message: " + e.getMessage()); 907 e.printStackTrace(); 908 reportGetterFailure("exception thrown."); 909 } finally { 910 is.close(); 911 } 912 System.out.println("loaded. "); 913 return retRec; 914 } 915 } 916 917 private class charsetSlot extends TestNodeWithIOExceptionProcessing { 918 919 @Override 920 protected String impl_getPathToResource() { 921 return "/test/fxmltests/resources/include3.fxml"; // customClassLoadResourcePath 922 } 923 924 @Override 925 public Node impl_drawNode() throws IOException { 926 Charset encoding = Charset.forName("UTF-16"); 927 FXMLLoader fxmlLoader = new FXMLLoader(encoding); 928 fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); 929 930 //Locale currentLocale = new Locale("en", "US"); 931 //ResourceBundle resourceBundle = ResourceBundle.getBundle("test.fxmltests.resources.resource1", currentLocale); 932 //fxmlLoader.setResources(resourceBundle); 933 934 InputStream is = null; 935 try { 936 // fxmlLoader.setLocation(resource); 937 System.out.println(" charset: " + fxmlLoader.getCharset()); 938 is = resource.openStream(); 939 fxmlLoader.load(is); 940 941 } catch (Exception e) { 942 System.out.println("message: " + e.getMessage()); 943 e.printStackTrace(); 944 reportGetterFailure("exception thrown."); 945 } finally { 946 is.close(); 947 } 948 949 System.out.println(" location: " + fxmlLoader.getLocation()); 950 System.out.println(" charset: " + fxmlLoader.getCharset()); 951 952 if (fxmlLoader.getCharset().toString().equals("UTF-16")) { 953 return retRec; 954 } else { 955 reportGetterFailure("failed."); 956 return redRectangle; 957 } 958 959 } 960 } 961 962 /* 963 * LoadExceptions test 964 */ 965 private class loadExceptionsSlot extends TestNodeWithIOExceptionProcessing { 966 967 @Override 968 public Node impl_drawNode() throws IOException{ 969 970 URL resourceURL1 = getClass().getResource(throw1ResourcePath); 971 URL resourceURL2 = getClass().getResource(throw2ResourcePath); 972 FXMLLoader fxmlLoader = new FXMLLoader(); 973 fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); 974 boolean exception1Thrown = false; 975 boolean exception2Thrown = false; 976 977 InputStream is = null; 978 System.out.println("loading RES 1 / " + resourceURL1); 979 try { 980 is = resourceURL1.openStream(); 981 fxmlLoader.load(is); 982 } catch (LoadException e) { 983 System.out.println("THROWN msg: " + e.getMessage()); 984 System.out.println("THROWN cause: " + e.getCause()); 985 exception1Thrown = true; 986 987 ParseTraceElement ptes[] = fxmlLoader.impl_getParseTrace(); 988 for (ParseTraceElement pte: ptes) { 989 // see rt-19329 990 System.out.println("trace element: " + pte); 991 } 992 } catch (Exception e) { 993 System.out.println("message: " + e.getMessage()); 994 e.printStackTrace(); 995 reportGetterFailure("exception thrown."); 996 } finally { 997 is.close(); 998 } 999 1000 is = null; 1001 System.out.println("loading RES 2 / " + resourceURL2); 1002 try { 1003 is = resourceURL2.openStream(); 1004 fxmlLoader.load(is); 1005 } catch (LoadException e) { 1006 exception2Thrown = true; 1007 System.out.println("2 THROWN msg: " + e.getMessage()); 1008 System.out.println("2 THROWN cause: " + e.getCause()); 1009 } catch (Exception e) { 1010 System.out.println("message: " + e.getMessage()); 1011 e.printStackTrace(); 1012 reportGetterFailure("exception thrown."); 1013 } finally { 1014 is.close(); 1015 } 1016 1017 1018 if ((true == exception1Thrown) && (true == exception2Thrown)) { 1019 boolean pass = true; 1020 } else { 1021 reportGetterFailure("failed."); 1022 } 1023 return retRec; 1024 } 1025 } 1026 1027 1028 1029 /* 1030 * 1031 Class javafx/fxml/FXMLLoader 1032 * 1033 + getBuilderFactory()Ljavafx/util/BuilderFactory; - - - - - - - - - - - - 1034 + getCharset()Ljava/nio/charset/Charset; - - - - - - - - - - - - 1035 + getController()Ljava/lang/Object; - - - - - - - - - - - - 1036 + getIncludes()Ljava/util/List; - - - - - - - - - - - - 1037 getLoadListener()Lcom/sun/javafx/fxml/LoadListener; - - - - - - - - - - - - 1038 + getLocation()Ljava/net/URL; - - - - - - - - - - - - 1039 + getNamespace()Ljavafx/collections/ObservableMap; - - - - - - - - - - - - 1040 + getResources()Ljava/util/ResourceBundle; - - - - - - - - - - - - 1041 + getRoot()Ljava/lang/Object; - - - - - - - - - - - - 1042 isStaticLoad()Z 1043 */ 1044 // Button b; 1045 1046 public static final String defaultPropertyLabeledResourcePath = RESOURCE_BASE + "rt14879-labeled.fxml"; 1047 1048 private class slotDefaultLabeled extends TestNodeWithIOExceptionProcessing { 1049 1050 @Override 1051 protected String impl_getPathToResource() { 1052 return defaultPropertyLabeledResourcePath; 1053 } 1054 1055 @Override 1056 public Node impl_drawNode() throws IOException { 1057 Node uplevelNode = null; 1058 1059 try { 1060 uplevelNode = FXMLLoader.load(resource); 1061 } catch (Exception e) { 1062 System.out.println("message: " + e.getMessage()); 1063 reportGetterFailure("message: " + e.getMessage()); 1064 } 1065 return uplevelNode; 1066 } 1067 } 1068 1069 public static final String defaultPropertyListViewResourcePath = RESOURCE_BASE + "rt14879-listview.fxml"; 1070 1071 private class slotDefaultListview extends TestNodeWithIOExceptionProcessing { 1072 1073 @Override 1074 protected String impl_getPathToResource() { 1075 return defaultPropertyListViewResourcePath; 1076 } 1077 1078 @Override 1079 public Node impl_drawNode() throws IOException { 1080 Node uplevelNode = null; 1081 1082 try { 1083 uplevelNode = FXMLLoader.load(resource); 1084 } catch (Exception e) { 1085 System.out.println("message: " + e.getMessage()); 1086 reportGetterFailure("message: " + e.getMessage()); 1087 } 1088 1089 /* DEBUG. let it be here for a while 1090 ListView lv = new ListView(); 1091 String st = "str"; 1092 lv.getItems().add(st); 1093 lv.getItems().add(st); 1094 lv.getItems().add(st); 1095 * 1096 */ 1097 1098 return uplevelNode; 1099 } 1100 } 1101 1102 public static final String defaultPropertyMenuResourcePath = RESOURCE_BASE + "rt14879-menu.fxml"; 1103 1104 private class slotDefaultMenu extends TestNodeWithIOExceptionProcessing { 1105 1106 @Override 1107 protected String impl_getPathToResource() { 1108 return defaultPropertyMenuResourcePath; 1109 } 1110 1111 @Override 1112 public Node impl_drawNode() throws IOException { 1113 Menu uplevelNode = null; 1114 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1115 try { 1116 uplevelNode = (Menu)fxmlLoader.load(); 1117 } catch (Exception e) { 1118 System.out.println("message: " + e.getMessage()); 1119 reportGetterFailure("message: " + e.getMessage()); 1120 ParseTraceElement ptes[] = fxmlLoader.impl_getParseTrace(); 1121 for (ParseTraceElement pte: ptes) { 1122 // see rt-19329 1123 System.out.println("trace element: " + pte); 1124 } 1125 1126 } 1127 MenuBar mb = new MenuBar(); 1128 mb.getMenus().add(uplevelNode); 1129 // debug: uplevelNode.getItems().add(new MenuItem("open!!")); 1130 return mb; 1131 } 1132 } 1133 1134 public static final String defaultPropertyMenuBarResourcePath = RESOURCE_BASE + "rt14879-menubar.fxml"; 1135 1136 private class slotDefaultMenuBar extends TestNodeWithIOExceptionProcessing { 1137 1138 @Override 1139 protected String impl_getPathToResource() { 1140 return defaultPropertyMenuBarResourcePath; 1141 } 1142 1143 @Override 1144 public Node impl_drawNode() throws IOException { 1145 Node uplevelNode = null; 1146 1147 try { 1148 uplevelNode = FXMLLoader.load(resource); 1149 } catch (Exception e) { 1150 System.out.println("message: " + e.getMessage()); 1151 reportGetterFailure("message: " + e.getMessage()); 1152 } 1153 1154 return uplevelNode; 1155 } 1156 } 1157 1158 public static final String defaultPropertyScrollpaneResourcePath = RESOURCE_BASE + "rt14879-scrollpane.fxml"; 1159 1160 private class slotDefaultScrollpane extends TestNodeWithIOExceptionProcessing { 1161 1162 @Override 1163 protected String impl_getPathToResource() { 1164 return defaultPropertyScrollpaneResourcePath; 1165 } 1166 1167 @Override 1168 public Node impl_drawNode() throws IOException { 1169 Node uplevelNode = null; 1170 1171 try { 1172 uplevelNode = FXMLLoader.load(resource); 1173 } catch (Exception e) { 1174 System.out.println("message: " + e.getMessage()); 1175 reportGetterFailure("message: " + e.getMessage()); 1176 } 1177 return uplevelNode; 1178 } 1179 } 1180 1181 public static final String defaultPropertyTabpaneResourcePath = RESOURCE_BASE + "rt14879-tabpane.fxml"; 1182 1183 private class slotDefaultTabpane extends TestNodeWithIOExceptionProcessing { 1184 1185 @Override 1186 protected String impl_getPathToResource() { 1187 return defaultPropertyTabpaneResourcePath; 1188 } 1189 1190 @Override 1191 public Node impl_drawNode() throws IOException { 1192 Node uplevelNode = null; 1193 1194 try { 1195 uplevelNode = FXMLLoader.load(resource); 1196 } catch (Exception e) { 1197 System.out.println("message: " + e.getMessage()); 1198 reportGetterFailure("message: " + e.getMessage()); 1199 } 1200 return uplevelNode; 1201 } 1202 } 1203 1204 public static final String defaultPropertyTableViewResourcePath = RESOURCE_BASE + "rt14879-tableview.fxml"; 1205 1206 private class slotDefaultTableview extends TestNodeWithIOExceptionProcessing { 1207 1208 @Override 1209 protected String impl_getPathToResource() { 1210 return defaultPropertyTableViewResourcePath; 1211 } 1212 1213 @Override 1214 public Node impl_drawNode() throws IOException { 1215 TableView<Text> table = new TableView<Text>(); 1216 1217 try { 1218 table = 1219 FXMLLoader.load(resource); 1220 } catch (Exception e) { 1221 System.out.println("message: " + e.getMessage()); 1222 reportGetterFailure("message: " + e.getMessage()); 1223 } 1224 1225 TableColumn<Text, String> firstNameCol = new TableColumn<Text, String>("First Name"); 1226 firstNameCol.setCellValueFactory(new PropertyValueFactory("text")); 1227 table.getColumns().setAll(firstNameCol); 1228 1229 Object o = table.getItems().get(0); 1230 System.out.println("item0 type: " + o.getClass().getName()); 1231 System.out.println("item0 text: " + table.getItems().get(0).getText()); 1232 1233 return table; 1234 } 1235 } 1236 1237 public static final String defaultPropertyTextinputResourcePath = RESOURCE_BASE + "rt14879-textinput.fxml"; 1238 1239 private class slotDefaultTextinput extends TestNodeWithIOExceptionProcessing { 1240 1241 @Override 1242 protected String impl_getPathToResource() { 1243 return defaultPropertyTextinputResourcePath; 1244 } 1245 1246 @Override 1247 public Node impl_drawNode() throws IOException { 1248 Node uplevelNode = null; 1249 1250 try { 1251 uplevelNode = FXMLLoader.load(resource); 1252 } catch (Exception e) { 1253 System.out.println("message: " + e.getMessage()); 1254 reportGetterFailure("message: " + e.getMessage()); 1255 } 1256 return uplevelNode; 1257 } 1258 } 1259 1260 public static final String defaultPropertyTitledpaneResourcePath = RESOURCE_BASE + "rt14879-titledpane.fxml"; 1261 1262 private class slotDefaultTitledpane extends TestNodeWithIOExceptionProcessing { 1263 1264 @Override 1265 protected String impl_getPathToResource() { 1266 return defaultPropertyTitledpaneResourcePath; 1267 } 1268 1269 @Override 1270 public Node impl_drawNode() throws IOException { 1271 Node uplevelNode = null; 1272 1273 try { 1274 uplevelNode = FXMLLoader.load(resource); 1275 } catch (Exception e) { 1276 System.out.println("message: " + e.getMessage()); 1277 reportGetterFailure("message: " + e.getMessage()); 1278 } 1279 return uplevelNode; 1280 } 1281 } 1282 1283 public static final String defaultPropertyTreeviewResourcePath = RESOURCE_BASE + "rt14879-treeview.fxml"; 1284 1285 private class slotDefaultTreeview extends TestNodeWithIOExceptionProcessing { 1286 1287 @Override 1288 protected String impl_getPathToResource() { 1289 return defaultPropertyTreeviewResourcePath; 1290 } 1291 1292 @Override 1293 public Node impl_drawNode() throws IOException { 1294 Node uplevelNode = null; 1295 try { 1296 uplevelNode = FXMLLoader.load(resource); 1297 } catch (Exception e) { 1298 System.out.println("message: " + e.getMessage()); 1299 reportGetterFailure("message: " + e.getMessage()); 1300 } 1301 //Font f = null; 1302 return uplevelNode; 1303 } 1304 } 1305 1306 public static final String defaultPropertyImageviewResourcePath = RESOURCE_BASE + "rt14879-imageview.fxml"; 1307 1308 private class slotDefaultImageview extends TestNodeWithIOExceptionProcessing { 1309 1310 @Override 1311 protected String impl_getPathToResource() { 1312 return defaultPropertyImageviewResourcePath; 1313 } 1314 1315 @Override 1316 public Node impl_drawNode() throws IOException { 1317 Node uplevelNode = null; 1318 1319 try { 1320 uplevelNode = FXMLLoader.load(resource); 1321 } catch (Exception e) { 1322 System.out.println("message: " + e.getMessage()); 1323 reportGetterFailure("message: " + e.getMessage()); 1324 } 1325 return uplevelNode; 1326 } 1327 } 1328 1329 public static final String defaultPropertyPaneResourcePath = RESOURCE_BASE + "rt14879-pane.fxml"; 1330 1331 private class slotDefaultPane extends TestNodeWithIOExceptionProcessing { 1332 1333 @Override 1334 protected String impl_getPathToResource() { 1335 return defaultPropertyPaneResourcePath; 1336 } 1337 1338 @Override 1339 public Node impl_drawNode() throws IOException { 1340 Node uplevelNode = null; 1341 try { 1342 uplevelNode = FXMLLoader.load(resource); 1343 } catch (Exception e) { 1344 System.out.println("message: " + e.getMessage()); 1345 reportGetterFailure("message: " + e.getMessage()); 1346 } 1347 return uplevelNode; 1348 } 1349 } 1350 1351 public static final String controllerFactoryPath = RESOURCE_BASE + "rt_16724.fxml"; 1352 1353 private class controllerFactoryPane extends TestNodeWithIOExceptionProcessing { 1354 1355 @Override 1356 protected String impl_getPathToResource() { 1357 return controllerFactoryPath; 1358 } 1359 1360 @Override 1361 public Node impl_drawNode() throws IOException { 1362 LoadableEntity uplevelNode = null; 1363 boolean cntrlrFctryInvoked = false; 1364 boolean cntrlrInvoked = false; 1365 FXMLLoader fxmlLoader2 = new FXMLLoader(); 1366 Callback cfViaGetter = null; 1367 1368 RT_16724ControllerFactory cf = new RT_16724ControllerFactory(); 1369 try { 1370 1371 uplevelNode = 1372 FXMLLoader.load(resource, null, null, cf); 1373 1374 cntrlrFctryInvoked = cf.isInvoked(); 1375 RT_16724Controller cntrlr = cf.getCntrlr(); 1376 cntrlrInvoked = cntrlr.isInvoked(); 1377 1378 fxmlLoader2.setControllerFactory(cf); 1379 cfViaGetter = fxmlLoader2.getControllerFactory(); 1380 1381 } catch (Exception e) { 1382 System.out.println("message: " + e.getMessage()); 1383 reportGetterFailure("message: " + e.getMessage()); 1384 } 1385 1386 System.out.println("name: " + uplevelNode.getName()); 1387 1388 if ( cf != cfViaGetter ){ 1389 reportGetterFailure("cf via getter failed"); 1390 } 1391 1392 if ( 0 != "nameLoadedViaDefaultProperty".compareTo(uplevelNode.getName())) { 1393 reportGetterFailure("load using defaultProperty in custom class failed"); 1394 } 1395 if ( false == cntrlrFctryInvoked || false == cntrlrInvoked ) { 1396 reportGetterFailure("failed."); 1397 return redRectangle; 1398 } else { 1399 return retRec; 1400 } 1401 1402 } 1403 } 1404 1405 1406 public static final String specificSignatureMethodPath = RESOURCE_BASE + "rt_18229.fxml"; 1407 1408 private class specificSignatureMethodPane extends TestNodeWithIOExceptionProcessing { 1409 1410 @Override 1411 protected String impl_getPathToResource() { 1412 return specificSignatureMethodPath; 1413 } 1414 1415 @Override 1416 public Node impl_drawNode() throws IOException { 1417 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1418 try { 1419 fxmlLoader.load(); 1420 } catch (Exception e) { 1421 System.out.println("message: " + e.getMessage()); 1422 reportGetterFailure("message: " + e.getMessage()); 1423 } 1424 1425 RT_18229Controller controller = (RT_18229Controller)fxmlLoader.getController(); 1426 if ( 0 != "abc".compareTo(controller.getRootName1())) { 1427 reportGetterFailure("compare 1"); 1428 } 1429 if ( 0 != "def".compareTo(controller.getRootName2())) { 1430 reportGetterFailure("compare 2"); 1431 } 1432 1433 final String rootName1 = "123"; 1434 controller.getRoot().setName1(rootName1); 1435 if ( 0 != rootName1.compareTo(controller.getRootName1())) { 1436 reportGetterFailure("compare 3"); 1437 } 1438 1439 final String rootName2 = "456"; 1440 controller.getRoot().setName2(rootName2); 1441 1442 if ( 0 != rootName2.compareTo(controller.getRootName2())) { 1443 reportGetterFailure("compare 4"); 1444 } 1445 1446 return retRec; 1447 } 1448 } 1449 1450 public static final String loadfontPath = RESOURCE_BASE + "fontload.fxml"; 1451 1452 private class loadfontSlot extends TestNodeWithIOExceptionProcessing { 1453 1454 @Override 1455 protected String impl_getPathToResource() { 1456 return loadfontPath ; 1457 } 1458 1459 @Override 1460 public Node impl_drawNode() throws IOException { 1461 Font fnt = null; 1462 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1463 try { 1464 fnt = (Font) fxmlLoader.load(); 1465 } catch (Exception e) { 1466 System.out.println("message: " + e.getMessage()); 1467 reportGetterFailure("message: " + e.getMessage()); 1468 } 1469 1470 System.out.println("font name: " + fnt.getName()); 1471 if ( 0 != "Lucida Bright Demibold".compareTo(fnt.getName())) { 1472 reportGetterFailure("font name check failed"); 1473 } 1474 1475 return retRec; 1476 } 1477 } 1478 1479 public static final String scenebuilderPath = RESOURCE_BASE + "scenebuilder.fxml"; 1480 1481 private class scenebuilderSlot extends TestNodeWithIOExceptionProcessing { 1482 1483 @Override 1484 protected String impl_getPathToResource() { 1485 return scenebuilderPath ; 1486 } 1487 1488 @Override 1489 public Node impl_drawNode() throws IOException { 1490 Scene tmpScene = null; 1491 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1492 try { 1493 tmpScene = (Scene) fxmlLoader.load(); 1494 } catch (Exception e) { 1495 System.out.println("message: " + e.getMessage()); 1496 reportGetterFailure("message: " + e.getMessage()); 1497 } 1498 1499 if ( 150 != tmpScene.getHeight()) { 1500 reportGetterFailure("sceneHeight check failed"); 1501 } 1502 if ( 100 != tmpScene.getWidth()) { 1503 reportGetterFailure("sceneWidth check failed"); 1504 } 1505 1506 return tmpScene.getRoot(); 1507 } 1508 } 1509 1510 1511 public static final String rt18299ResourcePath = RESOURCE_BASE + "rt18299-scene-without-root.fxml"; 1512 private class scenebuilderNoRootSlot extends scenebuilderSlot 1513 { 1514 1515 @Override 1516 protected String impl_getPathToResource() 1517 { 1518 return rt18299ResourcePath; 1519 } 1520 1521 } 1522 1523 public static final String rt19329ResourcePath = RESOURCE_BASE + "rt19329-error-FXML.fxml"; 1524 public static final String ERROR_INFO_ID = "error_info"; 1525 //public static final String FXML_ERROR_LOCATION = "<ErrorTag is not a valid type.>fxml:12"; 1526 private class errorFXMLLoader extends TestNodeWithIOExceptionProcessing 1527 { 1528 1529 @Override 1530 protected String impl_getPathToResource() 1531 { 1532 return rt19329ResourcePath; 1533 } 1534 1535 @Override 1536 protected Node impl_drawNode() throws IOException 1537 { 1538 final Label label = new Label(); 1539 label.setId(ERROR_INFO_ID); 1540 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1541 try 1542 { 1543 fxmlLoader.load(); 1544 } 1545 catch(IOException e) 1546 { 1547 boolean lineNumberPresentAndCorrect = false; 1548 System.out.println("Exception text=" + e.getMessage()); 1549 if (e.getMessage().contains("ErrorTag") && 1550 e.getMessage().contains("fxml:12")) 1551 { 1552 return retRec; 1553 } 1554 } 1555 reportGetterFailure("wrong error message"); 1556 return label; 1557 } 1558 1559 } 1560 1561 public static final String rt18218ResourcePath = RESOURCE_BASE + "rt18218-unknown-custom-type.fxml"; 1562 public static final String LOADER_LOG_ID = "loader_log"; 1563 public static final String SUCCESSFUL_STATIC_LOAD = "success"; 1564 private class UnknownCustomType extends TestNodeWithIOExceptionProcessing 1565 { 1566 @Override 1567 protected String impl_getPathToResource() 1568 { 1569 return rt18218ResourcePath; 1570 } 1571 1572 @Override 1573 protected Node impl_drawNode() throws IOException 1574 { 1575 final Label label = new Label(); 1576 label.setId(LOADER_LOG_ID); 1577 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1578 fxmlLoader.impl_setStaticLoad(true); 1579 try 1580 { 1581 fxmlLoader.load(); 1582 label.setText(SUCCESSFUL_STATIC_LOAD); 1583 } 1584 catch(LoadException e) 1585 { 1586 e.printStackTrace(); 1587 for(ParseTraceElement trace: fxmlLoader.impl_getParseTrace()) 1588 { 1589 label.setText(label.getText() + trace.toString() + '\n'); 1590 } 1591 } 1592 1593 return label; 1594 } 1595 1596 } 1597 1598 public static final String rt14345ResourcePath = RESOURCE_BASE + "rt14345-color-valueOf.fxml"; 1599 private class ColorValueOf extends TestNodeWithIOExceptionProcessing 1600 { 1601 1602 @Override 1603 protected String impl_getPathToResource() 1604 { 1605 return rt14345ResourcePath; 1606 } 1607 1608 @Override 1609 protected Node impl_drawNode() throws IOException 1610 { 1611 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1612 Node node = null; 1613 try 1614 { 1615 node = (Node) fxmlLoader.load(); 1616 } 1617 catch(Exception e) 1618 { 1619 System.out.println("message: " + e.getMessage()); 1620 reportGetterFailure("message: " + e.getMessage()); 1621 } 1622 1623 return node; 1624 } 1625 1626 } 1627 1628 public static final String rt18680ResourcePath = RESOURCE_BASE + "rt18680-escape-character.fxml"; 1629 private class EscapeCharacter extends TestNodeWithIOExceptionProcessing 1630 { 1631 1632 @Override 1633 protected String impl_getPathToResource() 1634 { 1635 return rt18680ResourcePath; 1636 } 1637 1638 @Override 1639 protected Node impl_drawNode() throws IOException 1640 { 1641 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1642 VBox node = null; 1643 try 1644 { 1645 node = (VBox) fxmlLoader.load(); 1646 for(Node child: node.getChildren()) 1647 { 1648 if((child.getId().equals("label_1") 1649 || child.getId().equals("label_2")) 1650 && !((Label) child).getText().equals("${foo}")) 1651 { 1652 reportGetterFailure(child.getId() + " text check failed"); 1653 } 1654 if((child.getId().equals("label_3") 1655 || child.getId().equals("label_4")) 1656 && !((Label) child).getText().equals("@{foo}")) 1657 { 1658 reportGetterFailure(child.getId() + " text check failed"); 1659 } 1660 if((child.getId().equals("label_5") 1661 || child.getId().equals("label_6")) 1662 && !((Label) child).getText().equals("%{foo}")) 1663 { 1664 reportGetterFailure(child.getId() + " text check failed"); 1665 } 1666 } 1667 } 1668 catch(Exception e) 1669 { 1670 System.out.println("message: " + e.getMessage()); 1671 reportGetterFailure("message: " + e.getMessage()); 1672 } 1673 1674 return node; 1675 } 1676 1677 } 1678 1679 public static final String rt17714ResourcePath = RESOURCE_BASE + "rt17714-collection-events-handlers.fxml"; 1680 private class CollectionEventsHandlers extends TestNodeWithIOExceptionProcessing 1681 { 1682 1683 @Override 1684 protected String impl_getPathToResource() 1685 { 1686 return rt17714ResourcePath; 1687 } 1688 1689 @Override 1690 protected Node impl_drawNode() throws IOException 1691 { 1692 FXMLLoader fxmlLoader = new FXMLLoader(resource); 1693 ObservableList<String> observableArrayList = null; 1694 //javafx.collections.FXCollections.observableArrayList(); 1695 try 1696 { 1697 observableArrayList = (ObservableList<String>) fxmlLoader.load(); 1698 System.out.println(fxmlLoader.getController().getClass()); 1699 observableArrayList.add("New added string"); 1700 } 1701 catch(Exception e) 1702 { 1703 System.out.println("message: " + e.getMessage()); 1704 reportGetterFailure("message: " + e.getMessage()); 1705 } 1706 1707 if(1 != CollectionController.callCount) 1708 { 1709 reportGetterFailure("Controller didn't handle event"); 1710 } 1711 1712 return new Label(observableArrayList.get(0).toString()); 1713 } 1714 1715 } 1716 1717 public static final String rt18229ResourcePath = RESOURCE_BASE + "rt18229-no-args-controller-method.fxml"; 1718 private class NoArgsControllerMethod extends TestNodeWithIOExceptionProcessing 1719 { 1720 @Override 1721 protected String impl_getPathToResource() 1722 { 1723 return rt18229ResourcePath; 1724 } 1725 1726 @Override 1727 public Node impl_drawNode() throws IOException 1728 { 1729 FXMLLoader loader = new FXMLLoader(resource); 1730 Button button = null; 1731 try 1732 { 1733 button = (Button) loader.load(); 1734 System.out.println(button.getId()); 1735 } 1736 catch(Exception e) 1737 { 1738 e.printStackTrace(); 1739 System.out.println("message: " + e.getMessage()); 1740 reportGetterFailure("message: " + e.getMessage()); 1741 } 1742 return button; 1743 } 1744 } 1745 1746 public static final String rt18229OverloadedResourcePath = RESOURCE_BASE + "rt18229-overloaded-controller-method.fxml"; 1747 private class OverloadedControllerMethod extends TestNodeWithIOExceptionProcessing 1748 { 1749 1750 @Override 1751 protected String impl_getPathToResource() 1752 { 1753 return rt18229OverloadedResourcePath; 1754 } 1755 1756 @Override 1757 public Node impl_drawNode() throws IOException 1758 { 1759 FXMLLoader loader = new FXMLLoader(resource); 1760 Button button = null; 1761 try 1762 { 1763 button = (Button) loader.load(); 1764 } 1765 catch(Exception e) 1766 { 1767 e.printStackTrace(); 1768 System.out.println("message: " + e.getMessage()); 1769 reportGetterFailure("message: " + e.getMessage()); 1770 } 1771 return button; 1772 } 1773 1774 } 1775 1776 public static final String rt17657ResourcePath = RESOURCE_BASE + "rt17657-custom-id-property.fxml"; 1777 private class CustomIDProperty extends TestNodeWithIOExceptionProcessing 1778 { 1779 1780 @Override 1781 protected String impl_getPathToResource() 1782 { 1783 return rt17657ResourcePath; 1784 } 1785 1786 @Override 1787 public Node impl_drawNode() throws IOException 1788 { 1789 FXMLLoader loader = new FXMLLoader(resource); 1790 CustomIDButton button = null; 1791 try 1792 { 1793 button = (CustomIDButton) loader.load(); 1794 System.out.println(button.getCustomID()); 1795 } 1796 catch(Exception e) 1797 { 1798 e.printStackTrace(); 1799 System.out.println("message: " + e.getMessage()); 1800 reportGetterFailure("message: " + e.getMessage()); 1801 } 1802 return button; 1803 1804 } 1805 1806 } 1807 1808 public static final String rt16722ResourcePath = RESOURCE_BASE + "rt16722-base-controller-properties.fxml"; 1809 private class BaseColntrollerProperty extends TestNodeWithIOExceptionProcessing 1810 { 1811 1812 @Override 1813 protected String impl_getPathToResource() 1814 { 1815 return rt16722ResourcePath; 1816 } 1817 1818 @Override 1819 public Node impl_drawNode() throws IOException 1820 { 1821 FXMLLoader loader = new FXMLLoader(resource); 1822 VBox vBox = null; 1823 try 1824 { 1825 vBox = (VBox) loader.load(); 1826 } 1827 catch(Exception e) 1828 { 1829 e.printStackTrace(); 1830 System.out.println("message: " + e.getMessage()); 1831 reportGetterFailure("message: " + e.getMessage()); 1832 } 1833 return vBox; 1834 1835 } 1836 1837 } 1838 1839 public static final String rt18956ResourcePath = RESOURCE_BASE + "rt18956-relative-stylesheets.fxml"; 1840 private class RelativeStylesheet extends TestNodeWithIOExceptionProcessing 1841 { 1842 @Override 1843 protected String impl_getPathToResource() 1844 { 1845 return rt18956ResourcePath; 1846 } 1847 1848 @Override 1849 public Node impl_drawNode() throws IOException 1850 { 1851 FXMLLoader loader = new FXMLLoader(resource); 1852 Label label = null; 1853 try 1854 { 1855 label = (Label) loader.load(); 1856 System.out.println("font:" + label.getFont().toString()); 1857 1858 System.out.println("Style:"); 1859 System.out.println(label.getStyle()); 1860 final ObservableList<String> sheets = label.getStylesheets(); 1861 for (String str : sheets) 1862 System.out.println("sheet:" + str); 1863 if (null != label.getBackground()) { 1864 final List<BackgroundFill> lbf = 1865 label.getBackground().getFills(); 1866 1867 1868 for (BackgroundFill bf : lbf) 1869 System.out.println("fill:" + bf.toString()); 1870 } else { 1871 System.out.println("null == label.getBackground() "); 1872 } 1873 final List<CssMetaData<? extends Styleable, ?>> ls = 1874 label.getControlCssMetaData(); 1875 1876 1877 for (CssMetaData<? extends Styleable, ?> md : ls) 1878 { 1879 System.out.println("css:" + md.toString()); 1880 if (md.getProperty().equals("-fx-region-background")){ 1881 final List<CssMetaData<? extends Styleable, ?>> subList = 1882 md.getSubProperties(); 1883 for (CssMetaData<? extends Styleable, ?> smd : subList){ 1884 System.out.println(" subcss:" + smd.toString()); 1885 if (smd.getProperty().equals("-fx-background-color")){ 1886 1887 } 1888 } 1889 } 1890 1891 } 1892 1893 1894 } 1895 catch(Exception e) 1896 { 1897 e.printStackTrace(); 1898 System.out.println("message: " + e.getMessage()); 1899 reportGetterFailure("message: " + e.getMessage()); 1900 } 1901 return label; 1902 1903 } 1904 1905 } 1906 1907 public static final String rt16815ResourcePath = RESOURCE_BASE + "FXMLLoaderAPI.fxml"; 1908 private class FXMLLoaderAPI extends TestNodeWithIOExceptionProcessing 1909 { 1910 1911 @Override 1912 protected String impl_getPathToResource() 1913 { 1914 return rt16815ResourcePath; 1915 } 1916 1917 @Override 1918 public Node impl_drawNode() throws IOException 1919 { 1920 FXMLLoader loader = new FXMLLoader(resource); 1921 ResourceBundle rb = ResourceBundle.getBundle("test.fxmltests.resources.resource1", new Locale("en", "US")); 1922 FXMLLoader loader2 = new FXMLLoader(resource, rb); 1923 FXMLLoader loader3 = new FXMLLoader(resource, rb, new JavaFXBuilderFactory()); 1924 ObservableList<Labeled> list = FXCollections.observableArrayList(); 1925 try 1926 { 1927 list.add((Labeled) loader.load()); 1928 // System.out.println(label.getStyle()); 1929 } 1930 catch(Exception e) 1931 { 1932 e.printStackTrace(); 1933 System.out.println("message: " + e.getMessage()); 1934 reportGetterFailure("message: " + e.getMessage()); 1935 } 1936 try 1937 { 1938 list.add((Labeled) loader2.load()); 1939 // System.out.println(label.getStyle()); 1940 } 1941 catch(Exception e) 1942 { 1943 e.printStackTrace(); 1944 System.out.println("message: " + e.getMessage()); 1945 reportGetterFailure("message: " + e.getMessage()); 1946 } 1947 try 1948 { 1949 list.add((Labeled) loader3.load()); 1950 // System.out.println(label.getStyle()); 1951 } 1952 catch(Exception e) 1953 { 1954 e.printStackTrace(); 1955 System.out.println("message: " + e.getMessage()); 1956 reportGetterFailure("message: " + e.getMessage()); 1957 } 1958 VBox vb = new VBox(); 1959 vb.getChildren().addAll(list); 1960 return vb; 1961 1962 } 1963 1964 } 1965 1966 public static final String references2Path = RESOURCE_BASE + "ref_test.fxml"; 1967 private class references2Slot extends TestNodeWithIOExceptionProcessing { 1968 // RT-18178 1969 AnchorPane anchorPane = null; 1970 1971 @Override 1972 protected String impl_getPathToResource() { 1973 return references2Path; 1974 } 1975 1976 @Override 1977 public Node impl_drawNode() throws IOException { 1978 InputStream is = null; 1979 try { 1980 FXMLLoader fxmlLoader2 = new FXMLLoader(); 1981 is = resource.openStream(); 1982 anchorPane = (AnchorPane) fxmlLoader2.load(is); 1983 } catch (Exception e) { 1984 e.printStackTrace(); 1985 System.out.println("message: " + e.getMessage()); 1986 reportGetterFailure("exception thrown."); 1987 } finally { 1988 is.close(); 1989 } 1990 1991 1992 Button button = null; 1993 Label label = null; 1994 for (Node node : anchorPane.getChildren()) { 1995 if (node instanceof Button) { 1996 button = (Button)node; 1997 } 1998 if (node instanceof Label) { 1999 label = (Label)node; 2000 } 2001 } 2002 2003 if ( null != label && null != button ) { 2004 System.out.println("label: " + label.getFont() + " / " + label.getTextFill()); 2005 System.out.println("button: " + button.getFont() + " / " + button.getTextFill()); 2006 2007 if (label.getTextFill().equals(button.getTextFill()) && 2008 label.getFont().equals(button.getFont())) { 2009 return retRec; 2010 } 2011 } 2012 reportGetterFailure("failed."); 2013 return redRectangle; 2014 } 2015 } 2016 2017 2018 2019 public static final String apConstraintsPath = RESOURCE_BASE + "project-with-all-AnchorPane-constraints.fxml"; 2020 private class apConstraintsSlot extends TestNodeWithIOExceptionProcessing { 2021 // RT-18178 2022 AnchorPane anchorPane = null; 2023 2024 @Override 2025 protected String impl_getPathToResource() { 2026 return apConstraintsPath; 2027 } 2028 2029 @Override 2030 public Node impl_drawNode() throws IOException { 2031 InputStream is = null; 2032 try { 2033 FXMLLoader fxmlLoader2 = new FXMLLoader(); 2034 is = resource.openStream(); 2035 anchorPane = (AnchorPane) fxmlLoader2.load(is); 2036 } catch (Exception e) { 2037 e.printStackTrace(); 2038 System.out.println("message: " + e.getMessage()); 2039 reportGetterFailure("exception thrown."); 2040 } finally { 2041 is.close(); 2042 } 2043 2044 return retRec; 2045 } 2046 } 2047 2048 2049 2050 2051 public static final String coercePath = RESOURCE_BASE + "project-with-all-p2-components.fxml"; 2052 private class coerceSlot extends TestNodeWithIOExceptionProcessing { 2053 // RT-18178 2054 AnchorPane anchorPane = null; 2055 2056 @Override 2057 protected String impl_getPathToResource() { 2058 return coercePath; 2059 } 2060 2061 @Override 2062 public Node impl_drawNode() throws IOException { 2063 InputStream is = null; 2064 try { 2065 FXMLLoader fxmlLoader2 = new FXMLLoader(); 2066 is = resource.openStream(); 2067 anchorPane = (AnchorPane) fxmlLoader2.load(is); 2068 } catch (Exception e) { 2069 e.printStackTrace(); 2070 System.out.println("message: " + e.getMessage()); 2071 reportGetterFailure("exception thrown."); 2072 } finally { 2073 is.close(); 2074 } 2075 return retRec; 2076 } 2077 } 2078 2079 public static final String gridappletPath = RESOURCE_BASE + "rt19752.fxml"; 2080 private class gridappletSlot extends TestNodeWithIOExceptionProcessing { 2081 // RT-18178 2082 GridPane gridPane = null; 2083 2084 @Override 2085 protected String impl_getPathToResource() { 2086 return gridappletPath; 2087 } 2088 2089 @Override 2090 public Node impl_drawNode() throws IOException { 2091 InputStream is = null; 2092 try { 2093 FXMLLoader fxmlLoader2 = new FXMLLoader(); 2094 is = resource.openStream(); 2095 gridPane = (GridPane) fxmlLoader2.load(is); 2096 } catch (Exception e) { 2097 e.printStackTrace(); 2098 System.out.println("message: " + e.getMessage()); 2099 reportGetterFailure("exception thrown."); 2100 } finally { 2101 is.close(); 2102 } 2103 return retRec; 2104 } 2105 } 2106 2107 /* 2108 public static final String csspathPath = RESOURCE_BASE + "rt18956.xml"; 2109 private class csspathSlot extends TestNodeWithIOExceptionProcessing { 2110 // RT-18956 2111 BorderPane gridPane = null; 2112 2113 @Override 2114 protected String impl_getPathToResource() { 2115 return csspathPath; 2116 } 2117 2118 @Override 2119 public Node impl_drawNode() throws IOException { 2120 InputStream is = null; 2121 try { 2122 FXMLLoader fxmlLoader2 = new FXMLLoader(); 2123 fxmlLoader2.setLocation(resource); 2124 2125 is = resource.openStream(); 2126 URL ggg; 2127 AnchorPane sc = (AnchorPane) fxmlLoader2.load(is); 2128 } catch (Exception e) { 2129 e.printStackTrace(); 2130 System.out.println("message: " + e.getMessage()); 2131 reportGetterFailure("exception thrown."); 2132 } finally { 2133 is.close(); 2134 } 2135 return retRec; 2136 } 2137 } 2138 */ 2139 2140 public static final String listviewPath = RESOURCE_BASE + "listview-items.fxml"; 2141 private class listviewSlot extends TestNodeWithIOExceptionProcessing { 2142 // RT-18178 2143 AnchorPane anchorPane = null; 2144 2145 @Override 2146 protected String impl_getPathToResource() { 2147 return listviewPath; 2148 } 2149 2150 @Override 2151 public Node impl_drawNode() throws IOException { 2152 InputStream is = null; 2153 try { 2154 FXMLLoader fxmlLoader2 = new FXMLLoader(); 2155 is = resource.openStream(); 2156 anchorPane = (AnchorPane) fxmlLoader2.load(is); 2157 } catch (Exception e) { 2158 e.printStackTrace(); 2159 System.out.println("message: " + e.getMessage()); 2160 reportGetterFailure("exception thrown."); 2161 } finally { 2162 is.close(); 2163 } 2164 2165 ListView lv = null; 2166 for (Node node : anchorPane.getChildren()) { 2167 System.out.println("anchorpane child: " + node); 2168 if (node instanceof ListView) { 2169 lv = (ListView)node; 2170 } 2171 } 2172 2173 int hboxcount = 0; 2174 if (null != lv) { 2175 for (Object node : lv.getItems()) { 2176 if (node instanceof HBox) { 2177 hboxcount = hboxcount + 1; 2178 } 2179 System.out.println("listview child: " + node); 2180 } 2181 2182 } 2183 2184 if ( 3 != hboxcount ) { 2185 reportGetterFailure("wrong items/items count."); 2186 return redRectangle; 2187 } else { 2188 return retRec; 2189 } 2190 } 2191 } 2192 2193 private class listenerNullArgSlot extends TestNodeWithIOExceptionProcessing { 2194 // RT-19133 2195 2196 @Override 2197 protected String impl_getPathToResource() { 2198 return rt19133ResourcePath; 2199 } 2200 2201 @Override 2202 public Node impl_drawNode() throws IOException { 2203 //InputStream is = null; 2204 try { 2205 //is = resource.openStream(); 2206 FXMLLoader fxmlLoader = new FXMLLoader(resource); 2207 2208 fxmlLoader.impl_setStaticLoad(true); 2209 fxmlLoader.setLoadListener(new LoadListener() { 2210 2211 @Override 2212 public void readImportProcessingInstruction(String target) { 2213 } 2214 2215 @Override 2216 public void readLanguageProcessingInstruction(String language) { 2217 } 2218 2219 @Override 2220 public void readComment(String comment) { 2221 } 2222 2223 @Override 2224 public void beginInstanceDeclarationElement(Class<?> type) { 2225 } 2226 2227 @Override 2228 public void beginUnknownTypeElement(String name) { 2229 } 2230 2231 @Override 2232 public void beginIncludeElement() { 2233 } 2234 2235 @Override 2236 public void beginReferenceElement() { 2237 } 2238 2239 @Override 2240 public void beginCopyElement() { 2241 } 2242 2243 @Override 2244 public void beginPropertyElement(String name, Class<?> sourceType) { 2245 } 2246 2247 @Override 2248 public void beginUnknownStaticPropertyElement(String name) { 2249 } 2250 2251 @Override 2252 public void beginScriptElement() { 2253 } 2254 2255 @Override 2256 public void beginDefineElement() { 2257 } 2258 2259 @Override 2260 public void readInternalAttribute(String name, String value) { 2261 } 2262 2263 @Override 2264 public void readPropertyAttribute(String name, Class<?> sourceType, String value) { 2265 } 2266 2267 @Override 2268 public void readUnknownStaticPropertyAttribute(String name, String value) { 2269 } 2270 2271 @Override 2272 public void readEventHandlerAttribute(String name, String value) { 2273 } 2274 2275 @Override 2276 public void endElement(Object value) { 2277 if (null == value) { 2278 System.out.println("endElement() arg is null: rt-19133"); 2279 reportGetterFailure("endElement() arg is null: rt-19133"); 2280 } else { 2281 System.out.println("endElement() arg:" + value); 2282 } 2283 } 2284 2285 @Override 2286 public void beginRootElement() { 2287 throw new UnsupportedOperationException("Not supported yet."); 2288 } 2289 }); 2290 2291 2292 fxmlLoader.load(); 2293 } catch (Exception e) { 2294 e.printStackTrace(); 2295 System.out.println("message: " + e.getMessage()); 2296 reportGetterFailure("exception thrown."); 2297 } finally { 2298 //is.close(); 2299 } 2300 return retRec; 2301 } 2302 } 2303 2304 public static final String fullyQualifiedNamesResPath = RESOURCE_BASE + "fully-qualified-name.fxml"; 2305 private class FullyQualifiedNamesSlot extends TestNodeWithIOExceptionProcessing { 2306 2307 @Override 2308 protected String impl_getPathToResource() { 2309 return fullyQualifiedNamesResPath; 2310 } 2311 2312 @Override 2313 public Node impl_drawNode() throws IOException { 2314 Label label = null; 2315 InputStream is = null; 2316 try { 2317 FXMLLoader fxmlLoader = new FXMLLoader(); 2318 is = resource.openStream(); 2319 label = (Label) fxmlLoader.load(is); 2320 } catch (Exception e) { 2321 e.printStackTrace(); 2322 System.out.println("message: " + e.getMessage()); 2323 reportGetterFailure("exception thrown."); 2324 } finally { 2325 is.close(); 2326 } 2327 return label; 2328 } 2329 } 2330 2331 public static final String importResPath = RESOURCE_BASE + "import.fxml"; 2332 private class ImportSlot extends TestNodeWithIOExceptionProcessing { 2333 2334 @Override 2335 protected String impl_getPathToResource() { 2336 return importResPath; 2337 } 2338 2339 @Override 2340 public Node impl_drawNode() throws IOException { 2341 Label label = null; 2342 InputStream is = null; 2343 try { 2344 FXMLLoader fxmlLoader = new FXMLLoader(); 2345 is = resource.openStream(); 2346 label = (Label) fxmlLoader.load(is); 2347 } catch (Exception e) { 2348 e.printStackTrace(); 2349 System.out.println("message: " + e.getMessage()); 2350 reportGetterFailure("exception thrown."); 2351 } finally { 2352 is.close(); 2353 } 2354 return label; 2355 } 2356 } 2357 2358 public static final String beanInstantiationResPath = RESOURCE_BASE + "bean-instantiation.fxml"; 2359 private class BeanInstantiationSlot extends TestNodeWithIOExceptionProcessing { 2360 2361 @Override 2362 protected String impl_getPathToResource() { 2363 return beanInstantiationResPath; 2364 } 2365 2366 @Override 2367 public Node impl_drawNode() throws IOException { 2368 Label label = new Label(); 2369 label.setId("label_from_bean"); 2370 InputStream is = null; 2371 try { 2372 FXMLLoader fxmlLoader = new FXMLLoader(); 2373 is = resource.openStream(); 2374 SimpleBean bean = (SimpleBean) fxmlLoader.load(is); 2375 label.setText(bean.getContent()); 2376 } catch (Exception e) { 2377 e.printStackTrace(); 2378 System.out.println("message: " + e.getMessage()); 2379 reportGetterFailure("exception thrown."); 2380 } finally { 2381 is.close(); 2382 } 2383 return label; 2384 } 2385 } 2386 2387 public static final String valueOfResPath = RESOURCE_BASE + "value-of.fxml"; 2388 private class ValueOfSlot extends TestNodeWithIOExceptionProcessing { 2389 2390 @Override 2391 protected String impl_getPathToResource() { 2392 return valueOfResPath; 2393 } 2394 2395 @Override 2396 public Node impl_drawNode() throws IOException { 2397 Label label = new Label(); 2398 label.setId("value_of_label"); 2399 InputStream is = null; 2400 try { 2401 FXMLLoader fxmlLoader = new FXMLLoader(); 2402 is = resource.openStream(); 2403 Double d = (Double) fxmlLoader.load(is); 2404 label.setText(d.toString()); 2405 } catch (Exception e) { 2406 e.printStackTrace(); 2407 System.out.println("message: " + e.getMessage()); 2408 reportGetterFailure("exception thrown."); 2409 } finally { 2410 is.close(); 2411 } 2412 return label; 2413 } 2414 } 2415 2416 public static final String rootResPath = RESOURCE_BASE + "root.fxml"; 2417 private class RootSlot extends TestNodeWithIOExceptionProcessing { 2418 2419 @Override 2420 protected String impl_getPathToResource() { 2421 return rootResPath; 2422 } 2423 2424 @Override 2425 public Node impl_drawNode() throws IOException { 2426 VBox vb = new VBox(); 2427 vb.setId("vb_root"); 2428 InputStream is = null; 2429 try { 2430 FXMLLoader fxmlLoader = new FXMLLoader(); 2431 fxmlLoader.setRoot(vb); 2432 is = resource.openStream(); 2433 fxmlLoader.load(is); 2434 } catch (Exception e) { 2435 e.printStackTrace(); 2436 System.out.println("message: " + e.getMessage()); 2437 reportGetterFailure("exception thrown."); 2438 } finally { 2439 is.close(); 2440 } 2441 return vb; 2442 } 2443 } 2444 2445 public static final String fxIdResPath = RESOURCE_BASE + "fx-id.fxml"; 2446 private class FxIdSlot extends TestNodeWithIOExceptionProcessing { 2447 2448 @Override 2449 protected String impl_getPathToResource() { 2450 return fxIdResPath; 2451 } 2452 2453 @Override 2454 public Node impl_drawNode() throws IOException { 2455 AnchorPane ap = null; 2456 InputStream is = null; 2457 FXMLLoader fxmlLoader = null; 2458 try { 2459 fxmlLoader = new FXMLLoader(); 2460 is = resource.openStream(); 2461 ap = (AnchorPane) fxmlLoader.load(is); 2462 } catch (Exception e) { 2463 e.printStackTrace(); 2464 System.out.println("message: " + e.getMessage()); 2465 reportGetterFailure("exception thrown."); 2466 } finally { 2467 is.close(); 2468 } 2469 Object label = fxmlLoader.getNamespace().get("cat_o_dog_label"); 2470 if(label == null || !(label instanceof Label)) 2471 { 2472 reportGetterFailure("no label with id cat_o_dog_label"); 2473 } 2474 if(label instanceof Label && !((Label) label).getText().equals("cat-o-dog")) 2475 { 2476 reportGetterFailure("invalid text in label"); 2477 } 2478 return ap; 2479 } 2480 } 2481 2482 private class controllerAttributeSlot extends TestNodeWithIOExceptionProcessing { 2483 2484 MyRootElement2 mr; 2485 2486 @Override 2487 protected String impl_getPathToResource() { 2488 return rootMethodEventHandlerResourcePath; 2489 } 2490 2491 @Override 2492 public Node impl_drawNode() { 2493 FXMLLoader loader = new FXMLLoader(); 2494 try { 2495 // https://javafx-jira.kenai.com/browse/RT-26774 2496 //mr = (MyRootElement2) FXMLLoader.load(resource); 2497 loader.setLocation(resource); 2498 mr = (MyRootElement2)loader.load(); 2499 } catch (Exception e) { 2500 System.out.println("message: " + e.getMessage()); 2501 e.printStackTrace(); 2502 reportGetterFailure("exception thrown."); 2503 } 2504 2505 if(!(loader.getController() instanceof MyRootElement2)) 2506 { 2507 reportGetterFailure("wrong controller"); 2508 } 2509 2510 return mr; 2511 } 2512 } 2513 2514 public static final String noDefControllerResPath = RESOURCE_BASE + "no-default-controller.fxml"; 2515 private class NoDefaultControllerSlot extends TestNodeWithIOExceptionProcessing { 2516 2517 @Override 2518 protected String impl_getPathToResource() { 2519 return noDefControllerResPath; 2520 } 2521 2522 @Override 2523 public Node impl_drawNode() throws IOException { 2524 Button button = null; 2525 InputStream is = null; 2526 FXMLLoader fxmlLoader = null; 2527 MyRootElement myRootElement = new MyRootElement(); 2528 try { 2529 fxmlLoader = new FXMLLoader(); 2530 fxmlLoader.setController(myRootElement); 2531 is = resource.openStream(); 2532 button = (Button) fxmlLoader.load(is); 2533 } catch (Exception e) { 2534 e.printStackTrace(); 2535 System.out.println("message: " + e.getMessage()); 2536 reportGetterFailure("exception thrown."); 2537 } finally { 2538 is.close(); 2539 } 2540 if(fxmlLoader.getController() != myRootElement) 2541 { 2542 reportGetterFailure("Wrong controller"); 2543 } 2544 return button; 2545 } 2546 } 2547 2548 private class LateRootSlot extends TestNodeWithIOExceptionProcessing { 2549 2550 @Override 2551 protected String impl_getPathToResource() { 2552 return rootResPath; 2553 } 2554 2555 @Override 2556 public Node impl_drawNode() throws IOException { 2557 VBox vb = new VBox(); 2558 vb.setId("vb_root"); 2559 Node node = null; 2560 FXMLLoader fxmlLoader = new FXMLLoader(); 2561 InputStream is = null; 2562 try { 2563 is = resource.openStream(); 2564 node = (Node) fxmlLoader.load(is); 2565 fxmlLoader.setRoot(vb); 2566 } catch (LoadException e) { 2567 e.printStackTrace(); 2568 System.out.println("message: " + e.getMessage()); 2569 return retRec; 2570 } catch (Exception exc) { 2571 exc.printStackTrace(); 2572 System.out.println("message: " + exc.getMessage()); 2573 reportGetterFailure("exception thrown."); 2574 } finally { 2575 is.close(); 2576 } 2577 // if(node.getId() == null || !node.getId().equals("default_root")) 2578 // { 2579 // reportGetterFailure("Root id: " + node.getId()); 2580 // } 2581 return redRectangle; 2582 } 2583 } 2584 2585 private class LateControllerSlot extends TestNodeWithIOExceptionProcessing { 2586 2587 @Override 2588 protected String impl_getPathToResource() { 2589 return noDefControllerResPath; 2590 } 2591 2592 @Override 2593 public Node impl_drawNode() throws IOException { 2594 Button button = null; 2595 InputStream is = null; 2596 FXMLLoader fxmlLoader = new FXMLLoader(); 2597 MyRootElement myRootElement = new MyRootElement(); 2598 try { 2599 is = resource.openStream(); 2600 fxmlLoader.load(is); 2601 fxmlLoader.setController(myRootElement); 2602 } catch (Exception e) { 2603 2604 if(e instanceof LoadException && e.getMessage().contains("No controller specified.")) 2605 { 2606 return retRec; 2607 } 2608 e.printStackTrace(); 2609 System.out.println("message: " + e.getMessage()); 2610 reportGetterFailure("exception thrown."); 2611 } finally { 2612 is.close(); 2613 } 2614 reportGetterFailure("Controller is not null."); 2615 return redRectangle; 2616 } 2617 } 2618 2619 private class VariableResolutionSlot extends TestNodeWithIOExceptionProcessing { 2620 2621 VBox vb; 2622 2623 @Override 2624 protected String impl_getPathToResource() { 2625 return fxdefineResourcePath; 2626 } 2627 2628 @Override 2629 public Node impl_drawNode() { 2630 try { 2631 vb = FXMLLoader.load(resource); 2632 } catch (Exception e) { 2633 System.out.println("message: " + e.getMessage()); 2634 reportGetterFailure("exception thrown."); 2635 } 2636 LinkedList<ToggleGroup> toggleGroups = new LinkedList<ToggleGroup>(); 2637 for(Node child: vb.getChildren()) 2638 { 2639 toggleGroups.add(((RadioButton) child).getToggleGroup()); 2640 } 2641 for(int i = 0; i < toggleGroups.size() - 2; i ++) 2642 { 2643 if(!toggleGroups.get(i).equals(toggleGroups.get(i + 1))) 2644 { 2645 reportGetterFailure("failed."); 2646 return redRectangle; 2647 } 2648 } 2649 return retRec; 2650 } 2651 } 2652 2653 public static final String externalScriptResPath = RESOURCE_BASE + "external-script.fxml"; 2654 private class ExternalScriptCodeSlot extends TestNodeWithIOExceptionProcessing 2655 { 2656 @Override 2657 protected String impl_getPathToResource() 2658 { 2659 return externalScriptResPath; 2660 } 2661 2662 @Override 2663 public Node impl_drawNode() throws IOException 2664 { 2665 FXMLLoader loader = new FXMLLoader(resource); 2666 VBox vb = null; 2667 try 2668 { 2669 vb = (VBox) loader.load(); 2670 } 2671 catch(Exception e) 2672 { 2673 e.printStackTrace(); 2674 System.out.println("message: " + e.getMessage()); 2675 reportGetterFailure("message: " + e.getMessage()); 2676 } 2677 return vb; 2678 } 2679 } 2680 2681 2682 @Override 2683 public TestNode setup() { 2684 System.out.println("java.library.path=" + System.getProperty("java.library.path")); 2685 TestNode rootTestNode = new TestNode(); 2686 2687 final int heightPageContentPane = 800; 2688 final int widthPageContentPane = 800; 2689 2690 List<Pair<String, TestNode>> hm = new ArrayList(); 2691 2692 hm.add(new Pair<String, TestNode>(Pages.staticProperty.name(), new slotStaticProperty())); 2693 hm.add(new Pair<String, TestNode>(Pages.HashMap.name(), new hashmaptest())); 2694 hm.add(new Pair<String, TestNode>(Pages.customClassAndInclude.name(), new customClassLoadSlot())); 2695 hm.add(new Pair<String, TestNode>(Pages.factory.name(), new factorySlot())); 2696 hm.add(new Pair<String, TestNode>(Pages.simple.name(), new simpleSlot())); 2697 hm.add(new Pair<String, TestNode>(Pages.propertyElements.name(), new propertyElementsSlot())); 2698 hm.add(new Pair<String, TestNode>(Pages.reference.name(), new referenceSlot())); 2699 hm.add(new Pair<String, TestNode>(Pages.copy.name(), new copySlot())); 2700 hm.add(new Pair<String, TestNode>(Pages.prSetter.name(), new propertySetterSlot())); 2701 hm.add(new Pair<String, TestNode>(Pages.roList.name(), new roListSlot())); 2702 hm.add(new Pair<String, TestNode>(Pages.roMap.name(), new roMapSlot())); 2703 hm.add(new Pair<String, TestNode>(Pages.defaultProperty.name(), new defaultPropertySlot())); 2704 hm.add(new Pair<String, TestNode>(Pages.fxdefine.name(), new fxdefineSlot())); 2705 hm.add(new Pair<String, TestNode>(Pages.namespaceBinding.name(), new namespaceBindingSlot())); 2706 hm.add(new Pair<String, TestNode>(Pages.staticProperties.name(), new staticPropertiesSlot())); 2707 hm.add(new Pair<String, TestNode>(Pages.rootMethodEventHandler.name(), new rootMethodEventHandlerSlot())); 2708 hm.add(new Pair<String, TestNode>(Pages.scriptEventHandler.name(), new scriptEventHandlerSlot())); 2709 hm.add(new Pair<String, TestNode>(Pages.script.name(), new scriptSlot())); 2710 hm.add(new Pair<String, TestNode>(Pages.menuItem.name(), new menuitemSlot())); 2711 hm.add(new Pair<String, TestNode>(Pages.resources1.name(), new resource1Slot())); 2712 hm.add(new Pair<String, TestNode>(Pages.resources2.name(), new resource2Slot())); 2713 hm.add(new Pair<String, TestNode>(Pages.namespace.name(), new namespaceSlot())); 2714 hm.add(new Pair<String, TestNode>(Pages.splitpanebug.name(), new splitpanebugSlot())); 2715 hm.add(new Pair<String, TestNode>(Pages.charset.name(), new charsetSlot())); 2716 hm.add(new Pair<String, TestNode>(Pages.loadExceptions.name(), new loadExceptionsSlot())); 2717 hm.add(new Pair<String, TestNode>(Pages.slotDefaultLabeled.name(), new slotDefaultLabeled())); 2718 hm.add(new Pair<String, TestNode>(Pages.slotDefaultListview.name(), new slotDefaultListview())); 2719 hm.add(new Pair<String, TestNode>(Pages.slotDefaultMenu.name(), new slotDefaultMenu())); 2720 hm.add(new Pair<String, TestNode>(Pages.slotDefaultMenuBar.name(), new slotDefaultMenuBar())); 2721 hm.add(new Pair<String, TestNode>(Pages.slotDefaultScrollpane.name(), new slotDefaultScrollpane())); 2722 hm.add(new Pair<String, TestNode>(Pages.slotDefaultTabpane.name(), new slotDefaultTabpane())); 2723 hm.add(new Pair<String, TestNode>(Pages.slotDefaultTableView.name(), new slotDefaultTableview())); 2724 hm.add(new Pair<String, TestNode>(Pages.slotDefaultTextinput.name(), new slotDefaultTextinput())); 2725 hm.add(new Pair<String, TestNode>(Pages.slotDefaultTitledpane.name(), new slotDefaultTitledpane())); 2726 hm.add(new Pair<String, TestNode>(Pages.slotDefaultTreeview.name(), new slotDefaultTreeview())); 2727 hm.add(new Pair<String, TestNode>(Pages.slotDefaultImageview.name(), new slotDefaultImageview())); 2728 hm.add(new Pair<String, TestNode>(Pages.slotDefaultPane.name(), new slotDefaultPane())); 2729 hm.add(new Pair<String, TestNode>(Pages.slotControllerFactory.name(), new controllerFactoryPane())); 2730 hm.add(new Pair<String, TestNode>(Pages.specificSignatureMethod.name(), new specificSignatureMethodPane())); 2731 hm.add(new Pair<String, TestNode>(Pages.loadfontSlot.name(), new loadfontSlot())); 2732 hm.add(new Pair<String, TestNode>(Pages.scenebuilderSlot.name(), new scenebuilderSlot())); 2733 hm.add(new Pair<String, TestNode>(Pages.references2.name(), new references2Slot())); 2734 hm.add(new Pair<String, TestNode>(Pages.apConstraints.name(), new apConstraintsSlot())); 2735 hm.add(new Pair<String, TestNode>(Pages.coerce.name(), new coerceSlot())); 2736 hm.add(new Pair<String, TestNode>(Pages.listviewItems.name(), new listviewSlot())); 2737 hm.add(new Pair<String, TestNode>(Pages.listenerNullArg.name(), new listenerNullArgSlot())); 2738 hm.add(new Pair<String, TestNode>(Pages.gridapplet.name(), new gridappletSlot())); 2739 //hm.add(new Pair<String, TestNode>(Pages.csspath.name(), new csspathSlot())); 2740 hm.add(new Pair<String, TestNode>(Pages.scenebuilderNoRoot.name(), new scenebuilderNoRootSlot())); 2741 hm.add(new Pair<String, TestNode>(Pages.errorFXML.name(), new errorFXMLLoader())); 2742 hm.add(new Pair<String, TestNode>(Pages.colorValueOF.name(), new ColorValueOf())); 2743 hm.add(new Pair<String, TestNode>(Pages.escapeCharacter.name(), new EscapeCharacter())); 2744 hm.add(new Pair<String, TestNode>(Pages.collectionEventsHandlers.name(), new CollectionEventsHandlers())); 2745 hm.add(new Pair<String, TestNode>(Pages.noArgControllerMethod.name(), new NoArgsControllerMethod())); 2746 hm.add(new Pair<String, TestNode>(Pages.overloadedControllerMethod.name(), new OverloadedControllerMethod())); 2747 hm.add(new Pair<String, TestNode>(Pages.customIDProperty.name(), new CustomIDProperty())); 2748 hm.add(new Pair<String, TestNode>(Pages.unknownCustomType.name(), new UnknownCustomType())); 2749 hm.add(new Pair<String, TestNode>(Pages.baseControllerProperty.name(), new BaseColntrollerProperty())); 2750 hm.add(new Pair<String, TestNode>(Pages.relativeStylesheet.name(), new RelativeStylesheet())); 2751 hm.add(new Pair<String, TestNode>(Pages.FXMLLoaderAPI.name(), new FXMLLoaderAPI())); 2752 hm.add(new Pair<String, TestNode>(Pages.fullyQualifiedNames.name(), new FullyQualifiedNamesSlot())); 2753 hm.add(new Pair<String, TestNode>(Pages.importPI.name(), new ImportSlot())); 2754 hm.add(new Pair<String, TestNode>(Pages.beanInstantiation.name(), new BeanInstantiationSlot())); 2755 hm.add(new Pair<String, TestNode>(Pages.valueOf.name(), new ValueOfSlot())); 2756 hm.add(new Pair<String, TestNode>(Pages.root.name(), new RootSlot())); 2757 hm.add(new Pair<String, TestNode>(Pages.fxId.name(), new FxIdSlot())); 2758 hm.add(new Pair<String, TestNode>(Pages.fxController.name(), new controllerAttributeSlot())); 2759 hm.add(new Pair<String, TestNode>(Pages.noDefaultController.name(), new NoDefaultControllerSlot())); 2760 hm.add(new Pair<String, TestNode>(Pages.lateRoot.name(), new LateRootSlot())); 2761 hm.add(new Pair<String, TestNode>(Pages.lateController.name(), new LateControllerSlot())); 2762 hm.add(new Pair<String, TestNode>(Pages.variableResolution.name(), new VariableResolutionSlot())); 2763 hm.add(new Pair<String, TestNode>(Pages.externalScript.name(), new ExternalScriptCodeSlot())); 2764 2765 2766 for (Pair<String, TestNode> tn : hm) { 2767 final PageWithSlots xPage = new PageWithSlots(tn.getKey(), heightPageContentPane, widthPageContentPane); 2768 xPage.setSlotSize(240, 180); 2769 xPage.add(tn.getValue(), tn.getKey()); 2770 rootTestNode.add(xPage); 2771 2772 } 2773 return rootTestNode; 2774 2775 } 2776 2777 public static void main(String[] args) { 2778 Utils.launch(staticPropertyLoadApp.class, args); 2779 } 2780 2781 }