1

在 Application.e4xmi 我有两个观点:

 ...  
  <children xsi:type="advanced:PerspectiveStack" xmi:id="_ySFusPeXEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.perspectivestack.main">
  <children xsi:type="advanced:Perspective" xmi:id="_83bVsPeXEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.perspective.testmanager" label="Test manager">
  ...
  <children xsi:type="advanced:Perspective" xmi:id="_bDA4oPeaEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.perspective.configurator" label="Configurator">
  ...

和一个包含两个项目的主菜单:

<mainMenu xmi:id="_xanVgPfWEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.menu.0">
  <children xsi:type="menu:HandledMenuItem" xmi:id="_22vnAPfWEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.handledmenuitem.uno" label="uno" command="_LFFTsPhHEeK44MdhTvpdlg">
    <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_28cw8PfXEeKXHJPsnYiiYQ" coreExpressionId="com.myapplication.ui.perspectiveselected.testmanager"/>
  </children>
  <children xsi:type="menu:HandledMenuItem" xmi:id="_49obAPfWEeKXHJPsnYiiYQ" elementId="com.myapplication.ui.handledmenuitem.due" label="due" command="_NXT1APhHEeK44MdhTvpdlg">
    <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_ZP4lgPhHEeK44MdhTvpdlg" coreExpressionId="com.myapplication.ui.perspectiveselected.configurator"/>
  </children>
  </mainMenu>

当显示透视图“com.myapplication.ui.perspective.testmanager”时,必须显示菜单项“com.myapplication.ui.handledmenuitem.uno”。当显示透视图“com.myapplication.ui.perspective.configurator”时,必须显示菜单项“com.myapplication.ui.handledmenuitem.due”。

因此,我在 plugin.xml 中定义:

  <extension
         point="org.eclipse.core.expressions.definitions">
      <definition
            id="com.myapplication.ui.perspectiveselected.testmanager">
         <with
               variable="activeWorkbenchWindow.activePerspective">
            <equals
                  value="com.myapplication.ui.perspective.testmanager">
            </equals>
         </with>
      </definition>
   </extension>
   <extension
         point="org.eclipse.core.expressions.definitions">
      <definition
            id="com.myapplication.ui.perspectiveselected.configurator">
         <with
               variable="activeWorkbenchWindow.activePerspective">
            <equals
                  value="com.myapplication.ui.perspective.configurator">
            </equals>
         </with>
      </definition>
   </extension>

它不起作用!(菜单项总是显示)有什么想法吗?

4

1 回答 1

0

我看到你已经应用了定义本身。创建一个新命令并将其注册到您的菜单中,然后在其上写下您的表达式。
例子:

  <command
       commandId=" "
       label=" "
       mnemonic="A">
     <visibleWhen
          checkEnabled="false">
        <with
             variable="">
           <equals
                value="1">
           </equals>
       </with>
    </visibleWhen>
 </command>
于 2015-07-14T11:23:27.627 回答