diff --git a/ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/Workspaces.java b/ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/Workspaces.java index 55c02c67c72..afcabf9cbfe 100644 --- a/ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/Workspaces.java +++ b/ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/Workspaces.java @@ -38,26 +38,46 @@ public static Optional getWorkspace(IProject project) { if (bndProject != null) { return Optional.ofNullable(bndProject.getWorkspace()); } else { - IFile bndFile = project.getFile(Project.BNDFILE); - if (bndFile.exists()) { - IPath location = bndFile.getLocation(); - if (location != null) { - File file = location.toFile(); - if (file != null) { - try { - Project nativeProject = Workspace.getProject(file.getParentFile()); - if (nativeProject != null) { - return Optional.ofNullable(nativeProject.getWorkspace()); + + if(isCnf(project)) { + + try { + File wsDir = project.getLocation().toFile().getParentFile(); + return Optional.ofNullable(Workspace.getWorkspace(wsDir)); + } catch (Exception e) { + } + } + else { + IFile bndFile = project.getFile(Project.BNDFILE); + if (bndFile.exists()) { + IPath location = bndFile.getLocation(); + if (location != null) { + File file = location.toFile(); + if (file != null) { + try { + Project nativeProject = Workspace.getProject(file.getParentFile()); + if (nativeProject != null) { + return Optional.ofNullable(nativeProject.getWorkspace()); + } + } catch (Exception e) { } - } catch (Exception e) { } } } } + } } return Optional.empty(); } + + private static boolean isCnf(IProject project) { + IPath projectPath = project.getLocation(); + if (projectPath != null) { + return Project.BNDCNF.equals(projectPath.lastSegment()); + } + return false; + } public static synchronized Optional getGlobalWorkspace() { // TODO the UI should support display multiple workspaces and give the user a