KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WorkbenchPreferenceInitializer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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 package org.eclipse.ui.internal;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.core.runtime.Platform;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
17 import org.eclipse.core.runtime.preferences.DefaultScope;
18 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19 import org.eclipse.core.runtime.preferences.IScopeContext;
20 import org.eclipse.core.runtime.preferences.InstanceScope;
21 import org.eclipse.jface.util.OpenStrategy;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.ui.IWorkbenchPreferenceConstants;
24 import org.osgi.service.prefs.BackingStoreException;
25
26 /**
27  * Implementation of the workbench plugin's preferences extension's
28  * customization element. This is needed in order to force the workbench
29  * plugin's preferences to be initialized properly when running without
30  * org.eclipse.core.runtime.compatibility. For more details, see bug 58975 - New
31  * preference mechanism does not properly initialize defaults.
32  *
33  * @since 3.0
34  */

35 public class WorkbenchPreferenceInitializer extends
36         AbstractPreferenceInitializer {
37     
38     
39
40     public void initializeDefaultPreferences() {
41         IScopeContext context = new DefaultScope();
42         IEclipsePreferences node = context.getNode(WorkbenchPlugin
43                 .getDefault().getBundle().getSymbolicName());
44
45         node
46                 .putBoolean(IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT,
47                         true);
48
49         node.putBoolean(IPreferenceConstants.EDITORLIST_PULLDOWN_ACTIVE, false);
50         node.putBoolean(IPreferenceConstants.EDITORLIST_DISPLAY_FULL_NAME,
51                 false);
52         node.putBoolean(IPreferenceConstants.STICKY_CYCLE, false);
53         node.putBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN, false);
54         node.putBoolean(IPreferenceConstants.REUSE_DIRTY_EDITORS, true);
55         node.putInt(IPreferenceConstants.REUSE_EDITORS, 8);
56         node.putBoolean(IPreferenceConstants.OPEN_ON_SINGLE_CLICK, false);
57         node.putBoolean(IPreferenceConstants.SELECT_ON_HOVER, false);
58         node.putBoolean(IPreferenceConstants.OPEN_AFTER_DELAY, false);
59         node.putInt(IPreferenceConstants.RECENT_FILES, 4);
60
61         node.putInt(IPreferenceConstants.VIEW_TAB_POSITION, SWT.TOP);
62         node.putInt(IPreferenceConstants.EDITOR_TAB_POSITION, SWT.TOP);
63
64         node.putBoolean(IPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, true);
65         node.putBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS, true);
66
67         node.putInt(IPreferenceConstants.EDITOR_TAB_WIDTH, 3); // high
68
node.putInt(IPreferenceConstants.OPEN_VIEW_MODE,
69                 IPreferenceConstants.OVM_EMBED);
70         node.putInt(IPreferenceConstants.OPEN_PERSP_MODE,
71                 IPreferenceConstants.OPM_ACTIVE_PAGE);
72         node.put(IPreferenceConstants.ENABLED_DECORATORS, ""); //$NON-NLS-1$
73
node.putInt(IPreferenceConstants.EDITORLIST_SELECTION_SCOPE,
74                 IPreferenceConstants.EDITORLIST_SET_PAGE_SCOPE); // Current
75
// Window
76
node.putInt(IPreferenceConstants.EDITORLIST_SORT_CRITERIA,
77                 IPreferenceConstants.EDITORLIST_NAME_SORT); // Name Sort
78
node.putBoolean(IPreferenceConstants.COLOR_ICONS, true);
79         node.putInt(IPreferenceConstants.KEYS_PREFERENCE_SELECTED_TAB, 0);
80         node.putBoolean(IPreferenceConstants.MULTI_KEY_ASSIST, true);
81         node.putInt(IPreferenceConstants.MULTI_KEY_ASSIST_TIME, 1000);
82
83         // Temporary option to enable wizard for project capability
84
node.putBoolean("ENABLE_CONFIGURABLE_PROJECT_WIZARD", false); //$NON-NLS-1$
85
// Temporary option to enable single click
86
node.putInt("SINGLE_CLICK_METHOD", OpenStrategy.DOUBLE_CLICK); //$NON-NLS-1$
87
// Temporary option to enable cool bars
88
node.putBoolean("ENABLE_COOL_BARS", true); //$NON-NLS-1$
89
// Temporary option to enable new menu organization
90
node.putBoolean("ENABLE_NEW_MENUS", true); //$NON-NLS-1$
91
//Temporary option to turn off the dialog font
92
node.putBoolean("DISABLE_DIALOG_FONT", false); //$NON-NLS-1$
93

94         // Heap status preferences
95
node.putBoolean(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, false);
96         node.putInt(IHeapStatusConstants.PREF_UPDATE_INTERVAL, 500);
97         node.putBoolean(IHeapStatusConstants.PREF_SHOW_MAX, false);
98         node.putBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION, false);
99         
100         IEclipsePreferences rootNode = (IEclipsePreferences) Platform
101                 .getPreferencesService().getRootNode()
102                 .node(InstanceScope.SCOPE);
103
104         final String JavaDoc workbenchName = WorkbenchPlugin.getDefault().getBundle()
105                 .getSymbolicName();
106         try {
107             if (rootNode.nodeExists(workbenchName)) {
108                 ((IEclipsePreferences) rootNode.node(workbenchName))
109                         .addPreferenceChangeListener(PlatformUIPreferenceListener
110                                 .getSingleton());
111             }
112         } catch (BackingStoreException e) {
113             IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin
114                     .getDefault().getBundle().getSymbolicName(), IStatus.ERROR,
115                     e.getLocalizedMessage(), e);
116             WorkbenchPlugin.getDefault().getLog().log(status);
117         }
118     
119     }
120
121 }
122
Popular Tags