如何在树视图项目的上下文中调用自定义命令?
我想调用自定义的“ ping”,并移交我的VS代码扩展程序所选树视图对象的详细信息。查看了几个示例后,我无法正确构建和注册命令。我可以调用命令,但是我缺少所选项目的信息。
let InfrastructureInfo = vscode.commands.registerCommand(
'infrastructure.info',
async (resource) => {
vscode.window.showInformationMessage('Ping Host Infrastructure. ....');
let strMessage: string = PingAgent(resource);
MessageUtils.showInfoMessage(strMessage);
}
);
context.subscriptions.push(ctmInfrastructureInfo);
该功能被调用。如何获取对象的详细信息? 请参阅图片。
主机上下文中的菜单”>
I want to invoke a custom "ping" and hand over the details of the selected treeview object of my VS Code Extension. After looking at several examples, I was not able to build and register the command properly. I can invoke the command, but I'm missing the information of the selected item.
let InfrastructureInfo = vscode.commands.registerCommand(
'infrastructure.info',
async (resource) => {
vscode.window.showInformationMessage('Ping Host Infrastructure. ....');
let strMessage: string = PingAgent(resource);
MessageUtils.showInfoMessage(strMessage);
}
);
context.subscriptions.push(ctmInfrastructureInfo);
The function is being called. How do I get the details of the object?
See picture.
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自定义命令正在使用呼叫发送的树节点ID。
由于TreeView的JSON保存在我的全局扩展存储中,因此我获取JSON数据并找到节点相应的节点。由于该命令取决于一些其他信息,因此我也必须从JSON获得。
工作方式:
可能有更好的方法可以做到这一点,这就是我的
the custom command is making use of the tree node id which the call is sending.
As the JSON of the TreeView is saved in my global extension storage, I fetch the json data and find the node corresponding node. Since the command depends on some additional information, I have to get that from the json as well.
There might be a better way to do it, however, this is how I've got it to work:
Regards