<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to EmfRcpPlugin</title><link>https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/</link><description>Recent changes to EmfRcpPlugin</description><atom:link href="https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 29 Nov 2013 02:19:36 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/feed" rel="self" type="application/rss+xml"/><item><title>EmfRcpPlugin modified by Tom Swain</title><link>https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -64,6 +64,8 @@
     a. The required action must be implemented in the &lt;code&gt;execute()&lt;/code&gt; method.
     b. The &lt;code&gt;isEnabled()&lt;/code&gt; and &lt;code&gt;isHandled()&lt;/code&gt; methods must return **true** to activate the associated menu item.

+Note: If a menu item is used by a plug-in higher in the dependency hierarchy **AND** `activeWhen` and `enabledWhen` expressions are needed for that menu item, then an equivalent `handler` extension point must be added to the using plug-in.
+
 ## Removing "Open File..." from the File Menu ##
 *Caveat*: This is useful to know but turned out to be the wrong thing to do for ESTA'. It turned out to be better to eliminate the generated **File-&gt;Open...** extension point because **Open File...** gives you access to Eclipse built in editors (*e.g.*, text and html), while **Open...** is just configured for EMF generated file types. Removing **Open...** requires removing the associated **action** from the &lt;code&gt;org.eclipse.ui.actionSets&lt;/code&gt; extension point and the associated **command** from the &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt; extension point (both in plugin.xml).

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom Swain</dc:creator><pubDate>Fri, 29 Nov 2013 02:19:36 -0000</pubDate><guid>https://sourceforge.netd041c7149f079931aa6121e815a3c3349c678013</guid></item><item><title>EmfRcpPlugin modified by Tom Swain</title><link>https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -68,7 +68,9 @@
 *Caveat*: This is useful to know but turned out to be the wrong thing to do for ESTA'. It turned out to be better to eliminate the generated **File-&gt;Open...** extension point because **Open File...** gives you access to Eclipse built in editors (*e.g.*, text and html), while **Open...** is just configured for EMF generated file types. Removing **Open...** requires removing the associated **action** from the &lt;code&gt;org.eclipse.ui.actionSets&lt;/code&gt; extension point and the associated **command** from the &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt; extension point (both in plugin.xml).

 Anyway, here is the way to remove **Open File...**:
+
 In the editor advisor class there should be a static WindowAdvisor subclass.  Just add the postWindowCreate method below to the WindowAdvisor.
