Class AbstractLightItem<T>

  • Type Parameters:
    T - - class of item data.
    Direct Known Subclasses:
    LightListItem

    public abstract class AbstractLightItem<T>
    extends Object
    Base class for list/tree/table items. Item has text and image. Text can be empty, image can be null.
    • Constructor Detail

      • AbstractLightItem

        public AbstractLightItem​(T data,
                                 ILightControl parent)
        Constructor.
        Parameters:
        data - - item data. Cannot be null.
        parent - - parent of this item. Cannot be null.
      • AbstractLightItem

        public AbstractLightItem​(T data,
                                 ILightControl parent,
                                 org.eclipse.jface.viewers.StyledString styledText,
                                 org.eclipse.swt.graphics.Image image)
        Constructor.
        Parameters:
        data - - item data. Cannot be null.
        parent - - parent of this item. Cannot be null.
        styledText - - item text. Cannot be null.
        image - - item image. Can be null.
    • Method Detail

      • setText

        public void setText​(org.eclipse.jface.viewers.StyledString text)
        Sets item text.
        Parameters:
        text - - item text. Cannot be null.
      • getText

        public String getText()
        Returns item text.
        Returns:
        item text. Cannot return null.
      • getData

        public T getData()
        Returns item data.
        Returns:
        item data. Cannot return null.
      • setSelected

        public void setSelected​(boolean isSelected)
        Sets if item is selected.
        Parameters:
        isSelected - - true if item is selected.
      • isSelected

        public boolean isSelected()
        Returns true if item is selected.
        Returns:
        true if item is selected.
      • setTextLocation

        public void setTextLocation​(int textLocation)
        Sets text location. (Should be SWT.LEFT | SWT.CENTER | SWT.RIGHT)
        Parameters:
        textLocation - - text location.
        See Also:
        SWT.LEFT, SWT.CENTER, SWT.RIGHT
      • getTextLocation

        public int getTextLocation()
        Returns text location. (Should be SWT.LEFT | SWT.CENTER | SWT.RIGHT)
        Returns:
        text location.
        See Also:
        SWT.LEFT, SWT.CENTER, SWT.RIGHT
      • setImageLocation

        public void setImageLocation​(int imageLocation)
        Sets image location relatively to text. (Should be SWT.LEFT | SWT.RIGHT)
        Parameters:
        imageLocation - - image location relatively to text.
        See Also:
        SWT.LEFT, SWT.RIGHT
      • getImageLocation

        public int getImageLocation()
        Returns image location relatively to text.
        Returns:
        image location relatively to text.
        See Also:
        SWT.LEFT, SWT.RIGHT
      • getParent

        public ILightControl getParent()
        Returns parent control.
        Returns:
        parent control. Cannot return null.
      • handleEvent

        public abstract void handleEvent​(org.eclipse.swt.widgets.Event event)
        Processes swt event.
        Parameters:
        event - - event to process. Cannot be null.
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(org.eclipse.swt.graphics.GC gc,
                                                          boolean flushCache)
        Computes item size.
        Parameters:
        gc - - gc to compute size. Cannot be null.
        flushCache - - true if cache should be flushed.
        Returns:
        item size. Cannot return null.
      • paint

        public void paint​(org.eclipse.swt.graphics.GC gc,
                          org.eclipse.swt.graphics.Rectangle rectangle)
        Paints item using given gc in given rectangle.
        Parameters:
        gc - - gc to use for painting. Cannot be null.
        rectangle - - rectangle to paint. Cannot be null.
      • setCalculateSubText

        public void setCalculateSubText​(boolean calculateSubText)
        Sets if sub text should be calculated or not. If true, sub text will be calculated if item text takes more space than given in paint rectangle.
        Parameters:
        calculateSubText - - true if sub text should be calculated.
      • isCalculateSubText

        public boolean isCalculateSubText()
        Returns true if sub text calculation enabled.
        Returns:
        true if sub text calculation enabled.
      • setHot

        protected void setHot​(boolean isHot)
        Sets item hot state.
        Parameters:
        isHot - - true if hot.