Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo ZERR2013-09-19 18:22:39 +0000
committerPaul Webster2013-10-01 20:07:16 +0000
commit216e6bf7e2f96d11714c9276d8d479b55c8a5780 (patch)
tree10a87891e24c158ba7c9d4af417ae0c1e1f32149
parente3032de58857478f941a50a3e7bf2fbbbf2ec7c4 (diff)
downloadorg.eclipse.e4.tools-216e6bf7e2f96d11714c9276d8d479b55c8a5780.tar.gz
org.eclipse.e4.tools-216e6bf7e2f96d11714c9276d8d479b55c8a5780.tar.xz
org.eclipse.e4.tools-216e6bf7e2f96d11714c9276d8d479b55c8a5780.zip
Bug 417315 - Improve "Explorer editing CSS with orion" with SWT
OrionControl Export packages + remove .setting to .gitignore + remove extra blank in the HTMLEditor.htmljet Change-Id: I47ece36a9c9c57f789b09718dcb44b98c9514186 Signed-off-by: Angelo ZERR <angelo.zerr@gmail.com>
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/.gitignore2
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/META-INF/MANIFEST.MF8
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/build.properties2
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/plugin.properties2
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/src/org/eclipse/e4/tools/orion/css/editor/CSSEditorPreferences.java95
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/web/css.html45
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/.classpath7
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/.gitignore2
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/.project28
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/META-INF/MANIFEST.MF11
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/build.properties5
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/plugin.properties12
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/CSSEditor.java106
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/HTMLEditorTest.java44
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/JSEditor.java106
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/.classpath7
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/.gitignore2
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/.jetproperties4
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/.project34
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/META-INF/MANIFEST.MF20
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/build.properties16
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/plugin.properties12
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/AbstractHTMLBuilder.java42
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/EditorOptions.java168
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/HTMLEditor.java46
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/IHTMLBuilder.java25
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSBuilder.java56
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSEdit.java29
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSOptions.java90
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/E4CSSBuilder.java95
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSBuilder.java55
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSEdit.java25
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSOptions.java82
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/internal/Activator.java48
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/BrowserFactory.java64
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/IDirtyListener.java24
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/OrionEditorControl.java336
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/WebBrowserType.java45
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/templates/CSSEdit.jsjet (renamed from bundles/org.eclipse.e4.tools.orion.css.editor/web/swtContentAssist.js)148
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/templates/HTMLEditor.htmljet45
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/templates/JSEdit.jsjet10
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.css (renamed from bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.css)0
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.js (renamed from bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.js)0
-rw-r--r--bundles/org.eclipse.e4.tools.orion.editor/web/orion.editor.txt (renamed from bundles/org.eclipse.e4.tools.orion.css.editor/web/orion.editor.txt)1
45 files changed, 1813 insertions, 198 deletions
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/.gitignore b/bundles/org.eclipse.e4.tools.orion.css.editor/.gitignore
new file mode 100644
index 00000000..84a4913a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.e4.tools.orion.css.editor/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index c537b630..00000000
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.orion.css.editor/META-INF/MANIFEST.MF
index 86e07e9a..5f324e73 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/META-INF/MANIFEST.MF
@@ -1,6 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Editor
+Bundle-Localization: plugin
+Bundle-Vendor: %providerName
+Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.e4.tools.orion.css.editor;singleton:=true
Bundle-Version: 0.15.0.qualifier
Bundle-Activator: org.eclipse.e4.tools.orion.css.editor.Activator
@@ -9,6 +11,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.100",
org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0",
org.eclipse.e4.core.contexts;bundle-version="1.3.0",
- org.eclipse.e4.ui.workbench
+ org.eclipse.e4.ui.workbench,
+ org.eclipse.e4.tools.orion.editor
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.e4.tools.orion.css.editor
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/build.properties b/bundles/org.eclipse.e4.tools.orion.css.editor/build.properties
index b5e6bafc..c88359b8 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/build.properties
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/build.properties
@@ -4,4 +4,4 @@ bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
- web/
+ plugin.properties
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/plugin.properties b/bundles/org.eclipse.e4.tools.orion.css.editor/plugin.properties
new file mode 100644
index 00000000..44153c6d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/plugin.properties
@@ -0,0 +1,2 @@
+pluginName = CSS Orion Editor
+providerName = Eclipse.org
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/src/org/eclipse/e4/tools/orion/css/editor/CSSEditorPreferences.java b/bundles/org.eclipse.e4.tools.orion.css.editor/src/org/eclipse/e4/tools/orion/css/editor/CSSEditorPreferences.java
index 40cd283e..58c0d475 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/src/org/eclipse/e4/tools/orion/css/editor/CSSEditorPreferences.java
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/src/org/eclipse/e4/tools/orion/css/editor/CSSEditorPreferences.java
@@ -24,6 +24,9 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.tools.orion.editor.builder.css.CSSBuilder;
+import org.eclipse.e4.tools.orion.editor.builder.css.E4CSSBuilder;
+import org.eclipse.e4.tools.orion.editor.swt.OrionEditorControl;
import org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.ITheme;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
@@ -46,8 +49,7 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
ITheme selection;
IThemeEngine engine;
boolean resetCurrentTheme;
- private Browser browser;
- private String editorHtml;
+ private OrionEditorControl editor;
private String editorContent;
private Path filePath;
@@ -67,8 +69,6 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
try {
initContent();
- loadEditorHtml();
-
// Render it
Composite composite3 = new Composite(parent, SWT.BORDER);
composite3.setLayout(new FillLayout());
@@ -77,8 +77,10 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
data.heightHint = 500;
composite3.setLayoutData(data);
- browser = new Browser(composite3, SWT.NONE);
- browser.setText(editorHtml, true);
+ // Create Orion control and fill the editor with the selected CSS theme.
+ editor = new OrionEditorControl(composite3, SWT.NONE, E4CSSBuilder.getInstance());
+ editor.setText(editorContent);
+
} catch (IOException e) {
Activator
.getDefault()
@@ -89,25 +91,6 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
}
}
- private void loadEditorHtml() throws IOException {
- final Bundle bundle = Activator.getDefault().getBundle();
- final InputStream contentAssistInput = bundle.getEntry(
- "/web/swtContentAssist.js").openStream();
- String contentAssistTemplate = loadFile(contentAssistInput, 1024);
- String keywords = loadKeywords();
- String contentAssist = String.format(contentAssistTemplate, keywords);
- final InputStream cssTemplateInput = bundle.getEntry("/web/css.html")
- .openStream();
- String cssTemplate = loadFile(cssTemplateInput, 1024);
- final String editorCssUrl = FileLocator.toFileURL(
- bundle.getEntry("/web/built-editor.css")).toExternalForm();
- final String editorJsUrl = FileLocator.toFileURL(
- bundle.getEntry("/web/built-editor.js")).toExternalForm();
-
- editorHtml = String.format(cssTemplate, editorCssUrl, editorJsUrl,
- contentAssist, editorContent);
- }
-
private void initContent() throws MalformedURLException, IOException {
final ITheme theme = selection;
List<String> sheets = ((ThemeEngine) engine).getStylesheets(theme);
@@ -127,45 +110,6 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
}
}
- private String loadKeywords() {
- StringBuilder buf = new StringBuilder();
-
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- IExtensionPoint extPoint = registry
- .getExtensionPoint("org.eclipse.e4.ui.css.core.propertyHandler");
- ArrayList<IConfigurationElement> matchingElements = new ArrayList<IConfigurationElement>();
- ArrayList<IConfigurationElement> controlAdapters = new ArrayList<IConfigurationElement>();
- for (IExtension e : extPoint.getExtensions()) {
- IConfigurationElement[] elements = e.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- controlAdapters.add(element);
- IConfigurationElement[] child = element
- .getChildren("property-name");
- for (int j = 0; j < child.length; j++) {
- matchingElements.add(child[j]);
- }
- }
- }
- Iterator<IConfigurationElement> iter = matchingElements.iterator();
- boolean once = true;
- while (iter.hasNext()) {
- IConfigurationElement type = iter.next();
- String name = type.getAttribute("name");
- if (!once) {
- buf.append(',');
- buf.append('\n');
- }
- buf.append('"');
- buf.append(name);
- buf.append('"');
- once = false;
- }
- buf.append('\n');
-
- return buf.toString();
- }
-
public String loadFile(final InputStream in, final int bufferSize)
throws IOException {
final char[] buffer = new char[bufferSize];
@@ -192,9 +136,13 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
if (oldSelection != null
&& !newTheme.getId().equals(oldSelection.getId())) {
try {
- initContent();
- loadEditorHtml();
- browser.setText(editorHtml, true);
+ if (!editor.isDisposed()) {
+ // The editor is not disposed, fill the Orion editor with the selected CSS Theme..
+ initContent();
+ editor.setText(editorContent);
+ editor.setDirty(false);
+ }
+
} catch (IOException e) {
Activator
.getDefault()
@@ -209,11 +157,7 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
}
private boolean isDirty() {
- final Object rc = browser.evaluate("return window.editor.isDirty();");
- if (rc instanceof Boolean) {
- return (Boolean) rc;
- }
- return false;
+ return editor.isDirty();
}
@Override
@@ -242,8 +186,7 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
IPath path = new Path(e4CSSPath
+ System.getProperty("file.separator")
+ filePath.lastSegment());
- final Object rc = browser
- .evaluate("return window.editor.getText();");
+ final Object rc = editor.getText();
if (!(rc instanceof String)) {
Activator
.getDefault()
@@ -336,8 +279,8 @@ public class CSSEditorPreferences extends PreferencePageEnhancer {
try {
initContent();
- loadEditorHtml();
- browser.setText(editorHtml, true);
+ editor.setText(editorContent);
+ editor.setDirty(false);
} catch (IOException e) {
Activator
.getDefault()
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/web/css.html b/bundles/org.eclipse.e4.tools.orion.css.editor/web/css.html
deleted file mode 100644
index 716dd05f..00000000
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/web/css.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<html>
-<head>
-<title>Theme CSS editor</title>
-<style>
-#editor {
- border: 1px solid teal;
- position: absolute;
- top: 0px;
- left: 0px;
- bottom: 0px;
- right: 0px;
- margin: 20px;
-}
-
-pre {
- margin: 0px;
-}
-</style>
-<link rel="stylesheet" type="text/css" href="%s"/>
-<script src="%s"></script>
-<script>
-%s
-</script>
-<script>
- /*globals require*/
- require(["orion/editor/edit", "examples/editor/swtContentAssist"], function(edit, mSWTContentAssist) {
- var editor = edit({
- lang: "css"
- });
- //ADD THE SWT CONTENT ASSIST
- var contentAssist = editor.getContentAssist ? editor.getContentAssist() : editor._contentAssist;
- contentAssist.addEventListener("Activating", function() { //$NON-NLS-0$
- contentAssist.providers.push(new mSWTContentAssist.SWTContentAssistProvider());
- });
- window.editor = editor;
- //----------------
- });
-</script>
-</head>
-<body spellcheck="false">
-<pre id="editor" class="editor" data-editor-lang="css">
-%s
-</pre>
-</body>
-</html>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/.classpath b/bundles/org.eclipse.e4.tools.orion.editor.samples/.classpath
new file mode 100644
index 00000000..ad32c83a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/.gitignore b/bundles/org.eclipse.e4.tools.orion.editor.samples/.gitignore
new file mode 100644
index 00000000..84a4913a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/.project b/bundles/org.eclipse.e4.tools.orion.editor.samples/.project
new file mode 100644
index 00000000..f60b79d2
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.e4.tools.orion.editor.samples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.orion.editor.samples/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..c44eabbd
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Localization: plugin
+Bundle-Vendor: %providerName
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.e4.tools.orion.editor.samples
+Bundle-Version: 0.15.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.e4.tools.orion.editor,
+ org.eclipse.swt;bundle-version="3.102.0"
+Export-Package: org.eclipse.e4.tools.orion.swt.samples
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/build.properties b/bundles/org.eclipse.e4.tools.orion.editor.samples/build.properties
new file mode 100644
index 00000000..aa1a0082
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/plugin.properties b/bundles/org.eclipse.e4.tools.orion.editor.samples/plugin.properties
new file mode 100644
index 00000000..c75a61cd
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/plugin.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+###############################################################################
+pluginName = SWT Orion Control - Samples
+providerName = Eclipse.org
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/CSSEditor.java b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/CSSEditor.java
new file mode 100644
index 00000000..9a059163
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/CSSEditor.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.swt.samples;
+
+import java.io.File;
+
+import org.eclipse.e4.tools.orion.editor.builder.css.CSSBuilder;
+import org.eclipse.e4.tools.orion.editor.swt.IDirtyListener;
+import org.eclipse.e4.tools.orion.editor.swt.OrionEditorControl;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Java main which uses {@link OrionEditorControl} to load CSS content with Orion
+ * editor.
+ */
+public class CSSEditor {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(500, 500);
+ shell.setText("Orion CSS Editor");
+ shell.setLayout(new GridLayout());
+
+ CSSBuilder builder = new CSSBuilder(new File(
+ "../org.eclipse.e4.tools.orion.editor"), "");
+ OrionEditorControl editor = new OrionEditorControl(shell, SWT.BORDER, builder);
+ editor.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Menu
+ Menu menuBar = createMenu(shell, editor);
+ shell.setMenuBar(menuBar);
+
+ editor.setText("body {\n\tcolor:red;\n}");
+
+ shell.open();
+ editor.setFocus();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+ private static Menu createMenu(final Shell shell, final OrionEditorControl editor) {
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ // File menu
+ createFileMenu(shell, menuBar, editor);
+ return menuBar;
+ }
+
+ private static void createFileMenu(final Shell shell, Menu menuBar,
+ final OrionEditorControl editor) {
+ MenuItem fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
+ fileMenuHeader.setText("&File");
+
+ Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
+ fileMenuHeader.setMenu(fileMenu);
+
+ // Save
+ final MenuItem fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
+ fileSaveItem.setText("&Save");
+ fileSaveItem.setEnabled(false);
+ fileSaveItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ editor.setDirty(false);
+ }
+ });
+
+ editor.addDirtyListener(new IDirtyListener() {
+ public void dirtyChanged(boolean dirty) {
+ fileSaveItem.setEnabled(dirty);
+ }
+ });
+
+ // Exit
+ MenuItem fileExitItem = new MenuItem(fileMenu, SWT.PUSH);
+ fileExitItem.setText("E&xit");
+ fileExitItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ shell.close();
+ // shell.getDisplay().dispose();
+ }
+ });
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/HTMLEditorTest.java b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/HTMLEditorTest.java
new file mode 100644
index 00000000..5e9aae55
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/HTMLEditorTest.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.swt.samples;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.e4.tools.orion.editor.builder.HTMLEditor;
+import org.eclipse.e4.tools.orion.editor.builder.EditorOptions;
+import org.eclipse.e4.tools.orion.editor.builder.css.CSSEdit;
+
+/**
+ * Main which shows how to use {@link HTMLEditor} builder to generate HTML Orion
+ * editor.
+ *
+ */
+public class HTMLEditorTest {
+
+ public static void main(String[] args) throws IOException {
+ HTMLEditor builder = new HTMLEditor();
+
+ File f = new File("");
+
+ EditorOptions context = new EditorOptions(f, "css");
+
+ String keywords = "";
+ String cssEdit = new CSSEdit().generate(keywords);
+ context.addScript(cssEdit);
+
+ context.getScripts();
+
+ String s = builder.generate(context);
+ System.err.println(s);
+
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/JSEditor.java b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/JSEditor.java
new file mode 100644
index 00000000..d0f83317
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor.samples/src/org/eclipse/e4/tools/orion/swt/samples/JSEditor.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.swt.samples;
+
+import java.io.File;
+
+import org.eclipse.e4.tools.orion.editor.builder.js.JSBuilder;
+import org.eclipse.e4.tools.orion.editor.swt.IDirtyListener;
+import org.eclipse.e4.tools.orion.editor.swt.OrionEditorControl;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Java main which uses {@link OrionEditorControl} to load JS content with Orion
+ * editor.
+ */
+public class JSEditor {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(500, 500);
+ shell.setText("Orion JS Editor");
+ shell.setLayout(new GridLayout());
+
+ JSBuilder builder = new JSBuilder(new File(
+ "../org.eclipse.e4.tools.orion.editor"));
+ OrionEditorControl editor = new OrionEditorControl(shell, SWT.BORDER, builder);
+ editor.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Menu
+ Menu menuBar = createMenu(shell, editor);
+ shell.setMenuBar(menuBar);
+
+ editor.setText("var arr = [];");
+
+ shell.open();
+ editor.setFocus();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+ private static Menu createMenu(final Shell shell, final OrionEditorControl editor) {
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ // File menu
+ createFileMenu(shell, menuBar, editor);
+ return menuBar;
+ }
+
+ private static void createFileMenu(final Shell shell, Menu menuBar,
+ final OrionEditorControl editor) {
+ MenuItem fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
+ fileMenuHeader.setText("&File");
+
+ Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
+ fileMenuHeader.setMenu(fileMenu);
+
+ // Save
+ final MenuItem fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
+ fileSaveItem.setText("&Save");
+ fileSaveItem.setEnabled(false);
+ fileSaveItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ editor.setDirty(false);
+ }
+ });
+
+ editor.addDirtyListener(new IDirtyListener() {
+ public void dirtyChanged(boolean dirty) {
+ fileSaveItem.setEnabled(dirty);
+ }
+ });
+
+ // Exit
+ MenuItem fileExitItem = new MenuItem(fileMenu, SWT.PUSH);
+ fileExitItem.setText("E&xit");
+ fileExitItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ shell.close();
+ // shell.getDisplay().dispose();
+ }
+ });
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/.classpath b/bundles/org.eclipse.e4.tools.orion.editor/.classpath
new file mode 100644
index 00000000..ad32c83a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/.gitignore b/bundles/org.eclipse.e4.tools.orion.editor/.gitignore
new file mode 100644
index 00000000..84a4913a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/.jetproperties b/bundles/org.eclipse.e4.tools.orion.editor/.jetproperties
new file mode 100644
index 00000000..2907c83a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/.jetproperties
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<jet-settings>
+ <template-container>templates</template-container> <source-container>src</source-container>
+</jet-settings>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/.project b/bundles/org.eclipse.e4.tools.orion.editor/.project
new file mode 100644
index 00000000..01104f92
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.e4.tools.orion.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.emf.codegen.JETBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.emf.codegen.jet.IJETNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.orion.editor/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..fdf98eb3
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Localization: plugin
+Bundle-Vendor: %providerName
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.e4.tools.orion.editor;singleton:=true
+Bundle-Version: 0.15.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework
+Require-Bundle: org.eclipse.swt;resolution:=optional,
+ org.eclipse.rap.rwt;resolution:=optional,
+ org.eclipse.core.runtime,
+ org.apache.commons.lang;bundle-version="2.6.0"
+Export-Package: org.eclipse.e4.tools.orion.editor.builder,
+ org.eclipse.e4.tools.orion.editor.builder.css,
+ org.eclipse.e4.tools.orion.editor.builder.js,
+ org.eclipse.e4.tools.orion.editor.internal,
+ org.eclipse.e4.tools.orion.editor.swt
+Bundle-Activator: org.eclipse.e4.tools.orion.editor.internal.Activator
+Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/build.properties b/bundles/org.eclipse.e4.tools.orion.editor/build.properties
new file mode 100644
index 00000000..d605380e
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/build.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2013 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ web/,\
+ plugin.properties
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/plugin.properties b/bundles/org.eclipse.e4.tools.orion.editor/plugin.properties
new file mode 100644
index 00000000..68fd8e9d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/plugin.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+###############################################################################
+pluginName = SWT Orion Control
+providerName = Eclipse.org
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/AbstractHTMLBuilder.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/AbstractHTMLBuilder.java
new file mode 100644
index 00000000..bfab55c4
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/AbstractHTMLBuilder.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder;
+
+/**
+ * Abstract class to build the Orion HTML editor.
+ *
+ */
+public class AbstractHTMLBuilder implements IHTMLBuilder {
+
+ private final String html;
+
+ public AbstractHTMLBuilder(EditorOptions options) {
+ this.html = generateHTML(options);
+ }
+
+ @Override
+ public String getHTML() {
+ return html;
+ }
+
+ /**
+ * Generate the Orion HTML editor by using the JET template
+ * HTMLEditor.htmljet
+ *
+ * @param options
+ * the editor options.
+ * @return the Orion HTML editor.
+ */
+ private String generateHTML(EditorOptions options) {
+ HTMLEditor template = new HTMLEditor();
+ return template.generate(options);
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/EditorOptions.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/EditorOptions.java
new file mode 100644
index 00000000..4bd317f2
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/EditorOptions.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.e4.tools.orion.editor.internal.Activator;
+
+/**
+ * Editor options used in the JET template HTMLEditor.htmljet to generate Orion
+ * HTML editor.
+ *
+ */
+public class EditorOptions {
+
+ public static final String BUILT_EDITOR_JS = "/web/built-editor.js";
+ public static final String BUILT_EDITOR_CSS = "/web/built-editor.css";
+ private static final String FILE_START_URL = "file://";
+
+ private final String editorCssUrl;
+ private final String editorJsUrl;
+ private final String lang;
+ private final Collection<String> scripts;
+
+ /**
+ * Constructor of the editor options with URL of CSS and JS.
+ *
+ * @param editorJsUrl
+ * the full URL of "built-editor.js".
+ * @param editorCssUrl
+ * the full URL of "built-editor.css".
+ * @param lang
+ * the mode of the editor (css, js, html, java).
+ */
+ public EditorOptions(String editorJsUrl, String editorCssUrl, String lang) {
+ this.editorCssUrl = editorCssUrl;
+ this.editorJsUrl = editorJsUrl;
+ this.scripts = new ArrayList<String>();
+ this.lang = lang;
+ }
+
+ /**
+ * Constructor of the editor options with the base URL of CSS and JS.
+ *
+ * @param baseURL
+ * base URL of the CSS and JS.
+ * @param lang
+ * the mode of the editor (css, js, html, java).
+ */
+ public EditorOptions(String baseURL, String lang) {
+ this(baseURL + BUILT_EDITOR_JS, baseURL + BUILT_EDITOR_CSS, lang);
+ }
+
+ /**
+ * Constructor of the editor options with the file base dir of CSS and JS.
+ *
+ * @param baseDir
+ * file base directory of the CSS and JS.
+ * @param lang
+ * the mode of the editor (css, js, html, java).
+ */
+ public EditorOptions(File baseDir, String lang) {
+ this(toURL(baseDir), lang);
+ }
+
+ /**
+ * Constructor of the editor options to use only on OSGi context.
+ *
+ * @param lang
+ * the mode of the editor (css, js, html, java).
+ */
+ public EditorOptions(String lang) throws IOException {
+ this(getURL(BUILT_EDITOR_JS), getURL(BUILT_EDITOR_CSS), lang);
+ }
+
+ /**
+ * Returns the full URL of the given path.
+ *
+ * @param path
+ * path to resolve.
+ * @return the full URL of the given path.
+ * @throws IOException
+ */
+ private static String getURL(String path) throws IOException {
+ if (Activator.getContext() == null) {
+ throw new IOException("Cannot resolve the path=" + path
+ + ". This constructor must be used only on OSGi context");
+ }
+ return FileLocator.toFileURL(
+ Activator.getContext().getBundle().getEntry(path))
+ .toExternalForm();
+ }
+
+ /**
+ * Returns the file URL formatted with file://
+ *
+ * @param file
+ * the file
+ * @return the file URL formatted with file://
+ */
+ private static String toURL(File file) {
+ try {
+ return new StringBuilder(FILE_START_URL).append(
+ file.getCanonicalPath()).toString();
+ } catch (IOException e) {
+ return new StringBuilder(FILE_START_URL).append(file.getPath())
+ .toString();
+ }
+ }
+
+ /**
+ * Returns the full URL of the Orion Javascript /web/built-editor.js
+ *
+ * @return the full URL of the Orion Javascript /web/built-editor.js
+ */
+ public String getEditorCssUrl() {
+ return editorCssUrl;
+ }
+
+ /**
+ * Returns the full URL of the Orion CSS /web/built-editor.css
+ *
+ * @return the full URL of the Orion CSS /web/built-editor.css
+ */
+ public String getEditorJsUrl() {
+ return editorJsUrl;
+ }
+
+ /**
+ * Add content script.
+ *
+ * @param script
+ * the content script to add.
+ */
+ public void addScript(String script) {
+ this.scripts.add(script);
+ }
+
+ /**
+ * Returns list of script content to add.
+ *
+ * @return
+ */
+ public Collection<String> getScripts() {
+ return scripts;
+ }
+
+ /**
+ * Returns the mode of the editor (css, js, html, java).
+ *
+ * @return the mode of the editor (css, js, html, java).
+ */
+ public String getLang() {
+ return lang;
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/HTMLEditor.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/HTMLEditor.java
new file mode 100644
index 00000000..b6412fe9
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/HTMLEditor.java
@@ -0,0 +1,46 @@
+package org.eclipse.e4.tools.orion.editor.builder;
+
+public class HTMLEditor
+{
+ protected static String nl;
+ public static synchronized HTMLEditor create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ HTMLEditor result = new HTMLEditor();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "<!DOCTYPE html>" + NL + "<html>" + NL + "<head>" + NL + "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />" + NL + "<title>Theme CSS editor</title>" + NL + "<style>" + NL + "#editor {" + NL + "\t//border: 1px solid teal;" + NL + "\tposition: absolute;" + NL + "\ttop: 0px;" + NL + "\tleft: 0px;" + NL + "\tbottom: 0px;" + NL + "\tright: 0px;" + NL + "\t//margin: 20px;" + NL + "\tmargin: 0px;" + NL + "}" + NL + "" + NL + "pre {" + NL + "\tmargin: 0px;" + NL + "}" + NL + "</style>" + NL + "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
+ protected final String TEXT_2 = "\"/>" + NL + "<script src=\"";
+ protected final String TEXT_3 = "\"></script>" + NL + "" + NL + "<script>" + NL + "\tfunction setOrionEditor(editor) {" + NL + "\t window.editor = editor;" + NL + "\t if (typeof orion_onLoad == 'function') orion_onLoad();" + NL + "\t}" + NL + "</script>" + NL;
+ protected final String TEXT_4 = NL + "<script>";
+ protected final String TEXT_5 = NL;
+ protected final String TEXT_6 = NL + "</script>";
+ protected final String TEXT_7 = NL + NL + "</head>" + NL + "<body spellcheck=\"false\">" + NL + "<pre id=\"editor\" class=\"editor\" data-editor-lang=\"";
+ protected final String TEXT_8 = "\" data-editor-show-folding-ruler=\"true\" >" + NL + "</pre>" + NL + "</body>" + NL + "</html>";
+ protected final String TEXT_9 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ EditorOptions options = (EditorOptions)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( options.getEditorCssUrl() );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( options.getEditorJsUrl() );
+ stringBuffer.append(TEXT_3);
+ for (String script : options.getScripts()) {
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( script );
+ stringBuffer.append(TEXT_6);
+ }
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( options.getLang() );
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(TEXT_9);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/IHTMLBuilder.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/IHTMLBuilder.java
new file mode 100644
index 00000000..a79436ae
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/IHTMLBuilder.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder;
+
+/**
+ * API of Orion HTML Editor builder.
+ *
+ */
+public interface IHTMLBuilder {
+
+ /**
+ * Returns the HTML of the Orion editor.
+ *
+ * @return
+ */
+ String getHTML();
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSBuilder.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSBuilder.java
new file mode 100644
index 00000000..b2e5abf1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSBuilder.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder.css;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.e4.tools.orion.editor.builder.AbstractHTMLBuilder;
+import org.eclipse.e4.tools.orion.editor.builder.IHTMLBuilder;
+
+/**
+ * {@link IHTMLBuilder} to build the Orion HTML editor for CSS mode.
+ *
+ */
+public class CSSBuilder extends AbstractHTMLBuilder {
+
+ /**
+ * Constructor with {@link CSSOptions}.
+ *
+ * @param options
+ * the CSS options.
+ */
+ public CSSBuilder(CSSOptions options) {
+ super(options);
+ }
+
+ /**
+ * Constructor with file base dir.
+ *
+ * @param baseDir
+ * base directory of the CSS and JS.
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public CSSBuilder(File baseDir, String keywords) {
+ this(new CSSOptions(baseDir, keywords));
+ }
+
+ /**
+ * Constructor to use only on OSGi context.
+ *
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public CSSBuilder(String keywords) throws IOException {
+ this(new CSSOptions(keywords));
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSEdit.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSEdit.java
new file mode 100644
index 00000000..adc3f947
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSEdit.java
@@ -0,0 +1,29 @@
+package org.eclipse.e4.tools.orion.editor.builder.css;
+
+public class CSSEdit
+{
+ protected static String nl;
+ public static synchronized CSSEdit create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CSSEdit result = new CSSEdit();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "" + NL + "/*global define */" + NL + "" + NL + "define('examples/editor/swtContentAssist', [ //$NON-NLS-0$" + NL + "\t'orion/editor/templates' //$NON-NLS-0$" + NL + "], function(mTemplates) {" + NL + "" + NL + "\tvar colorValues = {" + NL + "\t\ttype: \"link\", //$NON-NLS-0$" + NL + "\t\tvalues: [" + NL + "\t\t\t\"COLOR_BLACK\", //$NON-NLS-0$" + NL + "\t\t\t\"COLOR_INFO_BACKGROUND\", //$NON-NLS-0$" + NL + "\t\t\t\"black\", //$NON-NLS-0$" + NL + "\t\t\t\"white\", //$NON-NLS-0$" + NL + "\t\t\t\"red\", //$NON-NLS-0$" + NL + "\t\t\t\"green\", //$NON-NLS-0$" + NL + "\t\t\t\"blue\", //$NON-NLS-0$" + NL + "\t\t\t\"magenta\", //$NON-NLS-0$" + NL + "\t\t\t\"yellow\", //$NON-NLS-0$" + NL + "\t\t\t\"cyan\", //$NON-NLS-0$" + NL + "\t\t\t\"grey\", //$NON-NLS-0$" + NL + "\t\t\t\"darkred\", //$NON-NLS-0$" + NL + "\t\t\t\"darkgreen\", //$NON-NLS-0$" + NL + "\t\t\t\"darkblue\", //$NON-NLS-0$" + NL + "\t\t\t\"darkmagenta\", //$NON-NLS-0$" + NL + "\t\t\t\"darkcyan\", //$NON-NLS-0$" + NL + "\t\t\t\"darkyellow\", //$NON-NLS-0$" + NL + "\t\t\t\"darkgray\", //$NON-NLS-0$" + NL + "\t\t\t\"lightgray\" //$NON-NLS-0$" + NL + "\t\t]" + NL + "\t};" + NL + "\tfunction fromJSON(o) {" + NL + "\t\treturn JSON.stringify(o).replace(\"}\", \"\\\\}\"); //$NON-NLS-1$ //$NON-NLS-0$" + NL + "\t}" + NL + "\tvar templates = [" + NL + "\t\t{" + NL + "\t\t\tprefix: \"swt-outer-keyline-color\", //$NON-NLS-0$" + NL + "\t\t\tdescription: \"ctab folder keyline - keyline color\", //$NON-NLS-0$" + NL + "\t\t\ttemplate: \"swt-outer-keyline-color: ${color:\" + fromJSON(colorValues) + \"};\" //$NON-NLS-1$ //$NON-NLS-0$" + NL + "\t\t}," + NL + "\t\t{" + NL + "\t\t\tprefix: \"frame-image\", //$NON-NLS-0$" + NL + "\t\t\tdescription: \"image - the frame image\", //$NON-NLS-0$" + NL + "\t\t\ttemplate: \"frame-image: url(\\\"${uri}\\\");\" //$NON-NLS-0$" + NL + "\t\t}" + NL + "\t];" + NL + "\tvar keywords = [" + NL + "\t\t";
+ protected final String TEXT_2 = NL + "\t];" + NL + "" + NL + "\tfunction SWTContentAssistProvider() {" + NL + "\t}" + NL + "\tSWTContentAssistProvider.prototype = new mTemplates.TemplateContentAssist(keywords, templates);" + NL + "\t" + NL + "\tSWTContentAssistProvider.prototype.getPrefix = function(buffer, offset, context) {" + NL + "\t\tvar index = offset;" + NL + "\t\twhile (index && /[A-Za-z\\-\\@]/.test(buffer.charAt(index - 1))) {" + NL + "\t\t\tindex--;" + NL + "\t\t}" + NL + "\t\treturn index ? buffer.substring(index, offset) : \"\";" + NL + "\t};" + NL + "" + NL + "\treturn {" + NL + "\t\tSWTContentAssistProvider: SWTContentAssistProvider" + NL + "\t};" + NL + "});" + NL + "" + NL + "/*globals require*/" + NL + "require([\"orion/editor/edit\", \"examples/editor/swtContentAssist\"], function(edit, mSWTContentAssist) {" + NL + "\tvar editor = edit({" + NL + "\t\tlang: \"css\"" + NL + "\t});" + NL + "\t//ADD THE SWT CONTENT ASSIST" + NL + "\tvar contentAssist = editor.getContentAssist ? editor.getContentAssist() : editor._contentAssist;" + NL + "\tcontentAssist.addEventListener(\"Activating\", function() { //$NON-NLS-0$" + NL + "\t\tcontentAssist.providers.push(new mSWTContentAssist.SWTContentAssistProvider());" + NL + "\t});" + NL + "\tsetOrionEditor(editor);" + NL + "\t//----------------" + NL + "});";
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ String keywords = (String)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( keywords );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSOptions.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSOptions.java
new file mode 100644
index 00000000..69adcad1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/CSSOptions.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder.css;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.e4.tools.orion.editor.builder.EditorOptions;
+
+/**
+ * CSS Editor options.
+ *
+ */
+public class CSSOptions extends EditorOptions {
+
+ private static final String CSS_LANG = "css";
+
+ /**
+ * Constructor of the editor options with URL of CSS and JS.
+ *
+ * @param editorJsUrl
+ * the full URL of "built-editor.js".
+ * @param editorCssUrl
+ * the full URL of "built-editor.css".
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public CSSOptions(String editorJsUrl, String editorCssUrl, String keywords) {
+ super(editorJsUrl, editorCssUrl, CSS_LANG);
+ createEditor(keywords);
+ }
+
+ /**
+ * Constructor of the editor options with the base URL of CSS and JS.
+ *
+ * @param baseURL
+ * base URL of the CSS and JS.
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public CSSOptions(String baseURL, String keywords) {
+ super(baseURL, CSS_LANG);
+ createEditor(keywords);
+ }
+
+ /**
+ * Constructor of the editor options with the file base dir of CSS and JS.
+ *
+ * @param baseDir
+ * file base directory of the CSS and JS.
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public CSSOptions(File baseDir, String keywords) {
+ super(baseDir, CSS_LANG);
+ createEditor(keywords);
+ }
+
+ /**
+ * Constructor of the editor options to use only on OSGi context.
+ *
+ * @param keywords
+ * to customize CSS completion.
+ * @throws IOException
+ */
+ public CSSOptions(String keywords) throws IOException {
+ super(CSS_LANG);
+ createEditor(keywords);
+ }
+
+ /**
+ * Create the Orion editor with edit function.
+ *
+ * @param keywords
+ * to customize CSS completion.
+ */
+ private void createEditor(String keywords) {
+ String cssEdit = new CSSEdit().generate(keywords);
+ super.addScript(cssEdit);
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/E4CSSBuilder.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/E4CSSBuilder.java
new file mode 100644
index 00000000..d29f9ee1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/css/E4CSSBuilder.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder.css;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.RegistryFactory;
+
+/**
+ * Build the Orion HTML editor for CSS mode with E4 CSS selectors.
+ *
+ */
+public class E4CSSBuilder extends CSSBuilder {
+
+ private static E4CSSBuilder instance;
+
+ /**
+ * Returns an instance of E4CSSBuilder. Since instances of this class do not
+ * maintain any state, they can be shared between multiple clients.
+ *
+ * @return an instance of E4CSSBuilder
+ * @throws IOException
+ */
+ public static E4CSSBuilder getInstance() throws IOException {
+ synchronized (E4CSSBuilder.class) {
+ if (instance == null) {
+ instance = new E4CSSBuilder();
+ }
+ return instance;
+ }
+ }
+
+ public E4CSSBuilder() throws IOException {
+ super(loadKeywords());
+ }
+
+ /**
+ * Returns keywords for CSS completion with E4 CSS Engine properties to
+ * customize completion;
+ *
+ * @return keywords for CSS completion with E4 CSS Engine properties.
+ */
+ private static String loadKeywords() {
+ StringBuilder buf = new StringBuilder();
+
+ IExtensionRegistry registry = RegistryFactory.getRegistry();
+ IExtensionPoint extPoint = registry
+ .getExtensionPoint("org.eclipse.e4.ui.css.core.propertyHandler");
+ ArrayList<IConfigurationElement> matchingElements = new ArrayList<IConfigurationElement>();
+ ArrayList<IConfigurationElement> controlAdapters = new ArrayList<IConfigurationElement>();
+ for (IExtension e : extPoint.getExtensions()) {
+ IConfigurationElement[] elements = e.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ controlAdapters.add(element);
+ IConfigurationElement[] child = element
+ .getChildren("property-name");
+ for (int j = 0; j < child.length; j++) {
+ matchingElements.add(child[j]);
+ }
+ }
+ }
+ Iterator<IConfigurationElement> iter = matchingElements.iterator();
+ boolean once = true;
+ while (iter.hasNext()) {
+ IConfigurationElement type = iter.next();
+ String name = type.getAttribute("name");
+ if (!once) {
+ buf.append(',');
+ buf.append('\n');
+ }
+ buf.append('"');
+ buf.append(name);
+ buf.append('"');
+ once = false;
+ }
+ buf.append('\n');
+
+ return buf.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSBuilder.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSBuilder.java
new file mode 100644
index 00000000..04c495c3
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSBuilder.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder.js;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.e4.tools.orion.editor.builder.AbstractHTMLBuilder;
+import org.eclipse.e4.tools.orion.editor.builder.IHTMLBuilder;
+
+/**
+ * {@link IHTMLBuilder} to build the Orion HTML editor for JS mode.
+ *
+ */
+public class JSBuilder extends AbstractHTMLBuilder {
+
+ /**
+ * Constructor with {@link JSOptions}.
+ *
+ * @param options
+ * the JS options.
+ */
+ public JSBuilder(JSOptions options) {
+ super(options);
+ }
+
+ /**
+ * Constructor with file base dir.
+ *
+ * @param baseDir
+ * base directory of the CSS and JS.
+ */
+ public JSBuilder(File baseDir) {
+ this(new JSOptions(baseDir));
+ }
+
+ /**
+ * Constructor to use only on OSGi context.
+ *
+ * @throws IOException
+ *
+ */
+ public JSBuilder() throws IOException {
+ this(new JSOptions());
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSEdit.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSEdit.java
new file mode 100644
index 00000000..1ff0abf5
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSEdit.java
@@ -0,0 +1,25 @@
+package org.eclipse.e4.tools.orion.editor.builder.js;
+
+public class JSEdit
+{
+ protected static String nl;
+ public static synchronized JSEdit create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ JSEdit result = new JSEdit();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = NL + "/*globals require*/" + NL + "require([\"orion/editor/edit\"], function(edit) {" + NL + "\tvar editor = edit({" + NL + "\t\tlang: \"js\"" + NL + "\t});" + NL + "\tsetOrionEditor(editor);" + NL + "\t//----------------" + NL + "});";
+ protected final String TEXT_2 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSOptions.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSOptions.java
new file mode 100644
index 00000000..5d5b344e
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/builder/js/JSOptions.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.builder.js;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.e4.tools.orion.editor.builder.EditorOptions;
+
+/**
+ * JS Editor options.
+ *
+ */
+public class JSOptions extends EditorOptions {
+
+ private static final String JS_LANG = "js";
+
+ /**
+ * Constructor of the editor options with URL of CSS and JS.
+ *
+ * @param editorJsUrl
+ * the full URL of "built-editor.js".
+ * @param editorCssUrl
+ * the full URL of "built-editor.css".
+ */
+ public JSOptions(String editorJsUrl, String editorCssUrl) {
+ super(editorJsUrl, editorCssUrl, JS_LANG);
+ createEditor();
+ }
+
+ /**
+ * Constructor of the editor options with the base URL of CSS and JS.
+ *
+ * @param baseURL
+ * base URL of the CSS and JS.
+ */
+ public JSOptions(String baseURL) {
+ super(baseURL, JS_LANG);
+ createEditor();
+ }
+
+ /**
+ * Constructor of the editor options with the file base dir of CSS and JS.
+ *
+ * @param keywords
+ * to customize CSS completion.
+ */
+ public JSOptions(File baseDir) {
+ super(baseDir, JS_LANG);
+ createEditor();
+ }
+
+ /**
+ * Constructor of the editor options to use only on OSGi context.
+ *
+ * @throws IOException
+ */
+ public JSOptions() throws IOException {
+ super(JS_LANG);
+ createEditor();
+ }
+
+ /**
+ * Create the Orion editor with edit function.
+ *
+ * @param keywords
+ * to customize CSS completion.
+ */
+ private void createEditor() {
+ String jsEdit = new JSEdit().generate(null);
+ super.addScript(jsEdit);
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/internal/Activator.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/internal/Activator.java
new file mode 100644
index 00000000..7d699792
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/internal/Activator.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.internal;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/BrowserFactory.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/BrowserFactory.java
new file mode 100644
index 00000000..3d62a258
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/BrowserFactory.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * SWT {@link Browser} factory.
+ *
+ * With this factory it's possible to set the default browser style to create
+ * (for instance with a Preferences Page).
+ *
+ */
+public class BrowserFactory {
+
+ private static int defaultBrowserStyle = SWT.NONE;
+
+ /**
+ * Set the default browser style.
+ *
+ * @param defaultBrowserStyle
+ */
+ public static void setDefaultBrowserStyle(int defaultBrowserStyle) {
+ BrowserFactory.defaultBrowserStyle = defaultBrowserStyle;
+ }
+
+ /**
+ * Returns the default browser style.
+ *
+ * @return
+ */
+ public static int getDefaultBrowserStyle() {
+ return defaultBrowserStyle;
+ }
+
+ /**
+ * Create an instance of SWT {@link Browser}.
+ *
+ * @param parent
+ * a widget which will be the parent of the new instance (cannot
+ * be null)
+ * @param style
+ * the style of widget to construct. If null use the default.
+ * style
+ * @return an instance of SWT {@link Browser}.
+ */
+ public static Browser create(Composite parent, Integer style) {
+ if (style == null) {
+ // none style, use the default style.
+ style = getDefaultBrowserStyle();
+ }
+ return new Browser(parent, style);
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/IDirtyListener.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/IDirtyListener.java
new file mode 100644
index 00000000..9f7e04bc
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/IDirtyListener.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.swt;
+
+/**
+ * Listener to observe the dirty changed.
+ */
+public interface IDirtyListener {
+
+ /**
+ * call when dirty changed.
+ *
+ * @param dirty
+ */
+ void dirtyChanged(boolean dirty);
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/OrionEditorControl.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/OrionEditorControl.java
new file mode 100644
index 00000000..d6ab01f2
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/OrionEditorControl.java
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.swt;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.e4.tools.orion.editor.builder.IHTMLBuilder;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Layout;
+
+/**
+ * SWT Orion Editor control.
+ *
+ */
+public class OrionEditorControl extends Composite {
+
+ /**
+ * The SWT Browser which loads the HTML Orion editor.
+ */
+ private final Browser browser;
+
+ /**
+ * True when Orion editor is loaded and flase otherwise.
+ */
+ private boolean loaded;
+
+ /**
+ * Dirty listener.
+ */
+ private ListenerList dirtyListeners;
+
+ /**
+ * Text to set for Orion the editor although the editor is not loaded.
+ */
+ private String textToBeSet;
+
+ /**
+ * True if focus should be set for Orion the editor although the editor is
+ * not loaded.
+ */
+ private Boolean focusToBeSet;
+
+ /**
+ * Not null if dirty should be set for Orion the editor although the editor
+ * is not loaded.
+ */
+ private Boolean dirtyToBeSet;
+
+ /**
+ * Orion control constructor.
+ *
+ * @param parent
+ * widget which will be the parent of the new instance (cannot be
+ * null)
+ * @param style
+ * the style of the composite which wraps the SWT Browser.
+ * @param builder
+ * the HTML builder to use to load the Orion editor with SWT
+ * Browser.
+ */
+ public OrionEditorControl(Composite parent, int style, IHTMLBuilder builder) {
+ super(parent, style);
+ super.setLayout(new FillLayout());
+ this.browser = BrowserFactory.create(this, getBrowserStyle());
+ // System.err.println(builder.getHTML());
+ browser.setText(builder.getHTML());
+ createBrowserFunctions();
+ }
+
+ /**
+ * Create Broser functions.
+ */
+ protected void createBrowserFunctions() {
+ // onload function
+ new BrowserFunction(browser, "orion_onLoad") {
+ public Object function(Object[] arguments) {
+ onLoad();
+ return null;
+ }
+ };
+ // dirty function
+ new BrowserFunction(browser, "orion_dirty") {
+ public Object function(Object[] arguments) {
+ notifyDirtyListeners();
+ return null;
+ }
+ };
+ }
+
+ /**
+ * Returns the Browser style to use.
+ *
+ * @return the Browser style to use.
+ */
+ protected Integer getBrowserStyle() {
+ return null;
+ }
+
+ @Override
+ public void setLayout(Layout layout) {
+ throw new UnsupportedOperationException(
+ "Cannot change internal layout of Editor");
+ }
+
+ // ------------------------- Load methods -----------------------
+
+ /**
+ * Callback called when Orion editor is loaded.
+ */
+ protected void onLoad() {
+ loaded = true;
+ // Set text if need
+ if (textToBeSet != null) {
+ setText(textToBeSet);
+ textToBeSet = null;
+ }
+ // Set focus if need
+ if (focusToBeSet != null) {
+ if (focusToBeSet) {
+ browser.evaluate("editor.focus();");
+ }
+ focusToBeSet = null;
+ }
+ // add dirty event listener.
+ browser.evaluate("window.editor.addEventListener('DirtyChanged', orion_dirty, true)");
+ // Set dirty if need
+ if (dirtyToBeSet != null) {
+ setDirty(dirtyToBeSet);
+ dirtyToBeSet = null;
+ }
+ }
+
+ /**
+ * Returns true if Orion editor is loaded and false otherwise.
+ *
+ * @return
+ */
+ public boolean isLoaded() {
+ return loaded;
+ }
+
+ // ------------------------- Text methods -----------------------
+
+ /**
+ * Set the text in the Orion editor.
+ *
+ * @param text
+ * the text to set.
+ */
+ public void setText(String text) {
+ if (text == null || text.length() == 0) {
+ text = "";
+ }
+
+ if (isLoaded()) {
+ // orion editor is loaded, set the text in the editor
+ doSetText(text);
+ } else {
+ // Orion editor is not loaded, set the text in the textToBeSet
+ textToBeSet = text;
+ }
+ }
+
+ /**
+ * Set text in the Orion editor by using Javascript function editor.setInput
+ *
+ * @param text
+ * the text to set.
+ */
+ protected void doSetText(String text) {
+ String js = new StringBuilder("window.editor.setInput(null, null, \"")
+ .append(StringEscapeUtils.escapeJavaScript(text))
+ .append("\", false );").toString();
+ browser.evaluate(js);
+ }
+
+ /**
+ * Returns the text of the Orion editor.
+ *
+ * @return
+ */
+ public String getText() {
+ if (!isLoaded()) {
+ if (textToBeSet != null) {
+ return textToBeSet;
+ } else {
+ return "";
+ }
+ }
+ return doGetText();
+ }
+
+ /**
+ * Returns the text of the Orion editor by using Javascript function
+ * editor.getText
+ *
+ * @return the text of the Orion editor by using Javascript function
+ * editor.getText
+ */
+ private String doGetText() {
+ return (String) browser.evaluate("return editor.getText();");
+ }
+
+ // ------------------------- Focus methods -----------------------
+
+ @Override
+ public boolean setFocus() {
+ boolean result = browser.setFocus();
+ if (result) {
+ if (isLoaded()) {
+ browser.evaluate("window.editor.focus();");
+ } else {
+ focusToBeSet = true;
+ }
+ }
+ return result;
+ }
+
+ // ------------------------- Dirty methods -----------------------
+
+ /**
+ * Add dirty listener.
+ *
+ * @param listener
+ * dirty listener to add.
+ */
+ public void addDirtyListener(IDirtyListener dirtyListener) {
+ if (dirtyListener == null) {
+ throw new NullPointerException("Cannot add a null dirty listener"); //$NON-NLS-1$
+ }
+ if (dirtyListeners == null) {
+ dirtyListeners = new ListenerList(ListenerList.IDENTITY);
+ }
+ dirtyListeners.add(dirtyListener);
+
+ }
+
+ /**
+ * Remove dirty listener.
+ *
+ * @param listener
+ * dirty listener to remove.
+ */
+ public void removeDirtyListener(IDirtyListener dirtyListener) {
+ if (dirtyListener == null) {
+ throw new NullPointerException(
+ "Cannot remove a null dirty listener"); //$NON-NLS-1$
+ }
+
+ if (dirtyListeners != null) {
+ dirtyListeners.remove(dirtyListener);
+ if (dirtyListeners.isEmpty()) {
+ dirtyListeners = null;
+ }
+ }
+ }
+
+ /**
+ * Notify dirty listeners if need.
+ */
+ private void notifyDirtyListeners() {
+ if (dirtyListeners == null) {
+ return;
+ }
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ boolean dirty = isDirty();
+ final Object[] listeners = dirtyListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ IDirtyListener dirtyListener = (IDirtyListener) listeners[i];
+ dirtyListener.dirtyChanged(dirty);
+ }
+ }
+ });
+ }
+
+ /**
+ * Set the dirty flag.
+ *
+ * @param dirty
+ * the dirty flag.
+ */
+ public void setDirty(boolean dirty) {
+ if (isLoaded()) {
+ // orion editor is loaded, set the dirty in the editor
+ doSetDirty(dirty);
+ } else {
+ // Orion editor is not loaded, set the dirty in the dirtyToBeSet
+ dirtyToBeSet = dirty;
+ }
+ }
+
+ /**
+ * Set the dirty flag in the orion editor with Javascript function
+ * editor.setDirty.
+ *
+ * @param dirty
+ * the dirty flag.
+ */
+ public void doSetDirty(boolean dirty) {
+ String js = new StringBuilder("window.editor.setDirty(").append(dirty)
+ .append(");").toString();
+ browser.evaluate(js);
+ }
+
+ /**
+ * Returns true if Orion control is dirty and false otherwise.
+ *
+ * @return true if Orion control is dirty and false otherwise.
+ */
+ public boolean isDirty() {
+ if (!isLoaded()) {
+ if (dirtyToBeSet != null) {
+ return dirtyToBeSet;
+ }
+ return false;
+ }
+ final Object rc = browser.evaluate("return window.editor.isDirty();");
+ if (rc instanceof Boolean) {
+ return (Boolean) rc;
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/WebBrowserType.java b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/WebBrowserType.java
new file mode 100644
index 00000000..3b50c7e1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/src/org/eclipse/e4/tools/orion/editor/swt/WebBrowserType.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Angelo Zerr 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.tools.orion.editor.swt;
+
+import org.eclipse.swt.SWT;
+
+/**
+ * Web Browser type.
+ *
+ */
+public enum WebBrowserType {
+
+ Mozilla(SWT.MOZILLA), WebKit(SWT.WEBKIT), Default(SWT.NONE);
+
+ private final int style;
+
+ private WebBrowserType(int style) {
+ this.style = style;
+ }
+
+ public int getStyle() {
+ return style;
+ }
+
+ public String getName() {
+ return name();
+ }
+
+ public static WebBrowserType getWebBrowserType(String name) {
+ for (WebBrowserType browserType : values()) {
+ if (browserType.getName().equals(name)) {
+ return browserType;
+ }
+ }
+ return WebBrowserType.Default;
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/web/swtContentAssist.js b/bundles/org.eclipse.e4.tools.orion.editor/templates/CSSEdit.jsjet
index b371f6dd..b140083c 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/web/swtContentAssist.js
+++ b/bundles/org.eclipse.e4.tools.orion.editor/templates/CSSEdit.jsjet
@@ -1,66 +1,82 @@
-
-/*global define */
-
-define('examples/editor/swtContentAssist', [ //$NON-NLS-0$
- 'orion/editor/templates' //$NON-NLS-0$
-], function(mTemplates) {
-
- var colorValues = {
- type: "link", //$NON-NLS-0$
- values: [
- "COLOR_BLACK", //$NON-NLS-0$
- "COLOR_INFO_BACKGROUND", //$NON-NLS-0$
- "black", //$NON-NLS-0$
- "white", //$NON-NLS-0$
- "red", //$NON-NLS-0$
- "green", //$NON-NLS-0$
- "blue", //$NON-NLS-0$
- "magenta", //$NON-NLS-0$
- "yellow", //$NON-NLS-0$
- "cyan", //$NON-NLS-0$
- "grey", //$NON-NLS-0$
- "darkred", //$NON-NLS-0$
- "darkgreen", //$NON-NLS-0$
- "darkblue", //$NON-NLS-0$
- "darkmagenta", //$NON-NLS-0$
- "darkcyan", //$NON-NLS-0$
- "darkyellow", //$NON-NLS-0$
- "darkgray", //$NON-NLS-0$
- "lightgray" //$NON-NLS-0$
- ]
- };
- function fromJSON(o) {
- return JSON.stringify(o).replace("}", "\\}"); //$NON-NLS-1$ //$NON-NLS-0$
- }
- var templates = [
- {
- prefix: "swt-outer-keyline-color", //$NON-NLS-0$
- description: "ctab folder keyline - keyline color", //$NON-NLS-0$
- template: "swt-outer-keyline-color: ${color:" + fromJSON(colorValues) + "};" //$NON-NLS-1$ //$NON-NLS-0$
- },
- {
- prefix: "frame-image", //$NON-NLS-0$
- description: "image - the frame image", //$NON-NLS-0$
- template: "frame-image: url(\"${uri}\");" //$NON-NLS-0$
- }
- ];
- var keywords = [
- %s
- ];
-
- function SWTContentAssistProvider() {
- }
- SWTContentAssistProvider.prototype = new mTemplates.TemplateContentAssist(keywords, templates);
-
- SWTContentAssistProvider.prototype.getPrefix = function(buffer, offset, context) {
- var index = offset;
- while (index && /[A-Za-z\-\@]/.test(buffer.charAt(index - 1))) {
- index--;
- }
- return index ? buffer.substring(index, offset) : "";
- };
-
- return {
- SWTContentAssistProvider: SWTContentAssistProvider
- };
-}); \ No newline at end of file
+<%@ jet package="org.eclipse.e4.tools.orion.editor.builder.css" class="CSSEdit" %>
+<% String keywords = (String)argument; %>
+
+/*global define */
+
+define('examples/editor/swtContentAssist', [ //$NON-NLS-0$
+ 'orion/editor/templates' //$NON-NLS-0$
+], function(mTemplates) {
+
+ var colorValues = {
+ type: "link", //$NON-NLS-0$
+ values: [
+ "COLOR_BLACK", //$NON-NLS-0$
+ "COLOR_INFO_BACKGROUND", //$NON-NLS-0$
+ "black", //$NON-NLS-0$
+ "white", //$NON-NLS-0$
+ "red", //$NON-NLS-0$
+ "green", //$NON-NLS-0$
+ "blue", //$NON-NLS-0$
+ "magenta", //$NON-NLS-0$
+ "yellow", //$NON-NLS-0$
+ "cyan", //$NON-NLS-0$
+ "grey", //$NON-NLS-0$
+ "darkred", //$NON-NLS-0$
+ "darkgreen", //$NON-NLS-0$
+ "darkblue", //$NON-NLS-0$
+ "darkmagenta", //$NON-NLS-0$
+ "darkcyan", //$NON-NLS-0$
+ "darkyellow", //$NON-NLS-0$
+ "darkgray", //$NON-NLS-0$
+ "lightgray" //$NON-NLS-0$
+ ]
+ };
+ function fromJSON(o) {
+ return JSON.stringify(o).replace("}", "\\}"); //$NON-NLS-1$ //$NON-NLS-0$
+ }
+ var templates = [
+ {
+ prefix: "swt-outer-keyline-color", //$NON-NLS-0$
+ description: "ctab folder keyline - keyline color", //$NON-NLS-0$
+ template: "swt-outer-keyline-color: ${color:" + fromJSON(colorValues) + "};" //$NON-NLS-1$ //$NON-NLS-0$
+ },
+ {
+ prefix: "frame-image", //$NON-NLS-0$
+ description: "image - the frame image", //$NON-NLS-0$
+ template: "frame-image: url(\"${uri}\");" //$NON-NLS-0$
+ }
+ ];
+ var keywords = [
+ <%= keywords %>
+ ];
+
+ function SWTContentAssistProvider() {
+ }
+ SWTContentAssistProvider.prototype = new mTemplates.TemplateContentAssist(keywords, templates);
+
+ SWTContentAssistProvider.prototype.getPrefix = function(buffer, offset, context) {
+ var index = offset;
+ while (index && /[A-Za-z\-\@]/.test(buffer.charAt(index - 1))) {
+ index--;
+ }
+ return index ? buffer.substring(index, offset) : "";
+ };
+
+ return {
+ SWTContentAssistProvider: SWTContentAssistProvider
+ };
+});
+
+/*globals require*/
+require(["orion/editor/edit", "examples/editor/swtContentAssist"], function(edit, mSWTContentAssist) {
+ var editor = edit({
+ lang: "css"
+ });
+ //ADD THE SWT CONTENT ASSIST
+ var contentAssist = editor.getContentAssist ? editor.getContentAssist() : editor._contentAssist;
+ contentAssist.addEventListener("Activating", function() { //$NON-NLS-0$
+ contentAssist.providers.push(new mSWTContentAssist.SWTContentAssistProvider());
+ });
+ setOrionEditor(editor);
+ //----------------
+});
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/templates/HTMLEditor.htmljet b/bundles/org.eclipse.e4.tools.orion.editor/templates/HTMLEditor.htmljet
new file mode 100644
index 00000000..f202c7f6
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/templates/HTMLEditor.htmljet
@@ -0,0 +1,45 @@
+<%@ jet package="org.eclipse.e4.tools.orion.editor.builder" class="HTMLEditor" %>
+<% EditorOptions options = (EditorOptions)argument; %>
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge" />
+<title>Theme CSS editor</title>
+<style>
+#editor {
+ //border: 1px solid teal;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ bottom: 0px;
+ right: 0px;
+ //margin: 20px;
+ margin: 0px;
+}
+
+pre {
+ margin: 0px;
+}
+</style>
+<link rel="stylesheet" type="text/css" href="<%= options.getEditorCssUrl() %>"/>
+<script src="<%= options.getEditorJsUrl() %>"></script>
+
+<script>
+ function setOrionEditor(editor) {
+ window.editor = editor;
+ if (typeof orion_onLoad == 'function') orion_onLoad();
+ }
+</script>
+
+<% for (String script : options.getScripts()) { %>
+<script>
+<%= script %>
+</script>
+<% } %>
+
+</head>
+<body spellcheck="false">
+<pre id="editor" class="editor" data-editor-lang="<%= options.getLang() %>" data-editor-show-folding-ruler="true" >
+</pre>
+</body>
+</html>
diff --git a/bundles/org.eclipse.e4.tools.orion.editor/templates/JSEdit.jsjet b/bundles/org.eclipse.e4.tools.orion.editor/templates/JSEdit.jsjet
new file mode 100644
index 00000000..ec8f975e
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.editor/templates/JSEdit.jsjet
@@ -0,0 +1,10 @@
+<%@ jet package="org.eclipse.e4.tools.orion.editor.builder.js" class="JSEdit" %>
+
+/*globals require*/
+require(["orion/editor/edit"], function(edit) {
+ var editor = edit({
+ lang: "js"
+ });
+ setOrionEditor(editor);
+ //----------------
+});
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.css b/bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.css
index 5249d9cd..5249d9cd 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.css
+++ b/bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.css
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.js b/bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.js
index 0f6fca08..0f6fca08 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/web/built-editor.js
+++ b/bundles/org.eclipse.e4.tools.orion.editor/web/built-editor.js
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/web/orion.editor.txt b/bundles/org.eclipse.e4.tools.orion.editor/web/orion.editor.txt
index 1d2983e0..86a3d79a 100644
--- a/bundles/org.eclipse.e4.tools.orion.css.editor/web/orion.editor.txt
+++ b/bundles/org.eclipse.e4.tools.orion.editor/web/orion.editor.txt
@@ -1,3 +1,2 @@
The current built-editor.css and built-editor.js
are from orion 4.0 I20130910-1040
-

Back to the top