Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re: how to add to an existing edit policy?
Re: how to add to an existing edit policy? [message #66014] Thu, 19 October 2006 23:22 Go to next message
Eclipse UserFriend
Originally posted by: liam.morley.baesystems.com

Originally posted this on the GEF newsgroup only because it has more to do
with edit policies than anything specifically related to GMF, but it was
suggested that I post here as well. Here's the original question:

I'm writing a modular editor with the GMF where different plugins can add
functionality to the same editor. When a plugin adds something to the
palette, it needs to add an EditPolicy as well so that the plugin can
contribute the correct commands for the edition. I was using
EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE, but I
realize now that that erases the existing policy with the same key. Is there
a way to have multiple policies with the same key, or is there currently a
way to add functionality to an existing policy?

Thanks,
Liam Morley


"Pratik Shah" <none@unknown.com> wrote in message
news:eh63lv$ll9$1@utils.eclipse.org...
> You should ask on the GMF newsgroup about the best way to do this.
> There's only one editpolicy per role. But you can install several
> different editpolicies that can handle the same request type.
>
> "Liam Morley" <liam.morley@baesystems.com> wrote in message
> news:eh5uue$643$1@utils.eclipse.org...
>> I'm not sure if I follow- I want to be able to apply both policies to the
>> same role simultaneously. Are you saying to have one policy per role, but
>> have my policy function as a strategy? I think what you're saying is that
>> this functionality does not exist natively in the GEF, but I can
>> implement it on my own. Is that true?
>>
>> Liam
>>
>>
>> "Xiang Qinxian" <fyaoxy@gmail.com> wrote in message
>> news:1161187543.2964.14.camel@qinxian.xiang...
>> ? 2006-10-17?? 16:17 -0400,Liam Morley??:
>>> I'm writing a modular editor with the GMF where different plugins can
>>> add
>>> functionality to the same editor. When a plugin adds something to the
>>> palette, it needs to add an EditPolicy as well so that the plugin can
>>> contribute the correct commands for the edition. I was using
>>> EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE,
>>> but I
>>> realize now that that erases the existing policy with the same key. Is
>>> there
>>> a way to have multiple policies with the same key, or is there currently
>>> a
>>> way to add functionality to an existing policy?
>>>
>>> Thanks,
>>> Liam Morley
>>>
>>>
>> Hi,
>> Each existing Role with EditPolicy known about some Request, your Role
>> too. Now the same Role want capture difference Request, so it is a
>> choice that appling a strategy pattern for the special EditPolicy.
>>
>> Regards
>>
>> Qinxian.
>>
>>
>>
>
>
Re: how to add to an existing edit policy? [message #66036 is a reply to message #66014] Fri, 20 October 2006 01:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

As per GMF's programmer's manual:

EditPolicy Service (developer's guide to the gmf runtime):



EditPolicy Service is an important extensibility point since it allows clients
to install their own editpolicies on existing EditParts without overriding the
EditPart itself. Each EditPart when it is created in GMF will call the
EditPolicyService on activation to determine if any clients are contributing to
their set of EditPolicies.

+ An Editpolicy provider creates EditPolicies for a given editpart.

+ Providers implement the IEditPolicyProvider with the following method:

+ void createEditPolicies(EditPart editpart)

+ The service gives all interested providers a chance to create
+ editpolicies for the given editpart in order of priority from lowest to
+ highest.

+ Overriding an editpolicy is done by assigning a new one in the same
+ role.

+ Assigning null to an editpolicy role is equivalent to removing that
+ role behavior.

+ The service is very useful for adding/removing behavior without having
+ to subclass targeted editparts.

On Thu, 19 Oct 2006 19:22:46 -0400,
Liam Morley wrote:

> Originally posted this on the GEF newsgroup only because it has more to do
> with edit policies than anything specifically related to GMF, but it was
> suggested that I post here as well. Here's the original question:
>
> I'm writing a modular editor with the GMF where different plugins can add
> functionality to the same editor. When a plugin adds something to the
> palette, it needs to add an EditPolicy as well so that the plugin can
> contribute the correct commands for the edition. I was using
> EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE, but I
> realize now that that erases the existing policy with the same key. Is there
> a way to have multiple policies with the same key, or is there currently a
> way to add functionality to an existing policy?
>
> Thanks,
> Liam Morley
>
>
> "Pratik Shah" <none@unknown.com> wrote in message
> news:eh63lv$ll9$1@utils.eclipse.org...
>> You should ask on the GMF newsgroup about the best way to do this.
>> There's only one editpolicy per role. But you can install several
>> different editpolicies that can handle the same request type.
>>
>> "Liam Morley" <liam.morley@baesystems.com> wrote in message
>> news:eh5uue$643$1@utils.eclipse.org...
>>> I'm not sure if I follow- I want to be able to apply both policies to the
>>> same role simultaneously. Are you saying to have one policy per role, but
>>> have my policy function as a strategy? I think what you're saying is that
>>> this functionality does not exist natively in the GEF, but I can
>>> implement it on my own. Is that true?
>>>
>>> Liam
>>>
>>>
>>> "Xiang Qinxian" <fyaoxy@gmail.com> wrote in message
>>> news:1161187543.2964.14.camel@qinxian.xiang...
>>> ? 2006-10-17?? 16:17 -0400,Liam Morley??:
>>>> I'm writing a modular editor with the GMF where different plugins can
>>>> add
>>>> functionality to the same editor. When a plugin adds something to the
>>>> palette, it needs to add an EditPolicy as well so that the plugin can
>>>> contribute the correct commands for the edition. I was using
>>>> EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE,
>>>> but I
>>>> realize now that that erases the existing policy with the same key. Is
>>>> there
>>>> a way to have multiple policies with the same key, or is there currently
>>>> a
>>>> way to add functionality to an existing policy?
>>>>
>>>> Thanks,
>>>> Liam Morley
>>>>
>>>>
>>> Hi,
>>> Each existing Role with EditPolicy known about some Request, your Role
>>> too. Now the same Role want capture difference Request, so it is a
>>> choice that appling a strategy pattern for the special EditPolicy.
>>>
>>> Regards
>>>
>>> Qinxian.
>>>
>>>
>>>
>>
>>
Re: how to add to an existing edit policy? [message #66120 is a reply to message #66014] Fri, 20 October 2006 08:42 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Liam,

It is not possible to have multiple edit policies registered for one key
directly.
However, the pattern Composite could help in your situation.

Best regards,
Boris


"Liam Morley" <liam.morley@baesystems.com> wrote in message
news:eh91c5$hb$1@utils.eclipse.org...
> Originally posted this on the GEF newsgroup only because it has more to do
> with edit policies than anything specifically related to GMF, but it was
> suggested that I post here as well. Here's the original question:
>
> I'm writing a modular editor with the GMF where different plugins can add
> functionality to the same editor. When a plugin adds something to the
> palette, it needs to add an EditPolicy as well so that the plugin can
> contribute the correct commands for the edition. I was using
> EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE, but
> I realize now that that erases the existing policy with the same key. Is
> there a way to have multiple policies with the same key, or is there
> currently a way to add functionality to an existing policy?
>
> Thanks,
> Liam Morley
>
>
> "Pratik Shah" <none@unknown.com> wrote in message
> news:eh63lv$ll9$1@utils.eclipse.org...
>> You should ask on the GMF newsgroup about the best way to do this.
>> There's only one editpolicy per role. But you can install several
>> different editpolicies that can handle the same request type.
>>
>> "Liam Morley" <liam.morley@baesystems.com> wrote in message
>> news:eh5uue$643$1@utils.eclipse.org...
>>> I'm not sure if I follow- I want to be able to apply both policies to
>>> the same role simultaneously. Are you saying to have one policy per
>>> role, but have my policy function as a strategy? I think what you're
>>> saying is that this functionality does not exist natively in the GEF,
>>> but I can implement it on my own. Is that true?
>>>
>>> Liam
>>>
>>>
>>> "Xiang Qinxian" <fyaoxy@gmail.com> wrote in message
>>> news:1161187543.2964.14.camel@qinxian.xiang...
>>> ? 2006-10-17?? 16:17 -0400,Liam Morley??:
>>>> I'm writing a modular editor with the GMF where different plugins can
>>>> add
>>>> functionality to the same editor. When a plugin adds something to the
>>>> palette, it needs to add an EditPolicy as well so that the plugin can
>>>> contribute the correct commands for the edition. I was using
>>>> EditPart.installEditPolicy() to add another policy with SEMANTIC_ROLE,
>>>> but I
>>>> realize now that that erases the existing policy with the same key. Is
>>>> there
>>>> a way to have multiple policies with the same key, or is there
>>>> currently a
>>>> way to add functionality to an existing policy?
>>>>
>>>> Thanks,
>>>> Liam Morley
>>>>
>>>>
>>> Hi,
>>> Each existing Role with EditPolicy known about some Request, your Role
>>> too. Now the same Role want capture difference Request, so it is a
>>> choice that appling a strategy pattern for the special EditPolicy.
>>>
>>> Regards
>>>
>>> Qinxian.
>>>
>>>
>>>
>>
>>
>
>
Previous Topic:Missing properties in the Properties View
Next Topic:Refreshing Decorations
Goto Forum:
  


Current Time: Sat Aug 17 06:24:02 GMT 2024

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

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

Back to the top