Package com._1c.g5.v8.dt.common.ui
Class BaseEnumLabelProvider
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.jface.viewers.BaseLabelProvider
-
- org.eclipse.jface.viewers.LabelProvider
-
- com._1c.g5.v8.dt.common.ui.BaseEnumLabelProvider
-
- All Implemented Interfaces:
IBaseLabelProvider
,ILabelProvider
public class BaseEnumLabelProvider extends LabelProvider
This class serves as a label provider, which returns localized strings for literals ofEEnum
enumerations. It holds a reference to anNLS
instance, which, hopefully, contains fields named enum_name_literal, and returns the value of such a field in itsgetText(Object)
method.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
EMPTY
The empty value to return if the object provided togetText(Object)
method is not anEEnumLiteral
.protected static String
LOCALIZATION_KEY_TEMPLATE
Pattern for fields of anNLS
-descendant that hold strings of enumeration literals
-
Constructor Summary
Constructors Constructor Description BaseEnumLabelProvider(Class<? extends org.eclipse.osgi.util.NLS> messagesClass)
Creates a Label Provider for literals ofEEnum
enumerations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getText(Enum enumValue)
Retrieves a localized string corresponding to the provided enumValue from the underlying NLS descendant.String
getText(Object o)
Treats the incoming o as an enumeration.String
getText(org.eclipse.emf.ecore.EEnumLiteral literal)
Retrieves a localized string corresponding to the provided literal from the underlying NLS descendant.-
Methods inherited from class org.eclipse.jface.viewers.LabelProvider
createImageProvider, createTextImageProvider, createTextProvider, getImage
-
Methods inherited from class org.eclipse.jface.viewers.BaseLabelProvider
addListener, dispose, fireLabelProviderChanged, isLabelProperty, removeListener
-
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jface.viewers.IBaseLabelProvider
addListener, dispose, isLabelProperty, removeListener
-
-
-
-
Field Detail
-
LOCALIZATION_KEY_TEMPLATE
protected static final String LOCALIZATION_KEY_TEMPLATE
Pattern for fields of anNLS
-descendant that hold strings of enumeration literals
-
EMPTY
protected static final String EMPTY
The empty value to return if the object provided togetText(Object)
method is not anEEnumLiteral
.
-
-
Constructor Detail
-
BaseEnumLabelProvider
public BaseEnumLabelProvider(Class<? extends org.eclipse.osgi.util.NLS> messagesClass)
Creates a Label Provider for literals ofEEnum
enumerations.- Parameters:
messagesClass
- an NLS descendant containing fields named as defined byLOCALIZATION_KEY_TEMPLATE
-
-
Method Detail
-
getText
public String getText(Object o)
Treats the incoming o as an enumeration. If it is, redirects togetText(EEnumLiteral)
orgetText(Enum)
. Otherwise returnsEMPTY
.- Specified by:
getText
in interfaceILabelProvider
- Overrides:
getText
in classLabelProvider
-
getText
public String getText(org.eclipse.emf.ecore.EEnumLiteral literal)
Retrieves a localized string corresponding to the provided literal from the underlying NLS descendant. If the corresponding field is not found will return the name of the absent field.- Parameters:
literal
- the literal to find localized string for- Returns:
- a localized string for the provided literal, if it was found. Otherwise will return the key that was used to find the string in the underlying NLS-descendant.
-
getText
public String getText(Enum enumValue)
Retrieves a localized string corresponding to the provided enumValue from the underlying NLS descendant. If the corresponding field is not found will return the name of the absent field.- Parameters:
literal
- the literal to find localized string for- Returns:
- a localized string for the provided literal, if it was found. Otherwise will return the key that was used to find the string in the underlying NLS-descendant.
-
-