title: Custom Popup menu in eclipse plugin
body: <p>In my current project, I have created <strong>popup menus using eclipse plugin</strong>. Following is the code of <strong>plugin.xml</strong>. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252"?&gt;
   &lt;?eclipse version="3.0"?&gt;
   &lt;plugin&gt;
  &lt;extension point="org.eclipse.emf.ecore.generated_package"&gt;
          &lt;package 
          uri = "http://www.xtext.org/example/mydsl/MyDsl"
          class = "org.xtext.example.mydsl.myDsl.MyDslPackage"
          genModel = "model/generated/MyDsl.genmodel" /&gt;          
  &lt;/extension&gt;
  &lt;extension
     point="org.eclipse.ui.popupMenus"&gt; 
        &lt;objectContribution
        id="org.xtext.example.mydsl.contribution1"
        objectClass="org.eclipse.core.resources.IFile"&gt;           
  
     &lt;menu
           id="org.xtext.example.mydsl.menu1"
           label="IoTSuite Compilation"
           path="additions"&gt;             
        &lt;separator
              name="group1"&gt;
        &lt;/separator&gt;
     &lt;/menu&gt;                 
     &lt;visibleWhen
            checkEnabled="false"&gt;
         &lt;iterate
               ifEmpty="false"
               operator="or"&gt;
                &lt;test
                  property="org.eclipse.core.resources.IFile"
                  value="vocab.mydsl"&gt;
          &lt;action
          class="org.xtext.example.mydsl.popup.actions.CompileVocabSpec"
           enablesFor="1"
           id="org.xtext.example.mydsl.newAction"
           label="Compile Vocab.mydsl"
           menubarPath="org.xtext.example.mydsl.menu1/group1"&gt;
     &lt;/action&gt; 
                  &lt;/test&gt;
         &lt;/iterate&gt;
      &lt;/visibleWhen&gt;           
  
     &lt;action
           class="org.xtext.example.mydsl.popup.actions.CompileArchSpec"
           enablesFor="1"
           id="org.xtext.example.mydsl.newAction"
           label="Compile Arch.mydsl"
           menubarPath="org.xtext.example.mydsl.menu1/group1"&gt;
     &lt;/action&gt;
     &lt;action
           class="org.xtext.example.mydsl.popup.actions.CompileInteractionSpec"
           enablesFor="1"
           id="org.xtext.example.mydsl.newAction"
           label="Compile Interaction.mydsl"
           menubarPath="org.xtext.example.mydsl.menu1/group1"&gt;
     &lt;/action&gt;
     &lt;action
           class="org.xtext.example.mydsl.popup.actions.CompileDeploySpec"
           enablesFor="1"
           id="org.xtext.example.mydsl.newAction"
           label="Compile Deploy.mydsl"
           menubarPath="org.xtext.example.mydsl.menu1/group1"&gt;
     &lt;/action&gt;  
  
  &lt;/objectContribution&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>When I run above eclipse plugin application, it displays popup-menu as follows.<a href="http://i.stack.imgur.com/FlaHE.png" rel="nofollow">Click here for image</a>. The problem is, as shown in image I have four files <strong>vocab.mydsl, arch.mydsl, userinteraction.mydsl and deploy.mydsl</strong> and also <strong>four actions (Compile Vocab.mydsl, Compile Arch.mydsl, Compile Interaction.mydsl and Compile Deploy.mydsl )</strong> under a popup menu. Now I want to <strong>customize action</strong> in such way that, when I click on <strong>vocab.mydsl</strong> then it should <strong>display only Compile Vocab.mydsl</strong> as an action in popup menu similarly when I click in arch.mydsl than it should display only Compile Arch.mydsl etc. I have made changes as per suggestion, but it display error like <code>MESSAGE Plugin org.xtext.example.mydsl, extension org.eclipse.ui.popupMenus: Unknown extension tag found: visibleWhen</code>. Am I missing something ??</p>
  
  <p><strong>Edit</strong><br>
  Finally  partial problem is solved using comment. Content of updated plugin.xml file is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?eclipse version="3.4"?&gt;
  &lt;plugin&gt;
   &lt;extension
       point="org.eclipse.ui.menus"&gt;
       &lt;menuContribution
      allPopups="false"
      locationURI="menu:org.eclipse.ui.main.menu"&gt;
      &lt;command
         commandId="org.xtext.example.mydsl.popup.actions.CompileVocabSpec"
           defaultHandler="org.xtext.example.mydsl.popup.actions.CompileVocabSpec" 
         label="Compile Vocab"
         style="push"&gt;
          &lt;visibleWhen
            checkEnabled="false"&gt;
         &lt;iterate
               ifEmpty="false"
               operator="or"&gt;
            &lt;test
                  property="org.eclipse.core.resources.name"
                  value="vocab.mydsl"&gt;
            &lt;/test&gt;
         &lt;/iterate&gt;
      &lt;/visibleWhen&gt;
   &lt;/command&gt;
  
    &lt;command              
           commandId="org.xtext.example.mydsl.popup.actions.CompileArchSpec"
           defaultHandler="org.xtext.example.mydsl.popup.actions.CompileArchSpec"  
         label="Compile Arch"
         style="push"&gt;
          &lt;visibleWhen
            checkEnabled="false"&gt;
         &lt;iterate
               ifEmpty="false"
               operator="or"&gt;
            &lt;test
                  property="org.eclipse.core.resources.name"
                  value="arch.mydsl"&gt;
            &lt;/test&gt;
         &lt;/iterate&gt;
      &lt;/visibleWhen&gt;
   &lt;/command&gt;
   &lt;/menuContribution&gt;
    &lt;/extension&gt;
   &lt;/plugin&gt;
  </code></pre>
  
  <p>I am very new to this eclipse plugin development. When I fired <strong>Compile Vocab command</strong> than it should <strong>performed action</strong> mentioned in <code>CompileVocabSpec.java</code>. The content of <code>CompileVocabSpec.java</code> is as below:</p>
  
  <pre><code>package org.xtext.example.mydsl.popup.actions;
  import org.eclipse.jface.action.IAction;
  import org.eclipse.jface.viewers.ISelection;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.ui.IActionDelegate;
  import org.eclipse.ui.IObjectActionDelegate;
  import org.eclipse.ui.IWorkbenchPart;
  
  public class CompileVocabSpec implements IObjectActionDelegate {
  
  private Shell shell;
  
  /**
   * Constructor for Action1.
   */
  public CompileVocabSpec() {
      super();
  }
  
  /**
   * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
   */
  @Override
  public void setActivePart(IAction action, IWorkbenchPart targetPart) {
      shell = targetPart.getSite().getShell();
  }
  
  /**
   * @see IActionDelegate#run(IAction)
   */
  @Override
  public void run(IAction action) {
  
      String[] args = new String[3];
      args[0] = "compile-vocab-spec";
      args[1] = "C:/Template/";
  
      // Call to Main method in ToolSuite
      try {
          // Main.main(args);
          System.out.println("Compilation of Vocab");
      } catch (Exception e) {
          e.printStackTrace();
      }
      ;
  
  }
  
  /**
   * @see IActionDelegate#selectionChanged(IAction, ISelection)
   */
  @Override
  public void selectionChanged(IAction action, ISelection selection) {
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here when I fired Compile Vocab command it doesn't performed any action. Am I missing something ??</p>