From c15e5acca544c33e3a504d3934ef4f628951ec87 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sat, 5 Apr 2003 02:04:25 +0000 Subject: [PATCH] Make the preference constant visible for other plugins. --- .../eclipse/cdt/internal/ui/cview/CView.java | 3 +- .../ui/preferences/CPluginPreferencePage.java | 16 +++---- .../eclipse/cdt/ui/PreferenceConstants.java | 44 +++++++++++++++++++ 3 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java index fd03a5da677..aa7c2938187 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -1107,7 +1108,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge boolean refreshViewer= false; - if (event.getProperty() == CPluginPreferencePage.PREF_SHOW_CU_CHILDREN) { + if (event.getProperty() == PreferenceConstants.PREF_SHOW_CU_CHILDREN) { boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren(); ((CElementContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren); refreshViewer= true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java index 48beb898847..823b8fb2c36 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java @@ -8,6 +8,7 @@ package org.eclipse.cdt.internal.ui.preferences; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; @@ -21,8 +22,6 @@ import org.eclipse.ui.help.WorkbenchHelp; */ public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - private static final String PREF_LINK_TO_EDITOR= "linkToEditor"; //$NON-NLS-1$ - public static final String PREF_SHOW_CU_CHILDREN= "CUChildren"; //$NON-NLS-1$ private static final String LINK_TO_EDITOR_LABEL= "CBasePreferencePage.linkToEditor.label"; private static final String SHOW_CU_CHILDREN_LABEL= "CBasePreferencePage.CUChildren.label"; @@ -47,10 +46,10 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements protected void createFieldEditors() { Composite parent= getFieldEditorParent(); - BooleanFieldEditor linkEditor= new BooleanFieldEditor(PREF_LINK_TO_EDITOR, CUIPlugin.getResourceString(LINK_TO_EDITOR_LABEL), parent); + BooleanFieldEditor linkEditor= new BooleanFieldEditor(PreferenceConstants.PREF_LINK_TO_EDITOR, CUIPlugin.getResourceString(LINK_TO_EDITOR_LABEL), parent); addField(linkEditor); - BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent); + BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PreferenceConstants.PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent); addField(showCUChildrenEditor); BooleanFieldEditor useNewParserEditor= new BooleanFieldEditor(CCorePlugin.PREF_USE_NEW_PARSER, CUIPlugin.getResourceString(USE_NEW_PARSER_LABEL), parent); @@ -59,11 +58,11 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements public static boolean isLinkToEditor() { - return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_LINK_TO_EDITOR); + return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_LINK_TO_EDITOR); } public static boolean showCompilationUnitChildren() { - return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_SHOW_CU_CHILDREN); + return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN); } public static boolean useNewParser() { @@ -81,9 +80,10 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements * Initializes the default values of this page in the preference bundle. */ public static void initDefaults(IPreferenceStore prefs) { - prefs.setDefault(PREF_LINK_TO_EDITOR, true); - prefs.setDefault(PREF_SHOW_CU_CHILDREN, true); + prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, true); + prefs.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true); prefs.setDefault(CCorePlugin.PREF_USE_NEW_PARSER, CCorePlugin.getDefault().useNewParser()); + prefs.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java new file mode 100644 index 00000000000..57d724141e4 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -0,0 +1,44 @@ +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ +package org.eclipse.cdt.ui; + +/** + * Preference constants used in the JDT-UI preference store. Clients should only read the + * JDT-UI preference store using these values. Clients are not allowed to modify the + * preference store programmatically. + * + * @since 2.0 + */ + +public class PreferenceConstants { + + private PreferenceConstants() { + } + + /** + * A named preference that controls whether the cview's selection is linked to the active editor. + *

+ * Value is of type Boolean. + *

+ */ + public static final String PREF_LINK_TO_EDITOR= "org.eclipse.cdt.ui.editor.linkToEditor"; //$NON-NLS-1$ + + /** + * A named preference that speficies whether children of a translation unit are shown in the package explorer. + *

+ * Value is of type Boolean. + *

+ */ + public static final String PREF_SHOW_CU_CHILDREN= "org.eclipse.cdt.ui.editor.CUChildren"; //$NON-NLS-1$ + + /** + * A named preference that controls if segmented view (show selected element only) is turned on or off. + *

+ * Value is of type Boolean. + *

+ */ + public static final String EDITOR_SHOW_SEGMENTS= "org.eclipse.cdt.ui.editor.showSegments"; //$NON-NLS-1$ + +} \ No newline at end of file