|
Re: migrating preference-setting code to 3.0 [message #259653 is a reply to message #259434] |
Thu, 08 July 2004 15:00 |
Eclipse User |
|
|
|
Originally posted by: dj_houghton.nospam.ca.ibm.com
This should work fine in 3.0. The underlying preference mechanism has
changed but it hasn't been surfaced to the user yet and all the backward
compatibility code is fully functional.
Tom Roche wrote:
> I need to migrate some preference-setting code from 2.x to 3.0 and I'd
> like to know if I'm doing this correctly: please advise.
>
> When automating GUI testing (JUnit driving SWT using Abbot), I want to
> minimize my interactions with "non-essential" UIs (i.e. unrelated to
> the UIs I want to test), such as the welcome page and preference-
> switching dialogs. To prevent the latter I created some utility
> methods that worked with 2.1.3; now I want to migrate them to 3.0. The
> following code compiles ...
>
> > /**
> > * Get the preference found in UI as
> > * Windows>Preferences>Workbench>Perspecti ves>
> > * Switch to associated perspective when creating a new project
> > */
> > public static String getSwitchToPerspectivePreference() {
> > String val = null;
> > IPreferenceStore ps =
> WorkbenchPlugin.getDefault().getPreferenceStore();
> > if (ps == null) {
> > Logger.log("ERROR: could not get PreferenceStore from
> WorkbenchPlugin");
> > } else {
> > val =
> ps.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MOD E);
> > if (isEmpty(val)) {
> > if
> (ps.contains(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MOD E)) {
> > Logger.log("ERROR: PreferenceStore returned empty pref value");
> > } else {
> > Logger.log("ERROR: PreferenceStore does not contain desired
> pref key");
> > }
> > }
> > }
> > return val;
> > }
>
> > /**
> > * Set the preference found in UI as
> > * Windows>Preferences>Workbench>Perspecti ves>
> > * Switch to associated perspective when creating a new project
> > * Note that this pref is persisted!
> > */
> > public static void setSwitchToPerspectivePreference(String val) {
> > IPreferenceStore ps =
> WorkbenchPlugin.getDefault().getPreferenceStore();
> > Assert.isNotNull(ps);
> > if (ps.contains(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MOD E)) {
> > ps.setValue(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE , val);
> > } else {
> > Logger.log("ERROR: PreferenceStore does not contain desired pref
> key");
> > }
> > }
>
> > /**
> > * Set the preference found in UI as
> > * Windows>Preferences>Workbench>Perspecti ves>
> > * Switch to associated perspective when creating a new project
> > * to always switch. Note that this pref is persisted!
> > */
> > public static void alwaysSwitchToPerspective() {
> > setSwitchToPerspectivePreference(IDEInternalPreferences.PSPM _ALWAYS);
> > }
>
> ... but I'm wondering if, e.g., I should be accessing the preferences
> differently.
|
|
|
Powered by
FUDForum. Page generated in 0.03566 seconds