added sample scripts from eclipseCon europe 2015 demo
diff --git a/JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js b/JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js
index b3951de..3855482 100644
--- a/JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js
+++ b/JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2014 Christian Pontesegger and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Christian Pontesegger - initial API and implementation
- ******************************************************************************/
-
+ * Copyright (c) 2014 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
// change location according to your system
const
FILE_LOCATION = "/tmp/testfile.txt";
diff --git "a/JavaScript Beginner Tutorial/02 File IO/04 Create sample project \050java API\051.js" "b/JavaScript Beginner Tutorial/02 File IO/04 Create sample project \050java API\051.js"
new file mode 100644
index 0000000..aefed08
--- /dev/null
+++ "b/JavaScript Beginner Tutorial/02 File IO/04 Create sample project \050java API\051.js"
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ * description: Script to create a sample project, not meant for productive use
+ *******************************************************************************/
+
+var projectName = "EclipseCon 2015 Sample project";
+var files = [
+ ["Disclaimer.txt", "This is the disclaimer"],
+ ["HowTo.txt", "TODO: write HowTo Content"],
+ ["License.txt", "This project is licensed under the EPL."]
+ ];
+
+print("Creating sample project");
+
+// @type org.eclipse.core.resources.IWorkspaceRoot
+wsRoot = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot();
+
+// @type org.eclipse.core.resources.IProject
+newProject = wsRoot.getProject(projectName);
+
+// create project
+if (!newProject.exists()) {
+ print("\tcreating project");
+ newProject.create(null);
+ newProject.open(null);
+} else
+ print("\tproject already exists");
+
+
+// now create files
+for each (fileDescription in files) {
+
+ // @type org.eclipse.core.resources.IFile
+ file = newProject.getFile(fileDescription[0]);
+ if (!file.exists()) {
+ print("\tcreating file " + fileDescription[0]);
+ fileInput = new java.io.ByteArrayInputStream(new java.lang.String(fileDescription[1]).getBytes());
+ file.create(fileInput, true, null);
+ } else
+ print("\tfile " + fileDescription[0] + " already exists");
+}
+
diff --git "a/JavaScript Beginner Tutorial/02 File IO/05 Create sample project \050using modules\051.js" "b/JavaScript Beginner Tutorial/02 File IO/05 Create sample project \050using modules\051.js"
new file mode 100644
index 0000000..9e4c5f8
--- /dev/null
+++ "b/JavaScript Beginner Tutorial/02 File IO/05 Create sample project \050using modules\051.js"
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+var files = [
+ ["Disclaimer.txt", "This is the disclaimer"],
+ ["HowTo.txt", "TODO: write HowTo Content"],
+ ["License.txt", "This project is licensed under the EPL."]
+ ];
+
+
+print("Creating sample project");
+
+loadModule('/System/Resources');
+loadModule('/System/UI');
+
+// create project
+projectName = showInputDialog("Please provide the name of the project to create", "EclipseCon 2015 Sample project", "Create Project");
+if (projectName != null) {
+ createProject(projectName);
+
+ // now create files
+ for each (fileDescription in files)
+ writeFile("workspace://" + projectName + "/" + fileDescription[0], fileDescription[1]);
+}
+
diff --git a/JavaScript Beginner Tutorial/03 Threading/Master.js b/JavaScript Beginner Tutorial/03 Threading/01 Master.js
similarity index 89%
rename from JavaScript Beginner Tutorial/03 Threading/Master.js
rename to JavaScript Beginner Tutorial/03 Threading/01 Master.js
index a86a4a4..e4465f8 100644
--- a/JavaScript Beginner Tutorial/03 Threading/Master.js
+++ b/JavaScript Beginner Tutorial/03 Threading/01 Master.js
@@ -19,8 +19,8 @@
setSharedObject("file", file);
// spawn 2 engines
-engineA = fork("Thread A.js");
-engineB = fork("Thread B.js", "pass, some, delimited, script arguments");
+engineA = fork("01 Thread A.js");
+engineB = fork("01 Thread B.js", "pass, some, delimited, script arguments");
// wait for engines to be terminated
join(engineA);
diff --git a/JavaScript Beginner Tutorial/03 Threading/Thread A.js b/JavaScript Beginner Tutorial/03 Threading/01 Thread A.js
similarity index 100%
rename from JavaScript Beginner Tutorial/03 Threading/Thread A.js
rename to JavaScript Beginner Tutorial/03 Threading/01 Thread A.js
diff --git a/JavaScript Beginner Tutorial/03 Threading/Thread B.js b/JavaScript Beginner Tutorial/03 Threading/01 Thread B.js
similarity index 100%
rename from JavaScript Beginner Tutorial/03 Threading/Thread B.js
rename to JavaScript Beginner Tutorial/03 Threading/01 Thread B.js
diff --git a/JavaScript Beginner Tutorial/03 Threading/02 Task start.js b/JavaScript Beginner Tutorial/03 Threading/02 Task start.js
new file mode 100644
index 0000000..973c1f0
--- /dev/null
+++ b/JavaScript Beginner Tutorial/03 Threading/02 Task start.js
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ * description: Start a timer
+ * name: Task/start
+ * toolbar: Project Explorer
+ * image: http://files.softicons.com/download/system-icons/crystal-project-icons-by-everaldo-coelho/png/16x16/actions/agt_start_here.png
+ *******************************************************************************/
+
+start = java.lang.System.currentTimeMillis();
+
+loadModule('/System/Scripting');
+setSharedObject("Task/start", start, true, true);
+
diff --git a/JavaScript Beginner Tutorial/03 Threading/02 Task stop.js b/JavaScript Beginner Tutorial/03 Threading/02 Task stop.js
new file mode 100644
index 0000000..1fcf240
--- /dev/null
+++ b/JavaScript Beginner Tutorial/03 Threading/02 Task stop.js
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ * description: Stop timer and display elapsed time
+ * name: Task/stop
+ * toolbar: Project Explorer
+ * image: http://tdiv.free.fr/stop.png
+ *******************************************************************************/
+
+loadModule('/System/UI');
+loadModule('/System/Scripting');
+
+start = getSharedObject("Task/start");
+
+if (start != null) {
+ stop = java.lang.System.currentTimeMillis();
+ showInfoDialog("Your task took " + ((stop - start)/1000) + " seconds");
+ setSharedObject("Task/start", null, true, true);
+
+} else
+ showInfoDialog("No active task available");
diff --git a/JavaScript Beginner Tutorial/04 External libraries/01 ASCII art.js b/JavaScript Beginner Tutorial/04 External libraries/01 ASCII art.js
new file mode 100644
index 0000000..13c4a4d
--- /dev/null
+++ b/JavaScript Beginner Tutorial/04 External libraries/01 ASCII art.js
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+var libraryURL = "http://central.maven.org/maven2/com/github/lalyos/jfiglet/0.0.7/jfiglet-0.0.7.jar";
+var libraryLocation = "libs/jfiglet-0.0.7.jar";
+
+
+/**
+ * Download a binary file from the web.
+ * @param link URI to download from
+ * @param targetLocation workspace location to store the file to
+ */
+function downloadLibrary(link, targetLocation) {
+ target = getFile(targetLocation, false);
+ if (!target.exists()) {
+ input = new java.net.URL(link).openStream();
+ target.create(input, true, null);
+ input.close();
+
+ } else
+ printError("target library '" + targetLocation + "' already exists.");
+}
+
+// verify that external library is available
+loadModule('/System/Resources');
+if (!fileExists(libraryLocation)) {
+ downloadLibrary(libraryURL, libraryLocation);
+
+ if (!fileExists(libraryLocation)) {
+ printError("jfiglet library not available, please download from "
+ + libraryURL);
+ exit();
+ }
+}
+
+// load external library
+loadJar(libraryLocation);
+// load directly from the web
+// loadJar(libraryURL);
+
+// draw ASCII art
+com.github.lalyos.jfiglet.FigletFont
+ .convertOneLine("I love scripting");
\ No newline at end of file
diff --git a/JavaScript Beginner Tutorial/04 External libraries/libs/readme.txt b/JavaScript Beginner Tutorial/04 External libraries/libs/readme.txt
new file mode 100644
index 0000000..3031e8d
--- /dev/null
+++ b/JavaScript Beginner Tutorial/04 External libraries/libs/readme.txt
@@ -0,0 +1,3 @@
+This directory should host a file called 'jfiglet-0.0.7.jar'.
+If it is not available and the sample script cannot download the file, try to manually fetch it from
+http://central.maven.org/maven2/com/github/lalyos/jfiglet/0.0.7/jfiglet-0.0.7.jar
\ No newline at end of file
diff --git a/JavaScript Beginner Tutorial/99 Others/01 Charting.js b/JavaScript Beginner Tutorial/99 Others/01 Charting.js
new file mode 100644
index 0000000..cb6b019
--- /dev/null
+++ b/JavaScript Beginner Tutorial/99 Others/01 Charting.js
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+loadModule('/Charting');
+loadModule('/System/Platform');
+
+var servers = ["localhost", "www.eclipse.org", "www.google.com", "www.adelaidecitycouncil.com"];
+
+figure("Ping Statistics");
+clear();
+setXLabel("Ping attempt")
+setYLabel("Time [ms]")
+
+for each (address in servers) {
+ series(address);
+ for (var count = 1; count < 20; count++) {
+
+ // run 'ping' command
+// process = runProcess("ping", [ "-c 1", address ]); // linux command style
+ process = runProcess("ping", [ "-n", "1", address ]); // windows command style
+ while (!process.isFinished())
+ ;
+
+ // parse output
+ output = process.getOutput();
+ start = output.indexOf("time=");
+ if (start != -1) {
+ end = output.indexOf("ms", start);
+ if (end != -1) {
+ time = parseFloat(output.substring(start + 5, end).trim());
+ plotPoint(count, time);
+ }
+ }
+ }
+}
diff --git a/JavaScript Beginner Tutorial/99 Others/02 Title Clock.js b/JavaScript Beginner Tutorial/99 Others/02 Title Clock.js
new file mode 100644
index 0000000..d0c2fa4
--- /dev/null
+++ b/JavaScript Beginner Tutorial/99 Others/02 Title Clock.js
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+var formatter = java.text.SimpleDateFormat("yyyy-MM-dd, HH:mm:ss")
+time = formatter.format(java.lang.System.currentTimeMillis());
+
+// change application title
+loadModule('/System/UI');
+executeUI('getShell().setText("' + time + '")');
+
+// sleep 1s
+java.lang.Thread.sleep(1000);
+
+// restart script
+loadModule('/System/Scripting');
+fork(getScriptEngine().getExecutedFile());
\ No newline at end of file
diff --git a/JavaScript Beginner Tutorial/99 Others/03 Extract HTML anchors.js b/JavaScript Beginner Tutorial/99 Others/03 Extract HTML anchors.js
new file mode 100644
index 0000000..c2c2c43
--- /dev/null
+++ b/JavaScript Beginner Tutorial/99 Others/03 Extract HTML anchors.js
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+loadModule('/System/Resources');
+
+content = readStream(new java.net.URL("http://www.eclipse.org").openStream())
+
+// convert to JS string
+content = content + "";
+
+// find anchor tags
+anchors = content.match(/<a\s*href=".*?"\s*>/g);
+
+for each (anchor in anchors)
+ print(anchor);
+
diff --git a/JavaScript Beginner Tutorial/license.html b/JavaScript Beginner Tutorial/license.html
new file mode 100644
index 0000000..f19c483
--- /dev/null
+++ b/JavaScript Beginner Tutorial/license.html
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>February 1, 2011</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and
+Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named "src" of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ ("Specification").</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology
+ on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>