我创建了一个插件,用于查询所选项目Name&路径。这是代码:
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();
}
}
但是,我如何检查所选项目是关闭还是打开?
答案 0 :(得分:2)
IProject
有isOpen()
方法。这将告诉您项目当前是否已打开。