Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pontesegger2019-07-08 17:45:00 +0000
committerChristian Pontesegger2019-07-08 17:45:00 +0000
commitec498fe2b87701f110bef045ce08b6df3b7830fd (patch)
treeb6caae954607c8db1e3fdf60832882c265f16879
parent4adb3d178a5b32b922480ed922ddaffc1d4d4aa3 (diff)
downloadorg.eclipse.ease.scripts-ec498fe2b87701f110bef045ce08b6df3b7830fd.tar.gz
org.eclipse.ease.scripts-ec498fe2b87701f110bef045ce08b6df3b7830fd.tar.xz
org.eclipse.ease.scripts-ec498fe2b87701f110bef045ce08b6df3b7830fd.zip
Bug 549074: Add UI builder examples
-rw-r--r--Demos/UI Builder Examples/.project11
-rw-r--r--Demos/UI Builder Examples/AddressBook/Address Input.js48
-rw-r--r--Demos/UI Builder Examples/AddressBook/List.js35
-rw-r--r--Demos/UI Builder Examples/Plot function.js48
-rw-r--r--Demos/UI Builder Examples/Project Info Viewer.js37
5 files changed, 179 insertions, 0 deletions
diff --git a/Demos/UI Builder Examples/.project b/Demos/UI Builder Examples/.project
new file mode 100644
index 0000000..14d63ba
--- /dev/null
+++ b/Demos/UI Builder Examples/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>UI Builder Examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/Demos/UI Builder Examples/AddressBook/Address Input.js b/Demos/UI Builder Examples/AddressBook/Address Input.js
new file mode 100644
index 0000000..dcbf2a5
--- /dev/null
+++ b/Demos/UI Builder Examples/AddressBook/Address Input.js
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+loadModule("/System/UI Builder", false);
+loadModule("/System/UI");
+loadModule('/System/Resources');
+
+createView("Create Contact");
+
+createLabel("First Name:", "1/1 >x");
+var txtFirstName = createText("2-4/1 o!");
+createLabel("Last Name:", "1/2 >x");
+var txtLastName = createText("2-4/2 o!");
+
+createLabel("Phone:", "1/3 >x");
+var txtPhone = createText("2-4/3 o!");
+
+createLabel("ZIP Code:", "1/4 >x");
+var txtZipCode = createText("2/4 o");
+
+createLabel("Country:", "3/4 >x");
+var cmbCountry = createComboViewer([ "Austria", "Germany", "India", "USA" ],
+ null, "4/4 o")
+
+createSeparator(true, "1-4/5 o")
+createButton("Save", saveAddress, "4/6 >")
+
+function saveAddress() {
+
+ var address = new Object();
+ address.lastName = executeUI("txtLastName.getText();") + "";
+ address.firstName = executeUI("txtFirstName.getText();") + "";
+ address.phone = executeUI("txtPhone.getText();") + "";
+ address.zipCode = executeUI("txtZipCode.getText();") + "";
+ address.country = executeUI("cmbCountry.getSelection().getFirstElement();")
+ + "";
+ var data = JSON.stringify(address);
+
+ writeFile("workspace://UI Builder/AddressBook/data/" + address.lastName + " "
+ + address.firstName + ".address", data);
+} \ No newline at end of file
diff --git a/Demos/UI Builder Examples/AddressBook/List.js b/Demos/UI Builder Examples/AddressBook/List.js
new file mode 100644
index 0000000..7bea137
--- /dev/null
+++ b/Demos/UI Builder Examples/AddressBook/List.js
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+loadModule('/System/Resources');
+loadModule('/System/UI Builder');
+loadModule('/System/UI');
+
+createView("Phone Numbers")
+
+var tableViewer = createTableViewer(readAddresses())
+createViewerColumn(tableViewer, "Name", createLabelProvider("getProviderElement().firstName + ' ' + getProviderElement().lastName"))
+createViewerColumn(tableViewer, "Phone", createLabelProvider("getProviderElement().phone"))
+
+executeUI("tableViewer.setInput(readAddresses())");
+
+
+function readAddresses() {
+ var addresses = new Array();
+
+ var files = findFiles("*.address");
+ for (index in files) {
+ var data = readFile(files[index]);
+ var address = JSON.parse(data);
+ addresses.push(address);
+ }
+
+ return addresses;
+} \ No newline at end of file
diff --git a/Demos/UI Builder Examples/Plot function.js b/Demos/UI Builder Examples/Plot function.js
new file mode 100644
index 0000000..9eb31e1
--- /dev/null
+++ b/Demos/UI Builder Examples/Plot function.js
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+loadModule("/System/UI Builder");
+loadModule("/System/UI");
+loadModule("/Charting");
+
+createView("Function Plot")
+
+createLabel("Function:", "1/1 > x");
+var txtFunction = createText("2-6/1 o!");
+createButton("Plot", plotFunction, "7/1 o")
+
+createLabel("Range:", "1/2 > x")
+var txtRangeFrom = createText("2/2")
+createLabel("to", "3/2 < x")
+var txtRangeTo = createText("4/2")
+createLabel("Step size", "5/2 < x")
+var txtRangeStep = createText("6/2")
+createButton("Clear", "clear()", "7/2 o")
+
+executeUI("txtRangeFrom.setText('-10')")
+executeUI("txtRangeTo.setText('10')")
+executeUI("txtRangeStep.setText('1')")
+
+chart = createChart(getComposite());
+chartComposite = addControl(chart, "1-7/3 o! o!")
+
+function plotFunction() {
+ var formula = executeUI("txtFunction.getText()");
+ var rangeFrom = parseFloat(executeUI("txtRangeFrom.getText()"))
+ var rangeTo = parseFloat(executeUI("txtRangeTo.getText()"))
+ var rangeStep = parseFloat(executeUI("txtRangeStep.getText()"))
+
+ series(formula);
+ for (var x = rangeFrom; x <= rangeTo; x += rangeStep) {
+ print("from " + x)
+ y = eval("x=" + x + ";\n" + formula);
+ plotPoint(x, y);
+ }
+} \ No newline at end of file
diff --git a/Demos/UI Builder Examples/Project Info Viewer.js b/Demos/UI Builder Examples/Project Info Viewer.js
new file mode 100644
index 0000000..f48c83b
--- /dev/null
+++ b/Demos/UI Builder Examples/Project Info Viewer.js
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+loadModule("/System/UI Builder", false);
+loadModule("/System/Resources", false);
+
+createView("Project Info")
+var viewer = createTreeViewer(getWorkspace().getProjects(), getChildren);
+createViewerColumn(viewer, "Resource", new org.eclipse.ui.model.WorkbenchLabelProvider(), 4);
+createViewerColumn(viewer, "Size", createLabelProvider(getResourceSize), 1);
+
+createComparator(viewer, "return (getProviderElement() instanceof org.eclipse.core.resources.IContainer) ? 1: 2;")
+
+function getChildren() {
+ if (getProviderElement() instanceof org.eclipse.core.resources.IContainer)
+ return getProviderElement().members();
+
+ return null;
+}
+
+function getResourceSize() {
+ print(getProviderElement())
+ if (getProviderElement() instanceof org.eclipse.core.resources.IContainer)
+ return getProviderElement().members().length;
+
+ return getProviderElement().getRawLocation().toFile().length() + " bytes";
+}
+
+
+

Back to the top