Skip to content

Commit 1f85741

Browse files
chrisruegerlaeubi
authored andcommitted
fix bnd workspace for cnf project
Workspaces.getWorkspace(IProject) now returns the correct bnd workspace for the 'cnf' project which is a 'magic' marker project name for a bnd workspace. Clicking on a cnf project now gives the same bnd workspace as clicking on a normal bnd project.
1 parent c00ecd3 commit 1f85741

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/Workspaces.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,46 @@ public static Optional<Workspace> getWorkspace(IProject project) {
3838
if (bndProject != null) {
3939
return Optional.ofNullable(bndProject.getWorkspace());
4040
} else {
41-
IFile bndFile = project.getFile(Project.BNDFILE);
42-
if (bndFile.exists()) {
43-
IPath location = bndFile.getLocation();
44-
if (location != null) {
45-
File file = location.toFile();
46-
if (file != null) {
47-
try {
48-
Project nativeProject = Workspace.getProject(file.getParentFile());
49-
if (nativeProject != null) {
50-
return Optional.ofNullable(nativeProject.getWorkspace());
41+
42+
if(isCnf(project)) {
43+
44+
try {
45+
File wsDir = project.getLocation().toFile().getParentFile();
46+
return Optional.ofNullable(Workspace.getWorkspace(wsDir));
47+
} catch (Exception e) {
48+
}
49+
}
50+
else {
51+
IFile bndFile = project.getFile(Project.BNDFILE);
52+
if (bndFile.exists()) {
53+
IPath location = bndFile.getLocation();
54+
if (location != null) {
55+
File file = location.toFile();
56+
if (file != null) {
57+
try {
58+
Project nativeProject = Workspace.getProject(file.getParentFile());
59+
if (nativeProject != null) {
60+
return Optional.ofNullable(nativeProject.getWorkspace());
61+
}
62+
} catch (Exception e) {
5163
}
52-
} catch (Exception e) {
5364
}
5465
}
5566
}
5667
}
68+
5769
}
5870
}
5971
return Optional.empty();
6072
}
73+
74+
private static boolean isCnf(IProject project) {
75+
IPath projectPath = project.getLocation();
76+
if (projectPath != null) {
77+
return Project.BNDCNF.equals(projectPath.lastSegment());
78+
}
79+
return false;
80+
}
6181

6282
public static synchronized Optional<Workspace> getGlobalWorkspace() {
6383
// TODO the UI should support display multiple workspaces and give the user a

0 commit comments

Comments
 (0)