+
    :::java
    @Override
    public void postWindowCreate() {
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom Swain</dc:creator><pubDate>Thu, 17 Oct 2013 19:01:31 -0000</pubDate><guid>https://sourceforge.net99dbd41b6e06c68a462d1f9846e79e60e19a358c</guid></item><item><title>EmfRcpPlugin modified by Tom Swain</title><link>https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom Swain</dc:creator><pubDate>Thu, 17 Oct 2013 19:00:04 -0000</pubDate><guid>https://sourceforge.netb21ff8d6372acfae80e089635d11bb9d3c5ef26d</guid></item><item><title>EmfRcpPlugin modified by Tom Swain</title><link>https://sourceforge.net/p/esta/wiki/EmfRcpPlugin/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="eclipse-emf-rcp-plugin-development"&gt;Eclipse EMF RCP Plugin Development&lt;/h1&gt;
&lt;h2 id="transition-to-rcp-development"&gt;Transition to RCP Development&lt;/h2&gt;
&lt;h3 id="initial-rcp-creation"&gt;Initial RCP Creation&lt;/h3&gt;
&lt;p&gt;Do the following for jemf and testemf plugins:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In jemf.genmodel and testemf.genmodel, change property &lt;strong&gt;Rich Client Platform&lt;/strong&gt; (in the &lt;strong&gt;Editor&lt;/strong&gt; category) to &lt;strong&gt;True&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Backup, then Delete, plugin.xml and MANIFEST.MF for both plugins.&lt;/li&gt;
&lt;li&gt;Regenerate all code. For both plugins:&lt;br /&gt;
     a. Open the *.genmodel editor.&lt;br /&gt;
     b. Right click the root object and select &lt;strong&gt;Generate All&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;For plugin.xml and MANIFEST.MF in both plugins, &lt;br /&gt;
    a. Right click and select &lt;strong&gt;Compare With-&amp;gt;Latest from Repository&lt;/strong&gt;.&lt;br /&gt;
    b. Use the Source Compare window to copy extension points and other elements lost in steps 2 and 3.&lt;/li&gt;
&lt;li&gt;Fix import errors by importing any needed packages.&lt;/li&gt;
&lt;li&gt;In &lt;code&gt;getFileExtensionFilters()&lt;/code&gt; in the new files TestemfEditorAdvisor.java and JemfEditorAdvisor.java, change &lt;code&gt;result.addAll(EcoreEditor.FILE_EXTENSION_FILTERS)&lt;/code&gt; to &lt;code&gt;result.add(EcoreEditor.ECORE_FILE_EXTENSION)&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="resource-and-package-registration"&gt;Resource and Package Registration&lt;/h3&gt;
&lt;p&gt;In &lt;code&gt;TestemfEditorAdvisor.initialize()&lt;/code&gt;, append the following:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    &lt;span class="c1"&gt;// register resource factories&lt;/span&gt;
&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExtensionToFactoryMap&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;testemf&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;XMIResourceFactoryImpl&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExtensionToFactoryMap&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;tst&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;TstResourceFactoryImpl&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExtensionToFactoryMap&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;emf&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;XMIResourceFactoryImpl&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExtensionToFactoryMap&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;html&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;MmaResourceFactoryImpl&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Registry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INSTANCE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExtensionToFactoryMap&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;tml&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;TmlResourceFactoryImpl&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// cause the package to be registered&lt;/span&gt;
&lt;span class="n"&gt;TestemfPackage&lt;/span&gt; &lt;span class="n"&gt;testemfPackage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TestemfPackage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eINSTANCE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;EmfPackage&lt;/span&gt; &lt;span class="n"&gt;emfPackage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;EmfPackage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eINSTANCE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="top-level-menu-setup"&gt;Top Level Menu Setup&lt;/h2&gt;
&lt;h3 id="prep"&gt;Prep&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open editor for plugin.xml.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;Extensions&lt;/strong&gt; tab.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="create-the-commands"&gt;Create the Commands&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Add extension point &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Right-click &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt; and select &lt;strong&gt;New-&amp;gt;category&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set the id (&lt;em&gt;e.g&lt;/em&gt;, &lt;code&gt;edu.utk.sqrl.emf.commands.category&lt;/code&gt;), name, and description fields.&lt;/li&gt;
&lt;li&gt;For all commands to be implemented,&lt;br /&gt;
    a. Right-click &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt; and select &lt;strong&gt;New-&amp;gt;command&lt;/strong&gt;.&lt;br /&gt;
    b. Set the id field to something like &lt;code&gt;edu.utk.sqrl.emf.commands.&lt;em&gt;cmd&lt;/em&gt;&lt;/code&gt;, where &lt;em&gt;cmd&lt;/em&gt; is the command name in lower case.&lt;br /&gt;
    c. Set the &lt;strong&gt;name&lt;/strong&gt; and &lt;strong&gt;description&lt;/strong&gt; fields.&lt;br /&gt;
    d. Set &lt;strong&gt;categoryid&lt;/strong&gt; to the id entered in item 3 above.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="create-the-menu"&gt;Create the Menu&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Add extension point &lt;code&gt;org.eclipse.ui.menus&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Right-click &lt;code&gt;org.eclipse.ui.menus&lt;/code&gt; and select &lt;strong&gt;New-&amp;gt;menuContribution&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;locationURI&lt;/strong&gt; to &lt;code&gt;menu:org.eclipse.ui.main.menu?after=additions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Right-click the &lt;strong&gt;menuContribution&lt;/strong&gt; and select &lt;strong&gt;New-&amp;gt;menu&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;label&lt;/strong&gt;, &lt;strong&gt;id&lt;/strong&gt; (&lt;em&gt;e.g.&lt;/em&gt;, &lt;code&gt;edu.utk.sqrl.emf.menus.main&lt;/code&gt;), and &lt;strong&gt;mnemonic&lt;/strong&gt; fields.&lt;/li&gt;
&lt;li&gt;For each desired menu selection, &lt;br /&gt;
    a. Right-click the &lt;strong&gt;menu&lt;/strong&gt; entry and select &lt;strong&gt;New-&amp;gt;command&lt;/strong&gt;.&lt;br /&gt;
    b. Set &lt;strong&gt;commandId&lt;/strong&gt; field to the id of the corresponding command defined above.&lt;br /&gt;
    c. Set the &lt;strong&gt;id&lt;/strong&gt; field to something like &lt;code&gt;edu.utk.sqrl.emf.menus.&lt;em&gt;cmd&lt;/em&gt;&lt;/code&gt;, where &lt;em&gt;cmd&lt;/em&gt; is the command name in lower case.&lt;br /&gt;
    d. Set the &lt;strong&gt;mnemonic&lt;/strong&gt; field.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="create-handlers"&gt;Create Handlers&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Add extension point &lt;code&gt;org.eclipse.ui.handlers&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For each required command handler,&lt;br /&gt;
    a. Right-click &lt;code&gt;org.eclipse.ui.handlers&lt;/code&gt; and select &lt;strong&gt;New-&amp;gt;handler&lt;/strong&gt;.&lt;br /&gt;
    b. Set the &lt;strong&gt;commandId&lt;/strong&gt; field to the corresponding command id defined above.&lt;br /&gt;
    c. Set the &lt;strong&gt;class&lt;/strong&gt; field to the full name of the class (&lt;em&gt;e.g.&lt;/em&gt;, &lt;code&gt;edu.utk.sqrl.emf.handlers.CheckModel&lt;/code&gt;) that will process this command.&lt;br /&gt;
    d. Right-click the handler and create an &lt;strong&gt;activeWhen&lt;/strong&gt; expression.&lt;br /&gt;
    e. Right-click the handler and create an &lt;strong&gt;enabledWhen&lt;/strong&gt; expression.&lt;/li&gt;
&lt;li&gt;If the handler class specified in 2c does not exist already, clicking the &lt;strong&gt;class&lt;/strong&gt; link will generate it.&lt;br /&gt;
    a. The required action must be implemented in the &lt;code&gt;execute()&lt;/code&gt; method.&lt;br /&gt;
    b. The &lt;code&gt;isEnabled()&lt;/code&gt; and &lt;code&gt;isHandled()&lt;/code&gt; methods must return &lt;strong&gt;true&lt;/strong&gt; to activate the associated menu item.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="removing-open-file-from-the-file-menu"&gt;Removing "Open File..." from the File Menu&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Caveat&lt;/em&gt;: This is useful to know but turned out to be the wrong thing to do for ESTA'. It turned out to be better to eliminate the generated &lt;strong&gt;File-&amp;gt;Open...&lt;/strong&gt; extension point because &lt;strong&gt;Open File...&lt;/strong&gt; gives you access to Eclipse built in editors (&lt;em&gt;e.g.&lt;/em&gt;, text and html), while &lt;strong&gt;Open...&lt;/strong&gt; is just configured for EMF generated file types. Removing &lt;strong&gt;Open...&lt;/strong&gt; requires removing the associated &lt;strong&gt;action&lt;/strong&gt; from the &lt;code&gt;org.eclipse.ui.actionSets&lt;/code&gt; extension point and the associated &lt;strong&gt;command&lt;/strong&gt; from the &lt;code&gt;org.eclipse.ui.commands&lt;/code&gt; extension point (both in plugin.xml).&lt;/p&gt;
&lt;p&gt;Anyway, here is the way to remove &lt;strong&gt;Open File...&lt;/strong&gt;:&lt;br /&gt;
In the editor advisor class there should be a static WindowAdvisor subclass.  Just add the postWindowCreate method below to the WindowAdvisor.&lt;br /&gt;
    :::java&lt;br /&gt;
    @Override&lt;br /&gt;
    public void postWindowCreate() {&lt;br /&gt;
        super.postWindowCreate();&lt;br /&gt;
        // Find and remove the "Open File" menu item.&lt;br /&gt;
        //&lt;br /&gt;
        IMenuManager menuManager = getWindowConfigurer().getActionBarConfigurer().getMenuManager();&lt;br /&gt;
        IContributionItem[] menuItems = menuManager.getItems();&lt;br /&gt;
        // For each menu item, check the class.&lt;br /&gt;
        //&lt;br /&gt;
        for (int i = 0; i &amp;lt; menuItems.length; i++) {&lt;br /&gt;
            IContributionItem menuItem = menuItems&lt;span&gt;[i]&lt;/span&gt;;&lt;br /&gt;
            // If this is a menu manager, then check the id.&lt;br /&gt;
            //&lt;br /&gt;
            if (menuItem instanceof MenuManager) {&lt;br /&gt;
                // If this is the file menu, then remove the "Open File" menu action.&lt;br /&gt;
                //&lt;br /&gt;
                if (menuItem.getId().equals("file")) {&lt;br /&gt;
                    ((MenuManager) menuItem).remove("org.eclipse.ui.openLocalFile");&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom Swain</dc:creator><pubDate>Thu, 17 Oct 2013 18:59:36 -0000</pubDate><guid>https://sourceforge.net7a6d0a34572145bfd905eb8cbceae1ba379071f0</guid></item></channel></rss>