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