Time for action – styling label providers

The IStyledLabelProvider is used to style the representation of the tree viewer, as used by the Java outline viewer to display the return type of the method, and by the team's decorator when showing when changes have occurred.

  1. Add the IStyledLabelProvider interface to the TimeZoneLabelProvider class, and create the getStyledText method. If the selected element is a Map.Entry that contains a ZoneId, add the offset afterwards in brackets:
    public class TimeZoneLabelProvider extends LabelProvider implements IStyledLabelProvider { public StyledString getStyledText(Object element) { String text = getText(element); StyledString styledString = new StyledString(text); if (element instanceof ZoneId) { ZoneId zone ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.