Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pontesegger2014-11-25 11:31:53 +0000
committerChristian Pontesegger2014-11-25 11:31:53 +0000
commit39b427250fee4dca7b64a771afea8702932fac5d (patch)
tree2a0222c378ddb90d5f64bf1e65d35c188b0edb92
parent3d11cec0f84f300e774bd3d6196d4f5d25dfa6bb (diff)
downloadorg.eclipse.ease.scripts-39b427250fee4dca7b64a771afea8702932fac5d.tar.gz
org.eclipse.ease.scripts-39b427250fee4dca7b64a771afea8702932fac5d.tar.xz
org.eclipse.ease.scripts-39b427250fee4dca7b64a771afea8702932fac5d.zip
added sysout and resources tutorials
-rw-r--r--JavaScript Beginner Tutorial/01 Hello world/01 Hello world.js11
-rw-r--r--JavaScript Beginner Tutorial/01 Hello world/02 Hello World UI.js11
-rw-r--r--JavaScript Beginner Tutorial/01 Hello world/03 Hello World SysOut.js14
-rw-r--r--JavaScript Beginner Tutorial/02 File IO/01 Resources API.js34
-rw-r--r--JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js28
5 files changed, 98 insertions, 0 deletions
diff --git a/JavaScript Beginner Tutorial/01 Hello world/01 Hello world.js b/JavaScript Beginner Tutorial/01 Hello world/01 Hello world.js
index fc48d4d..078c97c 100644
--- a/JavaScript Beginner Tutorial/01 Hello world/01 Hello world.js
+++ b/JavaScript Beginner Tutorial/01 Hello world/01 Hello world.js
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
// to run, right click on file in Project Explorer and select "Run As/EASE Script"
// output will be printed to the console view
print("Hello World"); \ No newline at end of file
diff --git a/JavaScript Beginner Tutorial/01 Hello world/02 Hello World UI.js b/JavaScript Beginner Tutorial/01 Hello world/02 Hello World UI.js
index cdbe3e8..808729f 100644
--- a/JavaScript Beginner Tutorial/01 Hello world/02 Hello World UI.js
+++ b/JavaScript Beginner Tutorial/01 Hello world/02 Hello World UI.js
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
// load additional UI commands
loadModule('/System/UI');
diff --git a/JavaScript Beginner Tutorial/01 Hello world/03 Hello World SysOut.js b/JavaScript Beginner Tutorial/01 Hello world/03 Hello World SysOut.js
new file mode 100644
index 0000000..343de70
--- /dev/null
+++ b/JavaScript Beginner Tutorial/01 Hello world/03 Hello World SysOut.js
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+// print to sysout
+// to use java classes, use full qualified names
+java.lang.System.out.println("Hello World");
diff --git a/JavaScript Beginner Tutorial/02 File IO/01 Resources API.js b/JavaScript Beginner Tutorial/02 File IO/01 Resources API.js
new file mode 100644
index 0000000..9e2fd3a
--- /dev/null
+++ b/JavaScript Beginner Tutorial/02 File IO/01 Resources API.js
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+// load resources module
+loadModule('/System/Resources');
+
+// get project instance
+var project = getProject("Sample Project");
+
+if (!project.exists())
+ // project does not exist, create
+ project = createProject("Sample Project");
+
+// create a file within the project
+var file = createFile("workspace://Sample Project/License.txt");
+
+// write to file, we could use the file variable instead of the location, too
+var fileHandle = writeLine("workspace://Sample Project/License.txt", "This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0.");
+
+// to continue writing, use the handle, as we otherwise would override what we have just written before
+writeLine(fileHandle, "It is available at http://www.eclipse.org/legal/epl-v10.html");
+
+// open file in editor
+loadModule('/System/UI');
+showEditor("workspace://Sample Project/License.txt");
+
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
new file mode 100644
index 0000000..b3951de
--- /dev/null
+++ b/JavaScript Beginner Tutorial/02 File IO/02 Operate on OS files.js
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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";
+// const FILE_LOCATION = "C:\\temp\\testfile.txt";
+
+// use plain java API
+var file = new java.io.File(FILE_LOCATION);
+var writer = new java.io.PrintWriter(file);
+writer.println("This is a sample file");
+writer.close();
+
+// now append using resources module
+
+// load resources module
+loadModule('/System/Resources');
+
+// open in APPEND mode, APPEND is set when loading Resources module
+var handle = openFile(FILE_LOCATION, APPEND);
+writeFile(handle, "2nd line");

Back to the top