1 12 package org.eclipse.ui.internal; 13 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.Platform; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 18 import org.eclipse.core.runtime.preferences.DefaultScope; 19 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 20 import org.eclipse.core.runtime.preferences.IScopeContext; 21 import org.eclipse.core.runtime.preferences.InstanceScope; 22 import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; 23 import org.eclipse.ui.IWorkbenchPreferenceConstants; 24 import org.eclipse.ui.keys.IBindingService; 25 import org.osgi.service.prefs.BackingStoreException; 26 27 36 public class UIPreferenceInitializer extends AbstractPreferenceInitializer { 37 38 39 40 public void initializeDefaultPreferences() { 41 42 43 IScopeContext context = new DefaultScope(); 44 IEclipsePreferences node = context.getNode(UIPlugin.getDefault() 45 .getBundle().getSymbolicName()); 46 node.put(IWorkbenchPreferenceConstants.OPEN_NEW_PERSPECTIVE, 47 IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); 48 49 node.put(IWorkbenchPreferenceConstants.PROJECT_OPEN_NEW_PERSPECTIVE, 51 IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); 52 node.put(IWorkbenchPreferenceConstants.SHIFT_OPEN_NEW_PERSPECTIVE, 53 IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); 54 node.put(IWorkbenchPreferenceConstants.ALTERNATE_OPEN_NEW_PERSPECTIVE, 55 IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); 56 57 node.putBoolean(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR, 63 false); 64 65 node.put(IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID, 67 IWorkbenchConstants.DEFAULT_PRESENTATION_ID); 68 node 69 .putBoolean( 70 IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, 71 true); 72 node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, true); 73 node.put(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, 74 IWorkbenchPreferenceConstants.TOP_LEFT); 75 node.putBoolean( 76 IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR, 77 true); 78 79 node.put(IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION, 81 IWorkbenchPreferenceConstants.BOTTOM); 82 83 node.putBoolean(IWorkbenchPreferenceConstants.SHOW_INTRO, true); 85 86 node.put(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID, 88 IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID); 89 90 node.putBoolean(IWorkbenchPreferenceConstants.SHOW_SYSTEM_JOBS, false); 92 93 node 96 .putInt( 97 IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS, 98 -1); 99 100 node.putInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS, 1); 102 103 node.putBoolean(IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT, 105 false); 106 107 node 109 .putBoolean( 110 IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT, 111 false); 112 113 node 116 .putBoolean(IWorkbenchPreferenceConstants.SHOW_FILTERED_TEXTS, 117 true); 118 119 node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_DETACHED_VIEWS, 121 true); 122 123 node.putBoolean(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN, 125 true); 126 127 node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX, true); 129 130 node.putBoolean(IWorkbenchPreferenceConstants.DISABLE_NEW_FAST_VIEW, false); 132 133 node.putBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, false); 135 136 IEclipsePreferences rootNode = (IEclipsePreferences) Platform 137 .getPreferencesService().getRootNode() 138 .node(InstanceScope.SCOPE); 139 140 final String uiName = UIPlugin.getDefault().getBundle() 141 .getSymbolicName(); 142 try { 143 if (rootNode.nodeExists(uiName)) { 144 ((IEclipsePreferences) rootNode.node(uiName)) 145 .addPreferenceChangeListener(PlatformUIPreferenceListener 146 .getSingleton()); 147 } 148 } catch (BackingStoreException e) { 149 IStatus status = new Status(IStatus.ERROR, UIPlugin.getDefault() 150 .getBundle().getSymbolicName(), IStatus.ERROR, e 151 .getLocalizedMessage(), e); 152 UIPlugin.getDefault().getLog().log(status); 153 } 154 155 rootNode 156 .addNodeChangeListener(new IEclipsePreferences.INodeChangeListener() { 157 162 public void added(NodeChangeEvent event) { 163 if (!event.getChild().name().equals(uiName)) { 164 return; 165 } 166 ((IEclipsePreferences) event.getChild()) 167 .addPreferenceChangeListener(PlatformUIPreferenceListener 168 .getSingleton()); 169 170 } 171 172 177 public void removed(NodeChangeEvent event) { 178 180 } 181 182 }); 183 } 184 185 } 186 | Popular Tags |