KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > editors > text > EditorsPluginPreferenceInitializer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.editors.text;
13
14 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
15
16 import org.eclipse.jface.preference.IPreferenceStore;
17
18 import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
19 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
20
21
22 /**
23  * Preference initializer for Editors UI plug-in.
24  *
25  * @since 3.1
26  */

27 public class EditorsPluginPreferenceInitializer extends AbstractPreferenceInitializer {
28
29     /*
30      * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
31      * @since 3.1
32      */

33     public void initializeDefaultPreferences() {
34         IPreferenceStore store= EditorsPlugin.getDefault().getPreferenceStore();
35         TextEditorPreferenceConstants.initializeDefaultValues(store);
36         migrateOverviewRulerPreference(store);
37     }
38
39     /**
40      * Migrates the overview ruler preference by re-enabling it.
41      *
42      * @param store the preference store to migrate
43      * @since 3.1
44      */

45     private void migrateOverviewRulerPreference(IPreferenceStore store) {
46         String JavaDoc preference= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER;
47         String JavaDoc postfix= "_migration"; //$NON-NLS-1$
48
String JavaDoc MIGRATED= "migrated_3.1"; //$NON-NLS-1$
49
String JavaDoc migrationKey= preference + postfix;
50
51         String JavaDoc migrationValue= store.getString(migrationKey);
52         if (!MIGRATED.equals(migrationValue)) {
53             store.setValue(migrationKey, MIGRATED);
54             if (!store.getBoolean(preference))
55                 store.setValue(preference, true);
56         }
57     }
58 }
59
Popular Tags