Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Spontaneous Validation: how to add custom markers and problems?
Spontaneous Validation: how to add custom markers and problems? [message #487546] Wed, 23 September 2009 14:34 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Dear GMF folks,

I would like to add problem markers with an error message to my GMF
diagram spontaneously, i.e. not only when the user manually performs the
standard EMF model validation, but also when some custom internal event
happens.
So whenever such an event happens, I want to add a custom marker to a
specific object.

What are the options to do such thing? I'm only aware of the EMF
EValidator class that can be registered for the metamodel. But this
requires to do a full model validation. I would like to avoid that for
performance reasons.

Any hints?
Cheers,
Hauke
Re: Spontaneous Validation: how to add custom markers and problems? [message #487863 is a reply to message #487546] Thu, 24 September 2009 15:22 Go to previous messageGo to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hauke Fuhrmann schrieb:
> What are the options to do such thing? I'm only aware of the EMF
> EValidator class that can be registered for the metamodel. But this
> requires to do a full model validation. I would like to avoid that for
> performance reasons.

As I understand "Live Validation" is not setting decorators during
editing by purpose, is that right? So that won't help me either.

This info is taken from
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg02485.html


Is this still the case?
Any other ideas?

Hauke
Re: Spontaneous Validation: how to add custom markers and problems? [message #487990 is a reply to message #487546] Fri, 25 September 2009 08:46 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi Hauke,


Quote:

i.e. not only when the user manually performs the
standard EMF model validation, but also when some custom internal event
happens.




If by "some custom internal event" you mean some change to your data model EMF provides means to register a notification adapter somehow like that:
		yourEObject.eAdapters().add(new AdapterImpl() {
			public void notifyChanged(Notification notification) {
				// invoke validation action here
			}
		});

For more information see "EMF Model Transaction Developer Guide > Programmer's Guide Listening to Changes" in your Eclipse help.

To register those listeners you could provide an advice binding bound to the necessary elements. An example to start could be the NotationViewDependentsAdvice which is registered by the org.eclipse.gmf.runtime.diagram.core plug-in as follows:

     <extension
           point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
        <metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore">
           <adviceBinding
                 class="org.eclipse.gmf.runtime.diagram.core.edithelpers.NotationViewDependentsAdvice"
                 id="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"
                 inheritance="none"
                 typeId="*"/>
           <adviceBinding
                 class="org.eclipse.gmf.runtime.diagram.core.edithelpers.RemoveBookmarksAdvice"
                 id="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks"
                 inheritance="none"
                 typeId="*"/>
        </metamodel>
     </extension>
     
     <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
        <binding context="org.eclipse.gmf.runtime.emf.type.core.defaultContext">
           <elementType ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
           <elementType ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks"/>
        </binding>
     </extension>

For more informations about advice bindings see "GMF Developer Guide > Programmer's Guide > Runtime > Developer's Guide to the Extensible Type Registry > Examples > Code Examples > Binding Advice to an Existing Element Type" in your Eclipse help.


Best regards,

sas
Re: Spontaneous Validation: how to add custom markers and problems? [message #487999 is a reply to message #487863] Fri, 25 September 2009 09:12 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi Hauke,

Quote:

Any other ideas?



A very customizable support for validations delivers the oAW Check language.
openArchitectureWare provides an adapter to integrate oAW Check constraints into GMF editors. Furthermore they provide an editor (which btw works on EMF domain models) to easily build (labeled) constraints with an easy to understand syntax.

For furher informations see the documentation at www.openarchitectureware.org.

Best regards,

sas



[Updated on: Fri, 25 September 2009 09:16]

Report message to a moderator

Re: Spontaneous Validation: how to add custom markers and problems? [message #488420 is a reply to message #487990] Mon, 28 September 2009 15:30 Go to previous messageGo to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
news.sascha.gessler@googlemail.com schrieb:
> If by "some custom internal event" you mean some change to your data
> model EMF provides means to register a notification adapter somehow like
> that:

Yes, thanks, I already have registered listeners to my model that notice
some changes and react on them.

Actually my question is more related on how I can programmatically add a
problem marker to the diagram upon such event.
I already have an Xtend Check file for static checks, but that's not enough.

Concretely I have a complex String parser, that parses one of my model's
String labels. Whenever this parser fails with some internal exception,
I want to decorate my model with a problem marker that holds the message
of that exception. How can I do such thing?

> For more informations about advice bindings see "GMF Developer Guide >
> Programmer's Guide > Runtime > Developer's Guide to the Extensible Type
> Registry > Examples > Code Examples > Binding Advice to an Existing
> Element Type" in your Eclipse help.

Ah, thanks for that hint. I was not aware of it. I will have a look at it.

Cheers,
Hauke
Re: Spontaneous Validation: how to add custom markers and problems? [message #488501 is a reply to message #488420] Mon, 28 September 2009 23:09 Go to previous message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi,

Quote:

how I can programmatically add a
problem marker to the diagram upon such event.



As mentioned above I usually use oAW Check constraints (GMF adapter) which already provide the necessary decoration marker.

But I just stumbled over the (generated) ???ValidationDecoratorProvider which might give you a hint how to provide decorations and problem markers yourself. Just take a look at the refresh() method.


Best regards,

sas
Previous Topic:Custom Behaviour with GMF
Next Topic:Migration to GMF 2.2: Compile errors
Goto Forum:
  


Current Time: Thu Apr 25 15:26:51 GMT 2024

Powered by FUDForum. Page generated in 0.03967 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top