ps:内容来自Eclipse Preferences FAQ。代码简单,直接贴了。
1. | Through the backwards compatibility layer. Again, all the old APIs exist and are fully functional.
|
2. | Via navigation from the root node. If the user knows which scope they wish to store the preference in and knows the path structure for the hierarchy of that scope, then they are able to navigate directly to that preference node and set their preference value. In the example below we are setting the auto-build setting in the INSTANCE scope.
|
3. | Through the scope context. If the user knows which scope they wish to set the preference value in but doesn't know the path structure for that scope, (or prefers not to navigate it themselves) then they can use the convenience methods in IScopeContext to determine the correct preference node. This is the method in which we envision most clients setting preference values. In the example below we are storing the preference in the project preferences for "MyProject".
|