Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I attach arbitrary data to a GNode? #52

Closed
midrare opened this issue Dec 4, 2020 · 2 comments
Closed

How do I attach arbitrary data to a GNode? #52

midrare opened this issue Dec 4, 2020 · 2 comments
Labels

Comments

@midrare
Copy link

midrare commented Dec 4, 2020

Lets say that I have some extra data that I want to display in my custom GNodeSkin. From what I understand of the wiki page, this would be done by creating a new EMF model, and then creating a new EClass with the extra attributes needed. Whenever a new node of that extended type is needed, both a GNode and a MyExtendedGNode are instantiated, with the same ID, and both are added to the GModel.

But then how does the custom GNodeSkin get access to the MyExtendedGNode instance? Do I use the GNode to look up the MyExtendedGNode instance? Where do I do this? Do I do this in the skin factory? Is there a function I can call such as getMyExtendedGNodeById(String id), or do I manually keep a Map<String, MyExtendedGNode> that acts as an index for the extra attributes? I'm confused. What is the recommended approach? (Or am I going about this entirely the wrong way?)

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.85. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@eckig
Copy link
Owner

eckig commented Dec 4, 2020

The GNode is added to the GModel but your MyExtendedGNode needs to be added to the MyExtendedGModel (4.2 in the wiki).

In the GNodeSkin you can access the GModel with getGraphEditor().getModel() and from that you can retrieve your custom Model (via the editing domain).

If you frequently do this kind of a query, you should cache the value somehow, but that is up to you.

@midrare midrare closed this as completed Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants