1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<%@ 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);
//----------------
});
|