Bug 3421 - update referenced projects should be done by jcore (1GKCFJQ)
Summary: update referenced projects should be done by jcore (1GKCFJQ)
Status: RESOLVED DUPLICATE of bug 3435
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P2 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:54 EDT by Martin Aeschlimann CLA
Modified: 2002-01-11 09:22 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2001-10-10 22:54:50 EDT
MA (20.09.2001 10:38:48)
	The upating of referenced projects is currently done in our code. I think, it should be in JCore.

	When changing the class path the required projects have to be updated too. The algorithm
	preserves project dependencies added by the user.

MA (20.09.2001 10:41:23)
	Remark that the API
		String[] IJavaProject.getRequiredProjectNames();
	would better be
		IProject[] IJavaProject.getRequiredProjects();

		/**
	 * @param jproject The Java project after changing the class path
	 * @param prevRequiredProjects The required projects before changing the class path
	 */
	public static void updateReferencedProjects(IJavaProject jproject, String[] prevRequiredProjects, IProgressMonitor monitor) throws CoreException {
		String[] newRequiredProjects= jproject.getRequiredProjectNames();

		ArrayList prevEntries= new ArrayList(Arrays.asList(prevRequiredProjects));
		ArrayList newEntries= new ArrayList(Arrays.asList(newRequiredProjects));
		
		IProject proj= jproject.getProject();
		IProjectDescription projDesc= proj.getDescription();  
		
		ArrayList newRefs= new ArrayList();
		IProject[] referencedProjects= projDesc.getReferencedProjects();
		for (int i= 0; i < referencedProjects.length; i++) {
			String curr= referencedProjects[i].getName();
			if (newEntries.remove(curr) || !prevEntries.contains(curr)) {
				newRefs.add(referencedProjects[i]);
			}
		}
		IWorkspaceRoot root= proj.getWorkspace().getRoot();
		for (int i= 0; i < newEntries.size(); i++) {
			String curr= (String) newEntries.get(i);
			newRefs.add(root.getProject(curr));
		}		
		projDesc.setReferencedProjects((IProject[]) newRefs.toArray(new IProject[newRefs.size()]));
		proj.setDescription(projDesc, monitor);
	}	


NOTES:
Comment 1 Philipe Mulet CLA 2001-10-29 07:11:06 EST

*** This bug has been marked as a duplicate of 3435 ***
Comment 2 DJ Houghton CLA 2001-10-29 17:12:57 EST
PRODUCT VERSION:
	134