|
|
|
|
|
|
|
|
Re: Multiple grammars and example web editor [message #1798280 is a reply to message #1798274] |
Wed, 14 November 2018 20:27 |
Pierre Padovani Messages: 7 Registered: November 2018 |
Junior Member |
|
|
Right... I have a servlet class for each, and it looks like the annotation on the class is used to create the ServletHolder which in turn contains the servlet class. However, only the first servlet as defined in the workflow is ever instantiated and initialized. I've tried changing the urlPattern on the annotations to point to different paths, but that just breaks things. :-)
This is easily reproducible, use a workflow file like:
Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "com.civitaslearning.platform.configuration"
rootPath = rootPath
runtimeTest = {
enabled = true
}
eclipsePlugin = {
enabled = true
}
eclipsePluginTest = {
enabled = true
}
web = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "UTF-8"
lineDelimiter = "\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "com.civitaslearning.platform.configuration.DiscoveryPack"
fileExtensions = "dp"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
generateDeprecationValidation = true
}
parserGenerator = {
options = {
classSplitting = true
fieldsPerClass = "500"
backtrack=true
}
}
formatter = {
generateStub = true
}
}
language = StandardLanguage {
name = "com.civitaslearning.platform.configuration.ExtractDescriptor"
fileExtensions = "ed"
referencedResource =
"platform:/resource/com.civitaslearning.platform.configuration/src/com/civitaslearning/platform/configuration/DiscoveryPack.xtext"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
parserGenerator = {
options = {
classSplitting = true
fieldsPerClass = "500"
}
}
formatter = {
generateStub = true
}
}
}
}
Set whatever grammar you want into the two grammar xtext files. Generate everything including web example. Edit the index.html in the WebRoot, and change the extension to 'ed' instead of the 'dp' as defined above.
[Updated on: Wed, 14 November 2018 20:31] Report message to a moderator
|
|
|
|
Re: Multiple grammars and example web editor [message #1798287 is a reply to message #1798283] |
Wed, 14 November 2018 23:05 |
|
the following works for me for the communication
class MyDslAServlet extends XtextServlet {
DisposableRegistry disposableRegistry
override init() {
super.init()
new MyDslBWebSetup().createInjectorAndDoEMFRegistration
val injector = new MyDslAWebSetup().createInjectorAndDoEMFRegistration()
disposableRegistry = injector.getInstance(DisposableRegistry)
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en-us">
<title>Example Web Editor</title>
<link rel="stylesheet" type="text/css" href="xtext/2.15.0/xtext-ace.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="webjars/requirejs/2.3.2/require.min.js"></script>
<script type="text/javascript">
var baseUrl = window.location.pathname;
var fileIndex = baseUrl.indexOf("index.html");
if (fileIndex > 0)
baseUrl = baseUrl.slice(0, fileIndex);
require.config({
baseUrl: baseUrl,
paths: {
"jquery": "webjars/jquery/2.2.4/jquery.min",
"ace/ext/language_tools": "webjars/ace/1.2.3/src/ext-language_tools",
"xtext/xtext-ace": "xtext/2.15.0/xtext-ace"
}
});
require(["webjars/ace/1.2.3/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
xtext.createEditor({
baseUrl: baseUrl,
loadFromServer: false,
});
});
});
</script>
</head>
<body>
<div class="header">
<h1>Example MyDslA Web Editor</h1>
</div>
<div class="content">
<div class="xtext-editor" data-editor-resource-id="multi-resource/left.mydsla">
<pre>
HelloA A!
<pre>
</div>
</div>
<div class="content">
<div class="xtext-editor" data-editor-resource-id="multi-resource/right.mydslb">
<pre>
HelloB B!
</pre>
</div>
</div>
</body>
</html>
//needs copy of WebRoot/xtext-resources/generated/* to WebRoot/xtext-resources/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Multiple grammars and example web editor [message #1798288 is a reply to message #1798287] |
Wed, 14 November 2018 23:10 |
|
alternatively you can do it this way(client side)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en-us">
<title>Example Web Editor</title>
<link rel="stylesheet" type="text/css" href="xtext/2.15.0/xtext-ace.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="webjars/requirejs/2.3.2/require.min.js"></script>
<script type="text/javascript">
var baseUrl = window.location.pathname;
var fileIndex = baseUrl.indexOf("index.html");
if (fileIndex > 0)
baseUrl = baseUrl.slice(0, fileIndex);
require.config({
baseUrl: baseUrl,
paths: {
"jquery": "webjars/jquery/2.2.4/jquery.min",
"ace/ext/language_tools": "webjars/ace/1.2.3/src/ext-language_tools",
"xtext/xtext-ace": "xtext/2.15.0/xtext-ace"
}
});
require(["webjars/ace/1.2.3/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
xtext.createEditor({
baseUrl: baseUrl,
loadFromServer: false,
parentClass: "xtext-editora",
syntaxDefinition: "xtext-resources/generated/mode-mydsla"
});
xtext.createEditor({
baseUrl: baseUrl,
loadFromServer: false,
parentClass: "xtext-editorb",
syntaxDefinition: "xtext-resources/generated/mode-mydslb"
});
});
});
</script>
</head>
<body>
<div class="header">
<h1>Example MyDslA Web Editor</h1>
</div>
<div class="content">
<div class="xtext-editora" data-editor-resource-id="multi-resource/left.mydsla">
<pre>
HelloA A!
<pre>
</div>
</div>
<div class="content">
<div class="xtext-editorb" data-editor-resource-id="multi-resource/right.mydslb">
<pre>
HelloB B!
</pre>
</div>
</div>
</body>
</html>
ps.: here is my css
body {
width: 100%;
height: 100%;
overflow: hidden;
font: 16px Helvetica,sans-serif;
}
a {
color: #22a;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.content {
display: block;
width: 400px;
height: 300px;
}
.xtext-editor {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
.xtext-editora {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
.xtext-editorb {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.05031 seconds