Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How do I restrict changes to the model based on attribute values?
How do I restrict changes to the model based on attribute values? [message #148479] Thu, 30 August 2007 08:51 Go to next message
adotor is currently offline adotorFriend
Messages: 46
Registered: July 2009
Member
Hi,

I 'm not sure how to achieve the following goal with GMF: I want to render
my nodes uneditable based on an attribute value. But not every kind of
change should be forbidden. So, for example, my node mustn't be the target
of a new connection but can be the source. How do I achieve this?

I played around with the approveRequest-Method of a subclass of
AbstractEditHelperAdvice but ran into the difficulties with the
StackOverflow (see other thread). Is this the right way to achieve my goal
or are there other suggestions?

Greetings,
Alexander
Re: How do I restrict changes to the model based on attribute values? [message #148776 is a reply to message #148479] Mon, 03 September 2007 08:30 Go to previous messageGo to next message
Nicolai Kamenzky is currently offline Nicolai KamenzkyFriend
Messages: 82
Registered: July 2009
Member
Hi Alexander!
> So, for example, my node mustn't be the target of a new connection
> but can be the source. How do I achieve this?

I think a link constraint using OCL may work. (Add a "Link
Constraints" to your "Link Mapping" and then add a "Source End
Constraint" or a "TargetEnd Constraint".)

For example I used it while metamodeling an Activity Diagram. I want
theinitial node only having one outgoing connection and no incoming
connections.

For only one outgoing connection I set the Source End Constraint
to:self.outgoing->size() = 0
My initial node is an EClass in my metamodel. "outgoing" is an
EReferenceof it which has the lower bound 0 and the upper bound -1.

For no incoming connections I set the Target End Constraint to:
not self.oclIsTypeOf(InitialNode)
"InitialNode" is the actual name of the EClass in my metamodel.

To answer your question you also can access any EAttribute. For
example if you want to enable creating an incoming connection only if
a boolean attribute of the target node is set to true then use the
following OCLstatement as the Target End Constraint:
self.myBoolean = true
If you also have to check the type of the target EClass because you
link can connect to different node types then
use:self.oclIsTypeOf(myNodeTypeOfInterest) implies self.myBoolean =
true

Hope that helps.
Nicolai


--

I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Re: How do I restrict changes to the model based on attribute values? [message #149453 is a reply to message #148776] Fri, 07 September 2007 09:35 Go to previous messageGo to next message
adotor is currently offline adotorFriend
Messages: 46
Registered: July 2009
Member
Hi Nicolai,

yes that was very helpful, thank you! Now the creation is not possible when
I dissallow it.

But as far as I understand does this only work for creating connections.
What can I do to disallow deleteing connections and nodes?

Greetings,
Alexander

"Nicolai Kamenzky" <kamenzky@inf.fu-berlin.de> schrieb im Newsbeitrag
news:nemoMon090307101025@news.eclipse.org...
> Hi Alexander!
>> So, for example, my node mustn't be the target of a new connection
>> but can be the source. How do I achieve this?
>
> I think a link constraint using OCL may work. (Add a "Link
> Constraints" to your "Link Mapping" and then add a "Source End
> Constraint" or a "TargetEnd Constraint".)
>
> For example I used it while metamodeling an Activity Diagram. I want
> theinitial node only having one outgoing connection and no incoming
> connections.
>
> For only one outgoing connection I set the Source End Constraint
> to:self.outgoing->size() = 0
> My initial node is an EClass in my metamodel. "outgoing" is an
> EReferenceof it which has the lower bound 0 and the upper bound -1.
>
> For no incoming connections I set the Target End Constraint to:
> not self.oclIsTypeOf(InitialNode)
> "InitialNode" is the actual name of the EClass in my metamodel.
>
> To answer your question you also can access any EAttribute. For
> example if you want to enable creating an incoming connection only if
> a boolean attribute of the target node is set to true then use the
> following OCLstatement as the Target End Constraint:
> self.myBoolean = true
> If you also have to check the type of the target EClass because you
> link can connect to different node types then
> use:self.oclIsTypeOf(myNodeTypeOfInterest) implies self.myBoolean =
> true
>
> Hope that helps.
> Nicolai
>
> --
> I'm trying a new usenet client for Mac, Nemo OS X.
> You can download it at http://www.malcom-mac.com/nemo
>
Re: How do I restrict changes to the model based on attribute values? [message #149899 is a reply to message #149453] Tue, 11 September 2007 08:33 Go to previous message
Nicolai Kamenzky is currently offline Nicolai KamenzkyFriend
Messages: 82
Registered: July 2009
Member
Hi Alexander,

did you find a way prohibiting the deletion of nodes?

I currently face the same problem.

By the way:
The constraints I posted before I learnt from
< http://www.sts.tu-harburg.de/pw-and-m-theses/2006/dorai06.pd f>
It's a good thesis on many different kinds of constraints.
But as I know a constraint can't prohibit deleting a node or a link.

Cheers,
Nicolai


--

I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Previous Topic:Palette: how can I disable Note
Next Topic:to obtain EditPart source when one created a connection
Goto Forum:
  


Current Time: Tue Jul 16 06:50:17 GMT 2024

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

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

Back to the top