Understanding the Web Services [message #1747519] |
Tue, 15 November 2016 10:37  |
Eclipse User |
|
|
|
My goal for the DSL (created in the web editor) is to generate java code that I can use in other contexts. (for example creating a jar file)
1. How do I invoke the code generation (from the web editor and in general)?
2. How do I specify what I generate?
3. How do I specify where the generated file will be located?
The documentation on this is not very specific or/and not detailed. Either it is too trivial or it is thought of to be clear from the beginning.
As far as I understand it the methods under "Invoking Services" are all regarding the webeditor and its loading, checking and updating.
Am I missing a link to the JS front end frameworks?
(If those frameworks matter I will be using Orion)
|
|
|
|
|
|
|
|
|
Re: Understanding the Web Services [message #1748015 is a reply to message #1747519] |
Thu, 17 November 2016 13:50   |
Eclipse User |
|
|
|
Thanks for your support.
At the moment I can't find the time to browse through the code but at least I can show you the html. I didn't change much yet.
<!DOCTYPE html>
<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="orion/code_edit/built-codeEdit.css"/>
<link rel="stylesheet" type="text/css" href="xtext/2.10.0/xtext-orion.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="webjars/requirejs/2.2.0/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: {
"text": "webjars/requirejs-text/2.0.15/text",
"jquery": "webjars/jquery/2.2.3/jquery.min",
"xtext/xtext-orion": "xtext/2.10.0/xtext-orion"
}
});
require(["orion/code_edit/built-codeEdit-amd"], function() {
require(["xtext/xtext-orion"], function(xtext) {
xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/create-syntax"
});
jQuery('#generate-button').bind("click", function(e){
jQuery('#generator-result').html('<iframe src="http://' + location.host + '/xtext-service/generate-all?resource=example1.create"></iframe>');
e.preventDefault();
});
});
});
</script>
</head>
<body>
<div class="container">
<div class="header">
<h1>Example Create Web Editor</h1>
</div>
<div class="content">
<div id="xtext-editor"
class="editor"
data-editor-xtext-lang="create"
data-editor-resource-id="example1.create"
>
</div>
<div class="button-wrapper">
<button id="generate-button" value="Generate" title="Generate">Generate</button>
<div id="generator-result">
Result
</div>
</div>
</div>
</div>
</body>
</html>
And almost the same css as the shipped example:
body {
width: 100%;
height: 100%;
overflow: hidden;
font: 16px Helvetica,sans-serif;
}
a {
color: #22a;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.container {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 20px;
}
.header {
display: block;
position: absolute;
background-color: #e8e8e8;
top: 0;
left: 0;
right: 0;
height: 60px;
padding: 10px;
}
.content {
display: block;
position: absolute;
top: 90px;
bottom: 0;
left: 0;
width: 100%;
}
#xtext-editor {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 4px;
border: 1px solid #aaa;
width: 640px;
}
.button-wrapper {
border: 1px solid #aaa;
display: block;
left: 750px;
position: absolute;
width: 400px;
}
My problem while trying to fix the "not found" problems is that I can't place any text within the editor because it is not reachable. (most likely because of the existing errors). But therefore I can't give the editor code that could be generated.
To track down the issue I first commented the js parts and it still created the errors.
data-editor-resource-id="example1.create"
this is the central issue. As long as this snippet exists within the page, the errors occure. I haven't try to look into what orion tries to do with the tag. Maybe the orion related js already tries to "connect" or execute "something".
But that seems weird to do even before the editor could be manually written.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Understanding the Web Services [message #1748251 is a reply to message #1748243] |
Mon, 21 November 2016 10:32   |
Eclipse User |
|
|
|
Yes I'm sure.
<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: {
"text": "webjars/requirejs-text/2.0.15/text",
"jquery": "webjars/jquery/2.2.3/jquery.min",
"xtext/xtext-orion": "xtext/2.10.0/xtext-orion"
}
});
require(["orion/code_edit/built-codeEdit-amd"], function() {
require(["xtext/xtext-orion"], function(xtext) {
var editor = xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/create-syntax"
}).done(function(editViewer) {
jQuery('#generate-button').bind("click", function(e) {
var resource = editorViewer.xtextServices.options.resourceId;
var contentType = editorViewer.xtextServices.contentType;
var fullText = editorViewer.xtextServices.editorContext.getText();
console.log(fullText);
var data = {
resource: resource,
fullText: fullText,
contextType: contentType
};
});
jQuery.post('http://localhost:8080/xtext-service/generate-all', data, function(result) {
jQuery("#generator-result").text(JSON.stringify(result));
});
});
});
});
</script>
Take a look at the respository. It is the same there.
|
|
|
|
Powered by
FUDForum. Page generated in 0.09606 seconds