- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我负责重构我公司的 Eclipse 插件中的弹出菜单以使用新的命令/处理程序/菜单扩展点方案。我们有一些关于何时应该启用或不启用某些菜单项的业务逻辑,这是通过它们应用于操作的 SelectionListener 的 onSelectionChanged 方法来处理的。我现在正在尝试使用自定义 PropertyTester 来控制启用,但似乎我的自定义 PropertyTester 没有被加载。我遵循了 Eclipse 的文档以及我可以在网上找到的任何教程,但出于某种原因,它只是不想工作。即使我只是将“测试”方法设置为返回 true,它也不起作用,因为测试器甚至从未加载过(我放入了一些断点,但它们从未被击中)。我已经尝试在 xml 的测试中设置“forcePluginActivation='true'”标志,但这也不能解决这种情况。这是一些代码,公司名称替换为“公司”,产品替换为“产品”...
命令 XML
<extension
point="org.eclipse.ui.commands">
<command
categoryId="com.company.product.android.core.category2"
id="com.company.product.android.core.commands.convertToProduct"
name="Convert to product Android Project"
description="The resources, jars and native library to begin developing an product for Android project application will be added to the Android project">
</command>
<category
id="com.company.product.android.core.category2"
name="Product Tools">
</category>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.company.product.android.core.commands.ConvertToProduct"
commandId="com.company.product.android.core.commands.convertToProduct">
<enabledWhen>
<reference
definitionId="com.company.product.android.core.expressions.productProject">
</reference>
</enabledWhen>
</handler>
</extension>
<extension>
point="org.eclipse.core.expressions.definitions">
<definition
id="com.company.product.android.core.expressions.androidProjectNature">
<with variable="selection">
<iterate ifEmpty="false">
<test
property="org.eclipse.core.resources.projectNature"
value="com.android.ide.eclipse.adt.AndroidNature">
</test>
</iterate>
</with>
</definition>
<definition
id="com.company.product.android.core.expressions.productProject">
<with variable="selection">
<iterate ifEmpty="false">
<test
property="com.company.product.android.expressions.productProjectProperty"
forcePluginActivation="true">
</test>
</iterate>
</with>
</definition>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<menu
icon="icons/wht_ws.gif"
id="com.company.product.android.core.tools"
label="Product Tools">
<visibleWhen>
<reference
definitionId="com.company.product.android.core.expressions.androidProjectNature">
</reference>
</visibleWhen>
<command
commandId="com.company.product.android.core.commands.convertToProduct"
label="Convert to Product Android Project"
tooltip="The resources, jars and native library to begin developing an product for Android project application will be added to the Android project.">
</command>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="com.company.product.android.core.expressions.ProductProjectTester"
id="com.company.product.android.core.expressions.productProjectTester"
namespace="com.company.product.android.core.expressions"
properties="productProjectProperty"
type="java.lang.Object">
</propertyTester>
</extension>
package com.company.product.android.core.expressions;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.PlatformUI;
import com.company.product.android.core.ProjectUtils;
public class ProductProjectTester extends PropertyTester {
public ProductProjectTester() {
System.out.println("I AM PRODUCT PROJECT TESTER, AND I HAVE BEEN CREATED");
}
@Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
//IJavaProject project = null;
//ISelectionService selectionService =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
//ISelection selection = selectionService.getSelection();
//boolean enabled = ProjectUtils.isSingleProjectSelected(selection);
System.out.println("I entered the test method");
boolean enabled = false;
System.out.println("The receiver is a " + receiver.getClass().toString());
IJavaProject project = (IJavaProject)receiver;
//if (enabled && selection instanceof StructuredSelection) {
//project = ProjectUtils.getJavaProject();
if (project != null) {
enabled = ProjectUtils.hasNeedVersion(project)
&& (!ProjectUtils.isProductAndroidProject(project.getProject()));
}
//}
return enabled;
}
}
最佳答案
我为我的项目使用了 PropertyTester,它工作正常
在您的定义 XML 中
您没有正确引用您的 PropertyTester 定义:
<definition
id="com.company.product.android.core.expressions.productProject">
<with variable="selection">
<iterate ifEmpty="false">
<test
property="com.company.product.android.**core**.expressions.productProjectProperty"
forcePluginActivation="true">
</test>
</iterate>
</with>
</definition>
<menu
icon="icons/wht_ws.gif"
id="com.company.product.android.core.tools"
label="Product Tools">
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false">
<reference
definitionId="com.company.product.android.core.expressions.productProject"/>
</iterate>
</with>
</visibleWhen>
<command
commandId="com.company.product.android.core.commands.convertToProduct"
label="Convert to Product Android Project"
tooltip="The resources, jars and native library to begin developing an product for Android project application will be added to the Android project.">
</command>
</menu>
关于popup - 尽管有 forcePluginActivation,但属性测试器不会加载。用于弹出菜单启用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17458972/
希望你能帮助我。我阅读并再次阅读了 Magnific Popup 的文档,但我对 javascript 还不够好。 1- 我用这个链接打开一个弹出窗口: OPEN POPUP 和这个 javascri
我最近刚刚实现了“Magnific Popup”并且弹出窗口很好,但是当我单击一个输入框时,整个弹出窗口消失回到父页面。在插件网站上显示的示例中,整个对话框都是可单击的,直到您在该框外单击。 我希望它
我的弹出窗口正常工作,但有时用户会点击浏览器上的后退按钮关闭弹出窗口。 如何让浏览器后退按钮关闭已经打开的“magnific-popup”? 谢谢 最佳答案 经过一些挖掘发现 history.js 然
我制作了一个带有华丽弹出窗口的视频库。 但与图片库不同的是,视频库不显示计数器,例如1/3 在视频的右下角。为什么不?在图片库中,它运行良好。 视频库代码: $('.gallery_video').e
我正在使用 magnific popup 和 ajax 将内容加载到其中,并通过将查询字符串附加到 url 将值传递给 ajax 内容,除了在 IE7(可能还有 IE8)中工作正常。原因很可能是查询字
有没有办法绑定(bind)一个事件回调,以便为 Magnific Popup 的所有实例调用它?在我正在构建的网站上,当主浏览器滚动条消失时,几个元素具有固定位置和“跳转”。我想设置一个回调以在打开任
$.magnificPopup.open({ items: { src: $('#cabinet-msg') }, type:'inline', mid
在 jquery 对话框中我们可以做 $("#id").dialog('open|close') 打开关闭对话框。如何在 Magnific-popup 中做到这一点? 最佳答案 $.magnificP
我正在以这种方式制作新窗口: var WSHShell = WScript.CreateObject("WScript.Shell"); WSHShell.Popup("This is popup."
我打开一个带有 js 弹出窗口的 html 页面 Link to popup 现在我的弹出窗口中有一些链接,我想关闭我的链接的弹出窗口 onclick 并在旧窗口中打开链接。对于旧窗口,我指的是
无法在放大的弹出窗口中播放视频。 当我使用 class=iframe ,页面将重定向到 youtube 并播放视频。 但是当我使用 class=popup-youtube ,将显示弹出窗口,但我收到以
我有一个 Leaflet Popup 附加到一个标记,它给用户两个按钮来使用 jQuery 取消或移动到另一个页面。 这些按钮最初工作正常,除非您曾经准确地单击标记以使 Popup 消失,然后再次单击
我有 2 个 JQM 页面和 1 个它们共享的弹出窗口。我有一个事件处理程序绑定(bind)到两者的“pagecreate”,里面有这样的代码: $(document).on("pagecreate"
System.InvalidOperationException: You MUST call Rg.Plugins.Popup.Popup.Init(); prior to using it. 我已
测试 Magnific Popup 当前是否“打开”的最佳方法是什么? 检查某个 div 的存在是否会成为 future 的证明? 例如,如果我使用: if ($(".mfp-ready").leng
我的指令有问题。如果我从弹出 Controller 调用 $scope.popup.show = false 行,它就可以正常工作。如果我从子 contentDirective 调用 $scope.h
我在popup.js中有两个变量。我想把它们放在一起到一个 url ,无论如何就像 chrome.tabs.create({active: true, url: "https://"+savedApi
我有一些代码,它允许用户检查复选框并在提交时打开与新选项卡中的复选框关联的网址。如果两个复选框都被选中,则会打开两个选项卡。它的工作原理与预期一致,看起来像: document.getElementB
我有一个弹出窗口,其高度约为屏幕的 70%。我在这个弹出窗口中有 2 个 div, header-div 具有固定高度,例如20px 和一个 content-div,它应该使用剩余的可用高度。 目前我
我正在构建一个包含教程的 MMO。 当用户在教程中尝试离开教程或关闭选项卡/浏览器时,我需要显示一个自定义弹出窗口,其中包含有关用户退出教程的原因的选项。 我熟悉 onbeforeunload 事件,
我是一名优秀的程序员,十分优秀!