Package org.eclipse.jdt.ui

# Class JavaElementLabelProvider

java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.viewers.BaseLabelProvider
org.eclipse.jface.viewers.LabelProvider
org.eclipse.jdt.ui.JavaElementLabelProvider

All Implemented Interfaces:
  `org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider`, `org.eclipse.jface.viewers.IBaseLabelProvider`, `org.eclipse.jface.viewers.ILabelProvider`

public class JavaElementLabelProvider extends org.eclipse.jface.viewers.LabelProvider implements org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider
Standard label provider for Java elements. Use this class when you want to present the Java elements in a viewer.

The implementation also handles non-Java elements by forwarding the requests to the `IWorkbenchAdapter` of the element.

This class may be instantiated; it is not intended to be subclassed.

Since 3.4, this class also implements `DelegatingStyledCellLabelProvider.IStyledLabelProvider` for colored labels.

Restriction:
  This class is not intended to be subclassed by clients.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`SHOW_BASICS`
Constant (value `0`) indicating that the label should show the basic images only.
`static final int`
`SHOW_CONTAINER`
Deprecated.
Use SHOW_QUALIFIED or SHOW_ROOT instead
`static final int`
`SHOW_CONTAINER_QUALIFICATION`
Deprecated.
Use SHOW_QUALIFIED instead
`static final int`
`SHOW_DEFAULT`
Constant indicating the default label rendering.
`static final int`
`SHOW_OVERLAY_ICONS`
Flag (bit mask) indicating that the label should include overlay icons for element type and modifiers.
`static final int`
`SHOW_PARAMETERS`
Flag (bit mask) indicating that method label include parameter types.
`static final int`
`SHOW_POST_QUALIFIED`
Flag (bit mask) indicating that compilation units, class files, types, declarations and members should be rendered qualified.The qualification is appended.
`static final int`
`SHOW_POSTIFIX_QUALIFICATION`
Deprecated.
SHOW_POST_QUALIFIED instead
`static final int`
`SHOW_QUALIFIED`
Flag (bit mask) indicating that compilation units, class files, types, declarations and members should be rendered qualified.
`static final int`
`SHOW_RETURN_TYPE`
Flag (bit mask) indicating that methods labels include the method return type (appended).
`static final int`
`SHOW_ROOT`
Flag (bit mask) indicating that the label should include the name of the package fragment root (appended).
`static final int`
`SHOW_SMALL_ICONS`
Flag (bit mask) indicating that the label should show the icons with no space reserved for overlays.
`static final int`
`SHOW_TYPE`
Flag (bit mask) indicating that a field label should include the declared type.
`static final int`
`SHOW_VARIABLE`
Flag (bit mask) indicating that the package fragment roots from class path variables should be rendered with the variable in the name

## Constructor Summary

Constructors
Constructor
Description
`JavaElementLabelProvider()`
Creates a new label provider with `SHOW_DEFAULT` flag.
`JavaElementLabelProvider(int flags)`
Creates a new label provider.

## Method Summary

Modifier and Type
Method
Description
`void`
`dispose()`
`org.eclipse.swt.graphics.Image`
`getImage(Object element)`
`org.eclipse.jface.viewers.StyledString`
`getStyledText(Object element)`
Returns the styled text label for the given element
`String`
`getText(Object element)`
`void`
`turnOff(int flags)`
Turns off the rendering options specified in the given flags.
`void`
`turnOn(int flags)`
Turns on the rendering options specified in the given flags.

### Methods inherited from class org.eclipse.jface.viewers.LabelProvider

`createImageProvider, createTextImageProvider, createTextProvider`

### Methods inherited from class org.eclipse.jface.viewers.BaseLabelProvider

`addListener, 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, isLabelProperty, removeListener`

## Field Details

### SHOW_RETURN_TYPE

public static final int SHOW_RETURN_TYPE
Flag (bit mask) indicating that methods labels include the method return type (appended).

See Also:
  - Constant Field Values

### SHOW_PARAMETERS

public static final int SHOW_PARAMETERS
Flag (bit mask) indicating that method label include parameter types.

See Also:
  - Constant Field Values

### SHOW_CONTAINER

@Deprecated public static final int SHOW_CONTAINER
Deprecated.
Use SHOW_QUALIFIED or SHOW_ROOT instead
Flag (bit mask) indicating that the label of a member should include the container. For example, include the name of the type enclosing a field.

See Also:
  - Constant Field Values

### SHOW_CONTAINER_QUALIFICATION

@Deprecated public static final int SHOW_CONTAINER_QUALIFICATION
Deprecated.
Use SHOW_QUALIFIED instead
Flag (bit mask) indicating that the label of a type should be fully qualified. For example, include the fully qualified name of the type enclosing a type.

See Also:
  - Constant Field Values

### SHOW_OVERLAY_ICONS

public static final int SHOW_OVERLAY_ICONS
Flag (bit mask) indicating that the label should include overlay icons for element type and modifiers.

See Also:
  - Constant Field Values

### SHOW_TYPE

public static final int SHOW_TYPE
Flag (bit mask) indicating that a field label should include the declared type.

See Also:
  - Constant Field Values

### SHOW_ROOT

public static final int SHOW_ROOT
Flag (bit mask) indicating that the label should include the name of the package fragment root (appended).

See Also:
  - Constant Field Values

### SHOW_POSTIFIX_QUALIFICATION

@Deprecated public static final int SHOW_POSTIFIX_QUALIFICATION
Deprecated.
SHOW_POST_QUALIFIED instead
Flag (bit mask) indicating that the label qualification of a type should be shown after the name.

See Also:
  - Constant Field Values

### SHOW_SMALL_ICONS

public static final int SHOW_SMALL_ICONS
Flag (bit mask) indicating that the label should show the icons with no space reserved for overlays.

See Also:
  - Constant Field Values

### SHOW_VARIABLE

public static final int SHOW_VARIABLE
Flag (bit mask) indicating that the package fragment roots from class path variables should be rendered with the variable in the name

See Also:
  - Constant Field Values

### SHOW_QUALIFIED

public static final int SHOW_QUALIFIED
Flag (bit mask) indicating that compilation units, class files, types, declarations and members should be rendered qualified. Examples: `java.lang.String`, `java.util.Vector.size()`

Since:
  2.0
See Also:
  - Constant Field Values

### SHOW_POST_QUALIFIED

public static final int SHOW_POST_QUALIFIED
Flag (bit mask) indicating that compilation units, class files, types, declarations and members should be rendered qualified.The qualification is appended. Examples: `String - java.lang`, `size() - java.util.Vector`

Since:
  2.0
See Also:
  - Constant Field Values

### SHOW_BASICS

public static final int SHOW_BASICS
Constant (value `0`) indicating that the label should show the basic images only.

See Also:
  - Constant Field Values

### SHOW_DEFAULT

public static final int SHOW_DEFAULT
Constant indicating the default label rendering. Currently the default is equivalent to `SHOW_PARAMETERS | SHOW_OVERLAY_ICONS`.

See Also:
  - Constant Field Values

## Constructor Details

### JavaElementLabelProvider

public JavaElementLabelProvider()
Creates a new label provider with `SHOW_DEFAULT` flag.

Since:
  2.0
See Also:
  - `SHOW_DEFAULT`

### JavaElementLabelProvider

public JavaElementLabelProvider(int flags)
Creates a new label provider.

Parameters:
  `flags` - the initial options; a bitwise OR of `SHOW_*` constants

## Method Details

### turnOn

public void turnOn(int flags)
Turns on the rendering options specified in the given flags.

Parameters:
  `flags` - the options; a bitwise OR of `SHOW_*` constants

### turnOff

public void turnOff(int flags)
Turns off the rendering options specified in the given flags.

Parameters:
  `flags` - the initial options; a bitwise OR of `SHOW_*` constants

### getImage

public org.eclipse.swt.graphics.Image getImage(Object element)

Specified by:
  `getImage` in interface `org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider`
Specified by:
  `getImage` in interface `org.eclipse.jface.viewers.ILabelProvider`
Overrides:
  `getImage` in class `org.eclipse.jface.viewers.LabelProvider`

### getText

public String getText(Object element)

Specified by:
  `getText` in interface `org.eclipse.jface.viewers.ILabelProvider`
Overrides:
  `getText` in class `org.eclipse.jface.viewers.LabelProvider`

### getStyledText

public org.eclipse.jface.viewers.StyledString getStyledText(Object element)
Returns the styled text label for the given element

Specified by:
  `getStyledText` in interface `org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider`
Parameters:
  `element` - the element to evaluate the styled string for
Returns:
  the styled string.
Since:
  3.4

### dispose

public void dispose()

Specified by:
  `dispose` in interface `org.eclipse.jface.viewers.IBaseLabelProvider`
Overrides:
  `dispose` in class `org.eclipse.jface.viewers.BaseLabelProvider`