Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Ordering of elements in model vs. aird files matters?
Ordering of elements in model vs. aird files matters? [message #1801136] Mon, 14 January 2019 14:02 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 210
Registered: June 2010
Senior Member
Hi,

I have made various projects where I use an xtext-based serialization of models that are graphically represented by sirius. I get the idea that the aird files refer to model elements by their index in the container. (For intance '@interfaces.0' in the semanticElements property in the example below.)
    <ownedDiagramElements xmi:type="diagram:DNode" uid="_1jSaYOKbEeiQ7sVwYOU-Gw" name="i1DM" incomingEdges=...">
      <target xmi:type="data:DomainInterface" href="ExplainErrorHandlingModel.asome#//@interfaces.0"/>
      <semanticElements xmi:type="data:DomainInterface" href="ExplainErrorHandlingModel.asome#//@interfaces.0"/>
     ...
    </ownedDiagramElements>

Sometimes, I can't resist to change the xtext serialized representation of my models. For instance, I reorder elements in my files. The aird file is unaware of it so in the most positive outcome (if I exchange two elements of the same 'type') they end up with their positions exchanged on the diagram. Things get messy in case the type of the elements differ because likely in that case also their representation is really different.

To me, it seems to be more robust if in stead of referring to a model element by the number of occurrence, it would refer to the element by it's id. I understand that some languages don't have a textual representation, some elements that you want to visualize might not have an id.

Wouldn't it be possible to configure sirius such that it would use the 'id' property of the modelement it wants to refer to if such element has an 'id' property and use the sequence number only as fallback?

Greetings,
Wilbert.

Re: Ordering of elements in model vs. aird files matters? [message #1801229 is a reply to message #1801136] Tue, 15 January 2019 16:04 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi,

The way Sirius serializes the URI relies on the EMF mechanism. For a 'classic' EMF resource, this mechanism will call Resource.getURIFragment to get the EObject URI within the resource. But in the case of a xText resource, it seems that a specific implementation org.eclipse.xtext.resource.XtextResource.getURIFragment(EObject) delegates to a org.eclipse.xtext.resource.IFragmentProvider. I guess that it should be possible to provide a specific implementation that use EcoreUtil.getID(eObject) for instance.

Regards,

Florian
Re: Ordering of elements in model vs. aird files matters? [message #1801234 is a reply to message #1801229] Tue, 15 January 2019 16:38 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

Yes. If you want to re-order you need a better id-generation mechanism. This is determined by the XXXResourceImpl that performs your XXX save and so is probably nothing to do with Sirius. For standard resources you will probably find that imposing an order causes you more trouble than benefits. For custom resources you might want to look at OCL's Locally Unique Semantically Sensitive IDentifiers - GIT\org.eclipse.ocl\plugins\org.eclipse.ocl.pivot\src\org\eclipse\ocl\pivot\internal\resource\LUSSIDs.java. These produce xmi:ids that are highly stable and can be successfully referenced even when the referenced element is auto-generated.

Regards

Ed Willink
Previous Topic:How to convert sirius projects to eclipse RCP project ?
Next Topic:Leverage sirius with javascript
Goto Forum:
  


Current Time: Tue Sep 24 01:12:05 GMT 2024

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

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

Back to the top