2 // or |
2 // or |
3 // jjs -fx jsonviewer.js -- <url-of-json-doc> |
3 // jjs -fx jsonviewer.js -- <url-of-json-doc> |
4 |
4 |
5 /* |
5 /* |
6 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
6 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
7 * |
7 * |
8 * Redistribution and use in source and binary forms, with or without |
8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions |
9 * modification, are permitted provided that the following conditions |
10 * are met: |
10 * are met: |
11 * |
11 * |
12 * - Redistributions of source code must retain the above copyright |
12 * - Redistributions of source code must retain the above copyright |
13 * notice, this list of conditions and the following disclaimer. |
13 * notice, this list of conditions and the following disclaimer. |
14 * |
14 * |
15 * - Redistributions in binary form must reproduce the above copyright |
15 * - Redistributions in binary form must reproduce the above copyright |
16 * notice, this list of conditions and the following disclaimer in the |
16 * notice, this list of conditions and the following disclaimer in the |
17 * documentation and/or other materials provided with the distribution. |
17 * documentation and/or other materials provided with the distribution. |
18 * |
18 * |
19 * - Neither the name of Oracle nor the names of its |
19 * - Neither the name of Oracle nor the names of its |
20 * contributors may be used to endorse or promote products derived |
20 * contributors may be used to endorse or promote products derived |
21 * from this software without specific prior written permission. |
21 * from this software without specific prior written permission. |
22 * |
22 * |
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
24 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
24 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
50 var TreeItem = Java.type("javafx.scene.control.TreeItem"); |
50 var TreeItem = Java.type("javafx.scene.control.TreeItem"); |
51 var TreeView = Java.type("javafx.scene.control.TreeView"); |
51 var TreeView = Java.type("javafx.scene.control.TreeView"); |
52 |
52 |
53 // read text content of a URL |
53 // read text content of a URL |
54 function readTextFromURL(url) { |
54 function readTextFromURL(url) { |
55 // equivalent to |
55 // equivalent to |
56 // |
56 // |
57 // import java.io.*; |
57 // import java.io.*; |
58 // import java.net.*; |
58 // import java.net.*; |
59 // import java.lang.StringBuffer; |
59 // import java.lang.StringBuffer; |
60 // |
60 // |
61 // only inside the 'with' statement |
61 // only inside the 'with' statement |