<?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>MDA, MDSD, MDE, MDWhatever! &#187; magicdraw</title>
	<atom:link href="http://mdwhatever.free.fr/index.php/tag/magicdraw/feed/" rel="self" type="application/rss+xml" />
	<link>http://mdwhatever.free.fr</link>
	<description>About model driven engineering</description>
	<lastBuildDate>Mon, 12 Mar 2012 19:56:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to debug your MagicDraw plugin with Eclipse</title>
		<link>http://mdwhatever.free.fr/index.php/2010/07/how-to-debug-your-magicdraw-plugin/</link>
		<comments>http://mdwhatever.free.fr/index.php/2010/07/how-to-debug-your-magicdraw-plugin/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 05:08:10 +0000</pubDate>
		<dc:creator>xavier</dc:creator>
				<category><![CDATA[Model Driven]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[magicdraw]]></category>
		<category><![CDATA[magicdraw open API]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://mdwhatever.free.fr/?p=143</guid>
		<description><![CDATA[After reading this post, you are now MagicDraw open API experts! But you still need to debug your plugins! Here is a short presentation on how to debug your MagicDraw plugin with Eclipse. Create your MagicDraw user library First of all you need to create a user library (Window&#62;Preferences&#62;Java&#62;Build Path&#62;User Libraries) in Eclipse containing every]]></description>
			<content:encoded><![CDATA[<p>After reading this <a title="post" href="http://mdwhatever.free.fr/index.php/2010/03/how-to-develop-your-magicdraw-plugin/" target="_blank">post</a>, you are now MagicDraw open API experts! But you still need to debug your plugins! Here is a short presentation on how to debug your MagicDraw plugin with Eclipse.</p>
<p><span id="more-143"></span></p>
<h2>Create your MagicDraw user library</h2>
<p>First of all you need to create a user library (Window&gt;Preferences&gt;Java&gt;Build Path&gt;User Libraries) in Eclipse containing <strong>every *.jar</strong> from the &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;/lib</strong>&#8221; and its subfolders.</p>
<p style="text-align: center;"><a href="http://mdwhatever.free.fr/wp-content/uploads/MagicDrawUserLibrary.png" rel="shadowbox[post-143];player=img;" title="MagicDraw User Library"><img class="size-medium wp-image-148 aligncenter" style="border: 1px solid black;" title="MagicDraw User Library" src="http://mdwhatever.free.fr/wp-content/uploads/MagicDrawUserLibrary-300x187.png" alt="" width="300" height="187" /></a></p>
<h2>Create your debug project</h2>
<p>Create a new Java Project, and then you need to reference your plugin project in the build path of your debug project : (Right click ﻿on the project&gt;Configure build path)</p>
<p style="text-align: center;"><a href="http://mdwhatever.free.fr/wp-content/uploads/Properties-for-magicdraw-debug-.png" rel="shadowbox[post-143];player=img;" title="Add your plugin project to the build path"><img class="aligncenter size-medium wp-image-144" style="border: 1px solid black;" title="Add your plugin project to the build path" src="http://mdwhatever.free.fr/wp-content/uploads/Properties-for-magicdraw-debug--300x199.png" alt="" width="300" height="199" /></a></p>
<p>Here I take the Eclipse project given in this <a title="post" href="http://mdwhatever.free.fr/index.php/2010/03/how-to-develop-your-magicdraw-plugin/" target="_blank">post</a>.</p>
<p>Then you need to create a main class which will init your plugin and launch MagicDraw :</p>
<pre lang="java">
package fr.free.mdwhatever.magicdrawDebug;

import com.nomagic.magicdraw.core.Application;
import com.nomagic.runtime.ApplicationExitedException;

import fr.free.mdwhatever.simplePlugin.SimplePlugin;
/**
 * This class allows you to debug your MagicDraw plugin
 *
 * @author Xavier Seignard
 */
public class Debug {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			SimplePlugin plugin = new SimplePlugin();
			Application app = Application.getInstance();
			// Start the application (visible, not silent,
			// don't try to load a project, the given args,
			// the StartUp participant)
			app.start(true, false, false, args, null);
			plugin.init();
		} catch (ApplicationExitedException e) {
			e.printStackTrace();
		}
	}
}
</pre>
<p>Then all you need to do is to right-click on this class and choose &#8220;Debug as&#8221; to launch MagicDraw within the Eclipse debugger and use all the functionalities it gives us!</p>
<p><strong>Nota :</strong> Maybe you&#8217;ll need to tune up a bit more your debug configuration by adding &#8220;-Xmx1024m&#8221; as VM argument as shown below :</p>
<p style="text-align: center;"><a href="http://mdwhatever.free.fr/wp-content/uploads/RunConfiguration.png" rel="shadowbox[post-143];player=img;" title="Run Configuration VM argument"><img class="aligncenter size-medium wp-image-154" style="border: 1px solid black;" title="Run Configuration VM argument" src="http://mdwhatever.free.fr/wp-content/uploads/RunConfiguration-300x197.png" alt="" width="300" height="197" /></a></p>
<p>Hope this helps! See you!</p>
]]></content:encoded>
			<wfw:commentRss>http://mdwhatever.free.fr/index.php/2010/07/how-to-debug-your-magicdraw-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Model driven tools : the big list!</title>
		<link>http://mdwhatever.free.fr/index.php/2010/06/model-driven-tools-the-big-list/</link>
		<comments>http://mdwhatever.free.fr/index.php/2010/06/model-driven-tools-the-big-list/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 20:57:33 +0000</pubDate>
		<dc:creator>xavier</dc:creator>
				<category><![CDATA[Model Driven]]></category>
		<category><![CDATA[abse]]></category>
		<category><![CDATA[acceleo]]></category>
		<category><![CDATA[actifsource]]></category>
		<category><![CDATA[agile platform]]></category>
		<category><![CDATA[andromda]]></category>
		<category><![CDATA[aspectize]]></category>
		<category><![CDATA[atl]]></category>
		<category><![CDATA[atomweaver]]></category>
		<category><![CDATA[bluage]]></category>
		<category><![CDATA[celerio]]></category>
		<category><![CDATA[codefluent]]></category>
		<category><![CDATA[e4 xwt]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[emftext]]></category>
		<category><![CDATA[enterprise architect]]></category>
		<category><![CDATA[itemis]]></category>
		<category><![CDATA[jaxio]]></category>
		<category><![CDATA[jetbrain mps]]></category>
		<category><![CDATA[magicdraw]]></category>
		<category><![CDATA[mda]]></category>
		<category><![CDATA[mde]]></category>
		<category><![CDATA[mdsd]]></category>
		<category><![CDATA[mendix]]></category>
		<category><![CDATA[metacase]]></category>
		<category><![CDATA[metaedit+]]></category>
		<category><![CDATA[mia-software]]></category>
		<category><![CDATA[mia-studio]]></category>
		<category><![CDATA[model driven tools]]></category>
		<category><![CDATA[modisco]]></category>
		<category><![CDATA[obeo]]></category>
		<category><![CDATA[obeo designer]]></category>
		<category><![CDATA[qvto]]></category>
		<category><![CDATA[redview]]></category>
		<category><![CDATA[softfluent]]></category>
		<category><![CDATA[springfuse]]></category>
		<category><![CDATA[springroo]]></category>
		<category><![CDATA[wazaabi]]></category>
		<category><![CDATA[xpand]]></category>
		<category><![CDATA[xtend]]></category>
		<category><![CDATA[xtext]]></category>

		<guid isPermaLink="false">http://mdwhatever.free.fr/?p=121</guid>
		<description><![CDATA[I&#8217;ll try to list all the MDE tools I know, I&#8217;ll also try to reference them by their scope. Feel free to comment this list of MDE tools! M2M/M2T tools: actifsource (http://www.actifsource.com/) AndroMDA (http://www.andromda.org/) Eclipse ATL (http://www.eclipse.org/atl/) is a part of Eclipse Modeling project Eclipse QVTO (http://wiki.eclipse.org/M2M/QVTO) is a part of Eclipse Modeling project Itemis/Eclipse xpand/xtend (http://wiki.eclipse.org/Xpand)]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll try to list all the MDE tools I know, I&#8217;ll also try to reference them by their scope. Feel free to comment this list of MDE tools!</p>
<p><strong>M2M/M2T tools:</strong></p>
<ul>
<li>actifsource (<a href="http://www.actifsource.com/">http://www.actifsource.com/</a>)</li>
<li>AndroMDA (<a href="http://www.andromda.org/">http://www.andromda.org/</a>)</li>
<li>Eclipse ATL (<a href="http://www.eclipse.org/atl/">http://www.eclipse.org/atl/</a>) is a part of <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a></li>
<li>Eclipse QVTO (<a href="http://wiki.eclipse.org/M2M/QVTO">http://wiki.eclipse.org/M2M/QVTO</a>) is a part of <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a></li>
<li>Itemis/Eclipse xpand/xtend (<a href="http://wiki.eclipse.org/Xpand">http://wiki.eclipse.org/Xpand</a>) it was originaly a part of the no longer supported openArchitectureWare (<a href="http://oaw.itemis.com/">http://oaw.itemis.com/</a> &amp; <a href="http://www.openarchitectureware.org/">http://www.openarchitectureware.org/</a>)  is now a part of <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a></li>
<li><a href="http://www.eclipse.org/modeling/"></a>Mia-Software Mia-Generation (<a href="http://www.mia-software.com/">http://www.mia-software.com/</a>) is a part of Mia-Studio tool suite</li>
<li>Mia-Software Mia-Transformation (<a href="http://www.mia-software.com/">http://www.mia-software.com/</a>) is a part of Mia-Studio tool suite</li>
<li>Obeo/Eclipse Acceleo (<a href="http://www.eclipse.org/acceleo/">http://www.eclipse.org/acceleo/</a>) is a M2T tool that has recently moved from the Obeo (<a href="http://www.obeo.fr/">http://www.obeo.fr/</a>) company to <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a></li>
</ul>
<p><span id="more-121"></span></p>
<p><strong>MDE application builders:</strong></p>
<ul>
<li>Artisan Software Tools Artisan Studio (<a href="http://www.artisansoftwaretools.com/">http://www.artisansoftwaretools.com/</a>) for SysML</li>
<li>Aspectize (<a href="http://aspectize.com/">http://aspectize.com/</a>) for .NET target</li>
<li>BluAge (<a href="http://www.bluage.com/">http://www.bluage.com/</a>)</li>
<li>Jaxio Celerio (<a href="http://www.jaxio.com/">http://www.jaxio.com/</a>)</li>
<li>Jaxio SpringFuse (<a href="http://www.springfuse.com/">http://www.springfuse.com/</a>) for Java Spring</li>
<li>Mendix (<a href="http://www.mendix.com/">http://www.mendix.com/</a>)</li>
<li>Outsystems Agile Platform (<a href="http://www.outsystems.com/agile-platform">http://www.outsystems.com/agile-platform</a>)</li>
<li>SkyWay Software SkyWay Builder (<a href="http://www.skywayperspectives.org/">http://www.skywayperspectives.org/</a>) for Java Spring</li>
<li>Sodius MDWorkbench (<a href="http://www.mdworkbench.com/">http://www.mdworkbench.com/</a> &amp; <a href="http://www.sodius.com/">http://www.sodius.com/</a>)</li>
<li>SoftFluent CodeFluent Entities (<a href="http://www.codefluententities.com/">http://www.codefluententities.com/</a> &amp; <a href="http://www.softfluent.com/">http://www.softfluent.com/</a>) for .NET target</li>
<li>SpringSource SpringRoo (<a href="http://www.springsource.org/roo">http://www.springsource.org/roo</a>) for Java Spring</li>
</ul>
<p><strong>Language workbenches:</strong></p>
<ul>
<li>EMFText (<a href="http://www.emftext.org/index.php/EMFText">http://www.emftext.org/</a>)</li>
<li>Itemis/Eclipse TMF Xtext (<a href="http://xtext.itemis.com/">http://xtext.itemis.com/</a>) is a part of <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a> (<a href="http://www.eclipse.org/Xtext/">http://www.eclipse.org/Xtext/</a>)</li>
<li>Jetbrains MPS (<a href="http://www.jetbrains.com/mps/">http://www.jetbrains.com/mps/</a>)</li>
<li>Spoofax (<a href="http://strategoxt.org/Spoofax/WebHome">http://strategoxt.org/Spoofax/WebHome</a>)</li>
</ul>
<p><strong>DSM (Domain Specific Modeling) workbenches:</strong></p>
<ul>
<li>Isomeris ABSE &amp; Atomweaver (<a href="http://www.atomweaver.com/">http://www.atomweaver.com/</a> , <a href="http://www.abse.info/">http://www.abse.info/</a> &amp; <a href="http://www.isomeris.com/">http://www.isomeris.com/</a>) quite intriguing tools that will be launched during Q3(July) 2010</li>
<li>MetaCase MetaEdit+ (<a href="http://www.metacase.com/">http://www.metacase.com/</a>)</li>
<li>Obeo Designer (<a href="http://www.obeo.fr/pages/obeo-designer/en">http://www.obeo.fr/pages/obeo-designer/en</a>)</li>
</ul>
<p><strong>MDE UI design tools:</strong></p>
<ul>
<li>Eclipse E4/XWT (<a href="http://wiki.eclipse.org/E4/XWT">http://wiki.eclipse.org/E4/XWT</a>)</li>
<li>redView (<a href="http://redview.org/">http://redview.org/</a>)</li>
<li>wazaabi (<a href="http://wazaabi.org/">http://wazaabi.org/</a>)</li>
</ul>
<p><strong>Modernization tools:</strong></p>
<ul>
<li>eclipse MoDisco (<a href="http://www.eclipse.org/MoDisco/">http://www.eclipse.org/MoDisco/</a>) is a part of <a href="http://www.eclipse.org/modeling/">Eclipse Modeling project</a></li>
<li>Mia-Sotware Mia-Modernization (<a href="http://www.mia-software.com/">http://www.mia-software.com/</a>) is a part of Mia-Studio tool suite</li>
<li>Obeo Agility (<a href="http://www.obeo.fr/pages/agility/en">http://www.obeo.fr/pages/agility/en</a>)</li>
</ul>
<p><strong>CASE tools with MDE capabilities:</strong></p>
<ul>
<li>ModelioSoft Modelio (<a href="http://www.modeliosoft.com/">http://www.modeliosoft.com/</a>)</li>
<li>NoMagic MagicDraw (<a href="http://www.magicdraw.com/">http://www.magicdraw.com/</a>)</li>
<li>Sparx System Enterprise Architect (<a href="http://www.sparxsystems.com/products/ea/">http://www.sparxsystems.com/products/ea/</a>)</li>
</ul>
<p><strong>XSLT based tool:</strong></p>
<ul>
<li>Xomega (<a href="http://www.xomega.net/">http://www.xomega.net/</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mdwhatever.free.fr/index.php/2010/06/model-driven-tools-the-big-list/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>How to develop your MagicDraw plugin</title>
		<link>http://mdwhatever.free.fr/index.php/2010/03/how-to-develop-your-magicdraw-plugin/</link>
		<comments>http://mdwhatever.free.fr/index.php/2010/03/how-to-develop-your-magicdraw-plugin/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 21:18:38 +0000</pubDate>
		<dc:creator>xavier</dc:creator>
				<category><![CDATA[Model Driven]]></category>
		<category><![CDATA[magicdraw]]></category>
		<category><![CDATA[magicdraw open API]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[mde]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://mdwhatever.free.fr/?p=44</guid>
		<description><![CDATA[MagicDraw is a great modeling tool¹ for lot of reasons. First of all : this is a mature tool, enterprise ready, and easy to use. Then there&#8217;s a lot of great side functionalities like : reporting templates, dependency matrix, active validation and even more²! But in a model driven environment, MagicDraw is great because of]]></description>
			<content:encoded><![CDATA[<p>MagicDraw is a great modeling tool<a href="#note1">¹</a> for lot of reasons. First of all :</p>
<ul>
<li>this is a mature tool,</li>
<li>enterprise ready,</li>
<li>and easy to use.</li>
</ul>
<p>Then there&#8217;s a lot of great side functionalities like :</p>
<ul>
<li>reporting templates,</li>
<li>dependency matrix,</li>
<li>active validation</li>
<li>and even more<a href="#note2">²</a>!</li>
</ul>
<p>But in a model driven environment, MagicDraw is great because of its <a title="open API" href="http://www.magicdraw.com/main.php?ts=navig&amp;cmd_show=1&amp;menu=feature_list#Open_API" target="_blank">open API</a> which allows you to manipulate models and diagrams really easily.</p>
<p>So it&#8217;s time to introduce a simple plugin to get familiar with this open API!<span id="more-44"></span></p>
<h1>Some resources to start</h1>
<p>First of all, you&#8217;ll find javadoc and samples in the &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;\openapi</strong>&#8221; directory and documentation in &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;\manual\MagicDraw OpenAPI UserGuide.pdf</strong>&#8220;.</p>
<p>The documentation is really good, so I think you&#8217;ll find all what you need there.</p>
<h1>How plugins are working?</h1>
<p>Each time MagicDraw starts, it scans the &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;\plugin</strong>&#8221; directory to find subdirectories containing two main things :</p>
<ul>
<li>A &#8220;<strong>plugin.xml</strong>&#8221; file which describes your plugin, the required libraries, and how to start it.</li>
<li>A jar containing a class which extends the &#8220;<strong>com.nomagic.magicdraw.plugins.Plugin</strong>&#8221; and implements its &#8220;<strong>init()</strong>&#8221; method.</li>
</ul>
<h2>Plugin.xml</h2>
<pre lang="xml" escaped="true">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!-- The id must be unique, I generally put the class that extends the Plugin class as id. --&gt;
&lt;plugin
    &lt;!-- The id must be unique, I generally put the class that extends the Plugin class as id. --&gt;
    id="fr.free.mdwhatever.simplePlugin.magicDraw.SimplePlugin"
    name="SimplePlugin"

    &lt;!-- Here I put project.version as version because Maven will filter it and put the same version you find in the pom.xml. --&gt;
    version="${project.version}" 

    &lt;!-- Who is providing this plugin (i.e. your company or whatever). --&gt;
    provider-name="Xavier Seignard"

    &lt;!-- The class which extends the com.nomagic.magicdraw.plugins.Plugin class
    in order to init your plugin within MagicDraw. --&gt;
    class="fr.free.mdwhatever.simplePlugin.magicDraw.SimplePlugin"&gt;

    &lt;!-- MagicDraw API version required by plug-in. Plug-ins and their requires versions required by plug-in. --&gt;
    &lt;requires&gt;
        &lt;api version="1.0" /&gt;
    &lt;/requires&gt;

    &lt;!-- The runtime libraries your plugin needs. --&gt;
    &lt;runtime&gt;
        &lt;library name="${artifactId}-${version}.${packaging}" /&gt;
    &lt;/runtime&gt;
&lt;/plugin&gt;</pre>
<h2>The SimplePlugin class</h2>
<p>Here is the plugin entrance, take a look at the commented code.</p>
<pre lang="java">package fr.free.mdwhatever.simplePlugin;

import com.nomagic.magicdraw.plugins.Plugin;
import com.nomagic.actions.ActionsCategory;
import com.nomagic.magicdraw.actions.ActionsConfiguratorsManager;
import com.nomagic.magicdraw.core.Application;

/**
 * This class allows you to load your plugin in MagicDraw
 *
 * @author Xavier Seignard
 */
public class SimplePlugin extends Plugin {

    // Methods
    /**
     * Plugin initialization and registration of the action in MagicDraw
     */
    public void init() {
        try {
            // We create a new actions category
            ActionsCategory category = new ActionsCategory(null, null);
            // We add our plugin action in this newly created category
            category.addAction(new SimplePluginAction());
            // We get the MagicDraw action manager
            ActionsConfiguratorsManager manager = ActionsConfiguratorsManager.getInstance();
            // We add our new configuration for our category in the MagicDraw action manager
            manager.addContainmentBrowserContextConfigurator(new BrowserContextConfigurator(category));
            // If everything is OK we log it to the MagicDraw GUI logger
            // Not really clever to put it there, but it's just to show how to log something in MagicDraw
            Application.getInstance().getGUILog().log("[Simple Plugin] Loading OK");
        }
        catch (Exception e) {
            // If something goes wrong we log it to the MagicDraw GUI logger
            Application.getInstance().getGUILog().log(
                    "[Simple Plugin] Could not instantiate plugin : " + e.toString());
        }
    }

    /**
     * The plugin is always supported, no matter the version of MagicDraw, or the perspective, or what you want.
     *
     * @return always true
     */
    public boolean isSupported() {
        return true;
    }

    /**
     * Return true always, because this plugin does not have any close specific actions.
     *
     * @return always true
     */
    public boolean close() {
        return true;
    }
}</pre>
<h1>This plugin has to do something!</h1>
<h2>How to trigger it?</h2>
<p>Some plugin can just listen to some event, or it can be triggered by a contextual menu item or a button or whatever. In the case below we add a contextual menu item. (Have a look at the &#8220;<em>com.nomagic.magicdraw.actions.ActionsConfiguratorsManager</em>&#8220;)</p>
<pre lang="java">package fr.free.mdwhatever.simplePlugin;

import com.nomagic.actions.ActionsManager;
import com.nomagic.magicdraw.actions.BrowserContextAMConfigurator;
import com.nomagic.magicdraw.ui.browser.Tree;
import com.nomagic.actions.ActionsCategory;
import com.nomagic.actions.NMAction;
import com.nomagic.magicdraw.actions.MDActionsCategory;
import com.nomagic.actions.AMConfigurator;

/**
 * This class allows you to add your plugin action (i.e. SimplePluginAction.java) in MagicDraw contextual menu.
 * @author Xavier Seignard
 */
public class BrowserContextConfigurator implements BrowserContextAMConfigurator {
    // Attributes

    // Here is the category of the contextual menu where you'll find you plugin
    public final static String SIMPLE_PLUGIN_MENU_CATEGORY = "Simple Plugin Menu Category";
    // Here is the ID of your category
    public final static String SIMPLE_PLUGIN_MENU_ID = "SimplePluginMenuID";
    // Plugin action
    private NMAction action;

    /**
     * Default constructor.
     *
     * @param nmAction the NMAction to set
     */
    public BrowserContextConfigurator(NMAction nmAction) {
        this.action = nmAction;
    }

    // Methods
    /**
     * Adds the plugin in the MagicDraw ui.
     *
     * @param mngr the action manager of MagicDraw to be configured
     * @param tree the containement tree of MagicDraw, where the plugin will be added
     */
    public void configure(ActionsManager mngr, Tree tree) {
        // We try to find the existing category
        ActionsCategory category = (ActionsCategory) mngr.getActionFor(SIMPLE_PLUGIN_MENU_ID);
        // If it doesn't exist we create it
        if (category == null) {
            category = new MDActionsCategory(SIMPLE_PLUGIN_MENU_ID, SIMPLE_PLUGIN_MENU_CATEGORY);
            category.setNested(true);
            mngr.addCategory(category);
        }
        // Then we add the action to the category
        category.addAction(action);
    }

    /**
     * Getter for priority.
     *
     * @return the priority int
     */
    public int getPriority() {
        return AMConfigurator.MEDIUM_PRIORITY;
    }
}</pre>
<h2>Set its behaviour</h2>
<p>You have to extend the corresponding action, in this case : <strong>DefaultBrowserAction</strong>.</p>
<pre lang="java">package fr.free.mdwhatever.simplePlugin;

import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import com.nomagic.magicdraw.ui.browser.actions.DefaultBrowserAction;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element;

/**
 * This class defines the behavior of the action in your plugin.
 *
 * @author Xavier Seignard
 */
public class SimplePluginAction extends DefaultBrowserAction {
    // Attributes
    // Serial version UID.
    private static final long serialVersionUID = 1L;
    // The name of the action which will be displayed in MagicDraw
    private static final String SIMPLE_PLUGIN_ACTION_NAME = "Simple Plugin Action";
    // The id of the action which will be displayed in MagicDraw
    private static final String SIMPLE_PLUGIN_ACTION_ID = "SimplePluginActionID";

    /**
     * Default constructor.
     *
     * @throws Exception if the super(...) call fails
     */
    public SimplePluginAction() throws Exception {
        super(SIMPLE_PLUGIN_ACTION_ID, SIMPLE_PLUGIN_ACTION_NAME, null, null);
    }

    // Methods
    /**
     * Here you define what does your action
     *
     * @param actionEvent the triggering event
     */
    public void actionPerformed(ActionEvent actionEvent) {
        SimplePluginBehavior simplePluginBehavior = new SimplePluginBehavior();
        CountingVisitor countingVisitor = simplePluginBehavior.getVisitor();
        // Clear the map for a clean count
        countingVisitor.getMap().clear();

        // Visit the children for counting elements of each type
        simplePluginBehavior.visitChildren((Element) getSelectedObject());
        // Display the counting results
        String result = simplePluginBehavior.returnResults(countingVisitor.getMap());
        JOptionPane.showMessageDialog(null, result);
    }

    /**
     * Defines when your action is available.
     */
    public void updateState() {
        // This action is only available when your click on an instance of Element in the containment tree
        if (this.getSelectedObject() != null) {
            if (this.getSelectedObject() instanceof Element) {
                setEnabled(true);
            }
            else {
                setEnabled(false);
            }
        }
        else {
            setEnabled(false);
        }
    }
}</pre>
<h2>This visitor pattern</h2>
<p>The visitor pattern is well implemented in the Magicdraw open API, and it saves you a lot of efforts, so use it!</p>
<pre lang="java">package fr.free.mdwhatever.simplePlugin;

import java.util.HashMap;
import com.nomagic.magicdraw.uml.BaseElement;
import com.nomagic.magicdraw.uml.ClassTypes;
import com.nomagic.magicdraw.uml.InheritanceVisitor;
import com.nomagic.uml2.ext.jmi.reflect.VisitorContext;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element;

/**
 * This class extends InheritanceVisitor to count element through the visitor pattern.
 * @author Xavier Seignard
 *
 */
public class CountingVisitor extends InheritanceVisitor {

    // Map for counting results. Class type is a key, number is a value.
    private HashMap countMap = new HashMap();

    /**
     * The visitation of the element.
     *
     * @param element the element to visit.
     * @param context the context of the visitor.
     */
    public void visitElement(Element element, VisitorContext context) {
        super.visitElement(element, context);
        // Call the count
        countElements(element);
    }

    /**
     * Count elements of each type.
     *
     * @param element the element to count.
     */
    public void countElements(BaseElement element) {
        // We get the human readable name of the element
        String classType = ClassTypes.getShortName(element.getClassType());
        // Then we get the count of this type of elements
        Integer count = countMap.get(classType);
        // If it is the first element of this type we visit, we need to create a new value for the counting
        if (count == null) {
            count = Integer.valueOf(0);
        }
        // Finally we increase the count
        countMap.put(classType, Integer.valueOf(count.intValue() + 1));
    }

    /**
     * Getter for countMap.
     * @return the countMap
     */
    public HashMap getMap() {
        return countMap;
    }
}</pre>
<h2>The implementation of the behavior</h2>
<p>Finally here is the implementation of the behaviour which allows you to calculate some metric like classes per package, or methods per classes :</p>
<pre lang="java">package fr.free.mdwhatever.simplePlugin;

import java.util.HashMap;
import com.nomagic.magicdraw.core.Application;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element;

/**
 * The behavior of our MagicDraw plugin
 *
 * @author Xavier Seignard
 */
public class SimplePluginBehavior {  

    // Our visitor to count the type of each element.
    private CountingVisitor visitor = new CountingVisitor();

    /**
     * Returns a string containing the counting results
     *
     * @param map the HashMap containing the counting results
     * @return string describing the counting results
     */
    public String returnResults(HashMap map)
    {
        // The string to return
        String textToReturn = "";
        textToReturn += "Number of elements for each types :\n";
        for (String key : map.keySet()) {
            textToReturn += "\t"  + key + " : " + (map.get(key)).intValue() + "\n";
        }

        // Calculation for some means (the real interesting part)
        Integer packages = map.get("Package");
        Integer classes = map.get("Class");
        Integer attributes = map.get("Property");
        Integer operations = map.get("Operation");

        if (packages != null &amp;&amp; classes != null) {
            textToReturn += "Average classes per package : " + (classes.doubleValue()/packages.doubleValue()) + "\n";
        }

        if (classes!=null &amp;&amp; operations!=null) {
            textToReturn += "Average operations per class : " + (operations.doubleValue()/classes.doubleValue()) + "\n";
        }

        if (classes!=null &amp;&amp; attributes!=null)
            textToReturn += "Average attributes per class : " + (attributes.doubleValue()/classes.doubleValue()) + "\n";

        // if map was empty and no elements was found.
        if (textToReturn.length()==0)
        {
            textToReturn = "No elements found!";
        }

        return textToReturn;
    }

    /**
     * We parse all the children of the given root element.
     * For each element, we visit it to count the types of the elements
     *
     * @param rootElement the root element to start counting
     */
    public void visitChildren(Element rootElement)
    {
        try {
            rootElement.accept(visitor);
        }
        catch (Exception e) {
            // If something goes wrong we log it to the MagicDraw GUI logger
            Application.getInstance().getGUILog().log(
                    "[Simple Plugin] Exception occured : " + e.toString());
        }
        // We visit the children elements
        for (Element child : rootElement.getOwnedElement()) {
              visitChildren(child);
        }
    }

    /**
     * Getter for the visitor.
     * @return the visitor
     */
    public CountingVisitor getVisitor() {
        return visitor;
    }
}</pre>
<h1>Conclusion</h1>
<p>You&#8217;re now familiar with the MagicDraw openAPI! So lets go and develop your own plugin!</p>
<p>You&#8217;ll find a packaged version of this Eclipse/Maven2 project there : <a title="magicdraw-simple-plugin.tar.gz" href="http://mdwhatever.free.fr/wp-content/uploads/magicdraw-simple-plugin.tar.gz" target="_blank">magicdraw-simple-plugin.tar.gz</a><br />
To set up your environement, you&#8217;ll have to upload some MagicDraw libs to your maven2 local repo. You&#8217;ll find them in the &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;\lib\</strong>&#8221; directory. The list of the needed libs are described in the &#8220;<strong>dependencies</strong>&#8221; section in the &#8220;<strong>pom.xml</strong>&#8221; file.</p>
<p>You&#8217;ll also need to declare an environement variable &#8220;<strong>MDUML_HOME</strong>&#8221; which is the &#8220;<strong>&lt;MagicDraw_Install_Dir&gt;</strong>&#8220;.</p>
<p>Then if you execute a &#8220;<strong>mvn clean install</strong>&#8221; it will compile the plugin and install it on your MagicDraw installation. And you&#8217;ll just have to start MagicDraw to test the plugin.</p>
<p>In a next blog post we&#8217;ll see how to debug your plugins within Eclipse.</p>
<hr />
<p id="note1">1 : Have a look here : <a title="MagicDraw testimonials" href="http://www.magicdraw.com/main.php?ts=navig&amp;=&amp;cmd_show=1&amp;menu=testimonials" target="_blank">http://www.magicdraw.com/main.php?ts=navig&amp;=&amp;cmd_show=1&amp;menu=testimonials</a>, you&#8217;ll find my testimonial!</p>
<p id="note2">2 : Here is the features list of MagicDraw: <a title="MagicDraw features" href="http://www.magicdraw.com/main.php?ts=navig&amp;cmd_show=1&amp;menu=feature_list" target="_blank">http://www.magicdraw.com/main.php?ts=navig&amp;cmd_show=1&amp;menu=feature_list</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mdwhatever.free.fr/index.php/2010/03/how-to-develop-your-magicdraw-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Maven2 : &#8220;l&#8217;orchestrateur&#8221; de l&#8217;ingénierie des modèles</title>
		<link>http://mdwhatever.free.fr/index.php/2010/01/maven2-lorchestrateur-de-lingenierie-des-modeles/</link>
		<comments>http://mdwhatever.free.fr/index.php/2010/01/maven2-lorchestrateur-de-lingenierie-des-modeles/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 10:12:59 +0000</pubDate>
		<dc:creator>xavier</dc:creator>
				<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Model Driven]]></category>
		<category><![CDATA[emf]]></category>
		<category><![CDATA[magicdraw]]></category>
		<category><![CDATA[mde]]></category>
		<category><![CDATA[mia-software]]></category>

		<guid isPermaLink="false">http://mdwhatever.free.fr/?p=32</guid>
		<description><![CDATA[Dans un contexte d&#8217;ingénierie des modèles, Maven2 est un outil formidable pour orchestrer les différents traitements que subissent nos modèles. C&#8217;est ce que nous appliquons chez le client chez qui j&#8217;interviens. Maven2 nous sert (entre autres) à : Exécuter un export vers XMI depuis MagicDraw ; Exécuter des fonctionalités particulières de MagicDraw sans pour autant]]></description>
			<content:encoded><![CDATA[<p>Dans un contexte d&#8217;ingénierie des modèles, Maven2 est un outil formidable pour orchestrer les différents traitements que subissent nos modèles.</p>
<p>C&#8217;est ce que nous appliquons chez le client chez qui j&#8217;interviens.</p>
<p>Maven2 nous sert (entre autres) à :</p>
<ul>
<li>Exécuter un export vers XMI depuis MagicDraw ;</li>
<li>Exécuter des fonctionalités particulières de MagicDraw sans pour autant lancer MagicDraw en mode graphique ;</li>
<li>Exécuter nos propres plugins MagicDraw ;</li>
<li>Valider nos modèles avec nos propres règles de validation codées avec l&#8217;API emf/uml2 d&#8217;eclipse ;</li>
<li>Lancer nos transformations de modèle ;</li>
<li>Et finalement de générer avec MIA-Generation.</li>
</ul>
<p><span id="more-32"></span><br />
Pour certaines des tâches ci-dessus il existe des plugins Maven2, pour les autres vous pouvez développer vos propres plugins Maven2.</p>
<p>Pas de panique, la courbe d&#8217;apprentissage est faible, et on obtient rapidement ce que l&#8217;on veut!</p>
<p>Malheureusement, il n&#8217;est pas toujours facile de trouver de la documentation sur la création de plugins pour Maven2.<br />
Pour vous aider à débuter, voici quelques liens qui m&#8217;ont été très utiles :</p>
<ul>
<li><a href="http://maven.apache.org/developers/">Maven Developer Centre</a></li>
<li><a href="http://maven.apache.org/ref/2.1.0/maven-plugin-api/apidocs/index.html">API Maven 2.1.0 &#8211; Plugin</a></li>
<li><a href="http://maven.apache.org/ref/2.1.0/apidocs/index.html">API Maven 2.1.0 &#8211; Full</a></li>
<li><a href="http://maven.apache.org/guides/plugin/guide-java-plugin-development.html">Guide to Developing Java Plugins for Maven2</a></li>
<li><a href="http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook">Mojo Developer Cookbook</a></li>
<li><a href="http://docs.codehaus.org/display/MAVENUSER/Write+your+own+report+plugin">Write your own report plugin</a></li>
<li><a href="http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide">Maven Properties Guide</a></li>
<li><a href="http://www.sonatype.com/people/2009/08/create-a-customized-build-process-in-maven/">Create a Customized Build Process in Maven</a></li>
<li><a href="http://www.sonatype.com/books/mcookbook/reference/ch04s04.html#d0e2206">Creating an Ant Maven Plugin</a></li>
<li><a href="http://blog.tartachuc.org/2008/07/07/creer-un-packaging-maven2/">Créer un nouveau packaging Maven</a></li>
<li><a href="http://maven.apache.org/plugins/maven-docck-plugin/">Maven DOCCK Plugin &#8211; Documentation Validation</a></li>
<li><a href="http://maven.apache.org/guides/mini/guide-embedding-m2.html">Maven &#8211; The Maven Embedder</a></li>
<li><a href="http://tetedebois.org/fr/2009/01/19/maven-embarque/">Tetedebois.org » Maven embarqué</a></li>
<li><a href="http://www.mail-archive.com/users@maven.apache.org/msg66057.html">Re: Maven Embedder Example?</a></li>
<li><a href="http://www.developers-blog.org/blog/default/2009/09/18/How-to-resolve-an-artifact-with-maven-embedder">How to resolve an artifact with maven embedder</a></li>
</ul>
<p>Le rendez-vous est pris avec Maven3!</p>
]]></content:encoded>
			<wfw:commentRss>http://mdwhatever.free.fr/index.php/2010/01/maven2-lorchestrateur-de-lingenierie-des-modeles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
