001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal;
011:
012: import org.eclipse.core.runtime.IStatus;
013: import org.eclipse.core.runtime.Platform;
014: import org.eclipse.core.runtime.Status;
015: import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
016: import org.eclipse.core.runtime.preferences.DefaultScope;
017: import org.eclipse.core.runtime.preferences.IEclipsePreferences;
018: import org.eclipse.core.runtime.preferences.IScopeContext;
019: import org.eclipse.core.runtime.preferences.InstanceScope;
020: import org.eclipse.jface.util.OpenStrategy;
021: import org.eclipse.swt.SWT;
022: import org.eclipse.ui.IWorkbenchPreferenceConstants;
023: import org.osgi.service.prefs.BackingStoreException;
024:
025: /**
026: * Implementation of the workbench plugin's preferences extension's
027: * customization element. This is needed in order to force the workbench
028: * plugin's preferences to be initialized properly when running without
029: * org.eclipse.core.runtime.compatibility. For more details, see bug 58975 - New
030: * preference mechanism does not properly initialize defaults.
031: *
032: * @since 3.0
033: */
034: public class WorkbenchPreferenceInitializer extends
035: AbstractPreferenceInitializer {
036:
037: public void initializeDefaultPreferences() {
038: IScopeContext context = new DefaultScope();
039: IEclipsePreferences node = context.getNode(WorkbenchPlugin
040: .getDefault().getBundle().getSymbolicName());
041:
042: node
043: .putBoolean(
044: IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT,
045: true);
046:
047: node.putBoolean(
048: IPreferenceConstants.EDITORLIST_PULLDOWN_ACTIVE, false);
049: node.putBoolean(
050: IPreferenceConstants.EDITORLIST_DISPLAY_FULL_NAME,
051: false);
052: node.putBoolean(IPreferenceConstants.STICKY_CYCLE, false);
053: node.putBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN,
054: false);
055: node.putBoolean(IPreferenceConstants.REUSE_DIRTY_EDITORS, true);
056: node.putInt(IPreferenceConstants.REUSE_EDITORS, 8);
057: node.putBoolean(IPreferenceConstants.OPEN_ON_SINGLE_CLICK,
058: false);
059: node.putBoolean(IPreferenceConstants.SELECT_ON_HOVER, false);
060: node.putBoolean(IPreferenceConstants.OPEN_AFTER_DELAY, false);
061: node.putInt(IPreferenceConstants.RECENT_FILES, 4);
062:
063: node.putInt(IPreferenceConstants.VIEW_TAB_POSITION, SWT.TOP);
064: node.putInt(IPreferenceConstants.EDITOR_TAB_POSITION, SWT.TOP);
065:
066: node.putBoolean(IPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS,
067: true);
068: node.putBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS,
069: true);
070:
071: node.putInt(IPreferenceConstants.EDITOR_TAB_WIDTH, 3); // high
072: node.putInt(IPreferenceConstants.OPEN_VIEW_MODE,
073: IPreferenceConstants.OVM_EMBED);
074: node.putInt(IPreferenceConstants.OPEN_PERSP_MODE,
075: IPreferenceConstants.OPM_ACTIVE_PAGE);
076: node.put(IPreferenceConstants.ENABLED_DECORATORS, ""); //$NON-NLS-1$
077: node.putInt(IPreferenceConstants.EDITORLIST_SELECTION_SCOPE,
078: IPreferenceConstants.EDITORLIST_SET_PAGE_SCOPE); // Current
079: // Window
080: node.putInt(IPreferenceConstants.EDITORLIST_SORT_CRITERIA,
081: IPreferenceConstants.EDITORLIST_NAME_SORT); // Name Sort
082: node.putBoolean(IPreferenceConstants.COLOR_ICONS, true);
083: node.putInt(IPreferenceConstants.KEYS_PREFERENCE_SELECTED_TAB,
084: 0);
085: node.putBoolean(IPreferenceConstants.MULTI_KEY_ASSIST, true);
086: node.putInt(IPreferenceConstants.MULTI_KEY_ASSIST_TIME, 1000);
087:
088: // Temporary option to enable wizard for project capability
089: node.putBoolean("ENABLE_CONFIGURABLE_PROJECT_WIZARD", false); //$NON-NLS-1$
090: // Temporary option to enable single click
091: node.putInt("SINGLE_CLICK_METHOD", OpenStrategy.DOUBLE_CLICK); //$NON-NLS-1$
092: // Temporary option to enable cool bars
093: node.putBoolean("ENABLE_COOL_BARS", true); //$NON-NLS-1$
094: // Temporary option to enable new menu organization
095: node.putBoolean("ENABLE_NEW_MENUS", true); //$NON-NLS-1$
096: //Temporary option to turn off the dialog font
097: node.putBoolean("DISABLE_DIALOG_FONT", false); //$NON-NLS-1$
098:
099: // Heap status preferences
100: node.putBoolean(
101: IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR,
102: false);
103: node.putInt(IHeapStatusConstants.PREF_UPDATE_INTERVAL, 500);
104: node.putBoolean(IHeapStatusConstants.PREF_SHOW_MAX, false);
105: node.putBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION,
106: false);
107:
108: IEclipsePreferences rootNode = (IEclipsePreferences) Platform
109: .getPreferencesService().getRootNode().node(
110: InstanceScope.SCOPE);
111:
112: final String workbenchName = WorkbenchPlugin.getDefault()
113: .getBundle().getSymbolicName();
114: try {
115: if (rootNode.nodeExists(workbenchName)) {
116: ((IEclipsePreferences) rootNode.node(workbenchName))
117: .addPreferenceChangeListener(PlatformUIPreferenceListener
118: .getSingleton());
119: }
120: } catch (BackingStoreException e) {
121: IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin
122: .getDefault().getBundle().getSymbolicName(),
123: IStatus.ERROR, e.getLocalizedMessage(), e);
124: WorkbenchPlugin.getDefault().getLog().log(status);
125: }
126:
127: }
128:
129: }
|