|
Re: A New Diagram Editor integration into the Papyrus environment [message #1016509 is a reply to message #1016208] |
Wed, 06 March 2013 17:38 |
|
Hi Mary,
there is currently no online documentation on integrating a new editor in Papyrus.
However, this is quite easy and fast, as this is done by few hand-written classes, similar in each editor plugin. To see how you can do it, you can look in the class diagram plugin: org.eclipse.papyrus.uml.diagram.clazz.
The following classes are in charge of the integration of the generated editor into papyrus main editor:
- ClassDiagramCreationCondition.java
- ClassDiagramEditorFactory.java
- CreateClassDiagramCommand.java
- CreateClassDiagramWithNavigationHandler.java
- UmlClassDiagramForMultiEditor.java
Once you have 'duplicated' these classes in your plugin and updated your plugin.xml file, you should see your editor in Papyrus!
HTH
Remi
Remi Schnekenburger
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
|
|
|
Re: A New Diagram Editor integration into the Papyrus environment [message #1017128 is a reply to message #1017126] |
Sat, 09 March 2013 17:27 |
Simon Schwichtenberg Messages: 127 Registered: September 2011 |
Senior Member |
|
|
So these are the steps to integrate a GMF editor into Papyrus, which operates on another model than the UML model:
* Create a new class MyGMFDiagramEditorOverride that extends the generated class MyGMFDiagramEditor. Merge the contents from org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor and org.eclipse.papyrus.uml.diagram.clazz.part.UMLDiagramEditor into MyGMFDiagramEditorOverride
* Create a new class MyGMFDiagramEditorFactory that extends org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory and in its constructor call super(MyGMFDiagramEditorOverride.class, MyRootElementEditPart.MODEL_ID)
* realize the extension point org.eclipse.papyrus.infra.core.papyrusDiagram and refer to MyGMFDiagramEditorFactory
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.papyrus.infra.core.papyrusDiagram">
<editorDiagram
factoryClass="my.package.MyGMFDiagramEditorFactory"
icon="platform:/plugin/my.plugin/icons/obj16/Editor.gif">
</editorDiagram>
</extension>
</plugin>
[Updated on: Mon, 11 March 2013 16:32] Report message to a moderator
|
|
|
|
Re: A New Diagram Editor integration into the Papyrus environment [message #1017336 is a reply to message #1017283] |
Mon, 11 March 2013 15:59 |
Simon Schwichtenberg Messages: 127 Registered: September 2011 |
Senior Member |
|
|
yes, you will need to register your model resource to the modelset of papyrus.
Create a class like this:
public class MyResource extends org.eclipse.papyrus.infra.core.resource.AbstractBaseModel implements org.eclipse.papyrus.infra.core.resource.IModel{
public static final String MODEL_FILE_EXTENSION = "myextension";
public static final String MODEL_ID = "my.package.MyResource";
@Override
public void createModel(IPath fullPath) {
super.createModel(fullPath);
MyRootElement rootEl = MyModelPackage.eINSTANCE.getMyModelFactory().createMyRootElement();
getResource().getContents().add(rootEl);
}
@Override
public String getIdentifier() {
return MODEL_ID;
}
@Override
protected String getModelFileExtension() {
return MODEL_FILE_EXTENSION;
}
}
Add register it like this in plugin.xml
<extension
point="org.eclipse.papyrus.infra.core.model">
<model
classname="my.package.MyResource">
</model>
</extension>
Now every time you create a new papyrus model, you should get an extra model.myextension file. Do the same for the diagram resource.
(If you want to create the model only if needed, use AbstractDynamicModel instead of AbstractBaseModel).
If you want to add new model templates (besides UML, SysML) you must use the extension point org.eclipse.papyrus.uml.diagram.wizards.templates. (In my case, I am not using this extension point directly, but I use a customized version of its implementation, i.e. org.eclipse.papyrus.uml.diagram.wizards.CreateModelWizard and I call my wizard from the extension point org.eclipse.ui.newWizards)
[Updated on: Mon, 11 March 2013 22:15] Report message to a moderator
|
|
|
|
|
|
Re: A New Diagram Editor integration into the Papyrus environment [message #1017673 is a reply to message #1017665] |
Tue, 12 March 2013 09:56 |
Mary P. Messages: 48 Registered: November 2012 |
Member |
|
|
oh, sorry, I wrote a message and then saw your reply.
What I want exactly is:
To create my own diagram editor with on my own models. Yes, I generate this editor using GMF and I use this Tutorial http://wiki.eclipse.org/Papyrus_Developer_Guide/Papyrus_diagram_generation#How_to_generate_a_diagram_for_Papyrus
Then I want to perform the consistency check between my diagrams and UML Class diagrams generated with Papyrus
So, I would like
1. to use "Papyrus UML diagrams to create non-UML models" if it is possible. Because in this case it would be easier to perform the consistency check. But I do not understand how it may be possible if I want to have the elements that are different from the UML ones and that have different graphical representation. But if there is any way to extend the UML model (without using the Profile mechanism) it would be perfect.
2. If it is not possible I can us "my own model and my own diagrams in addition to the UML models and diagrams". Yes, I generate my diagrams using GMF.
[Updated on: Tue, 12 March 2013 15:50] Report message to a moderator
|
|
|
|
|
|
|
|
Re: A New Diagram Editor integration into the Papyrus environment [message #1018176 is a reply to message #1018159] |
Wed, 13 March 2013 10:12 |
Mary P. Messages: 48 Registered: November 2012 |
Member |
|
|
The problem is that I do not choose the technology and I need to use Papyrus.
Ok, then I will do everything you mentioned before in order integrate the editor generated only by GMF ([1]) wothout the Papyrus editor generation.
Quote:I integrated a 3rd party GMF editor into Papyrus without touching the code of Papyrus or the other diagram editor.
Sorry, but then I have a couple of questions to you.
0. Is there any documentation that helped you to do this?
1. Did you need to create your own diagram Category? Did you add an extension like this:
<diagramCategory
class="components.diagram.MyCreationCommand"
description="My diagram"
icon="icons/obj16/newDiagramFile.gif"
id="mydi"
label="MyDi">
</diagramCategory>
Did you create a class that implements IModelCreationCommand?
2. What extension points did you add to your plugin.xml besides
<extension
point="org.eclipse.papyrus.infra.core.model">
<model
classname="my.package.MyResource">
</model>
</extension>
and
<extension
point="org.eclipse.papyrus.infra.core.papyrusDiagram">
<editorDiagram
factoryClass="my.package.MyGMFDiagramEditorFactory"
icon="platform:/plugin/my.plugin/icons/obj16/Editor.gif">
</editorDiagram>
</extension>
Thank you!!!!!!!!!!
Mary
[Updated on: Wed, 13 March 2013 10:20] Report message to a moderator
|
|
|
Re: A New Diagram Editor integration into the Papyrus environment [message #1018483 is a reply to message #1018176] |
Wed, 13 March 2013 22:51 |
Simon Schwichtenberg Messages: 127 Registered: September 2011 |
Senior Member |
|
|
I open the diagrams from the context menu
public class ViewVisualContractAction extends org.eclipse.core.commands.AbstractHandler{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ServicesRegistry serviceRegistry = ServiceUtilsForActionHandlers
.getInstance().getServiceRegistry();
ModelSet modelSet = ServiceUtilsForActionHandlers.getInstance().getModelSet();
HenshinDiagramResource henshinDiagramModel = (HenshinDiagramResource) modelSet.getModelChecked(HenshinDiagramResource.MODEL_ID);
if(henshinDiagramModel.getResource()!=null){
Diagram diagram = (Diagram) henshinDiagramModel.getResource().getContents().get(0);
IPageMngr pageMngr = ServiceUtils.getInstance().getIPageMngr(
serviceRegistry);
if(pageMngr.isOpen(diagram)){
pageMngr.closePage(diagram);
}
pageMngr.openPage(diagram);
}
}
Replace HenshinDiagramResource with the name of your diagram resource.
further reading on how to call the handler: http://trac.rtsys.informatik.uni-kiel.de/trac/kieler/wiki/Help/EclipseCookbook/ContextMenu
[Updated on: Wed, 13 March 2013 22:52] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09014 seconds