<?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; eclipse</title>
	<atom:link href="http://cubussapiens.hu/tag/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>http://cubussapiens.hu</link>
	<description>A Cubus Sapiens oldal</description>
	<lastBuildDate>Sat, 14 Jan 2012 23:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Reusing PDE in modeling context</title>
		<link>http://cubussapiens.hu/2011/11/reusing-pde-in-modeling-context/</link>
		<comments>http://cubussapiens.hu/2011/11/reusing-pde-in-modeling-context/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 12:49:36 +0000</pubDate>
		<dc:creator>Balage</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[PDE]]></category>
		<category><![CDATA[Xtext]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=2187</guid>
		<description><![CDATA[If you&#8217;re developing with EMF it is a common task to separate the model into multiple files along with enabling the user to create crosslinks between them. This works out-of box if the files are located inside the same project. &#8230; <a href="http://cubussapiens.hu/2011/11/reusing-pde-in-modeling-context/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re developing with EMF it is a common task to separate the model into multiple files along with enabling the user to create crosslinks between them. This works out-of box if the files are located inside the same project. However, in some cases for larger models it is simply not enough. It can be useful to be able to define reusable (and versioned) packets of models and enable the user to define a configuration which determines the imported model packages. Sounds familiar? The same functionality exists in PDE. Maybe it can be reused for non-java purposes.</p>
<p><span id="more-2187"></span></p>
<p><strong>Plug-ins as model containers</strong></p>
<p>Creating plug-in projects to contain models is easy with PDE: not even a single line of code is needed. The user can create a non-java plug-in project, or convert a resource project to plug-in project by clicking on &#8216;Configure/Convert to Plug-in projects&#8217; in the pop-up menu of the project.</p>
<p>It&#8217;s finished: the user now can define dependencies between projects and even install/update third party plug-ins from update sites!</p>
<p><strong>Creating cross-links</strong></p>
<p>Of course, if the user wants to use the models from the dependent plug-ins we must show the contents of these models on the GUI. This step is highly domain-specific, therefore I leave it to the reader. The part of determining the visible resources from the imported plug-ins is common for all uses.</p>
<p>To use the dependent models, we need to load not only the directly referenced plug-ins, but the plug-ins needed by them recursively:</p>
<pre class="brush: java; gutter: true; first-line: 1; highlight: []; html-script: false">/**
 * Collect all plug-ins on which the given plug-in depends.
 * @param name
 * @return
 */
public static List&lt;String&gt; collectAllDependencies(String name){
    Set&lt;String&gt; all = new HashSet&lt;String&gt;();

    Queue&gt;IPlugin&lt; process = new LinkedList&lt;IPlugin&gt;();
    process.add(getPlugin(name));

    while(!process.isEmpty()){
        IPlugin plugin = process.poll();
        all.add(plugin.getId());
        for(IPluginImport pi : plugin.getImports()){
            String imported = pi.getId();
            if (!all.contains(imported)){
                process.add(getPlugin(imported));
            }
        }
    }

    return new ArrayList&lt;String&gt;(all);
}

public static IPlugin getPlugin(String name){
    IPluginModelBase mb = PluginRegistry.findModel(name);
    IPluginModel m = (IPluginModel)mb;
    return m.getPlugin();
}</pre>
<p>When we got all plug-ins to use, we just need to collect the resources from them. In this step we must prepare for two cases: whether the plug-in is a workspace plug-in or not. A workspace plug-in is a plug-in in development. There is a project in the workspace which contain the plug-in contents. Unlike installed plug-ins which exists in the plugins directory of the eclipse installation:</p>
<pre class="brush: java; gutter: true; first-line: 1; highlight: []; html-script: false">public static Collection&lt;URI&gt; getVisibleResources(String pluginname) throws CoreException{
    IPlugin plugin = getPlugin(pluginname);
    final Collection&lt;URI&gt; result = new ArrayList&lt;URI&gt;();

    //The plugin has an underlying resource if it is a workspace plug-in
    IResource r = plugin.getPluginModel().getUnderlyingResource();
    if (r != null){
        r = r.getProject();
        r.accept(new IResourceVisitor() {

            @Override
            public boolean visit(IResource resource) throws CoreException {
                if (resource instanceof IFile){
                    result.add(URI.createPlatformResourceURI(resource.getFullPath().toString(), true));
                    return false;
                }
                return true;
            }
        });
    }else{
        Bundle b = Platform.getBundle(plugin.getId());
        Enumeration&lt;URL&gt; urls = b.findEntries("/", "*.e", true);
        while(urls.hasMoreElements()){
            URL url = urls.nextElement();
            URI uri = URI.createPlatformPluginURI(pluginname+url.getPath(), true);
            result.add(uri);
        }
    }

    return result;

}</pre>
<p>As for normal eclipse plug-ins, if a workspace plug-in exists with the same name as an installed plug-in, the workspace version will be used.</p>
<p>Because EMF needs all resources to be loaded into one resource set to resolve crosslinks, it is advised to use some kind of indexer to reduce load times.</p>
<p><strong>Special case: Xtext</strong></p>
<p>If you&#8217;re using this method with Xtext, some things will become much simpler as it provides you some additional infrastructure compared to EMF. First, you won&#8217;t need to write your own indexing service as Xtext does everything for you from caching to lazy linking. Second, you can implement your own builders as builder participants, which leverages the problem of creating and configuring resource sets and loading resources.</p>
<p>The easiest way to use PDE functionality is to implement the possible crosslinks as scopes:</p>
<pre class="brush: java; gutter: true; first-line: 1; highlight: []; html-script: false">public class PluginDependencyScope extends AbstractScope {

    private final List&lt;IEObjectDescription&gt; descs = new ArrayList&lt;IEObjectDescription&gt;();

    /**
     * @param parent
     * @param ignoreCase
     */
    public PluginDependencyScope(URI context,ResourceSet resourceset, IScope parent) {
        super(parent, false);
        String projname = context.trimFragment().segment(1);
        List&lt;String&gt; deps = MODembedCore.collectAllDependencies(projname);

        for(String d : deps){
            try {
                for(URI uri : MODembedCore.getVisibleResources(d)){
                    try{
                        Resource r = resourceset.getResource(uri, true);
                        for(EObject eo : r.getContents()){
                            if (eo instanceof Package){
                                String name = ((Package) eo).getName();
                                QualifiedName qname = QualifiedName.create(name.split("\\."));
                                descs.add(EObjectDescription.create(qname, eo));
                            }
                        }
                    }catch(Exception e){

                    }
                }
            } catch (CoreException e) {

            }
        }
    }

    /* (non-Javadoc)
     * @see org.eclipse.xtext.scoping.impl.AbstractScope#getAllLocalElements()
     */
    @Override
    protected Iterable&lt;IEObjectDescription&gt; getAllLocalElements() {
        return descs;
    }

}</pre>
<p><strong>Problems</strong></p>
<p>This does the magic, but it&#8217;s not perfect. There are some major flaws which are not easy to deal with:</p>
<ul>
<li>Depending on PDE pulls the entire PDE+JDT into your product even if your user does not intend to use it. This is a minor problem, it just causes overhead on the disk usage.</li>
<li>PDE is defined mainly for Java Plug-in projects. The whole user interface contains items which are meaningless in our special case.</li>
<li>If the user is not familiar with PDE and OSGi concepts, she/he will have a hard time understanding the user interface and the operation of cross-link resolution.</li>
<li>When the user tries to add a plug-in to the dependency list, all installed plug-ins are listed, including platform, PDE, JDT, EMF and other components. It may be hard to tell which plug-in contain models of a specific domain.</li>
</ul>
<p><strong>Conclusion</strong></p>
<p>Functionally, PDE contains everything you will need for partitioning models. If the targeted user base is experienced with eclipse, reusing PDE is an option. If needed, some isses can be worked out with some effort. For example the MANIFEST.MF editor can be replaced with a more domain-specific editor, which can filter out uninteresting plug-ins from the dependency list and include additional information which may needed by your domain.</p>
<p>I&#8217;m using this technique to share some common libraries to users for my own domain-specific language. It&#8217;s better than telling the user to download some files and copy them to the workspace. Let me know if you found better ways.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2011/11/reusing-pde-in-modeling-context/feed/</wfw:commentRss>
		<slash:comments>3</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>0</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><iframe width="584" height="329" src="http://www.youtube.com/embed/3FgBYDoXPUU?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></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>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>
		<item>
		<title>Presentation theme for Eclipse</title>
		<link>http://cubussapiens.hu/2010/10/presentation-theme-for-eclipse/</link>
		<comments>http://cubussapiens.hu/2010/10/presentation-theme-for-eclipse/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 20:55:56 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[presentation theme]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1663</guid>
		<description><![CDATA[In the last year I often had to held live presentations of Eclipse development. At that point a typical problem is, that the font sizes used during development are too small for the projector. The possible solutions are either ignoring &#8230; <a href="http://cubussapiens.hu/2010/10/presentation-theme-for-eclipse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the last year I often had to held live presentations of Eclipse development. At that point a typical problem is, that the font sizes used during development are too small for the projector.</p>
<p>The possible solutions are either ignoring this fact, using a special environment, where all the appropriate settings have been made, or tweaking the development environment. The tweaking will not work, as several settings should be made, and they are easy to forget, while the special presentation environment seems too much of a hassle for me. This left as the only choice to ignore the fact.</p>
<p>But finally I had some hacking time, so I created a Presentation theme for Eclipse, that solves tweaking by a single selection of the user interface: Themes can be selected in the <strong>General</strong>/<strong>Appearance</strong> tab on the Preferences page.</p>
<p><a href="http://cubussapiens.hu/wp-content/uploads/2010/10/theme_settings.png" rel="lightbox[1663]" title="Selecting the Presentation theme"><img class="size-medium wp-image-1667" title="Selecting the Presentation theme" src="http://cubussapiens.hu/wp-content/uploads/2010/10/theme_settings-300x292.png" alt="The Presentation theme can be selected=" /></a></p>
<p>Currently, the theme description is a bit hacky: for every platform the default font is copied by hand to the plugin.xml (using a Windows 7, a OpenSuse 11.3 Linux and a Snow Leopard machine). More research is needed to solve this in a more generic way. Luckily only four fonts have been redefined by the theme.</p>
<p>Some things missing: support for resizing elements in JFace viewers (such as EMF tree editors or CNF views), and the theme was not tested with graphical editors &#8211; although they can be resized using the Zoom control.</p>
<p>Finally, an early alpha version can be downloaded from our update site: <a href="http://eclipse.cubussapiens.hu">http://eclipse.cubussapiens.hu</a></p>
<p>I&#8217;m looking for some feedback, or either alternative implementation ideas; I think, others have already met these problems.</p>
<p>The source is available from <a href="http://github.com/ujhelyiz/Presentation-Theme">GitHub</a>.</p>
<p><strong>Update</strong>: before/after screenshots below.</p>
<div id="attachment_1677" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2010/10/default_theme.png" rel="lightbox[1663]" title="The default theme"><img class="size-medium wp-image-1677" title="The default theme" src="http://cubussapiens.hu/wp-content/uploads/2010/10/default_theme-300x104.png" alt="The default theme on OSX uses small fonts" width="300" height="104" /></a><p class="wp-caption-text">Before: The default theme</p></div>
<div id="attachment_1679" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2010/10/pres_theme.png" rel="lightbox[1663]" title="Presentation theme"><img class="size-medium wp-image-1679" title="Presentation theme" src="http://cubussapiens.hu/wp-content/uploads/2010/10/pres_theme-300x104.png" alt="The Presentation theme uses increased font sizes" width="300" height="104" /></a><p class="wp-caption-text">After: Presentation theme</p></div>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2010/10/presentation-theme-for-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ecore model analysis for the win</title>
		<link>http://cubussapiens.hu/2010/08/ecore-model-analysis-for-the-win/</link>
		<comments>http://cubussapiens.hu/2010/08/ecore-model-analysis-for-the-win/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 22:04:57 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[static analysis]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1625</guid>
		<description><![CDATA[Today I tried to edit an Ecore/Generator model used in the VIATRA2 framework, but the system greated me with an error screen stating, there are 4 errors in the selected Genmodel. The error messages were a little bit cryptic (but &#8230; <a href="http://cubussapiens.hu/2010/08/ecore-model-analysis-for-the-win/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I tried to edit an Ecore/Generator model used in the VIATRA2 framework, but the system greated me with an error screen stating, there are 4 errors in the selected Genmodel.</p>
<p><a href="http://cubussapiens.hu/wp-content/uploads/2010/08/genmodel_validation.png" rel="lightbox[1625]" title="Validation errors in the genmodel"><img class="alignnone size-medium wp-image-1631" title="Validation errors in the genmodel" src="http://cubussapiens.hu/wp-content/uploads/2010/08/genmodel_validation-300x134.png" alt="Four validation errors at the opening of the genmodel" width="300" height="134" /></a></p>
<p>The error messages were a little bit cryptic (but all similar in nature): <tt>A containment reference of a type with a container feature platform:/resource/org.eclipse.viatra2.gtasm.model/model/gtasmmodel.ecore#//gtasm/metamodel/gt/GTPattern/namespace that requires instances to be contained elsewhere cannot be populated.</tt></p>
<p>This was scary, as I don&#8217;t remember any new core features in <a href="http://wiki.eclipse.org/EMF/New_and_Noteworthy/Helios">EMF 2.6</a>, that suggest such changes. My second guess was a misedited model, but after checking, that I have the same models as half year ago, this proved wrong. Even worse, these errors did not appear in either the <em>Problems</em> or <em>Error log</em> view. Checking the items mentioned in the error messages did not help, as the model elements looked &#8220;innocent enough&#8221; not to question their content.</p>
<p>It was only know when I saw that these errors are shown in a new, problem page in the editor (I often miss the editor pages option &#8211; except on form-based editors), and on the other page the tree is displayed, and code generation seemed also working.</p>
<p>At this point I looked on the internet for similar problems, and found a <a href="http://www.eclipse.org/forums/index.php?t=msg&amp;th=172359&amp;start=0&amp;">thread about the issue</a> in the EMF newsgroup. The main idea was Ed Merks&#8217;s comment:</p>
<blockquote><p>The point is supposed to be that you can&#8217;t be contained by more than one container, so you can&#8217;t have a container references that&#8217;s required as well as any other containment reference that&#8217;s not the opposite of that required container.  I.e., a required container prevents other containment references from ever being populated.</p></blockquote>
<p>Using this information I finally understood, what the error message meant, and begin looking for the cause in the Ecore model. After some searching (the error message only mentioned one model element from the three actors, and it is hard to get an overview of the inter modelelement relations in an EMF tree editor), I finally found the mentioned elements, that looked quite innocent at first &#8211; just take a look at the included graphical representation.</p>
<div id="attachment_1629" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2010/08/gtasmmodel_validationerror.png" rel="lightbox[1625]" title="Illustration of the found problem"><img class="size-medium wp-image-1629" title="Illustration of the found problem" src="http://cubussapiens.hu/wp-content/uploads/2010/08/gtasmmodel_validationerror-300x148.png" alt="An Ecore diagram to illustrate the found model validation error" width="300" height="148" /></a><p class="wp-caption-text">Illustration of the found problem</p></div>
<p>We have a <em>machine,</em> that contains both <em>patterns</em> and <em>rules</em>, while rules may contain addition pattern definitions (named <em>local pattern definitions</em>). On the other hand, patterns and rules have a backreference to the  machine (<em>namespace</em>). As we wanted to have the Machine reference available for local patterns, the pattern references exactly one machine.</p>
<p>The drawback of the solution is, that the <em>machine</em> reference is the inverse of the containment relation, so every <em>pattern</em> has to be contained in a <em>machine</em>. On the other hand, EMF requires that every EObject (not EClass) must have exactly one incoming containment reference for serialization, so it is not possible for a <em>rule</em> to be the container of a <em>pattern</em> &#8211; hence the error message.</p>
<p>This analysis is extremely useful: it shows, that our metamodel prevents having serializable models in some cases, which comes in handy (I wouldn&#8217;t like to be the one, who has to debug such an error after a runtime exception is caught&#8230;). The fix is not really straightforward, as this model is already used (interesting fact, that the issue has not been produced in runtime &#8211; this means, we don&#8217;t have 100% test coverage <img src='http://cubussapiens.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ), but by having a map to the error it is easier to fix.</p>
<p>I&#8217;d like to thank for the EMF team for this fine analysis solution, but some minor additions: don&#8217;t add warnings to a new page, use the existing reporting options; and try to rephrase the message for it to become more understandable.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2010/08/ecore-model-analysis-for-the-win/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update sites in the P2 era</title>
		<link>http://cubussapiens.hu/2010/08/update-sites-in-the-p2-era/</link>
		<comments>http://cubussapiens.hu/2010/08/update-sites-in-the-p2-era/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 19:56:26 +0000</pubDate>
		<dc:creator>Zoltán Ujhelyi</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[update site]]></category>

		<guid isPermaLink="false">http://cubussapiens.hu/?p=1579</guid>
		<description><![CDATA[Lately I have built several update sites during Eclipse development &#8211; e.g. for the last release of the Debug Visualisation plugin, or some related to VIATRA2 based articles (maybe more details later). They have all one thing in common: they &#8230; <a href="http://cubussapiens.hu/2010/08/update-sites-in-the-p2-era/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Lately I have built several update sites during Eclipse development &#8211; e.g. for the <a href="/?p=1483">last release of the Debug Visualisation</a> plugin, or some related to VIATRA2 based articles (maybe more details later). They have all one thing in common: they were not created using Update site projects.</p>
<p>In my experience since P2 came as a provisining platform the Update site projects were not the best available solutions: at first (in Ganymede) they did not produce everything P2 needed, while produced legacy information, that triggered a backward compatible mode in the provisining platform (officially the old Update managers site.xml should not be used). Even worse, I experienced some serious errors, when trying to add a new version of the already added plug-ins to the already built update site &#8211; in most cases the category definitions were removed (as in Galileo by default all features without category are hidden, this problem is quite serious).</p>
<p>On the other hand, not too long ago classic update sites were also needed to provide update sites for both the Update manager and P2. Today the Update Manager compatibility is not as crucial, as all Eclipse versions supported by eclipse.org use P2, so it is better to use some dedicated P2-based mechanism for Update site creation.</p>
<p>This mechanism is present since Eclipse 3.4 (at least from the command line, as documented in the Eclipse wiki), but is a bit hard to use. Recently I found a somewhat hidden option in the GUI, that provides the P2 metadata generation functionality &#8211; just as needed.</p>
<p>To use this, at least one (or possibly more) features are needed &#8211; the features are the minimum installable units. When the features are ready and the related plug-ins are attached, the Export wizard has to be invoked with the <em>Deployable Features</em> wizard from the <em>Plug-in Development</em> category.</p>
<p>The deployable features and the destination should be selected as needed (in my experience the directory export makes possible the easiest update site deployment, while the zipped archive allows the easiest direct transport &#8211; e.g. for dropins).</p>
<div id="attachment_1585" class="wp-caption alignnone" style="width: 310px"><a href="http://cubussapiens.hu/wp-content/uploads/2010/08/export_features2.png" rel="lightbox[1579]" title="Export deployable features wizard"><img class="size-medium wp-image-1585" title="Export deployable features wizard" src="http://cubussapiens.hu/wp-content/uploads/2010/08/export_features2-300x221.png" alt="The export deployable features wizard in action" width="300" height="221" /></a><p class="wp-caption-text">Export deployable features wizard</p></div>
<p>The P2-related magic should be initiated on the Options page: if the <em>Generate metadata repository</em> option is selected, as in the screenshot, during the export all metadata needed by P2 is generated.</p>
<p>For categorization of the repository a specific xml-file should be created: by creating a <em>Category Definition</em> from the <em>New&#8230;</em> wizard a simple form-based editor can be used to define categories for the installer, that can also be selected using the Export wizard.</p>
<p>Some additional tips and tricks related to the deployment:</p>
<ul>
<li><strong>To update existing P2-based update sites,</strong> simply point the export destination to the already existing update site. This updates the existing update site &#8211; I only tried this using the directory-based output.</li>
<li>To avoid <strong>runtime issues</strong>, make sure that the exported plug-in projects use the needed Java version compatibility in the project settings (e.g. if the manifest requires Java 1.5, make sure the project gets compiled in Java 1.5 compatibility mode), as the plug-ins are recompiled using these settings. I managed to get a Java 1.5 compatible project compiled with Java 1.6 compliance settings &#8211; the plug-ins even got installed, but did not work in the target computer, instead a hard to debug runtime exception is thrown.</li>
<li>It is possible to add <strong>source boundles</strong> by selecting the appropriate checkbox. On the other hand I couldn&#8217;t find a way to set the display name of the generated source bundles, and they are shown with the same name as the non-source plug-in, making it hard to distinguish between them during runtime. If you know the solution, please let me know.</li>
</ul>
<p>In general, this export mechanism works well, without any major issues, I tested in repeatedly with several update sites. Unless for some reason Update manager compatibility is needed, I don&#8217;t recommend using Update site projects anymore &#8211; simply export your features to deploy.</p>]]></content:encoded>
			<wfw:commentRss>http://cubussapiens.hu/2010/08/update-sites-in-the-p2-era/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

