Community
Participate
Working Groups
Right now sirius based editors are opened using the Model explorer. There also exists a way to open editors progrmmatically (see https://www.eclipse.org/forums/index.php/t/633830/ ) But as eclipse has already a nice editor framework with UI support in navigator views (open editor on registered file types with a doubleclick, right click on files -> Open with) I would like to request support to embed a Sirius based editor into that framework. In the end I would like to register a sirius editor using the org.eclipse.ui.editors extension point
Hi Christian, there is an example of that in EcoreTools (which I commented out for now ) Have a look in the plugin.xml : http://git.eclipse.org/c/ecoretools/org.eclipse.ecoretools.git/tree/org.eclipse.emf.ecoretools.design/plugin.xml <!-- <extension point="org.eclipse.ui.editors"> <editor class="org.eclipse.emf.ecoretools.design.editor.EcoreEntitiesReadOnlyEditor" contributorClass="org.eclipse.sirius.diagram.part.ViewpointDiagramActionBarContributor" default="false" extensions="ecore" icon="icons/full/obj16/EcoreModelFile.gif" id="org.eclipse.emf.ecoretools.design.editor.entities" matchingStrategy="org.eclipse.emf.ecoretools.design.editor.EcoreEntitiesMatchingStrategy" name="Viewpoint Ecore Editor"> </editor> </extension> --> This declare an editor on .ecore file which will use Sirius and will keep all the representation data in a transient area. The editor class itself is fairly simple : public class EcoreEntitiesReadOnlyEditor extends AbstractSpecificDDiagramEditor { public String getDiagramDescriptionName() { return "Entities"; } public URI getViewpointURI() { return URI .createURI("viewpoint:/org.eclipse.emf.ecoretools.design/Design"); } public boolean isSessionStoredInWorkspace() { return false; } } There are very few (known) usages of this capability to us so that has not been extensively tested in the wild and might lack flexibility depending on your use case.
I am trying to use our code sample to create an editor for the basicfamily sample project from the sirius website. How do you find out the URI for the viewpoint?
Hi Christian, For the EcoreTool's editor, if you look at the snippet given by Cédric, you will see: "viewpoint:/org.eclipse.emf.ecoretools.design/Design" viewpoint:/ is a specific URI scheme allowing to reference a Viewpoint with its containing plugin id and its name/id (and not the label). In your case, if you create a Viewpoint Specification Project for the basic family sample, the viewpoint uri should be viewpoint:/yourBasicFamilyDesignPluginId/yourViewpointId Rds, Maxime
Thanks, found the viewpoint ID: viewpoint:/org.eclipse.sirius.sample.basicfamily.design/Basic%20Family I am able to open the editor now. Regarding the example given in comment 1 I could not find org.eclipse.sirius.diagram.part.ViewpointDiagramActionBarContributor in Sirius 1.0.1. Instead I found org.eclipse.sirius.editor.editorPlugin.ViewpointActionBarContributor which seems to work. Is this the correct class to use?
org.eclipse.sirius.editor.editorPlugin.ViewpointActionBarContributor si the action bar contributor for the VSM (.odesign) editor. You should try to use org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor instead.
Created attachment 246704 [details] Editor project
Created attachment 246705 [details] Family test data
Still not there. Created a test project along with test data. The editor opens, but shows a note saying: "This diagram was not saved. You can close the editor" instead of displaying the representation. For the sample project just uploaded I used the basicfamily example from Sirius. I adapted the code a bit to use the representations.aird file.
Hi Christian, The message seems to indicate that the editor uri input does not point to a gmf Diagram element. private URI getNewEditorInputURI(final DRepresentation representation) { return EcoreUtil.getURI(representation); } You return the uri of the DRepresentation, the Sirius diagram in your case, but the editor expects the uri of the corresponding gmf Diagram. You can use org.eclipse.sirius.diagram.business.api.refresh.DiagramCreationUtil.findAssociatedGMFDiagram() or org.eclipse.sirius.diagram.ui.business.api.view.SiriusGMFHelper.getGmfDiagram(DDiagram, Session) to retrieve the diagram. It seems that the DDiagramEditorEditorImpl is able to take Diagram or DDiagram as input but we might have to improve org.eclipse.sirius.diagram.ui.tools.internal.resource.CustomSiriusDocumentProvider.caseURIEditorInput(IDocument, URIEditorInput, TransactionalEditingDomain) to make it able to take a UriEditorInput targeting a DDiagram (see org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.setInput(IEditorInput)