1 11 12 package org.eclipse.ui.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.internal.preferences.WorkingCopyPreferences; 20 import org.osgi.service.prefs.BackingStoreException; 21 22 30 public class WorkingCopyManager implements IWorkingCopyManager{ 31 32 private static final String EMPTY_STRING = ""; private Map workingCopies = new HashMap (); 35 36 37 40 public IEclipsePreferences getWorkingCopy(IEclipsePreferences original) { 41 if (original instanceof WorkingCopyPreferences) { 42 throw new IllegalArgumentException ("Trying to get a working copy of a working copy"); } 44 String absolutePath = original.absolutePath(); 45 IEclipsePreferences preferences = (IEclipsePreferences) workingCopies.get(absolutePath); 46 if (preferences == null) { 47 preferences = new WorkingCopyPreferences(original, this); 48 workingCopies.put(absolutePath, preferences); 49 } 50 return preferences; 51 } 52 53 54 57 public void applyChanges() throws BackingStoreException { 58 for (Iterator i = workingCopies.values().iterator(); i.hasNext();) { 59 WorkingCopyPreferences prefs = (WorkingCopyPreferences) i.next(); 60 if (prefs.nodeExists(EMPTY_STRING)) 61 prefs.flush(); 62 } 63 } 64 65 } 66 | Popular Tags |