|
|
|
Re: Overlay icons for validation [message #424179 is a reply to message #423852] |
Mon, 20 October 2008 07:33 |
Kristian Sons Messages: 27 Registered: July 2009 |
Junior Member |
|
|
Thanks Mario and Ed for your advice!
Here some snippets for those who want to achieve the same (based on the
generated RCP):
Editor::createPages:
labelDecorator = new MyLabelDecorator();
viewer.setLabelProvider(new DecoratingLabelProvider(new
AdapterFactoryLabelProvider(adapterFactory), labelDecorator ));
Editor::updateProblemIndication:
labelDecorator.setDiagnostics(diagnostic);
In MyLabelDecorator (implements ILabelDecorator):
public void setDiagnostics(Diagnostic diagnostic)
{
Map<Object, Integer> oldSeverityMap = severityMap;
severityMap = new HashMap<Object, Integer>();
processDiagnostic(diagnostic, severityMap);
notifyViewer(oldSeverityMap, severityMap);
}
private void notifyViewer(Map<Object, Integer> oldSeverityMap,
Map<Object, Integer> newSeverityMap)
{
List<Object> changedObjects = new ArrayList<Object>();
changedObjects.addAll(oldSeverityMap.keySet());
changedObjects.addAll(newSeverityMap.keySet());
fireLabelEvent(new LabelProviderChangedEvent(this,
changedObjects.toArray()));
}
private ComposedImage decorateSeverity(Image image, Integer severity)
{
List<Object> images = new ArrayList<Object>(2);
images.add(image);
if (severity == Diagnostic.WARNING)
images.add(X3DModelEditPlugin.INSTANCE.getImage("full/ovr16/warning_co "));
else
images.add(X3DModelEditPlugin.INSTANCE.getImage("full/ovr16/error_co "));
ComposedImage ci = new ComposedImage(images){
@Override
public List<Point> getDrawPoints(Size size)
{
List<Point> results = new ArrayList<Point>();
results.add(new Point());
Point overlay = new Point();
overlay.x = 0;
overlay.y = 7;
results.add(overlay);
return results;
}};
return ci;
}
Have fun!
Kristian
|
|
|
Re: Overlay icons for validation [message #424181 is a reply to message #424179] |
Mon, 20 October 2008 07:51 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Kristian,
That's very cool. Maybe we should provide something like this directly
in the framework. If you open a bugzilla enhancement request with this
as the contribution, I'll definitely look into it. It would make my
demos better! Thanks for sharing!!
Kristian Sons wrote:
> Thanks Mario and Ed for your advice!
>
> Here some snippets for those who want to achieve the same (based on
> the generated RCP):
>
> Editor::createPages:
> labelDecorator = new MyLabelDecorator();
> viewer.setLabelProvider(new DecoratingLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory), labelDecorator ));
>
> Editor::updateProblemIndication:
> labelDecorator.setDiagnostics(diagnostic);
>
> In MyLabelDecorator (implements ILabelDecorator):
>
> public void setDiagnostics(Diagnostic diagnostic)
> {
> Map<Object, Integer> oldSeverityMap = severityMap;
> severityMap = new HashMap<Object, Integer>();
> processDiagnostic(diagnostic, severityMap);
> notifyViewer(oldSeverityMap, severityMap);
> }
>
> private void notifyViewer(Map<Object, Integer>
> oldSeverityMap, Map<Object, Integer> newSeverityMap)
> {
> List<Object> changedObjects = new ArrayList<Object>();
> changedObjects.addAll(oldSeverityMap.keySet());
> changedObjects.addAll(newSeverityMap.keySet());
> fireLabelEvent(new LabelProviderChangedEvent(this,
> changedObjects.toArray()));
> }
>
> private ComposedImage decorateSeverity(Image image, Integer severity)
> {
> List<Object> images = new ArrayList<Object>(2);
> images.add(image);
> if (severity == Diagnostic.WARNING)
>
> images.add(X3DModelEditPlugin.INSTANCE.getImage("full/ovr16/warning_co "));
>
> else
>
> images.add(X3DModelEditPlugin.INSTANCE.getImage("full/ovr16/error_co "));
>
> ComposedImage ci = new ComposedImage(images){
>
> @Override
> public List<Point> getDrawPoints(Size size)
> {
> List<Point> results = new ArrayList<Point>();
> results.add(new Point());
> Point overlay = new Point();
> overlay.x = 0;
> overlay.y = 7;
> results.add(overlay);
> return results;
> }};
> return ci;
> }
>
>
> Have fun!
> Kristian
>
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05446 seconds