Mon, 02 Jul 2018 16:43:07 +0100
Merge
sundar@1241 | 1 | #// Usage: jjs -fx showenv.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 showenv.js"); |
sundar@1241 | 36 | exit(1); |
sundar@1241 | 37 | } |
sundar@1241 | 38 | |
sundar@1241 | 39 | // This script displays environment entries 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 classes used |
sundar@1241 | 44 | var Scene = Java.type("javafx.scene.Scene"); |
sundar@1241 | 45 | var WebView = Java.type("javafx.scene.web.WebView"); |
sundar@1241 | 46 | |
sundar@1241 | 47 | // JavaFX start method |
sundar@1241 | 48 | function start(stage) { |
sundar@1241 | 49 | start.title = "Your Environment"; |
sundar@1241 | 50 | var wv = new WebView(); |
sundar@1241 | 51 | var envrows = ""; |
sundar@1241 | 52 | for (var i in $ENV) { |
sundar@1241 | 53 | envrows += <<TBL |
sundar@1241 | 54 | <tr> |
sundar@1241 | 55 | <td> |
sundar@1241 | 56 | ${i} |
sundar@1241 | 57 | </td> |
sundar@1241 | 58 | <td> |
sundar@1241 | 59 | ${$ENV[i]} |
sundar@1241 | 60 | </td> |
sundar@1241 | 61 | </tr> |
sundar@1241 | 62 | TBL |
sundar@1241 | 63 | } |
sundar@1241 | 64 | |
sundar@1241 | 65 | wv.engine.loadContent(<<EOF |
sundar@1241 | 66 | <html> |
sundar@1241 | 67 | <head> |
sundar@1241 | 68 | <title> |
sundar@1241 | 69 | Your Environment |
sundar@1241 | 70 | </title> |
sundar@1241 | 71 | </head> |
sundar@1241 | 72 | <body> |
sundar@1241 | 73 | <h1>Your Environment</h1> |
sundar@1241 | 74 | <table border="1"> |
sundar@1241 | 75 | ${envrows} |
sundar@1241 | 76 | </table> |
sundar@1241 | 77 | </body> |
sundar@1241 | 78 | </html> |
sundar@1241 | 79 | EOF, "text/html"); |
sundar@1241 | 80 | stage.scene = new Scene(wv, 750, 500); |
sundar@1241 | 81 | stage.show(); |
sundar@1241 | 82 | } |