Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Extend existing diagram(Creating a new diagram type based on existing one)
Extend existing diagram [message #1771656] Tue, 29 August 2017 07:52 Go to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Hi,
I want to extend an existing Papyrus diagram (e.g. the statemachine diagram). I want to add new elements in the palette, new properties in object...
Is there a best way, and documeted, to extend the statemachine diagram, and keep usin the papyrus editor?

I eard about a forum last May, but I didn't found the link.
I'm using Papyrus 3.0.0

Best regards

[Updated on: Tue, 29 August 2017 07:53]

Report message to a moderator

Re: Extend existing diagram [message #1772001 is a reply to message #1771656] Sun, 03 September 2017 11:24 Go to previous messageGo to next message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
Hi,

I will try to tell you some steps, as far as I understand what you want to do.

If you want to reuse UML elements and diagrams it's a good idea to define a profile extending the elements and adding properties through stereotypes and tagged values. http://help.eclipse.org/oxygen/topic/org.eclipse.papyrus.uml.diagram.profile.doc/target/generated-eclipse-help/users/definingProfilesAndStereotypes.html?cp=79_0_1_6_2

And deploy it in a plugin. http://help.eclipse.org/oxygen/topic/org.eclipse.papyrus.uml.diagram.profile.doc/target/generated-eclipse-help/users/generatingStaticProfiles.html?cp=79_0_1_6_5

You can customize the properties view to edit easily stereotype properties. http://help.eclipse.org/oxygen/topic/org.eclipse.papyrus.views.properties.doc/target/generated-eclipse-help/properties-view.html?cp=79_1_0

Now, to reuse the Papyrus UML diagrams you should define an Architecture Model. http://help.eclipse.org/oxygen/topic/org.eclipse.papyrus.infra.architecture.doc/target/generated-eclipse-help/architecture.html?cp=79_1_3_3#Definition_of_New_Architecture_Models

With an Architecture Model you can customize the style and the palette.

I hope this helps you.

Regards.
Re: Extend existing diagram [message #1772002 is a reply to message #1771656] Sun, 03 September 2017 11:24 Go to previous messageGo to next message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
Sorry, I published twice the same message.

[Updated on: Sun, 03 September 2017 11:26]

Report message to a moderator

Re: Extend existing diagram [message #1772040 is a reply to message #1772002] Mon, 04 September 2017 13:23 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Thanks a lot!
That's exactly what I need.
Re: Extend existing diagram [message #1773402 is a reply to message #1772040] Wed, 27 September 2017 13:18 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
I Adrian,
Another question: How did you get the .gmfgen file, and after the *EditPart.java files?
Re: Extend existing diagram [message #1773411 is a reply to message #1773402] Wed, 27 September 2017 15:00 Go to previous messageGo to next message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
Hi Ismael,

If you want to reuse the Papyrus UML diagrams by extending them, you shouldn't need .gmfgen file and *EditPart.java files.

There is a library example in Papyrus repository where you can see what you need:
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/tree/examples/library?h=streams/3.0-maintenance

Benoit Maggi has cloned this repository in github
https://github.com/bmaggi/library-training
as he has told in the message
https://www.eclipse.org/forums/index.php?t=msg&th=1088876&goto=1773246&#msg_1773246.

If you need more help try to tell in what point you are, what is the next you want to do, and I will tell you what is the following step I would do.

Regards.
Re: Extend existing diagram [message #1773437 is a reply to message #1773411] Wed, 27 September 2017 20:16 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Thanks for your answer Adrian.
I've generated the genmodel from my profile. Then all classes.
The architecture model wasn't very clear for me, and I thought the gmfgen section was missing.

For my plugin I've a "ui" plugin which already manage old Papyrus EditPart ( adding palette, SVG, dragNdrop, properties tab...)
All my need was to add new attributes on object. That's the reason for why I extend the papyrus diagram.
Re: Extend existing diagram [message #1773470 is a reply to message #1773437] Thu, 28 September 2017 10:31 Go to previous messageGo to next message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
If you want to generate gmfgen file you need Eclipse Modeling Tools and Eclipse GMF plugin. Then with the GMF Dashboard you can manage the models you need.
index.php/fa/30856/0/

In the plugin org.eclipse.papyrus.uml.diagram.clazz you can find the class diagram .gmfgen file. And here are the requisites to explore it.


However, as far as I know, gmfgen is needed to make a diagram right from the start for a DSML meta-modeled with MOF.

But, if you are using a UML profile, there is a better way, which is to use the architecture model to extend UML Papyrus diagrams.

Install Papyrus Toolsmiths plugin from Papyrus repository to create and manage Architecture models.

Here you have architecture models of UML and SySML if you want to see how they do.

I have never used gmfgen with UML profiles, so I can't help you in that.

Regards.

Edited:
If you want to use GMF files, this example could interest you:
http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/tree/examples/others/org.eclipse.papyrus.example.diagram.simplediagram
see the tutorial:
http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/plain/examples/others/org.eclipse.papyrus.example.diagram.simplediagram/docs/PapyrusDevelopperTutorial_OnDiagramCreating.odt

[Updated on: Thu, 28 September 2017 18:47]

Report message to a moderator

Re: Extend existing diagram [message #1773922 is a reply to message #1773470] Fri, 06 October 2017 14:44 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Hi Adrian,
I have follow the Architecture way and the exemple you gave me.
Every things look fine, after the genmodel generation i have :

  • completed the plugin.xml file
  • created the .elementtypesconfigurations file
  • created the .paletteconfiguration file


Then i run the plugin.
My new architecture menu appears in new >> Papyrus model >> MyCustomArchitecture >> myCustomDiagram >> OK
But, when created, i get:
java.lang.NullPointerException
	at org.eclipse.papyrus.infra.architecture.ArchitectureDescriptionUtils$2.doExecute(ArchitectureDescriptionUtils.java:221)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.emf.common.command.CompoundCommand.execute(CompoundCommand.java:261)
	at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:488)
	at org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory.doExecute(CheckedOperationHistory.java:206)
	at org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory.execute(CheckedOperationHistory.java:195)
	at org.eclipse.papyrus.infra.emf.gmf.command.NotifyingWorkspaceCommandStack.doExecute(NotifyingWorkspaceCommandStack.java:264)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at org.eclipse.papyrus.infra.emf.gmf.command.NestingNotifyingWorkspaceCommandStack.execute(NestingNotifyingWorkspaceCommandStack.java:130)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.createEmptyDomainModel(CreateModelWizard.java:629)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.initDomainModel(CreateModelWizard.java:540)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.InitModelWizard.initDomainModel(InitModelWizard.java:184)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.createAndOpenPapyrusModel(CreateModelWizard.java:324)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.performFinish(CreateModelWizard.java:280)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:778)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:417)
	at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:619)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1472)

!ENTRY org.eclipse.papyrus.infra.gmfdiag.commands 4 0 2017-10-06 16:24:56.723
!MESSAGE Unexpected Error
!STACK 0
org.eclipse.papyrus.infra.core.services.ServiceException: The selected EObject must not be null
	at org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject.getServiceRegistry(ServiceUtilsForEObject.java:40)
	at org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramPrototype.instantiateOn(DiagramPrototype.java:57)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.initDiagrams(CreateModelWizard.java:766)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.InitModelWizard.initDiagrams(InitModelWizard.java:198)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.initDiagramModel(CreateModelWizard.java:705)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.createAndOpenPapyrusModel(CreateModelWizard.java:326)
	at org.eclipse.papyrus.uml.diagram.wizards.wizards.CreateModelWizard.performFinish(CreateModelWizard.java:280)


I don't know where is the link to my custom generated class (in src-gen). Seems like the EObject are not loaded.
My palette appears, but i can't drag&drop any element.
Re: Extend existing diagram [message #1774016 is a reply to message #1773922] Mon, 09 October 2017 09:11 Go to previous messageGo to next message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
Hi Ismael,

please check on the properties of the Desciption Language if you have written the correct Creation Command Class: org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand

It is needed to create the model. Choose that default class unless you want to customize the model creation action. I guess that's not the case.

The link to your custom class is applied in your *.elementtypesconfiguration file.

In this example, I create a Package element and then I apply my stereotype.

  <elementTypeConfigurations xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" identifier="SIMCANComponentPalette.component.tool.package_1505816000435" name="Scenario (Package)">
    <specializedTypes xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.Package_Shape"/>
  </elementTypeConfigurations>
  <adviceBindingsConfigurations xsi:type="applystereotypeadvice:ApplyStereotypeAdviceConfiguration" identifier="SIMCANComponentPalette.component.tool.package_1505816000435_ASAC" target="//@elementTypeConfigurations.0">
    <stereotypesToApply stereotypeQualifiedName="SIMCAN::Scenario" updateName="true">
      <requiredProfiles>SIMCAN</requiredProfiles>
    </stereotypesToApply>
  </adviceBindingsConfigurations>


If you want Papyrus to generate automatically the *.elementtypesconfiurations files use the PaletteConfiguration Editor. Since Papyrus 3.0.0 it doesn't come with Papyrus but once you have installed Papyrus Toolsmiths it is available.
How to use PaletteConfiguration Editor: https://www.youtube.com/watch?v=XnhxHPksbjc

There are some problems with the editor, so don't export the palette but go to C:\Users\"user name"\"workspace name"\.metadata\.plugins\org.eclipse.papyrus.infra.gmfdiag.common folder and copy the generated files. I also had problems by trying to edit a generated palette, that it to say, I had to create the palette with the editor at once. If I tried to reopen it, the editor changed the paths by wrong paths.

The files have to be registered for the palette to find them. You shall to registre both of the generated elementtypesconfigurations files with the following extension point:

   <extension
         point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
      <elementTypeSet
            clientContextID="org.eclipse.papyrus.infra.services.edit.TypeContext"
            path="palettes/componentDiagram/SIMCANComponentPalette_Semantic.elementtypesconfigurations">
      </elementTypeSet>
   </extension>


Regards.

[Updated on: Mon, 09 October 2017 09:15]

Report message to a moderator

Re: Extend existing diagram [message #1774104 is a reply to message #1774016] Tue, 10 October 2017 16:05 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
Hi Adrian,
Thanks again for the reply.
Now the model is created. No error logged. But the package is not created
index.php/fa/30970/0/
In the "Representation kind" I've write the creationCommandClass, where i create the diagram.

When right click on the model, i can "create my diagram", but it throw:
org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:496)
	at org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory.doExecute(CheckedOperationHistory.java:206)
	at org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory.execute(CheckedOperationHistory.java:195)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler.createDiagram(AbstractPapyrusGmfCreateDiagramCommandHandler.java:357)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler.createDiagram(AbstractPapyrusGmfCreateDiagramCommandHandler.java:389)
	at org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramPrototype.instantiateOn(DiagramPrototype.java:69)
	at org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramPrototype.instantiateOn(DiagramPrototype.java:50)
	at org.eclipse.papyrus.infra.gmfdiag.welcome.internal.widgets.CreateNewNotationButton.createDiagram(CreateNewNotationButton.java:182)
	at org.eclipse.papyrus.infra.gmfdiag.welcome.internal.widgets.CreateNewNotationButton.createDiagram(CreateNewNotationButton.java:151)
	at org.eclipse.papyrus.infra.gmfdiag.welcome.internal.widgets.CreateNewNotationButton$1.widgetSelected(CreateNewNotationButton.java:65)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Caused by: java.lang.NullPointerException
	at org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest.getEditContextCommand(CreateElementRequest.java:313)
	at org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest.getEditHelperContext(CreateElementRequest.java:440)
	at org.eclipse.papyrus.infra.gmfdiag.common.helper.DefaultEditHelper.getEditHelperAdvice(DefaultEditHelper.java:340)
	at org.eclipse.papyrus.infra.types.core.notification.AbstractNotifierEditHelper.getEditCommand(AbstractNotifierEditHelper.java:53)
	at org.eclipse.gmf.runtime.emf.type.core.MetamodelType.getEditCommand(MetamodelType.java:107)
	at org.eclipse.papyrus.infra.services.edit.internal.ElementEditService.getEditCommand(ElementEditService.java:85)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler$Creator.create(AbstractPapyrusGmfCreateDiagramCommandHandler.java:211)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler$Creator.createDiagram(AbstractPapyrusGmfCreateDiagramCommandHandler.java:172)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler$Creator.access$0(AbstractPapyrusGmfCreateDiagramCommandHandler.java:126)
	at org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler$1.doExecuteWithResult(AbstractPapyrusGmfCreateDiagramCommandHandler.java:441)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:488)
	... 37 more


Seems like it can't find my representation (I follow the library exemple you gave me)
  • Attachment: Capture.PNG
    (Size: 6.33KB, Downloaded 355 times)
Re: Extend existing diagram [message #1774285 is a reply to message #1774104] Thu, 12 October 2017 13:24 Go to previous messageGo to next message
Ismael Soulama is currently offline Ismael SoulamaFriend
Messages: 39
Registered: November 2016
Member
My bad,
a "/" was missing in the plugin.xml file, for the
<extension
         point="org.eclipse.emf.ecore.uri_mapping">
      <mapping
            source="pathmap://MY_PROFILE/"
            target="platform:/plugin/my.plugin/model/">
      </mapping>
   </extension>

Then, it can't find all my definitions.

But when i create my diagram, now it dont' have my stereotype directly. I must go on "profile >> apply stereotype", then select mine.
Even when i drag&drop my element.
Is there something missing?
Re: Extend existing diagram [message #1774363 is a reply to message #1774285] Fri, 13 October 2017 10:05 Go to previous message
Adrian Bernal Bermejo is currently offline Adrian Bernal BermejoFriend
Messages: 10
Registered: May 2017
Junior Member
Hi Ismael,

Ismael Soulama wrote on Thu, 12 October 2017 13:24

Is there something missing?


sorry, but I can't know if something is missing by just seeing a piece of code.

Some points to take in account:
- Are you sure your profile is being registered? You should be able to apply it from "Apply registered profile".

- If you want to apply the profile directly to your model when you create it, you must customize your creationCommandClass, as in the library example.
https://github.com/bmaggi/library-training/blob/master/org.eclipse.papyrus.training.library.architecture/src/org/eclipse/papyrus/training/library/architecture/TrainingLibraryModelCreationCommand.java

- If your stereotypes aren't applied on the element when you drag and drop it from your customized palette, review your *.elementtypesconfigurations files.
https://github.com/bmaggi/library-training/blob/master/org.eclipse.papyrus.training.library.newchild/resources/extLibrary.elementtypesconfigurations
https://github.com/bmaggi/library-training/blob/master/org.eclipse.papyrus.training.library.palette/resources/extlibrarydi.elementtypesconfigurations

To know if the elements are being rightly referenced, deploy the plugin and then open the palette model and the element type set models (*.elementtypesconfigurations files) and show the Properties tab. you should be able to navigate through the whole models. If some reference is wrong, you will get an error, so you will know what reference is wrong.

Regards.

[Updated on: Fri, 13 October 2017 10:38]

Report message to a moderator

Previous Topic:How to programmatically create temporary Papyrus diagrams?
Next Topic:C++ reverse to UML generation is broken on Oxygen
Goto Forum:
  


Current Time: Mon Jul 16 02:34:07 GMT 2018

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

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

Back to the top