Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 142328
Collapse All | Expand All

(-)src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java (-6 / +52 lines)
Lines 37-42 Link Here
37
import org.eclipse.jdt.core.IJavaProject;
37
import org.eclipse.jdt.core.IJavaProject;
38
import org.eclipse.jdt.core.JavaCore;
38
import org.eclipse.jdt.core.JavaCore;
39
import org.eclipse.jdt.core.JavaModelException;
39
import org.eclipse.jdt.core.JavaModelException;
40
import org.eclipse.jdt.internal.core.ClasspathEntry;
41
import org.eclipse.jdt.internal.core.JavaProject;
42
import org.eclipse.jdt.internal.core.util.Util;
43
import org.eclipse.jem.util.logger.proxy.Logger;
40
import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
44
import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin;
41
import org.eclipse.wst.common.componentcore.ComponentCore;
45
import org.eclipse.wst.common.componentcore.ComponentCore;
42
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
46
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
Lines 161-166 Link Here
161
    
165
    
162
    private List computeClasspathEntries()
166
    private List computeClasspathEntries()
163
    {
167
    {
168
    	IJavaProject javaProject = JavaCore.create(this.project);
169
		IClasspathEntry[] existingEntries = null;
170
		try {
171
			existingEntries = javaProject.getResolvedClasspath(true);
172
		} catch (JavaModelException e) {
173
			existingEntries = new IClasspathEntry[0];
174
			Logger.getLogger().logError(e);
175
		}
176
		
164
        final List entries = new ArrayList();
177
        final List entries = new ArrayList();
165
        
178
        
166
        final IVirtualComponent vc 
179
        final IVirtualComponent vc 
Lines 179-198 Link Here
179
            if(null != jarName){
192
            if(null != jarName){
180
                jarsHandled.add(jarName);
193
                jarsHandled.add(jarName);
181
            }
194
            }
195
            IPath newPath = null;
182
            if (comp.isBinary()) {
196
            if (comp.isBinary()) {
183
                VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) comp;
197
                VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) comp;
184
                java.io.File diskFile = archiveComp.getUnderlyingDiskFile();
198
                java.io.File diskFile = archiveComp.getUnderlyingDiskFile();
185
                if (diskFile.exists()) {
199
                if (diskFile.exists()) {
186
                    entries.add(new Path(diskFile.getAbsolutePath()));
200
                	newPath =new Path(diskFile.getAbsolutePath());
187
                } else {
201
                } else {
188
                    IFile iFile = archiveComp.getUnderlyingWorkbenchFile();
202
                    IFile iFile = archiveComp.getUnderlyingWorkbenchFile();
189
                    if (!entries.contains(iFile.getFullPath()))
203
                    if (!entries.contains(iFile.getFullPath())){
190
                        entries.add(iFile.getFullPath());
204
                        newPath = iFile.getFullPath();
205
                    }
191
                }
206
                }
192
            } else {
207
            } else {
193
                IProject project = comp.getProject();
208
                IProject project = comp.getProject();
194
                entries.add(project.getFullPath());    
209
                newPath = project.getFullPath();    
195
            }
210
            }
211
            
212
        	if(null != newPath && !isAlreadyOnClasspath(existingEntries, newPath)){
213
                entries.add(newPath);
214
        	}
215
196
        }
216
        }
197
        
217
        
198
        for( int i = 0; i < this.paths.length; i++ )
218
        for( int i = 0; i < this.paths.length; i++ )
Lines 222-228 Link Here
222
                    if(!jarsHandled.contains(p.lastSegment()) &&  isJarFile( r.getLocation().toFile() ) )
242
                    if(!jarsHandled.contains(p.lastSegment()) &&  isJarFile( r.getLocation().toFile() ) )
223
                    {
243
                    {
224
                        jarsHandled.add(p.lastSegment());
244
                        jarsHandled.add(p.lastSegment());
225
                        entries.add( p );
245
                        if(!isAlreadyOnClasspath(existingEntries, p)){
246
                        	entries.add( p );
247
                        }
226
                    }
248
                    }
227
                }
249
                }
228
            }
250
            }
Lines 238-244 Link Here
238
                        ! isSourceOrOutputDirectory( p ) )
260
                        ! isSourceOrOutputDirectory( p ) )
239
                    {
261
                    {
240
                        jarsHandled.add(p.lastSegment());
262
                        jarsHandled.add(p.lastSegment());
241
                        entries.add( p );
263
                        if(!isAlreadyOnClasspath(existingEntries, p)){
264
                        	entries.add( p );
265
                        }
242
                    }
266
                    }
243
                }
267
                }
244
            }
268
            }
Lines 348-353 Link Here
348
        return false;
372
        return false;
349
    }
373
    }
350
    
374
    
375
    /**
376
	 * Taken from {@link JavaProject#isOnClasspath(org.eclipse.core.resources.IResource)}
377
	 * 
378
	 * @param classpath
379
	 * @param newPath
380
	 * @return
381
	 */
382
	public static boolean isAlreadyOnClasspath(IClasspathEntry[] classpath, IPath newPath) {
383
		for (int i = 0; i < classpath.length; i++) {
384
			IClasspathEntry entry = classpath[i];
385
			IPath entryPath = entry.getPath();
386
			if (entryPath.equals(newPath)) { // package fragment roots must match exactly entry
387
				// pathes (no exclusion there)
388
				return true;
389
			}
390
			if (entryPath.isPrefixOf(newPath) && !Util.isExcluded(newPath, ((ClasspathEntry) entry).fullInclusionPatternChars(), ((ClasspathEntry) entry).fullExclusionPatternChars(), false)) {
391
				return true;
392
			}
393
		}
394
		return false;
395
	}
396
    
351
    private static class Listener
397
    private static class Listener
352
    
398
    
353
        implements IResourceChangeListener
399
        implements IResourceChangeListener

Return to bug 142328