diff options
author | 2021-06-27 14:22:40 +0200 | |
---|---|---|
committer | 2021-06-27 14:22:40 +0200 | |
commit | 07719e927f9d398765e661c84fd8778cefb39083 (patch) | |
tree | 9652080f7e580f09a0763a3e258348dea6e02684 /language-web/src/main/webapp | |
parent | Add enum support (diff) | |
download | refinery-07719e927f9d398765e661c84fd8778cefb39083.tar.gz refinery-07719e927f9d398765e661c84fd8778cefb39083.tar.zst refinery-07719e927f9d398765e661c84fd8778cefb39083.zip |
Simplify project layout
Diffstat (limited to 'language-web/src/main/webapp')
-rw-r--r-- | language-web/src/main/webapp/index.html | 49 | ||||
-rw-r--r-- | language-web/src/main/webapp/script.js | 20 | ||||
-rw-r--r-- | language-web/src/main/webapp/style.css | 105 | ||||
-rw-r--r-- | language-web/src/main/webapp/xtext-resources/generated/mode-problem.js | 22 |
4 files changed, 196 insertions, 0 deletions
diff --git a/language-web/src/main/webapp/index.html b/language-web/src/main/webapp/index.html new file mode 100644 index 00000000..3fb66d62 --- /dev/null +++ b/language-web/src/main/webapp/index.html | |||
@@ -0,0 +1,49 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
3 | <meta http-equiv="Content-Language" content="en-us"> | ||
4 | <title>Example Web Editor</title> | ||
5 | <link rel="stylesheet" type="text/css" href="webjars/codemirror/5.52.2/lib/codemirror.css" /> | ||
6 | <link rel="stylesheet" type="text/css" href="webjars/codemirror/5.52.2/addon/hint/show-hint.css" /> | ||
7 | <link rel="stylesheet" type="text/css" href="xtext/2.26.0.M1/xtext-codemirror.css" /> | ||
8 | <link rel="stylesheet" type="text/css" href="style.css" /> | ||
9 | <body> | ||
10 | <div class="container"> | ||
11 | <div class="header"> | ||
12 | <h1>Example Problem Web Editor</h1> | ||
13 | </div> | ||
14 | <div class="content"> | ||
15 | <div class="xtext-editor" | ||
16 | data-editor-xtext-lang="problem" | ||
17 | data-editor-enable-formatting-action="true" | ||
18 | data-editor-send-full-text="false" | ||
19 | ><pre>class Family { | ||
20 | contains Person[] members | ||
21 | } | ||
22 | |||
23 | class Person { | ||
24 | Person[] children opposite parent | ||
25 | Person parent opposite children | ||
26 | TaxStatus[1] taxStatus | ||
27 | } | ||
28 | |||
29 | enum TaxStatus { | ||
30 | child, student, adult, retired | ||
31 | } | ||
32 | |||
33 | error invalidTaxStatus(Person p) :- | ||
34 | taxStatus(p, child), children(p, _q). | ||
35 | |||
36 | Family('family'). | ||
37 | members('family', anne). | ||
38 | members('family', bob). | ||
39 | members('family', ciri). | ||
40 | children(anne, ciri). | ||
41 | ?children(bob, ciri). | ||
42 | taxStatus(anne, adult). | ||
43 | |||
44 | scope Family = 1, Person += 5..10.</pre></div> | ||
45 | </div> | ||
46 | </div> | ||
47 | <script type="text/javascript" src="webjars/requirejs/2.3.6/require.min.js"></script> | ||
48 | <script type="text/javascript" src="script.js"></script> | ||
49 | </body> | ||
diff --git a/language-web/src/main/webapp/script.js b/language-web/src/main/webapp/script.js new file mode 100644 index 00000000..dced7eca --- /dev/null +++ b/language-web/src/main/webapp/script.js | |||
@@ -0,0 +1,20 @@ | |||
1 | var baseUrl = window.location.pathname; | ||
2 | var fileIndex = baseUrl.indexOf("index.html"); | ||
3 | if (fileIndex > 0) | ||
4 | baseUrl = baseUrl.slice(0, fileIndex) | ||
5 | require.config({ | ||
6 | baseUrl: baseUrl, | ||
7 | paths: { | ||
8 | "text": "webjars/requirejs-text/2.26.0.M1/text", | ||
9 | "jquery": "webjars/jquery/3.6.0/jquery.min", | ||
10 | "xtext/xtext-codemirror": "xtext/2.26.0.M1/xtext-codemirror", | ||
11 | }, | ||
12 | packages: [{ | ||
13 | name: "codemirror", | ||
14 | location: "webjars/codemirror/5.52.2", | ||
15 | main: "lib/codemirror" | ||
16 | }] | ||
17 | }); | ||
18 | require(["xtext-resources/generated/mode-problem", "xtext/xtext-codemirror"], function(mode, xtext) { | ||
19 | window.xtextEditor = xtext.createEditor({baseUrl: baseUrl,}); | ||
20 | }); | ||
diff --git a/language-web/src/main/webapp/style.css b/language-web/src/main/webapp/style.css new file mode 100644 index 00000000..9a89dd81 --- /dev/null +++ b/language-web/src/main/webapp/style.css | |||
@@ -0,0 +1,105 @@ | |||
1 | body { | ||
2 | width: 100%; | ||
3 | height: 100%; | ||
4 | overflow: hidden; | ||
5 | font: 16px Helvetica,sans-serif; | ||
6 | } | ||
7 | |||
8 | a { | ||
9 | color: #22a; | ||
10 | text-decoration: none; | ||
11 | } | ||
12 | |||
13 | a:hover { | ||
14 | text-decoration: underline; | ||
15 | } | ||
16 | |||
17 | .container { | ||
18 | display: block; | ||
19 | position: absolute; | ||
20 | top: 0; | ||
21 | bottom: 0; | ||
22 | left: 0; | ||
23 | right: 0; | ||
24 | margin: 24px 24px 36px 24px; | ||
25 | } | ||
26 | |||
27 | .header { | ||
28 | display: block; | ||
29 | position: absolute; | ||
30 | top: 0; | ||
31 | left: 0; | ||
32 | right: 0; | ||
33 | padding: 16px; | ||
34 | background: #dbdbdb; | ||
35 | border-radius: 16px; | ||
36 | color: #383838; | ||
37 | } | ||
38 | |||
39 | .header h1 { | ||
40 | font-size: 36px; | ||
41 | margin: 0; | ||
42 | } | ||
43 | |||
44 | .content { | ||
45 | display: block; | ||
46 | position: absolute; | ||
47 | top: 108px; | ||
48 | bottom: 0; | ||
49 | left: 0; | ||
50 | width: 50%; | ||
51 | box-shadow: 0 0 8px rgba(80, 10, 98, .25), 0 10px 24px rgba(80, 10, 98, .35); | ||
52 | border-radius: 16px; | ||
53 | } | ||
54 | |||
55 | .xtext-editor { | ||
56 | display: block; | ||
57 | position: absolute; | ||
58 | top: 16px; | ||
59 | bottom: 16px; | ||
60 | left: 16px; | ||
61 | right: 16px; | ||
62 | border: 1px solid #aaa; | ||
63 | } | ||
64 | |||
65 | .problem-class { | ||
66 | color: #005032; | ||
67 | } | ||
68 | |||
69 | .problem-abstract { | ||
70 | color: #8b8816; | ||
71 | } | ||
72 | |||
73 | .problem-enum { | ||
74 | color: #644632; | ||
75 | } | ||
76 | |||
77 | .problem-reference { | ||
78 | color: #0000c0; | ||
79 | } | ||
80 | |||
81 | .problem-containment { | ||
82 | font-weight: bold; | ||
83 | } | ||
84 | |||
85 | |||
86 | .CodeMirror .problem-node { | ||
87 | color: inherit; | ||
88 | } | ||
89 | |||
90 | .problem-enum-node { | ||
91 | color: #1a1a1a !important; | ||
92 | font-weight: bold; | ||
93 | } | ||
94 | |||
95 | .problem-new-node { | ||
96 | font-style: italic; | ||
97 | } | ||
98 | |||
99 | .problem-variable { | ||
100 | color: #6a3e3e; | ||
101 | } | ||
102 | |||
103 | .problem-singleton-variable { | ||
104 | opacity: 0.7; | ||
105 | } | ||
diff --git a/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js b/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js new file mode 100644 index 00000000..89373b1c --- /dev/null +++ b/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js | |||
@@ -0,0 +1,22 @@ | |||
1 | define(["codemirror", "codemirror/addon/mode/simple"], function(CodeMirror, SimpleMode) { | ||
2 | var keywords = "abstract|class|contains|enum|error|extends|false|opposite|pred|problem|refers|scope|true|unknown"; | ||
3 | CodeMirror.defineSimpleMode("xtext/problem", { | ||
4 | start: [ | ||
5 | {token: "comment", regex: "\\/\\/.*$"}, | ||
6 | {token: "comment", regex: "\\/\\*", next : "comment"}, | ||
7 | {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, | ||
8 | {token: "constant.numeric", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, | ||
9 | {token: "lparen", regex: "[\\[({]"}, | ||
10 | {token: "rparen", regex: "[\\])}]"}, | ||
11 | {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} | ||
12 | ], | ||
13 | comment: [ | ||
14 | {token: "comment", regex: ".*?\\*\\/", next : "start"}, | ||
15 | {token: "comment", regex: ".+"} | ||
16 | ], | ||
17 | meta: { | ||
18 | dontIndentStates: ["comment"], | ||
19 | lineComment: "//" | ||
20 | } | ||
21 | }); | ||
22 | }); | ||