简体   繁体   中英

eclipse plugin: perspective deprecated in shortcut

I want to fix the last warning in my plugin.xml file, must have caused it as I followed tutorials from some older post. The warning says: Element perspective is deprecated, in the following extension:

<extension
     point="org.eclipse.debug.ui.launchShortcuts">
  <shortcut
        class="my.launch.MyLaunchShortcut"
        icon="icons/my_icon.gif"
        id="my.run.shortcut"
        label="my Workflow"
        modes="run, debug">
     <perspective     <---here is the warning
           id="my.perspective">
     </perspective>
     <configurationType
           id="my.run">
     </configurationType>
     <contextualLaunch>
        <enablement>
           <with
                 variable="selection">
              <count
                    value="1">
              </count>
              <iterate>
                 <or>
                    <instanceof
                          value="org.eclipse.core.resources.IProject">
                    </instanceof>
                 </or>
              </iterate>
           </with>
        </enablement>
     </contextualLaunch>
  </shortcut>

I try to remove the perspective element and add <test> in <contextualLaunch> , but all my tryings won't work. So how can I solve it?

btw. It's working fine. I can see my own context submenu in Run as -> Run My Project. But as long as I remove the <perspective> element, no matter what else I add in <contextualLaunch> , the submenu won't appear.

Your <contextualLaunch> element will only show the shortcut when you have a single Project selected. Something like the following will show it for any resource:

 <contextualLaunch>
    <enablement>
       <with
             variable="selection">
          <count
                value="1">
          </count>
          <iterate>
             <or>
                <instanceof
                      value="org.eclipse.core.resources.IResource">
                </instanceof>
             </or>
          </iterate>
       </with>
    </enablement>
 </contextualLaunch>

You probably need to specify a <contextLabel> as well - the following is the entry that the Ant plugin uses:

<contextualLaunch>
   <enablement>
     <with variable="selection">
       <count value="1"/>
       <iterate>
         <or>
           <instanceof value="org.eclipse.ant.internal.ui.model.AntElementNode"/>
           <test property="org.eclipse.debug.ui.matchesContentType" value="org.eclipse.ant.core.antBuildFile"/>
         </or>
       </iterate>
     </with>
   </enablement>
   <contextLabel
          mode="run"
          label="%AntLaunchShortcut.label"/>
   <contextLabel
          mode="debug"
          label="%AntLaunchShortcut.label"/>
</contextualLaunch>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM