Class CmsLabel

java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.LabelBase<String>
com.google.gwt.user.client.ui.Label
org.opencms.gwt.client.ui.input.CmsLabel
All Implemented Interfaces:
com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.client.LeafValueEditor<String>>, com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasDragEndHandlers, com.google.gwt.event.dom.client.HasDragEnterHandlers, com.google.gwt.event.dom.client.HasDragHandlers, com.google.gwt.event.dom.client.HasDragLeaveHandlers, com.google.gwt.event.dom.client.HasDragOverHandlers, com.google.gwt.event.dom.client.HasDragStartHandlers, com.google.gwt.event.dom.client.HasDropHandlers, com.google.gwt.event.dom.client.HasGestureChangeHandlers, com.google.gwt.event.dom.client.HasGestureEndHandlers, com.google.gwt.event.dom.client.HasGestureStartHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.dom.client.HasTouchCancelHandlers, com.google.gwt.event.dom.client.HasTouchEndHandlers, com.google.gwt.event.dom.client.HasTouchMoveHandlers, com.google.gwt.event.dom.client.HasTouchStartHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.i18n.client.HasDirection, com.google.gwt.i18n.shared.HasDirectionEstimator, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasAutoHorizontalAlignment, com.google.gwt.user.client.ui.HasDirectionalText, com.google.gwt.user.client.ui.HasHorizontalAlignment, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.HasWordWrap, com.google.gwt.user.client.ui.IsWidget, com.google.gwt.user.client.ui.SourcesClickEvents, com.google.gwt.user.client.ui.SourcesMouseEvents, I_CmsTruncable
Direct Known Subclasses:
CmsLabelLeftTruncating

public class CmsLabel extends com.google.gwt.user.client.ui.Label implements I_CmsTruncable
Single line label with text truncation and tool tip.

Since:
8.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for generating HTML titles (tooltips) for a label.

    Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

    com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled

    Nested classes/interfaces inherited from interface com.google.gwt.i18n.client.HasDirection

    com.google.gwt.i18n.client.HasDirection.Direction

    Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    com.google.gwt.user.client.ui.HasHorizontalAlignment.AutoHorizontalAlignmentConstant, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final I_CmsInputCss
    The CSS bundle instance used for this widget.
    protected static List<com.google.gwt.dom.client.Element>
    List of elements to measure.
    protected String
    The original untruncated text stored in the label.

    Fields inherited from class com.google.gwt.user.client.ui.Label

    DEFAULT_DIRECTION_ESTIMATOR

    Fields inherited from class com.google.gwt.user.client.ui.UIObject

    DEBUG_ID_PREFIX

    Fields inherited from interface com.google.gwt.user.client.ui.HasAutoHorizontalAlignment

    ALIGN_CONTENT_END, ALIGN_CONTENT_START

    Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty label.
    CmsLabel(com.google.gwt.dom.client.Element element)
    Creates an empty label using the given element.
    Creates a label with the specified text.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    getTitle(boolean truncating)
    Returns the title to be displayed, which is either produced by a title generator, or is equal to the original text if no title generator is set and the label is being truncated.
    void
     
    void
    Sets the inner HTML of the label.
    void
     
    void
    Sets the title generator.
    void
    truncate(String textMetricsKey, int labelWidth)
    Truncates long text and sets the original text to the title attribute.
    void
    updateTitle(boolean truncating)
    Updates the title.

    Methods inherited from class com.google.gwt.user.client.ui.Label

    addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, asEditor, getDirection, getText, getTextDirection, removeClickListener, removeMouseListener, removeMouseWheelListener, setDirection, setText, wrap

    Methods inherited from class com.google.gwt.user.client.ui.LabelBase

    getAutoHorizontalAlignment, getDirectionEstimator, getHorizontalAlignment, getWordWrap, setAutoHorizontalAlignment, setDirectionEstimator, setDirectionEstimator, setHorizontalAlignment, setWordWrap, updateHorizontalAlignment

    Methods inherited from class com.google.gwt.user.client.ui.Widget

    addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents

    Methods inherited from class com.google.gwt.user.client.ui.UIObject

    addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.google.gwt.event.shared.HasHandlers

    fireEvent
  • Field Details

    • CSS

      protected static final I_CmsInputCss CSS
      The CSS bundle instance used for this widget.

    • m_elements

      protected static List<com.google.gwt.dom.client.Element> m_elements
      List of elements to measure.
    • m_originalText

      The original untruncated text stored in the label.
  • Constructor Details

    • CmsLabel

      public CmsLabel()
      Creates an empty label.

    • CmsLabel

      public CmsLabel(com.google.gwt.dom.client.Element element)
      Creates an empty label using the given element.

      Parameters:
      element - the element to use
    • CmsLabel

      public CmsLabel(String text)
      Creates a label with the specified text.

      Parameters:
      text - the new label's text
  • Method Details

    • onAttach

      public void onAttach()
      Overrides:
      onAttach in class com.google.gwt.user.client.ui.Widget
      See Also:
      • Widget.onAttach()
    • setHTML

      public void setHTML(String html)
      Sets the inner HTML of the label.

      Avoid using this, better use setText(String)

      Parameters:
      html - the HTML to set
    • setText

      public void setText(String text)
      Specified by:
      setText in interface com.google.gwt.user.client.ui.HasText
      Overrides:
      setText in class com.google.gwt.user.client.ui.Label
      See Also:
      • HasText.setText(java.lang.String)
    • setTitleGenerator

      Sets the title generator.

      Parameters:
      titleGen - the new title generator
    • truncate

      public void truncate(String textMetricsKey, int labelWidth)
      Description copied from interface: I_CmsTruncable
      Truncates long text and sets the original text to the title attribute.

      Specified by:
      truncate in interface I_CmsTruncable
      Parameters:
      textMetricsKey - the key identifying the text metrics to use
      labelWidth - the width to use in pixels
      See Also:
    • updateTitle

      public void updateTitle(boolean truncating)
      Updates the title.

      Parameters:
      truncating - true if the label is being truncated
    • getTitle

      protected String getTitle(boolean truncating)
      Returns the title to be displayed, which is either produced by a title generator, or is equal to the original text if no title generator is set and the label is being truncated.

      Parameters:
      truncating - true if the label is being truncated
      Returns:
      the title to display