我正在开发 NetBeans 模块,并且我已经声明了一个操作(使用注释,它们被转换为 layer.xml 记录),它适用于我的自定义项目类型(EsperProject 类):
@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 从主菜单项“运行主项目”运行时,我需要触发该操作。
感谢您的任何建议。