开发者

How To Obtain All the Nodes and Connections After Launching the GMF Project

开发者 https://www.devze.com 2023-03-17 22:57 出处:网络
After launching the GMF project, I get a new window to make my own model. After placing some nodes and connections, I should calculate according to their attributes. At first, HO开发者_StackOverflow

After launching the GMF project, I get a new window to make my own model.

After placing some nodes and connections, I should calculate according to their attributes. At first, HO开发者_StackOverflow社区W can I obtain all the information of every node and every connection?


First , let's get the relevant editor:

DomainDiagramEditor d= (DomainDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();

Now, you can either get all the editparts in your diagram , getting the relevant model from them:

final List children = d.getDiagramEditPart().getChildren();

gets you a list of EditParts.

Or, you can get the model objects directly with:

EObject element = d.getDiagram().getElement();
EList<EObject> eContents_ = element.eContents();

That gives you a list of all the model objects in the active editor. Hope that answers your question

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号