1 11 package org.eclipse.ui.internal.util; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.preference.IPreferenceStore; 15 import org.eclipse.ui.internal.WorkbenchPlugin; 16 17 30 public class PrefUtil { 31 32 private PrefUtil() { 33 } 35 36 39 public static interface ICallback { 40 IPreferenceStore getPreferenceStore(); 41 42 void savePreferences(); 43 } 44 45 private static ICallback uiCallback; 46 47 private static IPreferenceStore uiPreferenceStore; 48 49 52 public static final void setUICallback(ICallback callback) { 53 Assert.isTrue(uiCallback == null); 54 uiCallback = callback; 55 } 56 57 62 public static IPreferenceStore getAPIPreferenceStore() { 63 if (uiPreferenceStore == null) { 64 Assert.isNotNull(uiCallback); 65 uiPreferenceStore = uiCallback.getPreferenceStore(); 66 } 67 return uiPreferenceStore; 68 } 69 70 75 public static IPreferenceStore getInternalPreferenceStore() { 76 return WorkbenchPlugin.getDefault().getPreferenceStore(); 77 } 78 79 82 public static void savePrefs() { 83 saveAPIPrefs(); 84 saveInternalPrefs(); 85 } 86 87 90 public static void saveAPIPrefs() { 91 Assert.isNotNull(uiCallback); 92 uiCallback.savePreferences(); 93 } 94 95 98 public static void saveInternalPrefs() { 99 WorkbenchPlugin.getDefault().savePluginPreferences(); 100 } 101 } 102 | Popular Tags |