我正在开发 NetBeans 模块,并且我已经声明了一个与我的自定义项目类型(EsperProject 类)配合使用的操作(使用注释,它们被转换为 layer.xml 记录):
@ActionID(category = "Run", id = "my.package.RunEsperAction")
@ActionRegistration(displayName = "My Action", asynchronous=true)
@ActionReferences({
@ActionReference(path = "Menu/BuildProject", position = 0)
})
public final class RunEsperAction implements ActionListener {
private final EsperProject project;
public RunEsperAction(EsperProject project) {
this.project = project;
}
@Override
public void actionPerformed(ActionEvent ev) {
// do sth with project
}
}
我可以从 BuildProject 菜单(实际上是“运行”菜单)运行该操作,但我无法使其在我需要的两种情况下工作(都按照注释中的声明异步调用):
- 我想从项目上下文菜单运行该操作。
- 我需要在我的 EsperProject 运行时触发该操作 从主菜单项“运行主项目”。
感谢您的任何建议。
最佳答案
1.I'd like to run the action from the project context menu.
只需将 @ActionReference(path = "Project/Actions",position = 0) 添加到 @ActionReferences 即可实现
关于java - NetBeans 模块中的操作 - 上下文菜单、主菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5842552/