Bug 490661 - Expose AbstractColorUpdater.getRGBValuesFromColorDescription in a proper API
Summary: Expose AbstractColorUpdater.getRGBValuesFromColorDescription in a proper API
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-03-30 04:15 EDT by Pierre-Charles David CLA
Modified: 2016-04-01 10:00 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2016-03-30 04:15:05 EDT
AbstractColorUpdater was extracted to share common code from dialect-specific "color updaters", but the conversion from a generic ColorDescription into concrete RGB values is something which could probably be made available more generaly.

Currently one has to do new AbstractColorUpdater().getRGBValuesFromColorDescription(o, c), which:
- is rather ugly (instantiating a class (improperly) named Abstract*);
- may have some bugs and/or performance issues in corner cases: when the ColorDescription is dynamic and requires evaluating expression, because we do not pass the IInterpreter to use the code ends up calling InterpreterRegistry.getInterpreter(EObject modelElement) which tries to identify the session from the semantic element, and we do this *on each invocation*. In the context of a refresh of a large representation which uses dynamic colors, it might be a performance issue (I have not actually measured so even if present it may be really small).


Anyway, we should probably have a proper API to do this, the more logical place to put it would be in org.eclipse.sirius.business.api.query.ColorQuery. It could be something like:

  RGBValues getRGBValues(EObject context, IInterpreter interpreter)

The ColorDescription is implicit, it's the query's target.

If the ColorDescription requires expression evaluation, it should use the interpreter specified if non-null, and only if none is given try to find the context's session to locate an interpreter. AbstractColorUpdater could be updated to use the new helper, and reworked (itself and/or its callers) to lookup the interpteter only once per refresh instead of once per color evaluation.