我创建了一个插件,用于查询所选项目的名称和路径。这是代码:
IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
Object firstElement = selection.getFirstElement();
if (firstElement != null) {
if (firstElement instanceof IAdaptable) {
IProject project = (IProject) ((IAdaptable) firstElement).getAdapter(IProject.class);
IPath path = project.getFullPath();
IPath location = project.getLocation();
}
}
但是,如何检查所选项目是关闭还是打开?
IProject
有一种isOpen()
方法。这将告诉您该项目当前是否打开。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句