Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Diagram stores all pictogramLinks - simplify xml
Diagram stores all pictogramLinks - simplify xml [message #1817497] Sun, 24 November 2019 20:14 Go to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Hi,

I try to simplify the stored xml representing pictogram elements. I have limited set of element types so I don't need to store in each element complete graphicsAlgorithm. I started to do it by creating my custom model that inherits from platform:/resource/org.eclipse.graphiti.mm/model/graphiti.ecore#//pictograms/ and overrides methods that create Pictogram elements on the fly.

I have question about pictograms/Diagram. As I see, it stores all pictogram links that are created by org.eclipse.graphiti.features.impl.AbstractFeatureProvider.link method. Why this knowledge is necessary on the level of Diagram?

Or maybe my whole approach is wrong and I should resign from inheriting graphiti.ecore and build model from scratch?
Re: Diagram stores all pictogramLinks - simplify xml [message #1817498 is a reply to message #1817497] Sun, 24 November 2019 20:25 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
I guess it is for methods like: getPictogramElementForBusinessObject and getAllPictogramElementsForBusinessObject. In theory we could look through whole graph. Was it performance decision to keep links handy?

Thanks,

Marek
Re: Diagram stores all pictogramLinks - simplify xml [message #1817509 is a reply to message #1817498] Mon, 25 November 2019 09:19 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Marek,

yes, the links are used to establish the logical connection between business objects and their graphical representation. It can be used to connect any Graphiti diagram object to the represented EMF object; in fact any Java obejct could be connected but that requires some addional effort in hooking in.

Unfortunately I cannot tell what the concrete reason was to make the link model separate, the reason for storing it on diagram level was to improve performance when collecting all the links (no need to dive into the object tree).

Regarding your original question, I'm not sure if I can help there. I have not tried anything like this before; an idea that came to my mind when I read it, was to change the EMF serialization, but I'm not sure if that will be of any help for you.

Michael
Re: Diagram stores all pictogramLinks - simplify xml [message #1818147 is a reply to message #1817509] Sun, 08 December 2019 16:25 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Thank you,
I still try to give a shot to overload model. I have additional question to that. What attributes "visible" and "active" on PictogramElement for are and what is their lifecycle? I guess that by changing visible to false I could hide element. But active? By default I see that for all ContainerShape in xml these attributes are set to true.
I am asking because when I overload isActive methods to return always true, I got StackOverflow exception because of endless refreshing.

Marek
Re: Diagram stores all pictogramLinks - simplify xml [message #1818148 is a reply to message #1818147] Sun, 08 December 2019 16:52 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
I feel that my loop is somehow related to:
public boolean isObjectAlive(EObject obj) {
return obj != null && obj.eResource() != null;
}
of EmfService.
I do not store graphicsAlgorithm in xml. Instead I create it on the fly. I feel under my skin that what I do is too hacky and probably I shouldn't do that way. But I am still curious how my editor would behave in that approach.
I see thay you were considering to not check eResource: https://git.eclipse.org/c/graphiti/org.eclipse.graphiti.git/commit/?id=cde31e3dec72018092880217e0ab90421f71a84e

Question: what for is this isObjectAlive method?

Marek
Re: Diagram stores all pictogramLinks - simplify xml [message #1818169 is a reply to message #1818148] Mon, 09 December 2019 09:51 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Marek,

active in short means that an object can be clicked and selected, there is some more behind in some scenarios, but that probably goes to deep for this.

The method isObjectAlive determines if an object is really part of the model, e.g. after delete the object might still be in memory but not part of an EMF resource or in creation the object might be created but not yet hooked into the model. For some operation we need to map an object to a file, that's why we check for the EMF resource as well.

Hope that helps.
MIchael
Re: Diagram stores all pictogramLinks - simplify xml [message #1823973 is a reply to message #1818169] Sun, 05 April 2020 21:09 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Hey,
I extended pictogram elements with my own one and I generate GraphicalAlgorithms and Anchors on the fly (using flyweight design pattern).
Model below:
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:diagram="http://ruminaq.org/diagram" xmlns:ruminaq="http://ruminaq.org">
  <diagram:RuminaqDiagram version="0.16.0" mainTask="/1">
    <children xsi:type="diagram:InputPortShape" x="100" y="100" modelObject="/1/@inputPort.0" label="/0/@children.1" outgoingConnections="/0/@connections.0"/>
    <children xsi:type="diagram:LabelShape" x="80" y="117" labeledShape="/0/@children.0"/>
    <children xsi:type="diagram:OutputPortShape" x="500" y="100" modelObject="/1/@outputPort.0" label="/0/@children.3" incomingConnections="/0/@connections.1"/>
    <children xsi:type="diagram:LabelShape" x="476" y="117" labeledShape="/0/@children.2"/>
    <children xsi:type="diagram:OutputPortShape" x="500" y="200" modelObject="/1/@outputPort.1" label="/0/@children.5" incomingConnections="/0/@connections.3"/>
    <children xsi:type="diagram:LabelShape" x="471" y="217" labeledShape="/0/@children.4"/>
    <children xsi:type="diagram:OutputPortShape" x="500" y="300" modelObject="/1/@outputPort.2" label="/0/@children.7" incomingConnections="/0/@connections.4"/>
    <children xsi:type="diagram:LabelShape" x="471" y="317" labeledShape="/0/@children.6"/>
    <children xsi:type="diagram:SimpleConnectionPointShape" x="196" y="103" outgoingConnections="/0/@connections.1 /0/@connections.2" incomingConnections="/0/@connections.0"/>
    <children xsi:type="diagram:SimpleConnectionPointShape" x="293" y="132" outgoingConnections="/0/@connections.3 /0/@connections.4" incomingConnections="/0/@connections.2"/>
    <connections xsi:type="diagram:SimpleConnectionShape" modelObject="/1/@connection.0 /1/@connection.1 /1/@connection.2" source="/0/@children.0" target="/0/@children.8"/>
    <connections xsi:type="diagram:SimpleConnectionShape" modelObject="/1/@connection.0" source="/0/@children.8" target="/0/@children.2"/>
    <connections xsi:type="diagram:SimpleConnectionShape" modelObject="/1/@connection.1 /1/@connection.2" source="/0/@children.8" target="/0/@children.9"/>
    <connections xsi:type="diagram:SimpleConnectionShape" modelObject="/1/@connection.1" source="/0/@children.9" target="/0/@children.4"/>
    <connections xsi:type="diagram:SimpleConnectionShape" modelObject="/1/@connection.2" source="/0/@children.9" target="/0/@children.6"/>
  </diagram:RuminaqDiagram>
  <ruminaq:MainTask version="1.0.0">
    <inputPort id="My Input Port"/>
    <outputPort id="My Output Port"/>
    <outputPort id="My Output Port 1"/>
    <outputPort id="My Output Port 2"/>
    <connection xsi:type="ruminaq:SimpleConnection" sourceRef="/1/@inputPort.0" targetRef="/1/@outputPort.0"/>
    <connection xsi:type="ruminaq:SimpleConnection" sourceRef="/1/@inputPort.0" targetRef="/1/@outputPort.1"/>
    <connection xsi:type="ruminaq:SimpleConnection" sourceRef="/1/@inputPort.0" targetRef="/1/@outputPort.2"/>
  </ruminaq:MainTask>
</xmi:XMI>

is displayed as:
index.php/fa/37751/0/
The Resource elements I generate on the fly are not stored. I created my own NoResource implementation that do nothing on most actions.

For now, I don't see any drawbacks.

Thanks,
Marek

[Updated on: Sun, 05 April 2020 21:10]

Report message to a moderator

Re: Diagram stores all pictogramLinks - simplify xml [message #1824051 is a reply to message #1823973] Tue, 07 April 2020 06:31 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thanks Marek for sharing this. Sounds cool. Probably it will work well if you do not use features that require mapping to files. What comes directly to my mind are error markers or selecting the file in the project/package explorer.

Michael
Previous Topic:Constrain size of Canvas
Next Topic:Problem with graphiti 0.11.4 dependency
Goto Forum:
  


Current Time: Mon Dec 02 17:27:09 GMT 2024

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

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

Back to the top