### Eclipse Workspace Patch 1.0 #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.14 diff -u -r1.14 IWorkingSetTest.java --- Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java 18 Dec 2006 16:35:19 -0000 1.14 +++ Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetTest.java 25 Oct 2007 23:34:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Benjamin Muskalla - bug 37183 (need "oldValue" forIWorkingSet PropertyChangeEvent) *******************************************************************************/ package org.eclipse.ui.tests.api; @@ -15,7 +16,10 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.tests.harness.util.ArrayUtil; @@ -34,6 +38,12 @@ IWorkingSet fWorkingSet; + public String fChangeProperty; + + public IWorkingSet fChangeNewValue; + + public IWorkingSet fChangeOldValue; + public IWorkingSetTest(String testName) { super(testName); } @@ -117,6 +127,36 @@ assertEquals(" ", fWorkingSet.getName()); } + public void testBug37183() throws CoreException { + class TestPropertyChangeListener implements IPropertyChangeListener { + public void propertyChange(PropertyChangeEvent event) { + fChangeProperty = event.getProperty(); + fChangeNewValue = (IWorkingSet) event.getNewValue(); + fChangeOldValue = (IWorkingSet) event.getOldValue(); + } + } + IPropertyChangeListener workingSetListener = new TestPropertyChangeListener(); + fWorkbench.getWorkingSetManager().addPropertyChangeListener(workingSetListener); + + final String newLabel = "new foo label"; + fWorkingSet.setLabel(newLabel); + assertNotNull(fChangeOldValue); + assertEquals(WORKING_SET_NAME_1, fChangeOldValue.getLabel()); + + fWorkingSet.setName(WORKING_SET_NAME_2); + assertNotNull(fChangeOldValue); + assertEquals(WORKING_SET_NAME_1, fChangeOldValue.getName()); + + IProject p1 = FileUtil.createProject("TP1"); + IFile f1 = FileUtil.createFile("f1.txt", p1); + IAdaptable[] elements = new IAdaptable[] { f1, p1 }; + fWorkingSet.setElements(elements); + assertNotNull(fChangeOldValue); + assertEquals(1, fChangeOldValue.getElements().length); + + fWorkbench.getWorkingSetManager().removePropertyChangeListener(workingSetListener); + } + public void testIsEmpty() { fWorkingSet.setElements(new IAdaptable[] {}); assertTrue(fWorkingSet.isEmpty()); Index: Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java,v retrieving revision 1.18 diff -u -r1.18 IWorkingSetManagerTest.java --- Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java 10 Sep 2007 17:44:04 -0000 1.18 +++ Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java 25 Oct 2007 23:34:46 -0000 @@ -131,19 +131,19 @@ // label property assertEquals(IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE, fChangeProperty); - assertEquals(null, fChangeOldValue); + assertNotNull(fChangeOldValue); assertEquals(fWorkingSet, fChangeNewValue); fWorkingSet.setName(WORKING_SET_NAME_2); assertEquals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE, fChangeProperty); - assertEquals(null, fChangeOldValue); + assertNotNull(fChangeOldValue); assertEquals(fWorkingSet, fChangeNewValue); resetChangeData(); fWorkingSet.setElements(new IAdaptable[] {}); assertEquals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE, fChangeProperty); - assertEquals(null, fChangeOldValue); + assertNotNull(fChangeOldValue); assertEquals(fWorkingSet, fChangeNewValue); } #P org.eclipse.ui.workbench Index: Eclipse UI/org/eclipse/ui/IWorkingSet.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSet.java,v retrieving revision 1.25 diff -u -r1.25 IWorkingSet.java --- Eclipse UI/org/eclipse/ui/IWorkingSet.java 16 Mar 2007 18:00:37 -0000 1.25 +++ Eclipse UI/org/eclipse/ui/IWorkingSet.java 25 Oct 2007 23:34:47 -0000 @@ -24,8 +24,9 @@ * @since 2.0 initial version * @since 3.0 now extends {@link org.eclipse.ui.IPersistableElement} * @since 3.2 now extends {@link org.eclipse.core.runtime.IAdaptable} + * @since 3.4 now extends {@link Cloneable} */ -public interface IWorkingSet extends IPersistableElement, IAdaptable { +public interface IWorkingSet extends IPersistableElement, IAdaptable, Cloneable { /** * Returns the elements that are contained in this working set. * Index: Eclipse UI/org/eclipse/ui/IWorkingSetManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSetManager.java,v retrieving revision 1.23 diff -u -r1.23 IWorkingSetManager.java --- Eclipse UI/org/eclipse/ui/IWorkingSetManager.java 29 Aug 2007 14:53:06 -0000 1.23 +++ Eclipse UI/org/eclipse/ui/IWorkingSetManager.java 25 Oct 2007 23:34:47 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Benjamin Muskalla - bug 37183 (need "oldValue" forIWorkingSet PropertyChangeEvent) *******************************************************************************/ package org.eclipse.ui; @@ -55,7 +56,6 @@ /** * Change event id when the working set contents changed * newValue of the PropertyChangeEvent will be the changed working set. - * oldValue will be null. * * @see IPropertyChangeListener */ @@ -64,7 +64,6 @@ /** * Change event id when the working set name changed. * newValue of the PropertyChangeEvent will be the changed working set. - * oldValue will be null. * * @see IPropertyChangeListener */ @@ -73,7 +72,6 @@ /** * Change event id when the working set label changed. * newValue of the PropertyChangeEvent will be the changed working set. - * oldValue will be null. * * @see IPropertyChangeListener * @since 3.2 @@ -83,15 +81,15 @@ /** * Change event id when a working set updater got installed. * NewValue of the PropertyChangeEvent will be the installed updater. - * OldValue will be null + * oldValue will be null * @since 3.1 */ public static final String CHANGE_WORKING_SET_UPDATER_INSTALLED = "workingSetUpdaterInstalled"; //$NON-NLS-1$ /** * Change event id when a working set updater got uninstalled. - * NewValue will be null - * OldValue of the PropertyChangeEvent will be the uninstalled updater. + * newValue will be null + * oldValue of the PropertyChangeEvent will be the uninstalled updater. * @since 3.3 */ public static final String CHANGE_WORKING_SET_UPDATER_UNINSTALLED = "workingSetUpdaterUninstalled"; //$NON-NLS-1$ Index: Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSet.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSet.java,v retrieving revision 1.8 diff -u -r1.8 AbstractWorkingSet.java --- Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSet.java 6 Sep 2006 14:16:42 -0000 1.8 +++ Eclipse UI/org/eclipse/ui/internal/AbstractWorkingSet.java 25 Oct 2007 23:34:48 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Benjamin Muskalla - bug 37183 (need "oldValue" forIWorkingSet PropertyChangeEvent) *******************************************************************************/ package org.eclipse.ui.internal; @@ -86,16 +87,34 @@ public void setName(String newName) { Assert.isNotNull(newName, "Working set name must not be null"); //$NON-NLS-1$ + IWorkingSet oldInstance = getCurrentStateObject(); + name = newName; - fireWorkingSetChanged(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE, null); + fireWorkingSetChanged(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE, oldInstance); if (labelBoundToName) { + oldInstance = getCurrentStateObject(); label = newName; - fireWorkingSetChanged(IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE, null); + fireWorkingSetChanged(IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE, oldInstance); } } /** + * Returns a clone of the current working set + * + * @return {@link IWorkingSet} the working set + */ + protected IWorkingSet getCurrentStateObject() { + IWorkingSet oldInstance = null; + try { + oldInstance = (IWorkingSet) this.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return oldInstance; + } + + /** * Connect this working set to a manger. * * @param manager the manager to connect to @@ -106,7 +125,7 @@ } /** - * Disconnet this working set from its manager, if any. + * Disconnect this working set from its manager, if any. */ public void disconnect() { this.manager= null; @@ -169,11 +188,12 @@ } public void setLabel(String label) { + IWorkingSet oldInstance = getCurrentStateObject(); this.label = label == null ? getName() : label; labelBoundToName = Util.equals(label, name); // rebind the label to the name fireWorkingSetChanged( - IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE, null); + IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE, oldInstance); } public boolean isEmpty() { @@ -187,4 +207,13 @@ public final ImageDescriptor getImage() { return getImageDescriptor(); } + + /* (non-Javadoc) + * @see java.lang.Object#clone() + */ + protected Object clone() throws CloneNotSupportedException { + AbstractWorkingSet clone = (AbstractWorkingSet) super.clone(); + clone.disconnect(); + return clone; + } } Index: Eclipse UI/org/eclipse/ui/internal/WorkingSet.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java,v retrieving revision 1.32 diff -u -r1.32 WorkingSet.java --- Eclipse UI/org/eclipse/ui/internal/WorkingSet.java 12 Sep 2007 13:04:40 -0000 1.32 +++ Eclipse UI/org/eclipse/ui/internal/WorkingSet.java 25 Oct 2007 23:34:48 -0000 @@ -19,6 +19,7 @@ import org.eclipse.ui.IElementFactory; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPersistableElement; +import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.misc.Policy; @@ -213,9 +214,10 @@ * @see org.eclipse.ui.IWorkingSet */ public void setElements(IAdaptable[] newElements) { + IWorkingSet oldInstance = getCurrentStateObject(); internalSetElements(newElements); fireWorkingSetChanged( - IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE, null); + IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE, oldInstance); } /*