Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2013-08-07 17:08:52 +0000
committerPaul Webster2013-08-07 17:12:13 +0000
commit1b498f25a89072161a1e84764a8e8eca9586ca6c (patch)
tree194f40d9e80c055ea91c0d03f4ab03e6141a3176
parent97cff625ee37a5a16dcdebcc7a248410eb8e3369 (diff)
downloadorg.eclipse.e4.tools-1b498f25a89072161a1e84764a8e8eca9586ca6c.tar.gz
org.eclipse.e4.tools-1b498f25a89072161a1e84764a8e8eca9586ca6c.tar.xz
org.eclipse.e4.tools-1b498f25a89072161a1e84764a8e8eca9586ca6c.zip
Bug 410841 - Explorer editing CSS with orionI20130807-2200
An example of hooking in CSS keywords.
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/edit.html103
-rw-r--r--bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/swtContentAssist.js68
2 files changed, 171 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/edit.html b/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/edit.html
new file mode 100644
index 00000000..fd62052c
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/edit.html
@@ -0,0 +1,103 @@
+<!DOCTYPE html>
+<!--
+ Sample that shows how to use the edit.js file to create an editor. For a complete list
+ of editor configuration options, see orion.editor#edit.
+-->
+<html>
+<head>
+<title>Orion Editor Sample</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="http://eclipse.org/orion/editor/releases/3.0/built-editor.css"/>
+<script src="http://eclipse.org/orion/editor/releases/3.0/built-editor.js"></script>
+<script src="swtContentAssist.js"></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());
+ });
+ //----------------
+ });
+</script>
+</head>
+<body spellcheck="false">
+<pre id="editor">
+
+@import url("e4_basestyle.css");
+
+.MTrimmedWindow {
+ background-color: COLOR_BLUE;
+}
+
+.MPartStack {
+ font-size: 9;
+ font-family: 'Segoe UI';
+ swt-simple: true;
+ swt-mru-visible: false;
+}
+
+.MTrimBar {
+ background-color: #E1E6F6;
+}
+
+.MTrimBar#org-eclipse-ui-main-toolbar {
+ background-image: url(./win7.png);
+}
+
+.MToolControl.TrimStack {
+ frame-image: url(./win7TSFrame.png);
+ handle-image: url(./win7Handle.png);
+}
+
+.MPartStack.active {
+ swt-unselected-tabs-color: #F3F9FF #D0DFEE #CEDDED #CEDDED #D2E1F0 #D2E1F0 #FFFFFF 20% 45% 60% 70% 100% 100%;
+ swt-outer-keyline-color: #B6BCCC;
+}
+
+#PerspectiveSwitcher {
+ background-color: #F5F7FC #E1E6F6 100%;
+}
+
+#org-eclipse-ui-editorss {
+ swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
+ swt-unselected-tabs-color: #F0F0F0 #F0F0F0 #F0F0F0 100% 100%;
+ swt-outer-keyline-color: #B4B4B4;
+ swt-inner-keyline-color: #F0F0F0;
+ swt-tab-outline: #F0F0F0;
+ color: #F0F0F0;
+ swt-tab-height: 8px;
+ padding: 0px 5px 7px;
+}
+
+CTabFolder.MArea .MPartStack, CTabFolder.MArea .MPartStack.active {
+ swt-shadow-visible: false;
+}
+
+CTabFolder Canvas {
+ background-color: #F8F8F8;
+}
+
+
+</pre>
+</body>
+</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/swtContentAssist.js b/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/swtContentAssist.js
new file mode 100644
index 00000000..77e9460f
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.orion.css.editor/content-assist-example/swtContentAssist.js
@@ -0,0 +1,68 @@
+
+/*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 = [
+ "swt-unselected-tabs-color", //$NON-NLS-0$
+ "swt-selected-tabs-background", //$NON-NLS-0$
+ "swt-outer-keyline-color" //$NON-NLS-0$
+ ];
+
+ 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

Back to the top