Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Custom diagram type for DSML: plugin/extension
Custom diagram type for DSML: plugin/extension [message #1719426] Thu, 07 January 2016 19:28 Go to next message
Kristof De Middelaer is currently offline Kristof De MiddelaerFriend
Messages: 10
Registered: December 2015
Junior Member
Hello!

The past couple of days I've been actively working with Papyrus to create a DSML for railway systems. I've created my UML profile, added icons and I'm now in the process of creating an eclipse plugin that will register my UML profile and more importantly: to add a new type of diagram. A "railway diagram" if you will.

I've found the "org.eclipse.papyrus.infra.core.papyrusDiagram" extension point which has some documentation together with an example. I've tried implementing it and was able to create a new diagram category but my new diagram wouldn't show.

I decided to take a step back and copy the example (that creates a sysml requirement diagram) but just put it in my new diagram category.

This is what I currently have:

<extension point="org.eclipse.papyrus.infra.core.papyrusDiagram">
 <diagramCategory
        id="railway"
     class="org.eclipse.papyrus.sysml.diagram.common.commands.CreateSysMLModelCommand"
        label="Railway"
        description="Railway diagrams"
        >
 </diagramCategory> 

 <editorDiagram
     actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor"
        factoryClass="org.eclipse.papyrus.sysml.diagram.requirement.RequirementDiagramEditorFactory"
        >
 </editorDiagram>

 <creationCommand
        id="org.eclipse.papyrus.sysml.diagram.requirement.CreateCommand"
     creationCommandClass="org.eclipse.papyrus.sysml.diagram.requirement.RequirementDiagramCreateCommand"
        label="Railway Diagram"
  language="railway">
 </creationCommand>
</extension>


I thought that the language in the creationCommand was the category the new diagram should go in? Why doesn't this work? Do I need more in order for the new diagram type to show and be used?

Kind regards,


Kristof
Re: Custom diagram type for DSML: plugin/extension [message #1719476 is a reply to message #1719426] Fri, 08 January 2016 09:28 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Kristof,

Is this an entirely new kind of diagram? (e.g. Generated from your own GMFGen model?)

Or is it an extension/customization of an existing Papyrus UML Diagram? (Similar to what is done for SysML 1.4 and most customizations in Papyrus)

If this is an extension, then you should have a look at the Papyrus Viewpoints mechanism rather than using the PapyrusDiagram extension point

Regards,
Camille


Camille Letavernier
Re: Custom diagram type for DSML: plugin/extension [message #1719481 is a reply to message #1719476] Fri, 08 January 2016 10:01 Go to previous messageGo to next message
Kristof De Middelaer is currently offline Kristof De MiddelaerFriend
Messages: 10
Registered: December 2015
Junior Member
Camille Letavernier wrote on Fri, 08 January 2016 09:28
Hi Kristof,

Is this an entirely new kind of diagram? (e.g. Generated from your own GMFGen model?)

Or is it an extension/customization of an existing Papyrus UML Diagram? (Similar to what is done for SysML 1.4 and most customizations in Papyrus)

If this is an extension, then you should have a look at the Papyrus Viewpoints mechanism rather than using the PapyrusDiagram extension point

Regards,
Camille


Hello Camille, thanks for replying.

What I want to do is similar to what has been done for SysML. I've imported the SysML plugins and have been taking a look at what has been done there which is a lot more than I would need. The relevant plugins I've found were the org.eclipse.papyrus.sysml.diagram ones where they use the papyrusDiagram extension point?

The only thing I could find there concerning 'viewpoints' is maybe the org.eclipse.gmf.runtime.diagram.core.viewProviders extension point. Is that the one you are talking about? (https://screencloud.net/v/g7Sr)

I've also tried to copy the org.eclipse.papyrus.sysml.diagram.requirement plugin and adapt it to make the diagram type show up in my new diagram category (railway). (http://screencloud.net/v/xvNv) but alas, it still won't show up there. It does show up under the SysML diagram category though. (http://screencloud.net/v/rFWe)

What I basically want is when creating a new model you can select "Railway" as a DSML (http://screencloud.net/v/g2Y1) and then be able to choose the "Railway diagram" which doesn't show yet (http://screencloud.net/v/gLwr). It would then open the Railway diagram with the Railway UML Profile applied and my customized palettes showing.

How can this be done?

Is all of this done by using ViewPoints mechanism as you said? Because I really thought using the papyrusDiagram was the way to go for this as this is what SysML seems to be using.

If all of this would work it would be amazing. I have to write a paper and make a presentation about this. If I could demonstrate this it would be fantastic!

Kind regards,


Kristof
Re: Custom diagram type for DSML: plugin/extension [message #1719485 is a reply to message #1719481] Fri, 08 January 2016 10:24 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Kristof,

The SysML (1.1) diagrams rely on a different, deprecated code generator. They are a programmatic extension of UML Diagrams, with a very thin CSS customization.

We don't recommend this approach anymore (Especially since the code generator is not publicly available nor maintained)

It would be better to rely on the SysML 1.4 approach [1] [2], as it requires much less code and is the one we want to promote in Papyrus Mars and further versions

Using a Viewpoint model will avoid the manual declaration for several extension points (Including Wizards integration, Diagram creation commands/menus, and others). You can check the embedded documentation to get more information about what Viewpoints do, and how you define them (Help > Help Contents > Papyrus Guide > User Guide > Viewpoints in Papyrus)

[1] Update site: http://download.eclipse.org/modeling/mdt/papyrus/components/sysml14
[2] Sources: https://git.eclipse.org/r/papyrus/org.eclipse.papyrus-sysml


Camille Letavernier
Re: Custom diagram type for DSML: plugin/extension [message #1719512 is a reply to message #1719485] Fri, 08 January 2016 14:16 Go to previous messageGo to next message
Kristof De Middelaer is currently offline Kristof De MiddelaerFriend
Messages: 10
Registered: December 2015
Junior Member
Camille Letavernier wrote on Fri, 08 January 2016 10:24
Hi Kristof,

The SysML (1.1) diagrams rely on a different, deprecated code generator. They are a programmatic extension of UML Diagrams, with a very thin CSS customization.

We don't recommend this approach anymore (Especially since the code generator is not publicly available nor maintained)

It would be better to rely on the SysML 1.4 approach [1] [2], as it requires much less code and is the one we want to promote in Papyrus Mars and further versions

Using a Viewpoint model will avoid the manual declaration for several extension points (Including Wizards integration, Diagram creation commands/menus, and others). You can check the embedded documentation to get more information about what Viewpoints do, and how you define them (Help > Help Contents > Papyrus Guide > User Guide > Viewpoints in Papyrus)

[1] Update site: http://download.eclipse.org/modeling/mdt/papyrus/components/sysml14
[2] Sources: https://git.eclipse.org/r/papyrus/org.eclipse.papyrus-sysml


Hello Camille,

This looks amazing! I've been playing around with it and it looks a lot easier than what I was doing before! Good that there's documentation about it too.

The thing I'm figuring out now is how to create a diagram category so that it stands next to SysML and SysML1.4 in the new project/new diagram wizard. I'll have a look at the SysML1.4 files. I was hoping the 'View Category' in the viewpoint .configuration file was going to take care of this but it looks like it doesn't. It doesn't show up anywhere.

I chose the configuration element in the viewpoints.policy.custom but in the model rule and owning rule of my diagram I've selected the UML package. Maybe this is why it is not showing up? (As the configuration element gets rid of all the UML/SysML diagrams etc.)

Thanks again, I really appreciate your replies!

Kristof
Re: Custom diagram type for DSML: plugin/extension [message #1719513 is a reply to message #1719485] Fri, 08 January 2016 14:17 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Hi Camille,

I've did a quick check but I couldn't find a new diagram type in the library example model : Am I right to say that the 'library example model' does not (yet?) contain an example of defining a new model via the viewpoint mechanism?

TIA

Re: Custom diagram type for DSML: plugin/extension [message #1719528 is a reply to message #1719513] Fri, 08 January 2016 16:08 Go to previous messageGo to next message
Kristof De Middelaer is currently offline Kristof De MiddelaerFriend
Messages: 10
Registered: December 2015
Junior Member
UPDATE:

I've managed to create my new "Railway diagram" to a new Diagram Category "Railway"! I had to create a new diagramCategory in the org.eclipse.papyrus.infra.core.papyrusDiagram extension point and use the same id there as the View Category in the .configuration file. I also changed my Diagram's Model and Owning rule element to a blank one in order to work as a Configuration viewpoint.

Next up is figuring out how I can get my profile to be automatically applied. In the viewpoint .configuration file the Diagram has a Profiles field, but you can only choose from the automatically populated list from the loaded EPackages. My profile isn't in there unfortunately and I need to find a way to do this. I've been tryign to add it by using the org.eclipse.emf.ecore.generated_package and org.eclipse.uml2.uml.generated_package but then I'd need a Java class etc. Maybe I'd need to use the dynamic_package ones?
Re: Custom diagram type for DSML: plugin/extension [message #1719684 is a reply to message #1719528] Mon, 11 January 2016 13:01 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Kristof,

If you use a GenModel for your Profile, then you can generate the Java Code associated to it. Pro: it's easier to manipulate your profile programmatically. Con: You lose support for automatic version update ("Reapply Profile")

With a GenModel (File > New > EMF Generator Model), you need to use the *.generated_package extension points. Otherwise, you have to use the *.dynamic_package extensions.

In both cases, the EPackage will be accessible from the EMF Ecore Package Registry and UML Profiles Registry, so it should be available to the viewpoints (And also to e.g. Model-to-Model and Model-to-Text transformations languages, and various other tools that rely on EMF/Ecore EPackages)

HTH,
Camille


Camille Letavernier
Re: Custom diagram type for DSML: plugin/extension [message #1719691 is a reply to message #1719684] Mon, 11 January 2016 13:35 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

On 2016-01-11 13:01:24 +0000, Camille Letavernier said:

> Hi Kristof,
>
> If you use a GenModel for your Profile, then you can generate the Java
> Code associated to it. Pro: it's easier to manipulate your profile
> programmatically. Con: You lose support for automatic version update
> ("Reapply Profile")

Ah, but that's also a "pro": if changes to the profile are compatible,
then there is no need for any re-application step. The profile
application and stereotype applications just continue to work always.
:-)

Christian
Re: Custom diagram type for DSML: plugin/extension [message #1757798 is a reply to message #1719513] Mon, 20 March 2017 00:34 Go to previous message
Tonero toneo is currently offline Tonero toneoFriend
Messages: 24
Registered: March 2017
Junior Member
Hi Camille,
I am running into some problems with my custom diagram for DSML. How do I display my custom diagram in the "Select a Diagram Kind" editor? I have implemented a viewpoint extension with a Diagram and a View Category but when I try to create a papyrus project, my custom diagram is not listed in the editor.


Previous Topic:Text placeholder for different properties in SVG
Next Topic:Attach CSS to Profile plugin
Goto Forum:
  


Current Time: Fri Mar 29 07:32:07 GMT 2024

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

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

Back to the top