1. <small id='UXPnT'></small><noframes id='UXPnT'>

        <bdo id='UXPnT'></bdo><ul id='UXPnT'></ul>

        <tfoot id='UXPnT'></tfoot>
        <i id='UXPnT'><tr id='UXPnT'><dt id='UXPnT'><q id='UXPnT'><span id='UXPnT'><b id='UXPnT'><form id='UXPnT'><ins id='UXPnT'></ins><ul id='UXPnT'></ul><sub id='UXPnT'></sub></form><legend id='UXPnT'></legend><bdo id='UXPnT'><pre id='UXPnT'><center id='UXPnT'></center></pre></bdo></b><th id='UXPnT'></th></span></q></dt></tr></i><div id='UXPnT'><tfoot id='UXPnT'></tfoot><dl id='UXPnT'><fieldset id='UXPnT'></fieldset></dl></div>

      1. <legend id='UXPnT'><style id='UXPnT'><dir id='UXPnT'><q id='UXPnT'></q></dir></style></legend>
      2. visibleWhen 命令出现在上下文菜单中

        visibleWhen for command to appear in context menu(visibleWhen 命令出现在上下文菜单中)

            <small id='bKcIX'></small><noframes id='bKcIX'>

            <i id='bKcIX'><tr id='bKcIX'><dt id='bKcIX'><q id='bKcIX'><span id='bKcIX'><b id='bKcIX'><form id='bKcIX'><ins id='bKcIX'></ins><ul id='bKcIX'></ul><sub id='bKcIX'></sub></form><legend id='bKcIX'></legend><bdo id='bKcIX'><pre id='bKcIX'><center id='bKcIX'></center></pre></bdo></b><th id='bKcIX'></th></span></q></dt></tr></i><div id='bKcIX'><tfoot id='bKcIX'></tfoot><dl id='bKcIX'><fieldset id='bKcIX'></fieldset></dl></div>
            1. <tfoot id='bKcIX'></tfoot>
              <legend id='bKcIX'><style id='bKcIX'><dir id='bKcIX'><q id='bKcIX'></q></dir></style></legend>

                • <bdo id='bKcIX'></bdo><ul id='bKcIX'></ul>
                    <tbody id='bKcIX'></tbody>
                  本文介绍了visibleWhen 命令出现在上下文菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 menuContribution 中的visibleWhen"表达式在上下文菜单中配置命令的可见性.我要做的是仅在以下情况下使命令在上下文菜单中可见:

                  I am trying configure visibility of a command within the context menu using 'visibleWhen' expression within a menuContribution. What I am trying to do is make the command visible in the context menu only if you:

                  1. 在资源视图(或包视图)中右键单击某些文件类型(资源)
                  2. 右键单击已打开文件类型的相应编辑器.它可以检测到我的编辑器已打开或该编辑器打开了某个资源.

                  我已经使用 'visibleWhen'>'selection(with)'>'iterate'>'org.eclipse.core.resources.IResource(adapt)' 完成了第一个,然后检查资源的文件扩展名.代码如下所示.但是,我不确定如何让相同的命令仅在您右键单击正确的编辑器时才出现,该编辑器打开了具有正确扩展名的文件 - ext1、ext2.

                  I've accomplished the first using 'visibleWhen'>'selection(with)'>'iterate'>'org.eclipse.core.resources.IResource(adapt)' then checking the file extension for the resource. The code is listed below. However, I'm not sure how to get the same command to only appear when you right-click the correct editor that has a file open with the correct extensions - ext1, ext2.

                  检查我的编辑器是否处于活动状态可以解决第二个问题,但似乎没有帮助,因为如果我单击不是我的类型的文件,它仍会在上下文菜单中显示命令.

                  Checking if my editor is active resolves the second issue but doesn't seem to help since if I click on files that are not my type, it will still show the command in the context menu.

                  有什么建议吗?Eclipse 插件(第 3 版)"显示了一些编辑器上下文菜单的示例,但它使用操作,我想坚持使用命令.

                  Any recommendations? The "Eclipse Plug-ins (3rd Edition)" shows some example for editor context menu but it uses actions and I want to stick with commands.

                  谢谢!!

                    <menuContribution
                          allPopups="false"
                          locationURI="popup:org.eclipse.ui.popup.any?before=additions">
                       <separator
                             name="com.test.ide.separator1"
                             visible="true">
                       </separator>
                       <menu
                             icon="icons/sample.gif"
                             label="Test Menu">
                          <command
                                commandId="com.test.commands.testCommand1"
                                icon="icons/sample.gif"
                                label="testCommand1"
                                style="push"
                                tooltip="This is a test command">
                             <visibleWhen
                                   checkEnabled="false">
                                <with
                                      variable="selection">
                                   <iterate
                                         ifEmpty="false"
                                         operator="or">
                                      <adapt
                                            type="org.eclipse.core.resources.IResource">
                                         <or>
                                            <test
                                                  property="org.eclipse.core.resources.extension"
                                                  value="ext1">
                                            </test>
                                            <test
                                                  property="org.eclipse.core.resources.extension"
                                                  value="ext2">
                                            </test>
                                         </or>
                                      </adapt>
                                   </iterate>
                                </with>
                             </visibleWhen>
                          </command>
                       </menu>
                    </menuContribution>
                  

                  推荐答案

                  我能够使用我遇到的 with 变量来完成它.使用上面相同的代码示例:

                  I was able to get it done with a with variable that I came across. Using the same code example above:

                  • <iterate> 块中添加 <or>
                  • 将现有的 <adapt> 块放入新的 <or>
                  • 添加一个名为 activeEditorInput 的新 with 变量
                  • Add an <or> block within the <iterate> block
                  • Place the existing <adapt> block in the new <or> block
                  • Add a new with variable called activeEditorInput

                  这是新的代码示例.

                  <iterate ifEmpty="false" operator="or">
                    <or>
                      <adapt type="org.eclipse.core.resources.IResource">
                        <or>
                          ...test extensions
                        </or>
                      </adapt>
                      <with variable="activeEditorInput">
                        <adapt type="org.eclipse.core.resources.IResource">
                          <or>
                            ...test extensions
                          </or>
                        </adapt>
                      </with>
                    </or>
                  </iterate>
                  

                  这篇关于visibleWhen 命令出现在上下文菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    1. <i id='AKuBW'><tr id='AKuBW'><dt id='AKuBW'><q id='AKuBW'><span id='AKuBW'><b id='AKuBW'><form id='AKuBW'><ins id='AKuBW'></ins><ul id='AKuBW'></ul><sub id='AKuBW'></sub></form><legend id='AKuBW'></legend><bdo id='AKuBW'><pre id='AKuBW'><center id='AKuBW'></center></pre></bdo></b><th id='AKuBW'></th></span></q></dt></tr></i><div id='AKuBW'><tfoot id='AKuBW'></tfoot><dl id='AKuBW'><fieldset id='AKuBW'></fieldset></dl></div>

                      • <bdo id='AKuBW'></bdo><ul id='AKuBW'></ul>

                            <tfoot id='AKuBW'></tfoot>
                              <tbody id='AKuBW'></tbody>
                            <legend id='AKuBW'><style id='AKuBW'><dir id='AKuBW'><q id='AKuBW'></q></dir></style></legend>
                          1. <small id='AKuBW'></small><noframes id='AKuBW'>