Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Web - Code generation(Problem when calling the generator)
Xtext Web - Code generation [message #1721313] Tue, 26 January 2016 14:28 Go to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
Hi,

i 've created a language with Xtext 2.9 and defined an Xtend code generator,
I produced the web paert of the editor and in the index.htlm i am trying to use a button to call the generator. The code is as follows:
require(["xtext/xtext"], function(xtext) {
var editor = xtext.createEditor();
$("#generate-button").click(function() {
var strings = 'http://' + location.host + '/xtext-service/generate?resource=' + editor.xtextServices.options.resourceId;
alert(strings);
window.open(strings);
});
});
However, when i try to click on the button nothing happens and by inserting the url in the browser e.g., http://localhost:8081/xtext-service/generate?resource=aa.edl i get
"The request type 'generate' is not supported.".

Do you have any ideas why the generator service of the editor is not working?

Thanks
Re: Xtext Web - Code generation [message #1721315 is a reply to message #1721313] Tue, 26 January 2016 14:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
i dont know if the session in the same if you simply type into the browser.
thus you should send the request using javascript
how does your generator impl look like?
did you remote debug the generator service?

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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721336 is a reply to message #1721315] Tue, 26 January 2016 16:35 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
Yes, i did, but without any luck!
I see that the require(["webjars/ace/1.2.0/src/ace"], function() is not executed.
Re: Xtext Web - Code generation [message #1721337 is a reply to message #1721336] Tue, 26 January 2016 16:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
Hmmm did you create a new project using the wizard?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721342 is a reply to message #1721337] Tue, 26 January 2016 17:17 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
Yes. I followed the steps for creating an Xtext project with Web support.
I inserted my dsl in the xtext file, create the artifacts and insert some custom code in the Generator.xtend.
I should note that i use the Xtext 2.9.0 beta.
Could be this the problem?
I am asking that because in the example i see that there is a reference in the xtext/2.9.2-SNAPSHOT/.
Re: Xtext Web - Code generation [message #1721343 is a reply to message #1721342] Tue, 26 January 2016 17:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
Yes and no you should adapt that as well as the mydsl2 to your situatio

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721344 is a reply to message #1721343] Tue, 26 January 2016 17:20 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
Yes, i have altered the mydsl2 to my situation but is there any new release of the Xtext e.g., 2.9.2?
Re: Xtext Web - Code generation [message #1721346 is a reply to message #1721344] Tue, 26 January 2016 17:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
No i use a nightly but it should be the same with the release 291. You should adapt the indexhtml generated by the wizard


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721347 is a reply to message #1721346] Tue, 26 January 2016 17:43 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
ok, thanks!
i'll try it!!
Re: Xtext Web - Code generation [message #1721430 is a reply to message #1721347] Wed, 27 January 2016 13:13 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member

[Updated on: Wed, 27 January 2016 13:13]

Report message to a moderator

Re: Xtext Web - Code generation [message #1721431 is a reply to message #1721347] Wed, 27 January 2016 13:14 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
No Message Body

[Updated on: Wed, 27 January 2016 13:14]

Report message to a moderator

Re: Xtext Web - Code generation [message #1721433 is a reply to message #1721431] Wed, 27 January 2016 13:15 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
I setup my workspace as indicated by the examples, i define the generate button but,
unfortunately, i am getting the following error:

HTTP ERROR 400
Problem accessing /xtext-service/generate. Reason:
The request type 'generate' is not supported.
Re: Xtext Web - Code generation [message #1721435 is a reply to message #1721433] Wed, 27 January 2016 13:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
can you give us hints what to do to reproduce the problem?
can you share your index.html?
did you debug the server part? (XtextServlet)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721454 is a reply to message #1721435] Wed, 27 January 2016 15:06 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member


[Updated on: Wed, 27 January 2016 15:07]

Report message to a moderator

Re: Xtext Web - Code generation [message #1721455 is a reply to message #1721454] Wed, 27 January 2016 15:07 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
Here is the index file

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>EDL WEB editor</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="keywords" content="opensource rich wysiwyg text editor jquery bootstrap execCommand html5" />
    <meta name="description" content="This tiny jQuery Bootstrap WYSIWYG plugin turns any DIV into a HTML5 rich text editor" />
    <link rel="apple-touch-icon" href="//mindmup.s3.amazonaws.com/lib/img/apple-touch-icon.png" />
    <link rel="shortcut icon" href="http://mindmup.s3.amazonaws.com/lib/img/favicon.ico" >
    <link href="external/google-code-prettify/prettify.css" rel="stylesheet">
    <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
    <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet">
	<link href="http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
	<script src="external/jquery.hotkeys.js"></script>
    <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
    <script src="external/google-code-prettify/prettify.js"></script>
    
    <!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="css/bootstrap.min.css" >	

	<!-- Optional theme -->
	<link rel="stylesheet" href="css/bootstrap-theme.min.css">

	<!-- Latest compiled and minified JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

	<link href="index.css" rel="stylesheet">
    <script src="bootstrap-wysiwyg.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Content-Language" content="en-us">
	
	<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
 
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
	<script src="http://maps.googleapis.com/maps/api/js"></script>
	
	<link rel="stylesheet" type="text/css" href="xtext/2.9.0.beta2/xtext.css"/>
	<link rel="stylesheet" type="text/css" href="index.css" />
	<script src="webjars/requirejs/2.1.17/require.min.js"></script>
	
	<script type="text/javascript" src="my_scripts/scripts.js"></script>
	<script type="text/javascript" src="my_scripts/code_templates.js"></script>  
	<!-- <script type="text/javascript" src="my_scripts/code_templates_with_predefined_values.js"><</script>  -->
	<script type="text/javascript" src="my_scripts/script__experiment_on_load.js"></script>
	<script type="text/javascript" src="/xtext/2.9.0.beta2/xtext.js"></script>
	

	<script type="text/javascript">
	require.config({
			paths: {
				"text": "webjars/requirejs-text/2.0.10-3/text",
				"jquery": "webjars/jquery/2.1.4/jquery.min",
				"xtext/xtext": "xtext/2.9.0.beta2/xtext",
				"ace/ext/language_tools": "webjars/ace/1.2.0/src/ext-language_tools",
				"xtext/xtext-ace": "xtext/2.9.2-SNAPSHOT/xtext-ace"
			}
		});
		require(["xtext/xtext"], function(xtext) {
			alert("prosbash 1");
			var editor = xtext.createEditor({syntaxDefinition: "xtext/edl-syntax", enableGeneratorService: "true"});
			alert("prosbash 2");
			jQuery('#generate-button').bind("click", function(e){
					alert('generate button pressed!!');
					jQuery('#generator-result').html('<iframe src="http://' + location.host + '/xtext-service/generate?resource=script.edl"></iframe>');
					alert('passed!!');
					e.preventDefault();
				});
		});
	</script>
</head>

<body onload="skeleton()">

<div class="container-fluid" style="min-height:100% ; background-color: rgb(102,150,211); " >
    <!--  ------------------------------------------------   MAIN ROW  ------------------------------------------------- -->
  	<div class="row " style=" min-height:100%; " >
  	<!--  ---------------------------------------------------  [ Buttons (10)]   --------------------------------------- -->
  	<div class="col-md-10"  >
  		<!--  ---------------------------------------------------   WEB editor   ----------------------------------- -->
	  	<div class="col-md-12 "  style="margin-left: -20px;  margin-top: -10px;">
	 	<p>
	 	<h2 style="font-style:italics;   color:rgb(92,198,211);  color:rgb(0,12,90); 
	 	color:#bc9a65;  color:white;  color:rgb(230,230,230); color:rgb(210,210,210);  color:rgb(0,12,90); ">
	 	<strong><i>   EDL WEB editor </i>
	 	<!-- 	<hr style="margin-top: -2px; margin-right: 900px"> 
	 	<hr style="margin-top: -15px; margin-right: 900px"> -->
	 	
	 	</strong>
	 	</h2>

                      <div class="btn-group" id="myButtons" data-target="#editor" data-role="editor-toolbar"><small><center>Tools</center></small>
				    <button type="button" id="generate-button"  class="btn btn-default" title="JSON" style="  padding:0px 0px 0px 0px; background-position: 1px 1px;" >
				     <img  src="my_icons/json1.jpg"
		    			 class="img-thumbnail" alt="JSON" style="  max-height: 32px; max-width:32px ;" >
				    </button>
				    <button type="button" class="btn btn-default" title="Files" style=" padding:0px 0px 0px 0px; background-position: 1px 1px;" >
				     <img  src="my_icons/files-icon.png"
		    			 class="img-thumbnail" alt="Files" style="  max-height: 32px; max-width:32px ;" >
				    </button>
				 </div>
	</div>
		
    <!--  -------------------------------------------------------     EDITOR  -------------------------------------------- -->
   	<div class="col-md-6 edit"> 

     <div class="xtext-editor" data-editor-lang="edl" data-editor-resource-id="script.edl" style="width:100%;height:800px;" >
    </div>
    </div>
   
    <!--  ---------------------------------------------------------   MAP   ---------------------------------------------- -->
   <div class="col-md-6 map">
  <!--  <img  align="right"  src="smy_icons/map.png" class="img-thumbnail" alt="RAWFiE Logo"  width="90%"
   style=" margin: 5px -7px; background-color: rgb(102,150,211);  border-color:rgb(102,150,211); "  >
		-->
		<div id="googleMap" style="width:100%;height:800px;"></div>
    </div>
    	<div class="col-md-6 edit">
    	<div id="generator-result"></div>
    	
    	 </div>
  	</div>   
  	</div>
</div>
 </body>
</html>


I should note that during the execution of gradle i take an error in the xtend-gen/Generator at the line 50
public static int[][] newIntegerArrayOfSize(final int nrow, final int ncol) {
Object[] _newArrayOfSize = new Object[nrow];
final Function1<Object, int[]> _function = (Object it) -> {
return new int[nrow][ncol];
};
return ((int[][])Conversions.unwrapArray(ListExtensions.<Object, int[]>map(((List<Object>)Conversions.doWrapArray(_newArrayOfSize)), _function), int[].class));
}

Finally, when i run the gradle and go to the http://localhost:8081/xtext/services/ no services are listed.
Re: Xtext Web - Code generation [message #1721459 is a reply to message #1721455] Wed, 27 January 2016 15:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
-is it possible to switch to xtext 2.9.1 (the latest release)
- there should not be any gradle error
where do you got the url http://localhost:8081/xtext/services/ from? the editor is under localhost:8080 on my machine


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Web - Code generation [message #1721463 is a reply to message #1721459] Wed, 27 January 2016 15:47 Go to previous messageGo to next message
Kostas Kls is currently offline Kostas KlsFriend
Messages: 20
Registered: October 2015
Junior Member
I run the gradle (i inserted the 8081 port just for testing) and after that i went to my browser
and inserted the link http://localhost:8081/xtext/services/ or http://localhost:8080/xtext/services/ in your case.
Re: Xtext Web - Code generation [message #1721467 is a reply to message #1721463] Wed, 27 January 2016 16:01 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
in xtext 2.9.1 it is http://localhost:8080/xtext-service/

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:global validation
Next Topic:Content of "Resource" in doGenerate method.
Goto Forum:
  


Current Time: Fri Sep 24 19:31:11 GMT 2021

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

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

Back to the top