1 11 12 package org.eclipse.ui.internal.preferences; 13 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 19 import org.eclipse.ui.preferences.IWorkingCopyManager; 20 import org.osgi.service.prefs.BackingStoreException; 21 22 30 public final class WorkingCopyManager implements IWorkingCopyManager{ 31 32 private Map workingCopies = new HashMap (); 34 35 43 public IEclipsePreferences getWorkingCopy(IEclipsePreferences original) { 44 if (original instanceof WorkingCopyPreferences) 45 throw new IllegalArgumentException ("Trying to get a working copy of a working copy"); String absolutePath = original.absolutePath(); 47 IEclipsePreferences preferences = (IEclipsePreferences) workingCopies.get(absolutePath); 48 if (preferences == null) { 49 preferences = new WorkingCopyPreferences(original, this); 50 workingCopies.put(absolutePath, preferences); 51 } 52 return preferences; 53 } 54 55 62 public void applyChanges() throws BackingStoreException { 63 for (Iterator i = workingCopies.values().iterator(); i.hasNext();) 64 ((WorkingCopyPreferences) i.next()).flush(); 65 } 66 67 } 68 | Popular Tags |