Lines 113-164
Link Here
|
113 |
SourceGroup[] groups = s.getSourceGroups(Sources.TYPE_GENERIC); |
113 |
SourceGroup[] groups = s.getSourceGroups(Sources.TYPE_GENERIC); |
114 |
|
114 |
|
115 |
FileObject projectDirectory = p.getProjectDirectory(); |
115 |
FileObject projectDirectory = p.getProjectDirectory(); |
116 |
SourceGroup projectDirGroup = null; |
|
|
117 |
|
118 |
// First find the source group which will represent the project |
119 |
for( int i = 0; i < groups.length; i++ ) { |
120 |
FileObject groupRoot = groups[i].getRootFolder(); |
121 |
if ( projectDirectory.equals( groupRoot ) || |
122 |
FileUtil.isParentOf( groupRoot, projectDirectory ) ) { |
123 |
if ( projectDirGroup != null ) { |
124 |
// more than once => Illegal |
125 |
projectDirGroup = null; |
126 |
break; |
127 |
} |
128 |
else { |
129 |
projectDirGroup = groups[i]; |
130 |
} |
131 |
} |
132 |
} |
133 |
|
134 |
if ( projectDirGroup == null ) { |
135 |
// Illegal project |
136 |
LOG.log(Level.WARNING, "Project {0} either does not contain its project directory under generic source groups or the directory is under more than one source group", p); |
137 |
return new Node[0]; |
138 |
} |
139 |
|
140 |
FileObject rootFolder = projectDirGroup.getRootFolder(); |
141 |
if (/* #150018 */!rootFolder.isValid() || /* #181323 */!rootFolder.isFolder()) { |
142 |
return new Node[0]; |
143 |
} |
144 |
|
145 |
// Create the nodes |
146 |
ArrayList<Node> nodesList = new ArrayList<Node>( groups.length ); |
116 |
ArrayList<Node> nodesList = new ArrayList<Node>( groups.length ); |
147 |
nodesList.add(new ProjectIconNode(new GroupNode(p, projectDirGroup, true, DataFolder.findFolder(rootFolder)), true)); |
|
|
148 |
|
117 |
|
149 |
for (SourceGroup group : groups) { |
118 |
for (SourceGroup group : groups) { |
150 |
if (group == projectDirGroup) { |
|
|
151 |
continue; |
152 |
} |
153 |
if ("sharedlibraries".equals(group.getName())) { //NOI18N |
119 |
if ("sharedlibraries".equals(group.getName())) { //NOI18N |
154 |
//HACK - ignore shared libs group in UI, it's only useful for version control commits. |
120 |
//HACK - ignore shared libs group in UI, it's only useful for version control commits. |
155 |
continue; |
121 |
continue; |
156 |
} |
122 |
} |
157 |
rootFolder = group.getRootFolder(); |
123 |
FileObject rootFolder = group.getRootFolder(); |
158 |
if (!rootFolder.isValid() || !rootFolder.isFolder()) { |
124 |
if (!rootFolder.isValid() || !rootFolder.isFolder()) { |
159 |
continue; |
125 |
continue; |
160 |
} |
126 |
} |
161 |
nodesList.add(new ProjectIconNode(new GroupNode(p, group, false, DataFolder.findFolder(rootFolder)), true)); |
127 |
nodesList.add(new ProjectIconNode(new GroupNode(p, group, projectDirectory.equals(rootFolder) || FileUtil.isParentOf(rootFolder, projectDirectory), DataFolder.findFolder(rootFolder)), true)); |
162 |
} |
128 |
} |
163 |
|
129 |
|
164 |
Node nodes[] = new Node[ nodesList.size() ]; |
130 |
Node nodes[] = new Node[ nodesList.size() ]; |