Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Understanding the Web Services
Understanding the Web Services [message #1747519] Tue, 15 November 2016 10:37 Go to next message
Eclipse UserFriend
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 #1747525 is a reply to message #1747519] Tue, 15 November 2016 11:20 Go to previous messageGo to next message
Eclipse UserFriend
no there is no "not understanding" there is simply nothing regarding this. you may digg into https://github.com/eclipse/xtext-web/issues/9 and the forum thread linked there https://www.eclipse.org/forums/index.php?t=msg&th=1076582&goto=1729581&#msg_1729581
Re: Understanding the Web Services [message #1747530 is a reply to message #1747525] Tue, 15 November 2016 11:45 Go to previous messageGo to next message
Eclipse UserFriend
Wait what? Very Happy

So what is the purpose of the web editor at the moment without that feature? At some point you want to get working code, right?

And as always, thanks Christian.
Re: Understanding the Web Services [message #1747536 is a reply to message #1747530] Tue, 15 November 2016 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Yes but that is all up to Adaption of your exact usese
Thus there is no default so far .
Re: Understanding the Web Services [message #1747560 is a reply to message #1747519] Tue, 15 November 2016 18:22 Go to previous messageGo to next message
Eclipse UserFriend
Is there a complete example for the requested changes? Could you post a link to it?

I used the code posted by you but it seems I'm missing a part. It seems I don't use the correct resource id?

In my case:
"data-editor-resource-id="example1.create"


with
				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();
				});


Firebug responds with:
"NetworkError: 404 The requested resource was not found. - http://localhost:8080/create/xtext-service/load?resource=example1.create"


Steps I did so far:
Created the "CreateXtextServiceDispatcher"
Bound it within "CreateWebModule"
C&P the jQuery part and the html fragments.

And to be honest I'm not that fit with Xtext like Stirling Poon. Very Happy
Re: Understanding the Web Services [message #1747568 is a reply to message #1747560] Tue, 15 November 2016 23:53 Go to previous messageGo to next message
Eclipse UserFriend
if there would be i would have pointed you.
and no this is not xtext but javascript crap.

i dont know if you need the service dispatcher at all. this is if you want to deliver multiple artifacts.

you have to make sure the identifier for the model file for the generate is the same as you use for the editor.
and the editor actually needs to have contents !!! otherwise the client will never have talked to the server
since you dont post the complete html and how you actually tested i cannot tell.

i just gave it a try and it works fine.



here is another snippet for just one artifact

https://www.eclipse.org/forums/index.php/t/1073968/?

you can find a all in one here (just made for you)

https://github.com/cdietrich/xtext-forum-support-example/tree/topic_1082486
Re: Understanding the Web Services [message #1747569 is a reply to message #1747568] Wed, 16 November 2016 00:03 Go to previous messageGo to next message
Eclipse UserFriend
and if you want to send the full text with the generate request have a look at https://www.eclipse.org/forums/index.php/m/1729826/?srch=xtext+fulltext#msg_1729826
but that example is incomplete as well, but as you can see you can do it.

thus the major problem is: too many possibilities, what to find as common starting usecase
Re: Understanding the Web Services [message #1748015 is a reply to message #1747519] Thu, 17 November 2016 13:50 Go to previous messageGo to next message
Eclipse UserFriend
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 #1748017 is a reply to message #1748015] Thu, 17 November 2016 14:06 Go to previous messageGo to next message
Eclipse UserFriend
can you please share a sample reproducing repo i can simpy checkout and run?
as said before: setting this up costs time i DONT have
Re: Understanding the Web Services [message #1748022 is a reply to message #1748017] Thu, 17 November 2016 15:13 Go to previous messageGo to next message
Eclipse UserFriend
ps if you dont configure the editor to use a fixed content type and resource id you have to respect that in your stuff as well

require(["orion/code_edit/built-codeEdit-amd"], function() {
			require(["xtext/xtext-orion"], function(xtext) {
				var editor = xtext.createEditor({
					baseUrl: baseUrl,
					syntaxDefinition: "xtext-resources/generated/mydsl-syntax"
				}).done(function(editorViewer) {
					jQuery('#generate-button').bind("click", function(e){
				    var resource = editorViewer.xtextServices.options.resourceId;
					var contentType=editorViewer.xtextServices.contentType;
					jQuery('#generator-result').html('<iframe src="http://' + location.host + '/xtext-service/generate-all?resource='+resource+'&contentType='+contentType+'"></iframe>');
					e.preventDefault();
				});
				});
				
				
				
				
				
			});
		});
Re: Understanding the Web Services [message #1748101 is a reply to message #1748022] Fri, 18 November 2016 08:45 Go to previous messageGo to next message
Eclipse UserFriend
Well, didn't find a option for pms. Here is the link:
Link to github

[Updated on: Fri, 18 November 2016 08:46] by Moderator

Re: Understanding the Web Services [message #1748125 is a reply to message #1748101] Fri, 18 November 2016 12:11 Go to previous messageGo to next message
Eclipse UserFriend
well if your orion does not work at all why are we discussing the generate all button?

i dont know here the problem is if it has to do which how you setup orion or if the context of the servlet is not right ..

my code is here https://github.com/cdietrich/xtext-forum-support-example/tree/xtext-orion
Re: Understanding the Web Services [message #1748147 is a reply to message #1748125] Fri, 18 November 2016 20:35 Go to previous messageGo to next message
Eclipse UserFriend
Why shouldn't Orion work? It worked so far. Why are you concluding that it isn't working?
Re: Understanding the Web Services [message #1748152 is a reply to message #1748147] Sat, 19 November 2016 02:41 Go to previous messageGo to next message
Eclipse UserFriend
If I type I get no highlighting a I get no content assist the JavaScript console is spitting out errors
Re: Understanding the Web Services [message #1748171 is a reply to message #1748152] Sat, 19 November 2016 21:24 Go to previous messageGo to next message
Eclipse UserFriend
The editor highlighting etc works if you remove the "data-editor-resource-id="example1.create"" part. I commited it so that you can see the errors. (that only occure with the generate part)
Re: Understanding the Web Services [message #1748173 is a reply to message #1748171] Sun, 20 November 2016 06:18 Go to previous messageGo to next message
Eclipse UserFriend
yes and

var editor = xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/create-syntax"
}).done(function(editorViewer) {
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/create/xtext-service/generate-all', data, function(result){
jQuery("#generator-result").text(JSON.stringify(result));
});
});
});




works as well (if you had implemented a generator)
Re: Understanding the Web Services [message #1748174 is a reply to message #1748173] Sun, 20 November 2016 06:18 Go to previous messageGo to next message
Eclipse UserFriend
(or inferrer)
Re: Understanding the Web Services [message #1748222 is a reply to message #1748174] Mon, 21 November 2016 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Ok. You only created a json output file to be displayed. How do I handle and pack java classes to (for example) a jar?

As far as I understand the Generator within Eclipse hierarchy it creates the java class files within the specified folder. I'm not sure how the ServiceDispatcher "connects" with the customized generator.

Edit:
And within the index.html I get a error:
ReferenceError: editorViewer is not defined

I also updated the repository.

[Updated on: Mon, 21 November 2016 07:37] by Moderator

Re: Understanding the Web Services [message #1748243 is a reply to message #1748222] Mon, 21 November 2016 09:36 Go to previous messageGo to next message
Eclipse UserFriend
sry as i said 100 posts before: there is nothing like that. you have to implement and care yourself.
are you sure you took the html 1:1 ?

function(editorViewer) {

editor viewer is defined right here
Re: Understanding the Web Services [message #1748251 is a reply to message #1748243] Mon, 21 November 2016 10:32 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Understanding the Web Services [message #1748258 is a reply to message #1748251] Mon, 21 November 2016 10:50 Go to previous message
Eclipse UserFriend
(1) editorViewer != editViewer
(2) it is

var data = {
resource : resource,
fullText : fullText,
contextType : contentType
};
jQuery.post('http://localhost:8080/create/xtext-service/generate-all', data, function(result){
jQuery("#generator-result").text(JSON.stringify(result));
});
Previous Topic:How to create my plug-in ?
Next Topic:Failing Reading column alias in MyEclipse 2016 db2 10
Goto Forum:
  


Current Time: Mon May 12 06:24:04 EDT 2025

Powered by FUDForum. Page generated in 0.09606 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top