diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileSettingsPreferencePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileSettingsPreferencePage.java index 939ecd351bd..586db031905 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileSettingsPreferencePage.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakefileSettingsPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 QNX Software Systems and others. + * Copyright (c) 2002, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,7 @@ package org.eclipse.cdt.make.internal.ui.preferences; import org.eclipse.cdt.make.core.MakeCorePlugin; -import org.eclipse.cdt.make.internal.ui.text.PreferencesAdapter; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PathEditor; @@ -21,6 +21,7 @@ import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.preferences.ScopedPreferenceStore; /** * MakePreferencePage @@ -34,13 +35,14 @@ public class MakefileSettingsPreferencePage extends FieldEditorPreferencePage im public MakefileSettingsPreferencePage() { super(GRID); - IPreferenceStore store = new PreferencesAdapter(MakeCorePlugin.getDefault().getPluginPreferences()); + IPreferenceStore store = new ScopedPreferenceStore(new InstanceScope(), MakeCorePlugin.PLUGIN_ID); setPreferenceStore(store); } /** * @see FieldEditorPreferencePage#createControl(Composite) */ + @Override protected void createFieldEditors() { String[][] personalities = {{POSIX_MAKE_LABEL, POSIX_MAKE_VALUE}, {GNU_MAKE_LABEL, GNU_MAKE_VALUE}}; RadioGroupFieldEditor combo = new RadioGroupFieldEditor(MakeCorePlugin.MAKEFILE_STYLE, @@ -59,6 +61,7 @@ public class MakefileSettingsPreferencePage extends FieldEditorPreferencePage im /** * Initializes the default values of this page in the preference bundle. + * @param prefs preference store */ public static void initDefaults(IPreferenceStore prefs) { } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/PreferencesAdapter.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/PreferencesAdapter.java deleted file mode 100644 index 64c121b9c48..00000000000 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/PreferencesAdapter.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.make.internal.ui.text; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * Adapts {@link org.eclipse.core.runtime.Preferences} to - * {@link org.eclipse.jface.preference.IPreferenceStore} - * - * @since 3.0 - */ -public class PreferencesAdapter implements IPreferenceStore { - - /** - * Property change listener. Listens for events of type - * {@link org.eclipse.core.runtime.Preferences.PropertyChangeEvent} and fires - * a {@link org.eclipse.jface.util.PropertyChangeEvent} on the - * adapter with arguments from the received event. - */ - private class PropertyChangeListener implements Preferences.IPropertyChangeListener { - - /* - * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) - */ - public void propertyChange(Preferences.PropertyChangeEvent event) { - firePropertyChangeEvent(event.getProperty(), event.getOldValue(), event.getNewValue()); - } - } - - /** Listeners on the adapter */ - private ListenerList fListeners= new ListenerList(); - - /** Listener on the adapted Preferences */ - private PropertyChangeListener fListener= new PropertyChangeListener(); - - /** Adapted Preferences */ - private Preferences fPreferences; - - /** True iff no events should be forwarded */ - private boolean fSilent; - - /** - * Initialize with empty Preferences. - */ - public PreferencesAdapter() { - this(new Preferences()); - } - /** - * Initialize with the given Preferences. - * - * @param preferences The preferences to wrap. - */ - public PreferencesAdapter(Preferences preferences) { - fPreferences= preferences; - } - - /** - * {@inheritDoc} - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListeners.size() == 0) - fPreferences.addPropertyChangeListener(fListener); - fListeners.add(listener); - } - - /** - * {@inheritDoc} - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - if (fListeners.size() == 0) - fPreferences.removePropertyChangeListener(fListener); - } - - /** - * {@inheritDoc} - */ - public boolean contains(String name) { - return fPreferences.contains(name); - } - - /** - * {@inheritDoc} - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - if (!fSilent) { - PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue); - Object[] listeners= fListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IPropertyChangeListener) listeners[i]).propertyChange(event); - } - } - - /** - * {@inheritDoc} - */ - public boolean getBoolean(String name) { - return fPreferences.getBoolean(name); - } - - /** - * {@inheritDoc} - */ - public boolean getDefaultBoolean(String name) { - return fPreferences.getDefaultBoolean(name); - } - - /** - * {@inheritDoc} - */ - public double getDefaultDouble(String name) { - return fPreferences.getDefaultDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getDefaultFloat(String name) { - return fPreferences.getDefaultFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getDefaultInt(String name) { - return fPreferences.getDefaultInt(name); - } - - /** - * {@inheritDoc} - */ - public long getDefaultLong(String name) { - return fPreferences.getDefaultLong(name); - } - - /** - * {@inheritDoc} - */ - public String getDefaultString(String name) { - return fPreferences.getDefaultString(name); - } - - /** - * {@inheritDoc} - */ - public double getDouble(String name) { - return fPreferences.getDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getFloat(String name) { - return fPreferences.getFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getInt(String name) { - return fPreferences.getInt(name); - } - - /** - * {@inheritDoc} - */ - public long getLong(String name) { - return fPreferences.getLong(name); - } - - /** - * {@inheritDoc} - */ - public String getString(String name) { - return fPreferences.getString(name); - } - - /** - * {@inheritDoc} - */ - public boolean isDefault(String name) { - return fPreferences.isDefault(name); - } - - /** - * {@inheritDoc} - */ - public boolean needsSaving() { - return fPreferences.needsSaving(); - } - - /** - * {@inheritDoc} - */ - public void putValue(String name, String value) { - try { - fSilent= true; - fPreferences.setValue(name, value); - } finally { - fSilent= false; - } - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, double value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, float value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, int value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, long value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, String defaultObject) { - fPreferences.setDefault(name, defaultObject); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, boolean value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setToDefault(String name) { - fPreferences.setToDefault(name); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, double value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, float value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, int value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, long value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, String value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, boolean value) { - fPreferences.setValue(name, value); - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index a3397a6269a..04f8540b0e6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -36,6 +36,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.help.IContextProvider; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IAction; @@ -137,6 +138,7 @@ import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.part.ShowInContext; +import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.ChainedPreferenceStore; @@ -205,7 +207,6 @@ import org.eclipse.cdt.internal.ui.text.CWordFinder; import org.eclipse.cdt.internal.ui.text.CWordIterator; import org.eclipse.cdt.internal.ui.text.DocumentCharacterIterator; import org.eclipse.cdt.internal.ui.text.ICReconcilingListener; -import org.eclipse.cdt.internal.ui.text.PreferencesAdapter; import org.eclipse.cdt.internal.ui.text.Symbols; import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; @@ -3331,7 +3332,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC } stores.add(CUIPlugin.getDefault().getPreferenceStore()); - stores.add(new PreferencesAdapter(CCorePlugin.getDefault().getPluginPreferences())); + stores.add(new ScopedPreferenceStore(new InstanceScope(), CCorePlugin.PLUGIN_ID)); stores.add(EditorsUI.getPreferenceStore()); return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreferencesAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreferencesAdapter.java deleted file mode 100644 index 608006f233c..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreferencesAdapter.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.internal.ui.text; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * Adapts {@link org.eclipse.core.runtime.Preferences} to - * {@link org.eclipse.jface.preference.IPreferenceStore} - * - * @since 3.0 - */ -public class PreferencesAdapter implements IPreferenceStore { - - /** - * Property change listener. Listens for events of type - * {@link org.eclipse.core.runtime.Preferences.PropertyChangeEvent} and fires - * a {@link org.eclipse.jface.util.PropertyChangeEvent} on the - * adapter with arguments from the received event. - */ - private class PropertyChangeListener implements Preferences.IPropertyChangeListener { - - /* - * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) - */ - public void propertyChange(Preferences.PropertyChangeEvent event) { - firePropertyChangeEvent(event.getProperty(), event.getOldValue(), event.getNewValue()); - } - } - - /** Listeners on the adapter */ - private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY); - - /** Listener on the adapted Preferences */ - private PropertyChangeListener fListener= new PropertyChangeListener(); - - /** Adapted Preferences */ - private Preferences fPreferences; - - /** True iff no events should be forwarded */ - private boolean fSilent; - - /** - * Initialize with empty Preferences. - */ - public PreferencesAdapter() { - this(new Preferences()); - } - /** - * Initialize with the given Preferences. - * - * @param preferences The preferences to wrap. - */ - public PreferencesAdapter(Preferences preferences) { - fPreferences= preferences; - } - - /** - * {@inheritDoc} - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListeners.size() == 0) - fPreferences.addPropertyChangeListener(fListener); - fListeners.add(listener); - } - - /** - * {@inheritDoc} - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - if (fListeners.size() == 0) - fPreferences.removePropertyChangeListener(fListener); - } - - /** - * {@inheritDoc} - */ - public boolean contains(String name) { - return fPreferences.contains(name); - } - - /** - * {@inheritDoc} - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - if (!fSilent) { - PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue); - Object[] listeners= fListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IPropertyChangeListener) listeners[i]).propertyChange(event); - } - } - - /** - * {@inheritDoc} - */ - public boolean getBoolean(String name) { - return fPreferences.getBoolean(name); - } - - /** - * {@inheritDoc} - */ - public boolean getDefaultBoolean(String name) { - return fPreferences.getDefaultBoolean(name); - } - - /** - * {@inheritDoc} - */ - public double getDefaultDouble(String name) { - return fPreferences.getDefaultDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getDefaultFloat(String name) { - return fPreferences.getDefaultFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getDefaultInt(String name) { - return fPreferences.getDefaultInt(name); - } - - /** - * {@inheritDoc} - */ - public long getDefaultLong(String name) { - return fPreferences.getDefaultLong(name); - } - - /** - * {@inheritDoc} - */ - public String getDefaultString(String name) { - return fPreferences.getDefaultString(name); - } - - /** - * {@inheritDoc} - */ - public double getDouble(String name) { - return fPreferences.getDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getFloat(String name) { - return fPreferences.getFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getInt(String name) { - return fPreferences.getInt(name); - } - - /** - * {@inheritDoc} - */ - public long getLong(String name) { - return fPreferences.getLong(name); - } - - /** - * {@inheritDoc} - */ - public String getString(String name) { - return fPreferences.getString(name); - } - - /** - * {@inheritDoc} - */ - public boolean isDefault(String name) { - return fPreferences.isDefault(name); - } - - /** - * {@inheritDoc} - */ - public boolean needsSaving() { - return fPreferences.needsSaving(); - } - - /** - * {@inheritDoc} - */ - public void putValue(String name, String value) { - try { - fSilent= true; - fPreferences.setValue(name, value); - } finally { - fSilent= false; - } - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, double value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, float value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, int value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, long value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, String defaultObject) { - fPreferences.setDefault(name, defaultObject); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, boolean value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setToDefault(String name) { - fPreferences.setToDefault(name); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, double value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, float value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, int value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, long value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, String value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, boolean value) { - fPreferences.setValue(name, value); - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 70c7f7cbfa3..d5a6271db9e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -36,6 +36,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; @@ -56,6 +57,7 @@ import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry; import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ConfigurationElementSorter; import org.osgi.framework.Bundle; @@ -90,7 +92,6 @@ import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager; import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools; import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory; import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.internal.ui.text.PreferencesAdapter; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; import org.eclipse.cdt.internal.ui.text.doctools.EditorReopener; @@ -122,6 +123,8 @@ public class CUIPlugin extends AbstractUIPlugin { public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$ public final static String CWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCWizards"; //$NON-NLS-1$ + /** @deprecated This wizard category has been merged with the {@link #CWIZARD_CATEGORY_ID c wizard category} */ + @Deprecated public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$ public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$ @@ -666,8 +669,11 @@ public class CUIPlugin extends AbstractUIPlugin { */ public IPreferenceStore getCombinedPreferenceStore() { if (fCombinedPreferenceStore == null) { - IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); - fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(CCorePlugin.getDefault().getPluginPreferences()), generalTextStore }); + fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { + getPreferenceStore(), + new ScopedPreferenceStore(new InstanceScope(), PLUGIN_CORE_ID), + EditorsUI.getPreferenceStore() + }); } return fCombinedPreferenceStore; } @@ -909,7 +915,7 @@ public class CUIPlugin extends AbstractUIPlugin { */ public ContextTypeRegistry getCodeTemplateContextRegistry() { if (fCodeTemplateContextTypeRegistry == null) { - fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry(); + fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry); FileTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);