<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GhoUl &#187; Zoltán Ujhelyi</title>
	<atom:link href="http://cubussapiens.hu/author/Stampie/feed/" rel="self" type="application/rss+xml" />
	<link>http://cubussapiens.hu</link>
	<description>A Cubus Sapiens oldal</description>
	<lastBuildDate>Fri, 24 Feb 2012 21:53:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Multitouch gesture support for Zest graphs</title>
		<link>http://cubussapiens.hu/2012/02/multitouch-gesture-support-for-zest-graphs/</link>
		<comments>http://cubussapiens.hu/2012/02/multitouch-gesture-support-for-zest-graphs/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 21:37:34 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[zest]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2275</guid>
		<description><![CDATA[When I read Jan Köhnlein&#8217;s post about multitouch gestures support in their graph viewer, I was thinking, these gestures would be a nice addition to the Zest visualization library. In addition to that, it could be my first new feature &#8230; <a href="http://cubussapiens.hu/2012/02/multitouch-gesture-support-for-zest-graphs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I read Jan Köhnlein&#8217;s post about <a href="http://koehnlein.blogspot.com/2012/01/multitouch-gestures-in-generic-graph.html">multitouch gestures support in their graph viewer</a>, I was thinking, these gestures would be a nice addition to the <a href="http://wiki.eclipse.org/Zest">Zest visualization library</a>. In addition to that, it could be my first new feature as a Zest committer, so I opened <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=371152">bug 371152</a>.</p>
<p>So I looked into the multitouch API in SWT (btw. it is really to use, check <a title="Multitouch gesture snippet" href="http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet353.java">snippet 353</a>). Luckily, only a gesture listener had to be added, that is already supported by the Zest graph widget.</p>
<p>I thought about what gestures could be universally supported in the Zest graph, and found that scrolling is already supported, magnification is easy to implement, and for rotation I found a possible use.</p>
<p>Today, I finished the implementation, and created a short video presentation that shows the features in action. See the Youtube video: <a href="http://youtu.be/cVVxOIwHN7s">http://youtu.be/cVVxOIwHN7s</a></p>
<p><span style="text-align:center; display: block;"><a href="http://cubussapiens.hu/2012/02/multitouch-gesture-support-for-zest-graphs/"><img src="http://img.youtube.com/vi/cVVxOIwHN7s/2.jpg" alt="" /></a></span></p>
<p>Additionally, it is possible to replace the built-in gestures by creating the graph with a specific style bit, and adding other gesture listeners manually as below:</p>
<pre class="brush: java; gutter: true">//Disabling default gestures
Graph graph = new Graph(parent, ZestStyles.GESTURES_DISABLED);
//Adding own gesture listener
graph.addGestureListener(new GestureListener() {

  public void gesture(GestureEvent e) {
    switch (e.detail) {
      // Do nothing
    }
  }
});</pre>
<p>I believe the base implementation of the gesture support is useful, but I am open to change it if someone has a better idea.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2012/02/multitouch-gesture-support-for-zest-graphs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reflective tree editor for Xtext-based languages</title>
		<link>http://cubussapiens.hu/2012/02/reflective-tree-editor-for-xtext-based-languages/</link>
		<comments>http://cubussapiens.hu/2012/02/reflective-tree-editor-for-xtext-based-languages/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 23:00:24 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[reflective editor]]></category>
		<category><![CDATA[Xtext]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2257</guid>
		<description><![CDATA[Xtext is a great technology. I really mean it. After 15-30 minutes (depending on your previous domain knowledge) you can get a really fancy textual editor, that parses your text into an EMF model. Xbase is even better: you can &#8230; <a href="http://cubussapiens.hu/2012/02/reflective-tree-editor-for-xtext-based-languages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://eclipse.org/Xtext">Xtext</a> is a great technology. I really mean it. After 15-30 minutes (depending on your previous domain knowledge) you can get a really fancy textual editor, that parses your text into an EMF model. <a href="http://eclipse.org/Xtext/#xbase">Xbase</a> is even better: you can simply include Java-like expressions into your language, that can be easily translated into pure Java code.</p>
<p>However, while using Xtext I found some minor &#8220;paper-cuts&#8221;. One of the most problematic of them was the fact that I cannot open my textual models using the <a href="http://wiki.eclipse.org/Xtext/FAQ#How_can_I_load_my_model_in_the_EMF_reflective_model_editor.C2.A0.3F">Sample Reflective Ecore  Model editor</a>, as I get an exception: <em>java.net.MalformedURLException: unknown protocol: java</em>.</p>
<p>A similar exception occurred if I tried to open the files programatically (but without the help of the generated Xtext editor). When I asked in the Eclipse forums how to <a href="http://www.eclipse.org/forums/index.php/m/777743/">open Xtext model files programatically</a>, I was answered (btw. very quickly &#8211; kudos for that <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) that a specific ResourceSet implementation is needed that refers to model files and classes available in a Java project.</p>
<p>This gave me the idea to create an Xtext extension that allows opening an EMF tree editor, the <strong>Xtext Reflective Tree Editor</strong>. The plug-in consists of two parts:</p>
<ol>
<li>An extended version of the <a href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.7.0/org/eclipse/emf/ecore/presentation/EcoreEditor.html">org.eclipse.emf.ecore.presentation.EcoreEditor</a> class, that opens its ResourceSet using the Xtext API (more specifically, uses an injected ResourceSet);</li>
<li>And an Xtext generator fragment, that can be used to generate a new editor extension to the ui project (with the corresponding dependency added to the reflective editor plug-in).</li>
</ol>
<h2>Usage</h2>
<p>To use the plug-in, just follow the following simple steps:</p>
<ol>
<li>Add <code>hu.cubussapiens.xtext.reflectiveeditor</code> as a dependency to your language project.</li>
<li>Extend your editor generation workflow:</li>
<ol>
<li>Import the generator package: <code>import hu.cubussapiens.xtext.reflectiveeditor.generator.*</code></li>
<li>Add the new generator fragment at the end of the generator (file.extensions is the list of file extensions defined in the default workflow):<br />
<code>fragment = ReflectiveXtextEditorFragment {<br />
fileExtensions = file.extensions<br />
}</code></li>
<li>Regenerate your language.</li>
</ol>
<li>Unless the plugin.xml files are updated automatically, you have to copy the newly generated editor extension from the end of the <em>plugin.xml_gen</em> file of the ui plug-in to the <em>plugin.xml</em> file. The simplest way to do this is to select both files, and open the compare editor from the popup menu (<em>Compare with/Each other&#8230;</em>), the copy the changes manually.</li>
<li>Finally, open the runtime workbench, and open your textual model files from the popup menu using <em>Open with/«LanguageName» Reflective Editor.</em> The result should be similar to the screenshot below.</li>
</ol>
<div id="attachment_2261" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2012/02/xtext-reflective.png" rel="lightbox[2257]" title="xtext-reflective"><img class="size-medium wp-image-2261" title="xtext-reflective" src="http://cubussapiens.hu/wp-content/uploads/2012/02/xtext-reflective-300x172.png" alt="" width="300" height="172" /></a><p class="wp-caption-text">The Xtext Reflective Editor</p></div>
<p>In my case, the editor shows both the domain model generated from the file directly (the <em>Pattern Model element</em>), the inferred JVM model classes (the various <em>JVM Generic Type</em> instances), and also the referred Java classes as external resources (the resources beginning with the <em>java:/</em> URIs).</p>
<h2>Download</h2>
<p>If you are interested in the plug-in in action, download it from our update site: <a href="http://eclipse.cubussapiens.hu,">http://eclipse.cubussapiens.hu,</a> or take a look at the repository on Github: <a href="https://github.com/ujhelyiz/xtext-reflective">https://github.com/ujhelyiz/xtext-reflective</a></p>
<p>Version 0.5.3 is already available, and hopefully works well for all languages.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2012/02/reflective-tree-editor-for-xtext-based-languages/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Applications of high-performance model queries @ OMG/Eclipse workshop</title>
		<link>http://cubussapiens.hu/2012/02/applications-of-high-performance-model-queries-omgeclipse-workshop/</link>
		<comments>http://cubussapiens.hu/2012/02/applications-of-high-performance-model-queries-omgeclipse-workshop/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 12:46:41 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[eclipse/omg workshop]]></category>
		<category><![CDATA[eclipsecon]]></category>
		<category><![CDATA[EMF IncQuery]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2229</guid>
		<description><![CDATA[At the last EclipseCon Europe, my collegue, István Ráth presented our incremental model query approach in the Modeling Symposium. Since then, we are working hard to evaluate further uses of the technology while creating a better tooling support for the &#8230; <a href="http://cubussapiens.hu/2012/02/applications-of-high-performance-model-queries-omgeclipse-workshop/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At <a title="EMF-IncQuery @ EclipseCon Europe ’11" href="http://cubussapiens.hu/2011/10/emf-incquery-eclipsecon-europe-11/">the last EclipseCon Europe</a>, my collegue, István Ráth presented our <a href="http://viatra.inf.mit.bme.hu/incquery">incremental model query approach</a> in the Modeling Symposium. Since then, we are working hard to evaluate further uses of the technology while creating a better tooling support for the specification of those queries.</p>
<p>This year, during the <a title="OMG/Eclipse workshop program" href="http://www.omg.org/news/meetings/tc/dc-12/special-events/Eclipse_Program.htm">OMG/Eclipse workshop</a> a day before EclipseCon 2012 István will present our approach together with our new results:</p>
<blockquote><p>14:35 – 15:00</p>
<p><strong>High performance queries and their novel applications</strong></p>
<p><em>István Ráth- Research Associate, BME</em></p>
<p>High-performance model queries are still a major challenge for the industry standard Eclipse Modeling Framework (EMF), they are intensively used in various model validation, model transformation or code generation scenarios. Existing EMF-based query technologies (like Eclipse OCL, EMF Model Query 1-2, or native Java programs) can have significant scalability issues for complex queries of models over 50-100000 model elements. Moreover, it is often tedious and time consuming to efficiently implement EMF-based queries manually on a case-by-case basis.</p>
<p>Recent initiatives, such as the EMF-IncQuery framework (<a href="http://viatra.inf.mit.bme.hu/incquery">http://viatra.inf.mit.bme.hu/incquery</a>) have proposed innovative algorithms to mitigate this issue. EMF-IncQuery uses a graph query language, and provides incremental query evaluation by caching the results of the model queries and incrementally maintaining the cache when the underlying EMF model changes. Furthermore, the EMF-IncQuery framework can be easily integrated into existing EMF-based applications in a non-intrusive way.</p>
<p>In the first part of the talk, we overview the results of a thorough benchmark comparison<br />
intended to aid software engineers in picking the best tool for a given purpose. The measurements involve several versions of Eclipse OCL, manually optimized Java code, dedicated academic query and well-formedness checking tools and EMF-IncQuery and highlight the most important practical considerations of queries in model-driven tool design.</p>
<p>In the second part of the talk, we briefly overview novel and innovative uses of high performance queries such design-space exploration, whereby traditional modeling is augmented with AI techniques to aid the (semi-automatic) optimization of model-based software designs.</p></blockquote>
<p>If you are interested in modeling techniques, I recommend attending to the talk. As a teaser, I show now an existing application of such AI-based techniques: an automated quick fix generation for domain-specific modeling languages. We already presented this technique, albeit based on the VIATRA2 transformation framework in VL/HCC 2011. The article, together with a video demonstration is available from <a href="http://dx.doi.org/10.1109/VLHCC.2011.6070373">http://dx.doi.org/10.1109/VLHCC.2011.6070373</a></p>
<p>For interest, the video demonstration is also uploaded to Youtube for easier watching. (<strong>UPDATE</strong>: For feed readers the video url is the following: <a href="http://youtu.be/kPc4x01K7-s">http://youtu.be/kPc4x01K7-s</a>).</p>
<p><span style="text-align:center; display: block;"><a href="http://cubussapiens.hu/2012/02/applications-of-high-performance-model-queries-omgeclipse-workshop/"><img src="http://img.youtube.com/vi/kPc4x01K7-s/2.jpg" alt="" /></a></span></p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2012/02/applications-of-high-performance-model-queries-omgeclipse-workshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EMF-IncQuery @ EclipseCon Europe &#8217;11</title>
		<link>http://cubussapiens.hu/2011/10/emf-incquery-eclipsecon-europe-11/</link>
		<comments>http://cubussapiens.hu/2011/10/emf-incquery-eclipsecon-europe-11/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 14:57:05 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[eclipsecon]]></category>
		<category><![CDATA[EMF IncQuery]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2167</guid>
		<description><![CDATA[The research of my group often build on various Eclipse technologies. We are developers of the VIATRA2 model transformation framework. Recently we also created EMF-IncQuery, an incremental query technology over EMF models, that we believe really useful in various areas, &#8230; <a href="http://cubussapiens.hu/2011/10/emf-incquery-eclipsecon-europe-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The research of my group often build on various Eclipse technologies. We are developers of the <a href="http://eclipse.org/gmt/VIATRA2/">VIATRA2 model transformation framework</a>. Recently we also created EMF-IncQuery, an incremental query technology over EMF models, that we believe really useful in various areas, such as <a title="Incremental validation of UML models using EMF-IncQuery" href="http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/">model validation during editing</a> or model synchronization scenarios.</p>
<p>This year, a collegue of mine, István Ráth will attend at EclipseCon Europe, and during the <a href="http://mariot-thoughts.blogspot.com/2011/10/modeling-symposium.html">Modeling Symposium</a> present the basic use cases of the tool. In the following I attach a short abstract of the talk to give a basic idea:</p>
<blockquote>
<h2>EMF-IncQuery: Incremental evaluation of model queries over large EMF model</h2>
<p>A Talk at the EclipseCon Europe 2011 Modeling Symposium<br />
<strong>Presenter</strong>: <a href="http://www.eclipsecon.org/europe2011/users/68">István Ráth</a></p>
<p>High-performance model queries are still a major challenge for the industry standard Eclipse Modeling Framework (EMF), as they are intensively used in various model validation, model transformation or code generation scenarios.</p>
<p>Existing EMF-based query technologies (like OCL, EMF Query or native Java programs) have significant scalability issues for models over 50000 model elements. Moreover, it is often tedious and time consuming to efficiently implement EMF-based queries manually on a case-by-case basis.</p>
<p>This talk introduces EMF-IncQuery, a declarative and scalable EMF model query framework. EMF-IncQuery uses a graph query language, and provides incremental query evaluation by caching the results of the model queries and incrementally maintaining the cache when the underlying EMF model changes. Furthermore, the EMF-IncQuery framework can be easily integrated into existing EMF-based applications in a non-intrusive way.</p>
<p>During the talk, we quickly overview how easy it is to define and integrate highly scalable model queries into existing EMF-based applications, in the form of a very short live demonstration using the MDT Papyrus modeling tool. The scalability of the engine will also be demonstrated, with on-the-fly constraint revalidation that takes less than 100 milliseconds over large AUTOSAR models with over 1 million elements.</p>
<p>&nbsp;</p>
<p>More info: <a href="http://viatra.inf.mit.bme.hu/incquery">http://viatra.inf.mit.bme.hu/incquery</a></p></blockquote>
<p>Unfortunately, I cannot go to the conference, but I hope, the 10th birthday of Eclipse will be celebrated well. Have fun, and if you are interested, listen at our talk.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/10/emf-incquery-eclipsecon-europe-11/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Source code visualisation for my projects</title>
		<link>http://cubussapiens.hu/2011/09/source-code-visualisation-for-my-projects/</link>
		<comments>http://cubussapiens.hu/2011/09/source-code-visualisation-for-my-projects/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 21:11:16 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Debug Visualisation]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[debug visualisation]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[EMF IncQuery]]></category>
		<category><![CDATA[viatra]]></category>
		<category><![CDATA[zest]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2151</guid>
		<description><![CDATA[Today I read the announcement of SourceCloud, a new Zest/Cloudio-based visualization for source code. As I like cool visualizations, I tried it out on the open projects I am participating in. At first I created the cloud for the source &#8230; <a href="http://cubussapiens.hu/2011/09/source-code-visualisation-for-my-projects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">Today I read <a href="http://misto.ch/tag-cloud-visualization-for-source-code/">the announcement of SourceCloud</a>, a new Zest/Cloudio-based visualization for source code. As I like cool visualizations, I tried it out on the open projects I am participating in.</div>
<div class="mceTemp">At first I created the cloud for the source code of the <a href="http://code.google.com/p/debugvisualisation/">Debug Visualisation project</a>. Globally it consists of about half Eclipse debugger/UI and Java keywords &#8211; as this is quite a small project (about 4 kLOC), this is somewhat expected with 200 words.</div>
<div id="attachment_2155" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2011/09/dv-cloud.png" rel="lightbox[2151]" title="dv-cloud"><img class="size-medium wp-image-2155" title="dv-cloud" src="http://cubussapiens.hu/wp-content/uploads/2011/09/dv-cloud-300x244.png" alt="" width="300" height="244" /></a><p class="wp-caption-text">SourceCloud of the Debug Visualisation Project</p></div>
<p>However, it is interesting, that the strings &#8216;<em>end_of_line</em>&#8216; and &#8216;<em>sp_cleanup</em>&#8216; found their way in. Luckily, only a few one-character names and numbers are present, meaning, we managed to created longer variable names&#8230;</p>
<p>The cloud of the <a href="http://www.eclipse.org/gmt/VIATRA2/">VIATRA2 model transformation framework</a> is more interesting: it is a much larger codebase, developed for several year by around a dozen people. Because of the size I generated the cloud using 300 words, but almost no Java keywords found their way into the graph.</p>
<div id="attachment_2157" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2011/09/viatra-cloud.png" rel="lightbox[2151]" title="SourceCloud of the VIATRA2 framework"><img class="size-medium wp-image-2157" title="SourceCloud of the VIATRA2 framework" src="http://cubussapiens.hu/wp-content/uploads/2011/09/viatra-cloud-300x269.png" alt="" width="300" height="269" /></a><p class="wp-caption-text">SourceCloud of the VIATRA2 framework</p></div>
<p>However, the mandatory comment parts did, e.g. nbsp or the names of some creators. A lot of EMF-specific keywords are also present. They are present because we have quite a large EMF metamodel that provides several hundred generated Java files.</p>
<p>At last, but not least I also checked the cloud of the <a href="http://viatra.inf.mit.bme.hu/incquery">EMF-IncQuery project</a>. This is smaller, then the VIATRA2 project, but larger then the Debug Visualisation. Additionally, it has a shorter history, but with several key committers.</p>
<div id="attachment_2153" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2011/09/iq-cloud.png" rel="lightbox[2151]" title="SourceCode of the EMF-IncQuery project"><img class="size-medium wp-image-2153" title="SourceCode of the EMF-IncQuery project" src="http://cubussapiens.hu/wp-content/uploads/2011/09/iq-cloud-300x266.png" alt="" width="300" height="266" /></a><p class="wp-caption-text">SourceCloud of the EMF-IncQuery project</p></div>
<p>My personal favorite is this diagram, as it shows a lot of nice things: e.g. four digit numbers in large quantities (magic numbers FTW) or the absolute champion string: &#8216;<em>HUKfyM7ahfg</em>&#8216;. All of them are present in the Ecore Diagram of the defined metamodel (the meaningless string 152 times as a postfix of an identifier <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). At least, I learned something about the internal model representation of GMF.</p>
<p>And how do your projects look like?</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/09/source-code-visualisation-for-my-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incremental validation of UML models using EMF-IncQuery</title>
		<link>http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/</link>
		<comments>http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 13:13:16 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[EMF IncQuery]]></category>
		<category><![CDATA[viatra]]></category>
		<category><![CDATA[videó]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2089</guid>
		<description><![CDATA[Last week we created in the university a nice demo application to demonstrate the validation capabilities of our EMF-IncQuery framework. The application was presented on the conference ECMFA 2011 as a tutorial. EMF-IncQuery provides an incrementally evaluated model query framework: &#8230; <a href="http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last week we created in the university a nice demo application to demonstrate the validation capabilities of our EMF-IncQuery framework. The application was presented on the conference <a title="ECMFA Tutorial" href="http://www.ecmfa-2011.org/tutorials.html#t2">ECMFA 2011 as a tutorial</a>.</p>
<p>EMF-IncQuery provides an incrementally evaluated model query framework: as the underlying EMF model is changed, the query results are re-evaluated, and are instantly returned when needed. Queries are formulated using the <a href="http://wiki.eclipse.org/VIATRA2/Examples/VTCL/GraphPattern">pattern language of the VIATRA2</a> transformation system, and the Java code necessary to execute queries are generated.</p>
<p>In our demo application we extended the <a title="Papyrus MDT" href="http://www.eclipse.org/modeling/mdt/papyrus/">Papyrus</a> UML editor with on-the-fly validation of well-formedness constraints. During editing we check for non-local constraints (e.g. a Behaviour must have the same number of parameters as the corresponding operation); display the results in the editor and in the problems view; we try to provide and remove these error markers without saving or manual need to start validation.</p>
<p>Basically, the constraint validators are generated from specially annotated VIATRA2 patterns; the generation is currently somewhat specific to the Papyrus editor, but can be extended to support most EMF-based editors easily.</p>
<p>A screencast of the demo is presented below. It is important to note, that the Papyrus editor was not modified in any way, and the framework generated all Java code used during validation. More details about the demo application, such as source code, tutorial slides, can be found on <a href="http://viatra.inf.mit.bme.hu/incquery/events/ecmfa2011">the homepage of the application</a>.</p>
<p><span style="text-align:center; display: block;"><a href="http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/"><img src="http://img.youtube.com/vi/3FgBYDoXPUU/2.jpg" alt="" /></a></span></p>
<p>(If the embedded video does not show &#8211; e.g. in a feed reader &#8211; you could watch it on <a href="http://www.youtube.com/watch?v=3FgBYDoXPUU">on Youtube</a>)</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/06/incremental-validation-of-uml-models-using-emf-incquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom markers and annotations &#8211; the bright side of Eclipse</title>
		<link>http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/</link>
		<comments>http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/#comments</comments>
		<pubDate>Wed, 25 May 2011 22:06:00 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[markers]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2021</guid>
		<description><![CDATA[Motto: I have discovered a truly remarkable proof of this theorem which this margin is too small to contain. Pierre de Fermat During the development of editors it is often needed to display additional information next to the document, such &#8230; <a href="http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Motto</strong>:</p>
<blockquote><p>I have discovered a truly remarkable proof of this theorem which this margin is too small to contain.<br />
Pierre de Fermat</p></blockquote>
<p>During the development of editors it is often needed to display additional information next to the document, such as error markers, search results or various coverage metrics. However, it is not a good idea to hardcode the list of supported markers during development, as the best ideas will be introduced by others &#8211; who do not want to have anything to do with our editor.</p>
<p>Luckily, Eclipse provides a simple way to attach markers to documents without explicit support needed from the editor developer: the markers (and annotations) created by their corresponding extensions are stored independently from the document, so these additions can be made without disturbing any existing user of the files.</p>
<p>As I described it in my previous post about <a title="Markers and Annotations in Eclipse for Error Feedback" href="http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/">error markers</a>, such markers can be defined creating an extension for the extension point <code>org.eclipse.core.resources.marker</code>, and then using the <code>IResource.createMarker()</code> method to create the marker instances as needed. Then using some magic it can be displayed as the yellow or red wriggly lines during the text.</p>
<p>Other markers (and annotations) can be created in similarly: we create our own marker type, and register an annotation type for it, and the platform manages the rest. In my case I wanted to represent a calculated set of program statements similar to the code coverage display used by <a href="http://www.eclemma.org/">the EclEmma tool</a>: the covered statements are highlighted with the green background.</p>
<p><a href="http://cubussapiens.hu/wp-content/uploads/2011/05/eclemma.png" rel="lightbox[2021]" title="Code coverage with EclEmma"><img class="alignnone size-medium wp-image-2043" title="Code coverage with EclEmma" src="http://cubussapiens.hu/wp-content/uploads/2011/05/eclemma-300x183.png" alt="" width="300" height="183" /></a></p>
<p>To support such a display, I created a new marker type, that is a text marker; and to make the lifecycle-management easier, I did not set it persistent. This has been reached using the following code:</p>
<pre class="brush: xml; gutter: true; first-line: 1">&lt;extension
    id="org.eclipse.viatra2.slicemarker"
    name="GTASM Slice"
    point="org.eclipse.core.resources.markers"&gt;
  &lt;super
    type="org.eclipse.core.resources.textmarker"&gt;
  &lt;/super&gt;
&lt;/extension&gt;</pre>
<p>The most important difference between this marker and the one defined in the previous <a title="Markers and Annotations in Eclipse for Error Feedback" href="http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/">Markers and Annotations post</a> is that the newly defined marker is not a problem marker, but a simple text marker. This means, the created marker will not show in the <em>Problems view</em> (that is nice &#8211; we don&#8217;t want to display problems now), and no default annotation is created (that will need fixing).</p>
<p>In theory it is possible to create annotations programmatically together with the markers, but in practice it is really a bad idea. First of all, annotations are created for the document model (thus assuming an open editor and a code dependency to that document model), are never persisted, and the resulting code fails indeterministically (I once debugged a code like that, every annotation creation code ran correctly, but some annotations were missing; re-running the code re-added the missing ones, but sometimes removed others), so this idea will not work.</p>
<p>Luckily, the platform provides two extension points that can be used to automatically assign annotations to marker instances. To define an automatically generated annotation type for the markers, the <code>org.eclipse.ui.editors.annotationTypes</code> extension point is used: basically a marker and an annotation ID is stored this way.</p>
<p>&nbsp;</p>
<pre class="brush:xml">   &lt;extension
         point="org.eclipse.ui.editors.annotationTypes"&gt;
      &lt;type
            markerType="org.eclipse.viatra2.slicemarker"
            name="org.eclipse.viatra2.slicemarker"&gt;
      &lt;/type&gt;
   &lt;/extension&gt;</pre>
<p>&nbsp;</p>
<p>To define the appearance of the created annotation the <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point can be used. In the extensions we have to specify the annotation display methods used together with color and formatting settings.</p>
<p>&nbsp;</p>
<pre class="brush:xml">   &lt;extension
         point="org.eclipse.ui.editors.markerAnnotationSpecification"&gt;
      &lt;specification
            annotationType="org.eclipse.viatra2.slicemarker"
            colorPreferenceKey="org.eclipse.viatra2.slice.color"
            colorPreferenceValue="192,255,192"
            contributesToHeader="false"
            highlightPreferenceKey="org.eclipse.viatra2.slice.highlight"
            highlightPreferenceValue="true"
            includeOnPreferencePage="true"
            label="GTASM Slice Marker"
            overviewRulerPreferenceKey="org.eclipse.viatra2.slice.overview"
            overviewRulerPreferenceValue="true"
            presentationLayer="0"
            textPreferenceKey="org.eclipse.viatra2.slice.text"
            textPreferenceValue="true"
            textStylePreferenceValue="BOX"
            verticalRulerPreferenceKey="org.eclipse.viatra2.slice.ruler"
            verticalRulerPreferenceValue="true"&gt;
      &lt;/specification&gt;
   &lt;/extension&gt;</pre>
<p>Even better, by assigning preference keys to the various settings the platform also offers the users the possibility to configure the annotations: the <em>General/Editors/Text Editors/Annotations</em> preference page will list our annotation, and allows setting its preference values. If the preference keys are unique (that is our responsibility <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ), then creating this extension ends our work: annotations will be generated automatically, and they will be displayed in the opened text editors.</p>
<div id="attachment_2061" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2011/05/annotation_prefs.png" rel="lightbox[2021]" title="Annotation preferences"><img class="size-medium wp-image-2061" title="Annotation preferences" src="http://cubussapiens.hu/wp-content/uploads/2011/05/annotation_prefs-300x173.png" alt="" width="300" height="173" /></a><p class="wp-caption-text">Annotation Preferences</p></div>
<p>The marker creation process is entirely the same as the creation of error markers: a new marker is initialized using the IResource.createMarker(String markerId) method, and the <em>IMarker.CHAR_START</em> and <em>IMarker.CHAR_END </em>markers are set for positioning the markers.</p>
<div id="attachment_2065" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2011/05/slices.png" rel="lightbox[2021]" title="Annotated code"><img class="size-medium wp-image-2065" title="Annotated code" src="http://cubussapiens.hu/wp-content/uploads/2011/05/slices-300x157.png" alt="" width="300" height="157" /></a><p class="wp-caption-text">An editor opened with the annotated code</p></div>
<p>Alltogether, the markers and annotations provide an easy way to extend existing editors with meta-information (e.g. execution state, dependencies, coverage, etc.), that can be used with a very little amount of Java programming. Sadly, the content assists for extensions is not that discoverable as the Java APIs, so a lot of experimenting and/or documentation reading is needed. Luckily, documentation is available for these extension points, so knowing their name will be enough for most cases.</p>
<p>So, lets hope, Eclipse gives us a big enough margin to contain our <del>proo</del> metainformation.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Debug Visualisation 0.8.2 out</title>
		<link>http://cubussapiens.hu/2011/01/debug-visualisation-0-8-2-out/</link>
		<comments>http://cubussapiens.hu/2011/01/debug-visualisation-0-8-2-out/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 14:23:29 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Debug Visualisation]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1937</guid>
		<description><![CDATA[I update the Debug Visualisation plug-in &#8211; a nasty bug was present related to opening new nodes that caused in the best case slowdowns, in worst cases exceptions and crashes. This release is a bugfix release only, it is avaiable &#8230; <a href="http://cubussapiens.hu/2011/01/debug-visualisation-0-8-2-out/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I update the Debug Visualisation plug-in &#8211; a nasty bug was present related to opening new nodes that caused in the best case slowdowns, in worst cases exceptions and crashes.</p>
<p>This release is a bugfix release only, it is avaiable from the update site or Eclipse Marketplace, and recommended for every user of the plug-in.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/01/debug-visualisation-0-8-2-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating Java code from EMF models automatically</title>
		<link>http://cubussapiens.hu/2010/12/generating-java-code-from-emf-models-automatically/</link>
		<comments>http://cubussapiens.hu/2010/12/generating-java-code-from-emf-models-automatically/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 22:34:51 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[emf]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1737</guid>
		<description><![CDATA[EMF provides a nice code generation facility for generating Java class hierarchy from ecore models. There is support for hand-made modifications to the generated code, or a large selection of generation parameters are available through a generator model. However, we &#8230; <a href="http://cubussapiens.hu/2010/12/generating-java-code-from-emf-models-automatically/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>EMF provides a nice code generation facility for generating Java class hierarchy from ecore models. There is support for hand-made modifications to the generated code, or a large selection of generation parameters are available through a generator model.</p>
<p>However, we had a different need together with the VIATRA2 project: we explicitly forbid in our internal policy modifications to the generated Java code in order to avoid non-reusable models, and as this way the generated code does not contain any extra information to the generator model, we do not want to store the Java classes in our Subversion repository.</p>
<p>Another minor obstacle was that the code generation does not happen automatically (e.g. as in the LPG editor of the <a href="http://www.eclipse.org/imp/">IMP project</a>) &#8211; so simply not committing the generated code to the repository would mean a manual invocation of the generator that is inconvenient.</p>
<p>Luckily, the code generator is available using specific ANT tasks, allowing to write a build file that describes how to generate the required Java code, reusing the existing build model if necessary:</p>
<pre class="brush:xml">&lt;emf.Ecore2Java
 genModel=&quot;org.eclipse.viatra2.gtasm.model/model/gtasmmodel_updated.genmodel&quot;
 model=&quot;org.eclipse.viatra2.gtasm.model/model/gtasmmodel.ecore&quot;
 generatemodelproject=&quot;true&quot;
 generateeditorproject=&quot;true&quot;
 generateeditproject=&quot;true&quot;
 reconcilegenmodel=&quot;reload&quot; &gt;</pre>
<p>Some interesting points:</p>
<ul>
<li>As the selected Ant task is provided by an OSGi plug-in, it is important to set the <em>Runtime JRE</em> to the same one as used by the workspace, otherwise the called task will not be found.</li>
<li>As the genmodel generator is not available as an Ant task, the ecore2Java task was used. In this case it is important to use the [cci]reconcilegenmodel[/cci] attribute to avoid the unnecessary override of the genmodel</li>
<li>Regardless of the value of the [cci]generate*project[/cci] attributes if the [cci]*project[/cci] were not given as sub-tags, the corresponding code was not generated. This seems like a bug for me, as this duplicates information already present in the genmodel, but I am not sure.</li>
<li>The code generator does not set the generated files <em>Derived</em> attribute, thus it is not excluded from the svn repository. Unfortunately, it is not possible without writing custom tasks, as there <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=30440">is no such command (yet) in Eclipse</a> (but hopefully the patch gets committed in Indigo).</li>
</ul>
<p>This ant task mimics the GUI-based code generators functionality, thus fulfilling our needs, except two things: it does not exclude generated code from the repository, and does not run automatically.</p>
<p>The repository exclusion is resolved using a hack: the [cci]src[/cci] folders are listed in all generated projects in the svn:ignore variable &#8211; thus manually disallowing their sharing. This approach works well, because if no code is generated, the [cci]src[/cci] folder might be missing, that is marked with a very explicit error message (as it is still referenced in the project properties), but if the task is executed, the folder is created as well (and the source folder reference will be working).</p>
<p>For the automatic building Eclipse provides a neat way: External tools (e.g. Ant scripts, or shell scripts, etc.) can be added as project builders. A Run configuration has to be created for the selected task, that can be added to the project. This means, our script is executed each time the selected project changes</p>
<div id="attachment_1745" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2010/12/Screen-shot-2010-12-12-at-23.11.33.png" rel="lightbox[1737]" title="Ant task as external builder"><img class="size-medium wp-image-1745" title="Ant task as external builder" src="http://cubussapiens.hu/wp-content/uploads/2010/12/Screen-shot-2010-12-12-at-23.11.33-300x206.png" alt="The Ant task has been set as a custom builder" width="300" height="206" /></a><p class="wp-caption-text">Builders page in the Project properties</p></div>
<p>Finally, some other modifications were made to the task in order to provide a more standard build: first, as not the entire project is generated at every invocation of the script (the projects could not be deleted, because the generator does not support setting the version number of the generated edit and editor projects), if all project stubs are downloaded from the repository, the build order might not be adequate. To overcome this, a manual build is executed for all projects at the end.</p>
<p>A second modification is a clean task, that removes all source folders, in order to provide a &#8220;clean&#8221;, out-of-the-box experience for a regeneration. This task can also be registered at the builder properties.</p>
<p>The full, modified script looks as following (using Gist from Github):<br />
<script type="text/javascript" src="https://gist.github.com/738410.js?file=Ant%20Build%20script%20for%20EMF%20model%20building"></script></p>
<p><strong>Update:</strong> the eclipse.build tasks are not available in Eclipse, as mentioned by a comment. They are provided by the Buckminster tool, and are not required for the EMF code generation, so it is safe to remove them. However, in this case the refreshing and building of the projects have to be managed in another way (e.g. registering the Ant script as an External builder for the projects).</p>
<p>This simple script helps in a lot of cases &#8211; and because the ecore models does not change very often, its performance is not really an issue (we have quite a large ecore model, so the generator runs about 30-40 seconds). My main issues are the following:</p>
<ul>
<li>I don&#8217;t like to reproduce information from the genmodel in the build script. I am not entirely sure which information is read from the genmodel and which is inferred from the parameters, making the solution a bit volatile.</li>
<li>The missing derived flag command. It would be quite a nice touch if the code would take care of it.</li>
</ul>
<p>Alltogether, if you like it, feel free to use it (<a href="http://www.eclipse.org/org/documents/epl-v10.php">licensed under EPL</a>). I also would be glad if somebody could give me a hint about how to enhance the script &#8211; this is only my second Ant build script, so I don&#8217;t know the language very well. <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2010/12/generating-java-code-from-emf-models-automatically/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Markers and Annotations in Eclipse for Error Feedback</title>
		<link>http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/</link>
		<comments>http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 16:46:03 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[markers]]></category>
		<category><![CDATA[text editor]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1683</guid>
		<description><![CDATA[Motto: Ninety per cent of most magic merely consists of knowing one extra fact. Terry Pratchett, Night Watch Development in Eclipse keeps fascinating me, as there are a lot of very thoroughly designed services and features integrated to allow detailed &#8230; <a href="http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Motto:</strong></p>
<blockquote><p>Ninety  per cent of most magic merely consists of knowing one extra fact.<br />
Terry Pratchett, Night Watch</p></blockquote>
<p>Development in Eclipse keeps fascinating me, as there are a lot of very thoroughly designed services and features integrated to allow detailed customization &#8211; on the other hand, “with big power comes big responsibility”, but at least a steep learning curve. I had such an experience with the problem handling support not long ago.</p>
<p>We developed our own textual language, that provided error markers and editor annotations as error feedback. The problem was that the editor annotations were sometimes missing: our planned functionality worked like we like to add an annotation each time our marker was added, but the annotations were not always updated (so we got an inconsistent state between markers and annotations &#8211; but not every time).</p>
<p>Of course that was caused by the fact that we were rolling out our own implementation of marker/annotation synchronization &#8211; we were not aware that the JFace TextEditor provides such a service out of the box &#8211; and I did not found it documented on the various locations (that&#8217;s why this blog post is born <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<h2>Our requirements</h2>
<p>First of all, lets assemble the various ways Eclipse editors can provide error feedback:</p>
<ul>
<li>The most basic (and least usable) way is the use of pop-up windows &#8211; they are annoying, and not persistent (after pressing a button, they disappear, before the error could be solved).</li>
<li>Writing to the <em>Error log</em> view &#8211; a bit better, but the log could be overwhelmed, if the messages are too many, because they cannot be deleted when the problem is solved.</li>
<li>Displaying the error in the <em>Problems</em> view &#8211; that&#8217;s one of the standard places, where parse errors should be displayed. The problems view is generated by reading (and filtering) the error <strong>marker</strong> type (<em>org.eclipse.core.resources.problemmarker</em>).</li>
<li>Marking the files in the <em>Project Navigator</em> view with a small symbol, if they contain errors/warnings. This is also handled using the previously mentioned error marker.</li>
<li>Underlining the erroneous parts in the editor. For this reason <strong>annotations</strong> should be added to the JFace Document Model used by the JFace TextEditor component.</li>
</ul>
<p>The basic idea is to create a marker and an annotation each time a problem is found. The problem with annotations, that creating them requires some  connection with the editor object, or at least the document model, but our parser should not depend on the editor (core component should not depend on the GUI!).</p>
<h2>Mark My Words!</h2>
<p>The management of the markers is well described in the <a href="http://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html">Mark My Words</a> tutorial. Basically markers are attached to <em>IResources</em>, and provide a simple key-value interface with a freely definable key set (and the IMarker interface specifies some commonly used keys).</p>
<p>Following the tutorial we could create our own marker with the parent of the <em>org.eclipse.core.resources.marker</em> marker, after this adding the markers to the selected files managed the error display in the <em>Problems</em> and <em>Project Navigator</em> views.</p>
<p>So our marker definition looks as follows:</p>
<pre class="brush: xml; gutter: true; first-line: 1">   &lt;extension
         id="org.eclipse.viatra2.loaders.vtclparsermarker"
         name="VTCL Parsing Problems"
         point="org.eclipse.core.resources.markers"&gt;
      &lt;super
            type="org.eclipse.core.resources.problemmarker"&gt;
      &lt;/super&gt;
      &lt;persistent
            value="true"&gt;
      &lt;/persistent&gt;
   &lt;/extension&gt;</pre>
<p>&nbsp;</p>
<p>The problem marker understands severity, error message and line number parameters, and is capable of displaying them in the <em>Problems</em> view.</p>
<pre class="brush: java; gutter: true; first-line: 1">IMarker marker = file.createMarker(markerId);
 marker.setAttribute(IMarker.SEVERITY, severity);
 marker.setAttribute(IMarker.MESSAGE, message);
 marker.setAttribute(IMarker.LINE_NUMBER, line);</pre>
<h2>Annotating the document manually</h2>
<p>As stated before, markers could be added easily without knowing anything about who has opened the file currently, so they are really useful for error feedback, but this information should be also available in the open editors.</p>
<p>Our first idea may be to create some glue code, that listens to the marker changes, and updates our editor accordingly. The drawbacks of this approach are first the fact that we have to code something that trivial, and the second (as we saw in our project), that the editor update could be quite tricky (missing or not deleted annotations).</p>
<p>My theory is, that we have encountered some kind of race condition with our naive implementation, as the annotation creation code was always executed, but sometimes the results were lost. So, in the end, this listener is not so trivial. <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h2>Automatic annotation display</h2>
<p>This was the part that gave us the most headache &#8211; we did not understand, what caused the inconsistent display problem. On the other hand, knowing one extra fact (&#8220;magic&#8221;) the problem is trivially solvable.</p>
<p>So, here comes the Eclipse magic: we don&#8217;t have to create this service manually, we should reuse the already existing one. For that, we would need that our marker also become a child marker of the <em>org.eclipse.core.resources.textmarker</em>, and a minimal set of position data should be added to the marker.</p>
<p>This position information is described by the start and end offset value &#8211; instead of the human-readable line/column position information a machine-readable single position is used: the number of characters that has to be read from the start of the string stream. Its lucky, that most parser generators provide such output that this information is trivially available from the AST level</p>
<pre class="brush: xml; gutter: true; first-line: 1; highlight: [11,12,13]">   &lt;extension
         id="org.eclipse.viatra2.loaders.vtclparsermarker"
         name="VTCL Parsing Problems"
         point="org.eclipse.core.resources.markers"&gt;
      &lt;super
            type="org.eclipse.core.resources.problemmarker"&gt;
      &lt;/super&gt;
      &lt;persistent
            value="true"&gt;
      &lt;/persistent&gt;
      &lt;super
            type="org.eclipse.core.resources.textmarker"&gt;
      &lt;/super&gt;
   &lt;/extension&gt;</pre>
<p>&nbsp;</p>
<p>And the marker creator Java code looks as follows:</p>
<pre class="brush: java; gutter: true; first-line: 1">IMarker marker = file.createMarker(markerId);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.LINE_NUMBER, line);
if (pos.offset != 0) {
  marker.setAttribute(IMarker.CHAR_START,pos.offset);
  marker.setAttribute(IMarker.CHAR_END,pos.offset+pos.length);
}</pre>
<p>After that, the platform uses a default implementation, that provides the well-known wriggly underline to annotate our text files with the associated markers.</p>
<h2>Summary</h2>
<p>Alltogether, the following steps are needed to provide a simple error reporting for our existing editor:</p>
<ul>
<li>Create a custom marker type
<ul>
<li>With a supertype of <em>org.eclipse.core.resources.problemmarker</em> to display the report in the problems view</li>
<li>With a supertype of <em>org.eclipse.core.resources.textmarker</em> to underline the errors in the textual editor</li>
</ul>
</li>
<li>Create a marker instance
<ul>
<li>Setting the <em>IMarker.SEVERITY</em>, <em>IMarker.MESSAGE</em> and <em>IMarker.LINE_NUMBER</em> attributes for the Problems view.</li>
<li> Setting the <em>IMarker.CHAR_START</em> and <em>IMarker.CHAR_END</em> for the editor annotations.</li>
</ul>
</li>
</ul>
<h2>Conclusion</h2>
<p>The Eclipse text editors provide a well-defined, easy to use error reporting mechanism nearly for free. The main catch is, we have to be careful to set everything &#8211; if something is missing, we got the silent failure issue &#8211; no exception is thrown, but something is not shown.</p>
<p>The biggest issue in our implementation was that the <em>IMarker.CHAR_START</em> and <em>IMarker.CHAR_END</em> marker attributes are ignored, if the used marker is not a text attribute, making this problem hard to identify.</p>
<p>A fine thing with this error reporting mechanism is, that it is independent of the concrete text editor used: when we changed our implementation in the VIATRA framework, the resulting reports were visible in every text editor (e.g. the dedicated VIATRA text editor, or the default text editor in Eclipse) &#8211; thus helping error recovery.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2010/11/markers-and-annotations-in-eclipse-for-error-feedback/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

