From 4a66e7076693ce65e1ab4818cd270b946fdc7f9c Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 11 Nov 2010 09:01:41 +0000 Subject: [PATCH] Bug 329676: Open element for enumerators. --- .../internal/core/browser/IndexModelUtil.java | 4 ++++ .../browser/typeinfo/TypeInfoLabelProvider.java | 4 ++++ .../ui/browser/typeinfo/TypeInfoMessages.java | 2 ++ .../browser/typeinfo/TypeInfoMessages.properties | 5 +++-- .../ui/browser/typeinfo/TypeSelectionDialog.java | 16 ++++++++++++++-- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java index f9c06c3f561..eeeb4b3d474 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java @@ -85,6 +85,10 @@ public class IndexModelUtil { if(binding instanceof IVariable) return true; break; + case ICElement.C_ENUMERATOR: + if (binding instanceof IEnumerator) + return true; + break; } } return false; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java index 0af9880351a..45dc538e70b 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java @@ -57,6 +57,7 @@ public class TypeInfoLabelProvider extends LabelProvider { private static final Image FUNCTION_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FUNCTION); private static final Image VARIABLE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_VARIABLE); private static final Image VARIABLE_LOCAL_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LOCAL_VARIABLE); + private static final Image ENUMERATOR_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ENUMERATOR); private static final Image MACRO_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO); private static final Image UNKNOWN_TYPE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_UNKNOWN_TYPE); @@ -228,6 +229,9 @@ public class TypeInfoLabelProvider extends LabelProvider { case ICElement.C_VARIABLE: return VARIABLE_ICON; + case ICElement.C_ENUMERATOR: + return ENUMERATOR_ICON; + case ICElement.C_MACRO: return MACRO_ICON; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java index f1f50807352..4f0a5953719 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java @@ -36,6 +36,8 @@ public final class TypeInfoMessages extends NLS { public static String TypeSelectionDialog_filterUnions; public static String TypeSelectionDialog_filterFunctions; public static String TypeSelectionDialog_filterVariables; + /** @since 5.3 */ + public static String TypeSelectionDialog_filterEnumerators; public static String TypeSelectionDialog_filterMacros; public static String TypeSelectionDialog_filterLowLevelTypes; public static String TypeInfoLabelProvider_globalScope; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties index d804e0ca6fc..7a42f626056 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2008 QNX Software Systems and others. +# Copyright (c) 2000, 2010 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 @@ -26,7 +26,8 @@ TypeSelectionDialog_filterEnums=&Enumeration TypeSelectionDialog_filterUnions=&Union TypeSelectionDialog_filterFunctions=&Function TypeSelectionDialog_filterVariables=&Variable -TypeSelectionDialog_filterMacros=M&acros +TypeSelectionDialog_filterEnumerators=Enume&rator +TypeSelectionDialog_filterMacros=M&acro TypeSelectionDialog_filterLowLevelTypes=Show &low-level elements (names beginning with '_') diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java index 4c931c06c0b..5cae83cb0b5 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -204,6 +204,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { private static final String SETTINGS_SHOW_UNIONS = "show_unions"; //$NON-NLS-1$ private static final String SETTINGS_SHOW_FUNCTIONS = "show_functions"; //$NON-NLS-1$ private static final String SETTINGS_SHOW_VARIABLES = "show_variables"; //$NON-NLS-1$ + private static final String SETTINGS_SHOW_ENUMERATORS = "show_enumerators"; //$NON-NLS-1$ private static final String SETTINGS_SHOW_MACROS = "show_macros"; //$NON-NLS-1$ private static final String SETTINGS_SHOW_LOWLEVEL = "show_lowlevel"; //$NON-NLS-1$ @@ -218,7 +219,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { private static final int[] ALL_TYPES = { ICElement.C_NAMESPACE, ICElement.C_CLASS, ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION, - ICElement.C_UNION, ICElement.C_FUNCTION, ICElement.C_VARIABLE, ICElement.C_MACRO }; + ICElement.C_UNION, ICElement.C_FUNCTION, ICElement.C_VARIABLE, + ICElement.C_ENUMERATOR, ICElement.C_MACRO }; // the filter matcher contains state information, must not be static private final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher(); @@ -381,6 +383,9 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { case ICElement.C_VARIABLE: name = TypeInfoMessages.TypeSelectionDialog_filterVariables; break; + case ICElement.C_ENUMERATOR: + name = TypeInfoMessages.TypeSelectionDialog_filterEnumerators; + break; case ICElement.C_MACRO: name = TypeInfoMessages.TypeSelectionDialog_filterMacros; break; @@ -517,6 +522,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { section.put(SETTINGS_SHOW_UNIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_UNION))); section.put(SETTINGS_SHOW_FUNCTIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_FUNCTION))); section.put(SETTINGS_SHOW_VARIABLES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_VARIABLE))); + section.put(SETTINGS_SHOW_ENUMERATORS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_ENUMERATOR))); section.put(SETTINGS_SHOW_MACROS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_MACRO))); section.put(SETTINGS_SHOW_LOWLEVEL, fFilterMatcher.getShowLowLevelTypes()); } @@ -533,6 +539,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { section.put(SETTINGS_SHOW_UNIONS, true); section.put(SETTINGS_SHOW_FUNCTIONS, true); section.put(SETTINGS_SHOW_VARIABLES, true); + section.put(SETTINGS_SHOW_ENUMERATORS, true); section.put(SETTINGS_SHOW_MACROS, true); section.put(SETTINGS_SHOW_LOWLEVEL, false); } @@ -594,6 +601,11 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { if (fKnownTypes.contains(typeObject)) fFilterMatcher.getVisibleTypes().add(typeObject); } + if (section.getBoolean(SETTINGS_SHOW_ENUMERATORS)) { + Integer typeObject = new Integer(ICElement.C_ENUMERATOR); + if (fKnownTypes.contains(typeObject)) + fFilterMatcher.getVisibleTypes().add(typeObject); + } if (section.getBoolean(SETTINGS_SHOW_MACROS)) { Integer typeObject = new Integer(ICElement.C_MACRO); if (fKnownTypes.contains(typeObject))