Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125201 Details for
Bug 262891
[WorkingSets] WorkingSetManager allows addition of WorkingSet with same name but different labels.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
patch_262891_1.txt (text/plain), 6.52 KB, created by
Hitesh
on 2009-02-10 02:30:12 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Hitesh
Created:
2009-02-10 02:30:12 EST
Size:
6.52 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/WorkingSetComparator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSetComparator.java,v >retrieving revision 1.12 >diff -u -r1.12 WorkingSetComparator.java >--- Eclipse UI/org/eclipse/ui/internal/WorkingSetComparator.java 9 May 2008 14:13:13 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/WorkingSetComparator.java 29 Jan 2009 12:46:47 -0000 >@@ -24,8 +24,19 @@ > * Static instance of this class. > * @since 3.2 > */ >- public static WorkingSetComparator INSTANCE = new WorkingSetComparator(); >+ public static WorkingSetComparator INSTANCE_NAMES_ONLY = new WorkingSetComparator(false); > >+ public static WorkingSetComparator INSTANCE_LABELS_NAMES = new WorkingSetComparator(); >+ >+ private boolean useLabels; >+ >+ public WorkingSetComparator(){ >+ this(true); >+ } >+ >+ public WorkingSetComparator(boolean useLabels){ >+ this.useLabels=useLabels; >+ } > private Collator fCollator = Collator.getInstance(); > > /** >@@ -34,29 +45,31 @@ > * @see Comparator#compare(Object, Object) > */ > public int compare(Object o1, Object o2) { >- String name1 = null; >- String name2 = null; >- >- if (o1 instanceof IWorkingSet) { >- name1 = ((IWorkingSet) o1).getLabel(); >- } >- >- if (o2 instanceof IWorkingSet) { >- name2 = ((IWorkingSet) o2).getLabel(); >- } >- >- int result = fCollator.compare(name1, name2); >- if (result == 0) { // okay, same name - now try the unique id >- >- if (o1 instanceof IWorkingSet) { >- name1 = ((IWorkingSet) o1).getName(); >- } >- >- if (o2 instanceof IWorkingSet) { >- name2 = ((IWorkingSet) o2).getName(); >- } >- result = name1.compareTo(name2); >- } >- return result; >- } >+ String name1 = null; >+ String name2 = null; >+ int result = 0; >+ if(useLabels){ >+ if (o1 instanceof IWorkingSet) { >+ name1 = ((IWorkingSet) o1).getLabel(); >+ } >+ >+ if (o2 instanceof IWorkingSet) { >+ name2 = ((IWorkingSet) o2).getLabel(); >+ } >+ >+ result = fCollator.compare(name1, name2); >+ } >+ if (result == 0) { // okay, same name - now try the unique id >+ >+ if (o1 instanceof IWorkingSet) { >+ name1 = ((IWorkingSet) o1).getName(); >+ } >+ >+ if (o2 instanceof IWorkingSet) { >+ name2 = ((IWorkingSet) o2).getName(); >+ } >+ result = name1.compareTo(name2); >+ } >+ return result; >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSetManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSetManager.java,v >retrieving revision 1.35 >diff -u -r1.35 AbstractWorkingSetManager.java >--- Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSetManager.java 27 Nov 2008 09:55:11 -0000 1.35 >+++ Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSetManager.java 29 Jan 2009 12:46:47 -0000 >@@ -15,6 +15,7 @@ > import java.io.IOException; > import java.io.OutputStreamWriter; > import java.util.ArrayList; >+import java.util.Arrays; > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; >@@ -91,7 +92,7 @@ > StatusUtil.newStatus(PlatformUI.PLUGIN_ID, exception)); > } > } >- private SortedSet workingSets = new TreeSet(WorkingSetComparator.INSTANCE); >+ private SortedSet workingSets = new TreeSet(WorkingSetComparator.INSTANCE_NAMES_ONLY); > > /** > * Size of the list of most recently used working sets. >@@ -258,7 +259,7 @@ > * @see org.eclipse.ui.IWorkingSetManager > */ > public IWorkingSet[] getWorkingSets() { >- SortedSet visibleSubset = new TreeSet(WorkingSetComparator.INSTANCE); >+ SortedSet visibleSubset = new TreeSet(WorkingSetComparator.INSTANCE_LABELS_NAMES); > for (Iterator i = workingSets.iterator(); i.hasNext();) { > IWorkingSet workingSet = (IWorkingSet) i.next(); > if (workingSet.isVisible()) { >@@ -269,7 +270,9 @@ > } > > public IWorkingSet[] getAllWorkingSets() { >- return (IWorkingSet[]) workingSets.toArray(new IWorkingSet[workingSets.size()]); >+ IWorkingSet[] wSets= (IWorkingSet[]) workingSets.toArray(new IWorkingSet[workingSets.size()]); >+ Arrays.sort(wSets,WorkingSetComparator.INSTANCE_LABELS_NAMES); >+ return wSets; > } > > /* (non-Javadoc) >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java,v >retrieving revision 1.16 >diff -u -r1.16 IWorkingSetTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java 24 Mar 2008 19:13:46 -0000 1.16 >+++ Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java 29 Jan 2009 12:46:52 -0000 >@@ -99,7 +99,37 @@ > fWorkingSet.setId(null); > assertEquals(null, fWorkingSet.getId()); > } >- >+ 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); >+ } >+ > public void testSetName() throws Throwable { > boolean exceptionThrown = false; > >@@ -131,7 +161,7 @@ > assertFalse(fWorkingSet.isEmpty()); > } > >- >+ > public void testApplicableTo_ResourceWorkingSet() { > fWorkingSet.setId("org.eclipse.ui.resourceWorkingSetPage"); > assertEquals("org.eclipse.ui.resourceWorkingSetPage", fWorkingSet
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262891
: 125201