Bug 11116 - [Viewers] Viewers should add support for colour
Summary: [Viewers] Viewers should add support for colour
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, investigate
: 25739 (view as bug list)
Depends on:
Blocks: 10282
  Show dependency tree
 
Reported: 2002-03-11 14:37 EST by Nick Edgar CLA
Modified: 2003-02-13 11:26 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2002-03-11 14:37:15 EST
Build 20020307

EG says:
finally... now the variables view can use red text labels for changed values 
rather
than greying out the icons.

From the eclipse newsgroup:

In the latest Integration and Stable builds this is not possible.  However,
we have just released code for Windows that will do this (it is in the
nightly builds but I recommend you wait for the next integration build).
There is new API on TableItem and TreeItem called setForeground() and
setBackground().  The implementation for this functionality on motif, photon
and gtk will also be available shortly.

---

Darin, I got exited too soon, using colors in table items also needs JFace 
support...

Nick, are there any plans to surface this new support through JFace 
Viewers/LabelProviders?
We have some good uses of this in JDT.

---

NE replies:

This would be good to add.  How about:

/**
 * Extends <code>IBaseLabelProvider</code> with the methods to provide
 * the foreground and background color for the label of a given element.
 * Used by table viewers and tree viewers.
 * <p>
 * This interface is normally implemented by a class also implementing
 * <code>ILabelProvider</code> or <code>ITableLabelProvider</code>.
 */
interface ILabelColorProvider extends IBaseLabelProvider {
    /**
     * Returns the foreground color to use for the label of the given element,
     * or <code>null</code> to use the default foreground color.
     */
    Color getForeground(Object element);

    /**
     * Returns the background color to use for the label of the given element,
     * or <code>null</code> to use the default background color.
     */
    Color getBackground(Object element);
}
Comment 1 Nick Edgar CLA 2002-03-11 14:37:59 EST
Should do for early M5.
Comment 2 Erich Gamma CLA 2002-03-11 18:34:58 EST
Makes sense. 
Should there be color support for label decorators as well? The problem is that 
a label can only have a single color, but the user can control which decorator 
should have control. A colored label for dirty elements looks nicer than the 
ASCII ">". 

(carboned Kevin since we have discussed this some time ago)

Comment 3 Nick Edgar CLA 2002-03-12 14:58:02 EST
Should be able to do this by having DecoratingLabelProvider implement the 
interface above, and check for it on its decorator (only one involved here).

The decorator manager could work similarly, but only consider the first 
decorator to implement the interface above.  
Alternatively, it could stop when it found a colour decoration.  This could 
lead to different decorators providing the foreground and background colours 
though.  But that may be more flexible.
Comment 4 Nick Edgar CLA 2002-03-28 13:24:08 EST
Erich, how important is this for 2.0?
Can we defer?
Comment 5 Nick Edgar CLA 2002-04-03 17:08:38 EST
Haven't heard back from EG.
My feeling is this is not a strong requirement for 2.0, and using colour has 
accessibility issues.
Defering to post-2.0.
Comment 6 Randy Giffen CLA 2002-08-09 15:47:32 EDT
Reopen to investigate
Comment 7 Gary Gregory CLA 2002-08-30 19:45:58 EDT
For my ramblings on how cool colors and fonts could be, please see 
http://bugs.eclipse.org/bugs/show_bug.cgi?id=23011.
Comment 8 Sonia Dimitrov CLA 2002-11-06 09:33:55 EST
*** Bug 25739 has been marked as a duplicate of this bug. ***
Comment 9 Nick Edgar CLA 2003-02-09 22:30:29 EST
Added support for colour in AbstractTreeViewer for M4.  See IColorProvider.
Need to add to remaining viewers.
Comment 10 Nick Edgar CLA 2003-02-13 11:11:12 EST
Added support in TableViewer for I20030213.
Comment 11 Nick Edgar CLA 2003-02-13 11:26:52 EST
Added support in TableTreeViewer for >I20030213.

Tree, Table and TableTree are the only SWT controls that support colour per 
item.  AbstractTreeViewer (which covers Tree and TableTree) and TableViewer 
(which covers Table) now support IColorProvider, so this work is complete.