author | sundar |
Thu, 12 Nov 2015 12:30:15 +0530 | |
changeset 33693 | cc0617a78522 |
parent 31924 | 243ebe5fe525 |
permissions | -rw-r--r-- |
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 showenv.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 showenv.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 environment entries 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 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 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
|
46 |
|
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 |
// 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
|
48 |
function start(stage) { |
31924
243ebe5fe525
8132305: fix incorrect title assignment in Nashorn JavaFX samples
mhaupt
parents:
29280
diff
changeset
|
49 |
stage.title = "Your Environment"; |
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
|
50 |
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
|
51 |
var envrows = ""; |
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 |
for (var i in $ENV) { |
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 |
envrows += <<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
|
54 |
<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
|
55 |
<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
|
56 |
${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
|
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 |
<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
|
59 |
${$ENV[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
|
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 |
</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
|
62 |
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
|
63 |
} |
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 |
|
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 |
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
|
66 |
<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
|
67 |
<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
|
68 |
<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
|
69 |
Your Environment |
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 |
</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
|
72 |
<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
|
73 |
<h1>Your Environment</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
|
74 |
<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
|
75 |
${envrows} |
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> |
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 |
</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
|
78 |
</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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
} |