Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 262891

Summary: [WorkingSets] WorkingSetManager allows addition of WorkingSet with same name but different labels.
Product: [Eclipse Project] Platform Reporter: Hitesh <hsoliwal>
Component: UIAssignee: Hitesh <hsoliwal>
Status: RESOLVED DUPLICATE QA Contact: Eric Moffatt <emoffatt>
Severity: normal    
Priority: P3 CC: emoffatt
Version: 3.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 212583    
Attachments:
Description Flags
patch none

Description Hitesh CLA 2009-01-29 06:35:02 EST
The spec for IWorkingSet.setName(String) says

"Sets the name of the working set. The working set name should be unique. The working set name must not have leading or trailing whitespace."

Steps To Reproduce:
Goto Eclipse Unit Tests. Class - org.eclipse.ui.tests.api.IWorkingSetTest.
Add the following test just BEFORE the "testSetName()" and execute.

public void testNoDuplicateWorkingSetNamesDifferentLabels()
		throws Throwable {
	/* get workingSetManager */
	IWorkingSetManager workingSetManager = fWorkbench
			.getWorkingSetManager();
	/*
	 * check that initially workingSetManager contains "fWorkingSet"
	 */
	assertTrue(ArrayUtil.equals(new IWorkingSet[] { fWorkingSet },
			workingSetManager.getWorkingSets()));

	String sameName = fWorkingSet.getName();
	IWorkingSet wSet = workingSetManager.createWorkingSet(sameName,
				new IAdaptable[] {});
	wSet.setLabel(WORKING_SET_NAME_2);

	/*
	 * Expected to throw an error as the wSet has the same name as
	 * fWorkingSet
	 */
	boolean exceptionThrown = false;
	try {
		workingSetManager.addWorkingSet(wSet);
		/* Test failed, restore state */
		workingSetManager.removeWorkingSet(wSet);
	} catch (RuntimeException exception) {
		exceptionThrown = true;
	}
		assertTrue(exceptionThrown);
}

More information:
The AbstractWorkingSetManager uses a SortedSet in conjunction with a Comparator that compares labels and then names to determine equality.
Comment 1 Eric Moffatt CLA 2009-01-29 14:29:54 EST
Should I assign this one to you ?
Comment 2 Hitesh CLA 2009-01-30 02:48:44 EST
Eric, please assign this to me. 
Comment 3 Hitesh CLA 2009-02-10 02:30:12 EST
Created attachment 125201 [details]
patch
Comment 4 Hitesh CLA 2009-02-12 07:35:50 EST
Eric, Bug 212583, depending on the solution, either depends on this or may even fix this.
Comment 5 Eric Moffatt CLA 2009-02-13 15:39:48 EST
Hitesh, if this defect were fixed would it fix the other one(s)?

Comment 6 Hitesh CLA 2009-02-16 01:19:32 EST
(In reply to comment #5)
> Hitesh, if this defect were fixed would it fix the other one(s)?
> 

Eric ,no, the other way around.A possible fix for Bug 212583 could also fix this bug.
Comment 7 Eric Moffatt CLA 2009-04-23 14:25:35 EDT
Hitesh, if this has been fixed by the changes made in bug 212583 you might want to mark this one as a DUP.
Comment 8 Hitesh CLA 2009-04-24 05:47:21 EDT

*** This bug has been marked as a duplicate of bug 212583 ***