Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 95934 - Support for color and font providers
Summary: Support for color and font providers
Status: VERIFIED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Edit (show other bugs)
Version: 2.1   Edit
Hardware: Macintosh All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Dave Steinberg CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 204200
  Show dependency tree
 
Reported: 2005-05-19 09:03 EDT by Bryan Hunt CLA
Modified: 2008-01-28 16:39 EST (History)
4 users (show)

See Also:


Attachments
A prototype design... (47.34 KB, patch)
2006-10-31 08:38 EST, Ed Merks CLA
no flags Details | Diff
Updated results (50.88 KB, patch)
2006-11-09 14:38 EST, Ed Merks CLA
no flags Details | Diff
Updated patch for EMF 2.4 (58.31 KB, patch)
2007-10-27 13:45 EDT, Ed Merks CLA
no flags Details | Diff
Final updates to make it ready for review (206.40 KB, patch)
2008-01-12 13:54 EST, Ed Merks CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Hunt CLA 2005-05-19 09:03:41 EDT
It would be nice if EMF edit supported jface color and font providers.  ie ITableColorProvider and 
ITableFontProvider
Comment 1 Ed Merks CLA 2005-05-19 12:07:37 EDT
That would be cool.  We'd need to come up with a declarative way to do that,
similar to how the images are just treated as URLs until you need a real image
in the GUI, so that EMF.Edit still would not depend on GUI code or Eclipse.
Comment 2 Bryan Hunt CLA 2005-05-22 09:05:05 EDT
Could you introduce a ColorDescriptor and FontDescriptor?  They would be fairly simple:

ColorDescriptor
  int r;
  int g;
  int b;

FontDescriptor
  String name;
  int height;
  int style;
Comment 3 Ed Merks CLA 2006-10-31 08:38:58 EST
Created attachment 52983 [details]
A prototype design...

Here is a partial prototype design for supporting these things.  Quite a bit more work is needed.  It's particularly frustrating that the most common usage for IFontProvider is to specify a delta on the font already being used by the view yet there is no mechanism to know which view is asking for the font.  One design that I was going to experiment with is to use a URI to specify the font, e.g., font://<font-name>/<size>/<style> and then use something like font:///+2 to indicate a font that's two points bigger, or font:////bold to indicate a bold variation of the font.  I can imagine that the color issue is similar, i.e., you might want to specify a color that's a greyed/faded versin of the color currently being used so something like color:/*0.5/*0.5/*0.5 might be used for that...
Comment 4 Ed Merks CLA 2006-11-09 14:38:35 EST
Created attachment 53569 [details]
Updated results

The support is a bit more complete now.  Item providers can contain specializations like this:

  public Object getFont(Object object)
  {
    return URI.createURI("font:///-1/Bold");
  }

  public Object getForeground(Object object)
  {
    return URI.createURI("color:/255/0/0");
  }
Comment 5 Kenn Hussey CLA 2007-10-25 10:53:32 EDT
Could this enhancement not also be contained in the 2.4 release (given that a working patch already exists)?
Comment 6 Ed Merks CLA 2007-10-25 11:07:48 EDT
I hope so.  :-)
Comment 7 Ed Merks CLA 2007-10-27 13:45:42 EDT
Created attachment 81329 [details]
Updated patch for EMF 2.4

This also includes changes for the Ecore editor to  make abstract types italic and containment references bold as an example.
Comment 8 Ed Merks CLA 2008-01-12 13:54:52 EST
Created attachment 86764 [details]
Final updates to make it ready for review

Dave,

This is ready to commit now pending your review.  I've added GenModel properties so that support for this is generated automatically based on the properties.  The changes to ecore.edit and ecore.editor are just examples and I'll commit those in a separate bugzilla later, so that's just and example.

To test it out, just generated a model and at this to the item provider for it:

  
  @Override
  public Object getFont(Object object)
  {
    return BOLD_FONT;
  }
  
  @Override
  public Object getForeground(Object object)
  {
    return GRAYED_OUT_COLOR;
  }
Comment 9 Ed Merks CLA 2008-01-12 13:55:51 EST
Marcelo,

You're review would be helpful too.  I'd like to commit this for next week's build...
Comment 10 Ed Merks CLA 2008-01-15 12:37:50 EST
The changes after Dave's review have been committed to CVS for 2.4.  This included adding support for "GenModel.tableProviders".
Comment 11 Nick Boldt CLA 2008-01-15 21:26:29 EST
Fixed in I200801152000.
Comment 12 Nick Boldt CLA 2008-01-28 16:39:26 EST
Move to verified as per bug 206558.