eclipse插件:检查所选项目是关闭还是打开

时间:2014-12-19 10:40:14

标签: java eclipse eclipse-plugin swt

我创建了一个插件,用于查询所选项目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();
    }
}

但是,我如何检查所选项目是关闭还是打开?

1 个答案:

答案 0 :(得分:2)

IProjectisOpen()方法。这将告诉您项目当前是否已打开。