Lines 64-73
Link Here
|
64 |
import org.eclipse.core.runtime.*; |
64 |
import org.eclipse.core.runtime.*; |
65 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
65 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
66 |
import org.eclipse.core.runtime.jobs.Job; |
66 |
import org.eclipse.core.runtime.jobs.Job; |
67 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
|
|
68 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
67 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
69 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
68 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
70 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
|
|
71 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
69 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
72 |
import org.eclipse.jdt.internal.core.*; |
70 |
import org.eclipse.jdt.internal.core.*; |
73 |
import org.eclipse.jdt.internal.core.util.MementoTokenizer; |
71 |
import org.eclipse.jdt.internal.core.util.MementoTokenizer; |
Lines 992-1005
Link Here
|
992 |
* @since 3.0 |
990 |
* @since 3.0 |
993 |
*/ |
991 |
*/ |
994 |
public static final String PRIVATE = "private"; //$NON-NLS-1$ |
992 |
public static final String PRIVATE = "private"; //$NON-NLS-1$ |
995 |
|
|
|
996 |
/** |
997 |
* New Preferences API |
998 |
* @since 3.1 |
999 |
*/ |
1000 |
public static final IEclipsePreferences[] preferencesLookup = new IEclipsePreferences[2]; |
1001 |
static final int PREF_INSTANCE = 0; |
1002 |
static final int PREF_DEFAULT = 1; |
1003 |
|
993 |
|
1004 |
/** |
994 |
/** |
1005 |
* Creates the Java core plug-in. |
995 |
* Creates the Java core plug-in. |
Lines 2301-2308
Link Here
|
2301 |
Hashtable defaultOptions = new Hashtable(10); |
2291 |
Hashtable defaultOptions = new Hashtable(10); |
2302 |
|
2292 |
|
2303 |
// see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings |
2293 |
// see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings |
2304 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
2294 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
2305 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
2295 |
IEclipsePreferences defaultPreferences = manager.getDefaultPreferences(); |
|
|
2296 |
HashSet optionNames = manager.optionNames; |
2306 |
|
2297 |
|
2307 |
// initialize preferences to their default |
2298 |
// initialize preferences to their default |
2308 |
Iterator iterator = optionNames.iterator(); |
2299 |
Iterator iterator = optionNames.iterator(); |
Lines 2319-2344
Link Here
|
2319 |
|
2310 |
|
2320 |
return defaultOptions; |
2311 |
return defaultOptions; |
2321 |
} |
2312 |
} |
2322 |
|
|
|
2323 |
/** |
2324 |
* @since 3.1 |
2325 |
*/ |
2326 |
public static IEclipsePreferences getInstancePreferences() { |
2327 |
if (preferencesLookup[PREF_INSTANCE] == null) { |
2328 |
preferencesLookup[PREF_INSTANCE] = new InstanceScope().getNode(PLUGIN_ID); |
2329 |
} |
2330 |
return preferencesLookup[PREF_INSTANCE]; |
2331 |
} |
2332 |
|
2333 |
/** |
2334 |
* @since 3.1 |
2335 |
*/ |
2336 |
public static IEclipsePreferences getDefaultPreferences() { |
2337 |
if (preferencesLookup[PREF_DEFAULT] == null) { |
2338 |
preferencesLookup[PREF_DEFAULT] = new DefaultScope().getNode(PLUGIN_ID); |
2339 |
} |
2340 |
return preferencesLookup[PREF_DEFAULT]; |
2341 |
} |
2342 |
|
2313 |
|
2343 |
/** |
2314 |
/** |
2344 |
* Returns the workspace root default charset encoding. |
2315 |
* Returns the workspace root default charset encoding. |
Lines 2395-2403
Link Here
|
2395 |
return ERROR; |
2366 |
return ERROR; |
2396 |
} |
2367 |
} |
2397 |
String propertyName = optionName; |
2368 |
String propertyName = optionName; |
2398 |
if (JavaModelManager.getJavaModelManager().optionNames.contains(propertyName)){ |
2369 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
|
|
2370 |
if (manager.optionNames.contains(propertyName)){ |
2399 |
IPreferencesService service = Platform.getPreferencesService(); |
2371 |
IPreferencesService service = Platform.getPreferencesService(); |
2400 |
String value = service.get(optionName, null, preferencesLookup); |
2372 |
String value = service.get(optionName, null, manager.preferencesLookup); |
2401 |
return value==null ? null : value.trim(); |
2373 |
return value==null ? null : value.trim(); |
2402 |
} |
2374 |
} |
2403 |
return null; |
2375 |
return null; |
Lines 2419-2432
Link Here
|
2419 |
|
2391 |
|
2420 |
// init |
2392 |
// init |
2421 |
Hashtable options = new Hashtable(10); |
2393 |
Hashtable options = new Hashtable(10); |
2422 |
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames; |
2394 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
|
|
2395 |
HashSet optionNames = manager.optionNames; |
2423 |
IPreferencesService service = Platform.getPreferencesService(); |
2396 |
IPreferencesService service = Platform.getPreferencesService(); |
2424 |
|
2397 |
|
2425 |
// set options using preferences service lookup |
2398 |
// set options using preferences service lookup |
2426 |
Iterator iterator = optionNames.iterator(); |
2399 |
Iterator iterator = optionNames.iterator(); |
2427 |
while (iterator.hasNext()) { |
2400 |
while (iterator.hasNext()) { |
2428 |
String propertyName = (String) iterator.next(); |
2401 |
String propertyName = (String) iterator.next(); |
2429 |
String propertyValue = service.get(propertyName, null, preferencesLookup); |
2402 |
String propertyValue = service.get(propertyName, null, manager.preferencesLookup); |
2430 |
if (propertyValue != null) { |
2403 |
if (propertyValue != null) { |
2431 |
options.put(propertyName, propertyValue); |
2404 |
options.put(propertyName, propertyValue); |
2432 |
} |
2405 |
} |
Lines 3987-3994
Link Here
|
3987 |
public static void setOptions(Hashtable newOptions) { |
3960 |
public static void setOptions(Hashtable newOptions) { |
3988 |
|
3961 |
|
3989 |
try { |
3962 |
try { |
3990 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
3963 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
3991 |
IEclipsePreferences instancePreferences = getInstancePreferences(); |
3964 |
IEclipsePreferences defaultPreferences = manager.getDefaultPreferences(); |
|
|
3965 |
IEclipsePreferences instancePreferences = manager.getInstancePreferences(); |
3992 |
|
3966 |
|
3993 |
if (newOptions == null){ |
3967 |
if (newOptions == null){ |
3994 |
instancePreferences.clear(); |
3968 |
instancePreferences.clear(); |
Lines 4064-4097
Link Here
|
4064 |
// request state folder creation (workaround 19885) |
4038 |
// request state folder creation (workaround 19885) |
4065 |
JavaCore.getPlugin().getStateLocation(); |
4039 |
JavaCore.getPlugin().getStateLocation(); |
4066 |
|
4040 |
|
4067 |
// Listen to instance preferences node removal from parent in order to refresh stored one |
4041 |
// Initialize eclipse preferences |
4068 |
IEclipsePreferences.INodeChangeListener listener = new IEclipsePreferences.INodeChangeListener() { |
4042 |
manager.initializePreferences(); |
4069 |
public void added(IEclipsePreferences.NodeChangeEvent event) { |
|
|
4070 |
// do nothing |
4071 |
} |
4072 |
public void removed(IEclipsePreferences.NodeChangeEvent event) { |
4073 |
if (event.getChild() == preferencesLookup[PREF_INSTANCE]) { |
4074 |
preferencesLookup[PREF_INSTANCE] = new InstanceScope().getNode(PLUGIN_ID); |
4075 |
} |
4076 |
} |
4077 |
}; |
4078 |
((IEclipsePreferences) getInstancePreferences().parent()).addNodeChangeListener(listener); |
4079 |
|
4080 |
// Listen to default preferences node removal from parent in order to refresh stored one |
4081 |
listener = new IEclipsePreferences.INodeChangeListener() { |
4082 |
public void added(IEclipsePreferences.NodeChangeEvent event) { |
4083 |
// do nothing |
4084 |
} |
4085 |
public void removed(IEclipsePreferences.NodeChangeEvent event) { |
4086 |
if (event.getChild() == preferencesLookup[PREF_DEFAULT]) { |
4087 |
preferencesLookup[PREF_DEFAULT] = new DefaultScope().getNode(PLUGIN_ID); |
4088 |
} |
4089 |
} |
4090 |
}; |
4091 |
((IEclipsePreferences) getDefaultPreferences().parent()).addNodeChangeListener(listener); |
4092 |
|
4043 |
|
4093 |
// retrieve variable values |
4044 |
// retrieve variable values |
4094 |
getInstancePreferences().addPreferenceChangeListener(new JavaModelManager.EclipsePreferencesListener()); |
|
|
4095 |
manager.loadVariablesAndContainers(); |
4045 |
manager.loadVariablesAndContainers(); |
4096 |
|
4046 |
|
4097 |
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
4047 |
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); |