Wed, 07 Oct 2015 10:01:40 -0700
Merge
sundar@1241 | 1 | #// Usage: jjs -fx showsysprops.js |
sundar@1241 | 2 | |
sundar@1241 | 3 | /* |
sundar@1241 | 4 | * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
sundar@1241 | 5 | * |
sundar@1241 | 6 | * Redistribution and use in source and binary forms, with or without |
sundar@1241 | 7 | * modification, are permitted provided that the following conditions |
sundar@1241 | 8 | * are met: |
sundar@1241 | 9 | * |
sundar@1241 | 10 | * - Redistributions of source code must retain the above copyright |
sundar@1241 | 11 | * notice, this list of conditions and the following disclaimer. |
sundar@1241 | 12 | * |
sundar@1241 | 13 | * - Redistributions in binary form must reproduce the above copyright |
sundar@1241 | 14 | * notice, this list of conditions and the following disclaimer in the |
sundar@1241 | 15 | * documentation and/or other materials provided with the distribution. |
sundar@1241 | 16 | * |
sundar@1241 | 17 | * - Neither the name of Oracle nor the names of its |
sundar@1241 | 18 | * contributors may be used to endorse or promote products derived |
sundar@1241 | 19 | * from this software without specific prior written permission. |
sundar@1241 | 20 | * |
sundar@1241 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
sundar@1241 | 22 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
sundar@1241 | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
sundar@1241 | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
sundar@1241 | 25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
sundar@1241 | 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
sundar@1241 | 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
sundar@1241 | 28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
sundar@1241 | 29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
sundar@1241 | 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
sundar@1241 | 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sundar@1241 | 32 | */ |
sundar@1241 | 33 | |
sundar@1241 | 34 | if (!$OPTIONS._fx) { |
sundar@1241 | 35 | print("Usage: jjs -fx showsysprops.js"); |
sundar@1241 | 36 | exit(1); |
sundar@1241 | 37 | } |
sundar@1241 | 38 | |
sundar@1241 | 39 | // This script displays System properties as a HTML table. |
sundar@1241 | 40 | // Demonstrates heredoc to generate HTML content and display |
sundar@1241 | 41 | // using JavaFX WebView. |
sundar@1241 | 42 | |
sundar@1241 | 43 | // JavaFX, Java classes used |
sundar@1241 | 44 | var Scene = Java.type("javafx.scene.Scene"); |
sundar@1241 | 45 | var System = Java.type("java.lang.System"); |
sundar@1241 | 46 | var WebView = Java.type("javafx.scene.web.WebView"); |
sundar@1241 | 47 | |
sundar@1241 | 48 | // JavaFX start method |
sundar@1241 | 49 | function start(stage) { |
sundar@1241 | 50 | start.title = "Your System Properties"; |
sundar@1241 | 51 | var wv = new WebView(); |
sundar@1241 | 52 | var sysproprows = ""; |
sundar@1241 | 53 | var sysprops = System.properties; |
sundar@1241 | 54 | for (var i in sysprops) { |
sundar@1241 | 55 | sysproprows += <<TBL |
sundar@1241 | 56 | <tr> |
sundar@1241 | 57 | <td> |
sundar@1241 | 58 | ${i} |
sundar@1241 | 59 | </td> |
sundar@1241 | 60 | <td> |
sundar@1241 | 61 | ${sysprops[i]} |
sundar@1241 | 62 | </td> |
sundar@1241 | 63 | </tr> |
sundar@1241 | 64 | TBL |
sundar@1241 | 65 | } |
sundar@1241 | 66 | |
sundar@1241 | 67 | wv.engine.loadContent(<<EOF |
sundar@1241 | 68 | <html> |
sundar@1241 | 69 | <head> |
sundar@1241 | 70 | <title> |
sundar@1241 | 71 | Your System Properties |
sundar@1241 | 72 | </title> |
sundar@1241 | 73 | </head> |
sundar@1241 | 74 | <body> |
sundar@1241 | 75 | <h1>Your System Properties</h1> |
sundar@1241 | 76 | <table border="1"> |
sundar@1241 | 77 | ${sysproprows} |
sundar@1241 | 78 | </table> |
sundar@1241 | 79 | </body> |
sundar@1241 | 80 | </html> |
sundar@1241 | 81 | EOF, "text/html"); |
sundar@1241 | 82 | stage.scene = new Scene(wv, 750, 500); |
sundar@1241 | 83 | stage.show(); |
sundar@1241 | 84 | } |