Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Extending an EditHelper
Extending an EditHelper [message #897519] Tue, 24 July 2012 11:54 Go to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
Hi,

I am implementing a synchronization mechanism in Papyrus that keeps an UML model and an ECORE model consistent.

Now I want to hook in the Delete Command so that e.g. for every UML::Class the corresponding ECORE::EClass is deleted. I saw that there is this centralized ElementEditService that access the EditHelpers. So, I tried to override the existing EditHelpers and call my own DestroyElementPapyrusCommand that deletes the EClass.

I am using this plugin.xml

   <extension
         point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
   		<metamodel nsURI="http://www.eclipse.org/uml2/4.0.0/UML">
   			<metamodelType id="org.eclipse.papyrus.ext.uml.Class" name="UML::Class"
		eclass="Class"
		edithelper="de.upb.swt.rsdl.editor.ext.edit.commands.ClassEditHelperOverride"
		kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >
			<param name="semanticHint" value="UML::Class"/>
	</metamodelType>
	</metamodel>
   </extension>
   <extension
         point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
      <binding
            context="org.eclipse.papyrus.infra.services.edit.TypeContext">
         <elementType
               ref="org.eclipse.papyrus.ext.uml.Class">
         </elementType>
      </binding>
      <clientContext
            id="org.eclipse.papyrus.infra.services.edit.TypeContext">
      </clientContext>
   </extension>


But the ElementEditService is still using the old ClassEditHelper.
Do I have to also override the org.eclipse.papyrus.infra.core.service extension point?
Re: Extending an EditHelper [message #897522 is a reply to message #897519] Tue, 24 July 2012 12:02 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hello,

In Papyrus, we use org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice (org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice) to add Advices (Pre/Post actions) for an EditHelper. You can add them by adding an "adviceBinding" element in the elementTypes extension point.

See org.eclipse.papyrus.uml.service.types/plugin.xml for a few examples.


Regards,
Camille


Camille Letavernier
Re: Extending an EditHelper [message #897665 is a reply to message #897522] Wed, 25 July 2012 02:23 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
Thank you for your reply. I tried that, but only the constructor of my Advice class is called, when I want to "Delete Selected Element" from the context menu.

Now, I am using the following plugin.xml. Actually, when I use this XML, I cannot delete messages between lifelines anymore ("Delete Selected Element" is disabled). I discovered that, because there is already an existing MessageHelperAdvice I tried out. So maybe there is a problem when you use the same elementTypeBindings or ClientContexts multiple times?

	<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">

		<binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
			<elementType ref="org.eclipse.papyrus.uml.Class" />
			<advice ref="de.upb.swt.rsdl.editor.ext.edit.commands.ClassEditHelperAdvice" />
		</binding>
	</extension>
	<extension
         point="org.eclipse.papyrus.infra.core.service">
      <service
            classname="de.upb.swt.rsdl.editor.ext.sync.UML2EcoreMappingService"
            description="Stores the mapping of classes"
            id="de.upb.swt.rsdl.editor.ext.sync.UML2EcoreMappingService"
            priority="1"
            startKind="startup">
      </service>
   </extension>

[Updated on: Wed, 25 July 2012 02:24]

Report message to a moderator

Re: Extending an EditHelper [message #897744 is a reply to message #897665] Wed, 25 July 2012 08:01 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
sorry, I wanted to copy that excerpt:

	
<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
		<metamodel nsURI="http://www.eclipse.org/uml2/4.0.0/UML">
			<adviceBinding id="de.upb.swt.rsdl.editor.ext.edit.commands.ClassEditHelperAdvice"
				class="de.upb.swt.rsdl.editor.ext.edit.commands.ClassEditHelperAdvice"
				inheritance="all" typeId="org.eclipse.papyrus.uml.Class">
			</adviceBinding>
		</metamodel>
	</extension>
	<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
		<binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
			<elementType ref="org.eclipse.papyrus.uml.Class" />
			<advice ref="de.upb.swt.rsdl.editor.ext.edit.commands.ClassEditHelperAdvice" />
		</binding>
	</extension>
Re: Extending an EditHelper [message #897970 is a reply to message #897744] Wed, 25 July 2012 14:20 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
I found out, that getAfterDestroyDependentsCommand is actually working, i.e. this method is called.
Re: Extending an EditHelper [message #903468 is a reply to message #897970] Thu, 23 August 2012 18:11 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
I want to synchronize Associations between Classes as well. I tried to create an AssociactionEditHelperAdvice, but I cannot get it running.

In a first step, I put some breakpoints into the classes org.eclipse.papyrus.uml.service.types.helper.AssociationBaseEditHelper and org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice, but none of their methods is called when I draw an Association between two Classes.

Maybe it is because of this?
		<!-- ISpecializationType Association of UML::AssociationBase -->
	<specializationType id="org.eclipse.papyrus.uml.Association" name="UML::Association"
		edithelperadvice="org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice"
		kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >
			<param name="semanticHint" value="UML::Association"/>
		<specializes id="org.eclipse.papyrus.uml.AssociationBase" />
		<matcher class ="org.eclipse.papyrus.uml.service.types.matcher.AssociationMatcher" />
	</specializationType>


What's wrong here? Or do I have to override org.eclipse.papyrus.uml.diagram.clazz.edit.policies.ClassItemSemanticEditPolicy.getCompleteCreateRelationshipCommand(CreateRelationshipRequest) instead?

[Updated on: Thu, 23 August 2012 18:12]

Report message to a moderator

Re: Extending an EditHelper [message #903924 is a reply to message #903468] Mon, 27 August 2012 10:01 Go to previous message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
Registered: September 2011
Senior Member
Ok, it works when I create an Advice for AssociationBase.
Previous Topic:Assistance with Reply Action on Activity Diagram
Next Topic:DSL Documentation
Goto Forum:
  


Current Time: Thu Mar 28 14:30:32 GMT 2024

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

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

Back to the top