Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to get Diagram from EditPart(need to get a Diagram Object from an EditPart)
How to get Diagram from EditPart [message #1807827] Mon, 10 June 2019 12:20 Go to next message
Dylan Trenti is currently offline Dylan TrentiFriend
Messages: 6
Registered: March 2019
Junior Member
Hi everyone,

I'm trying to create a filter to display only dependencies wich have a specific stereotype, into a BDD.

I did something similar on State Machine Diagrams (filtering transitions), but the procedure looks quite different when I need to extract the diagram from the IGraphicalEditPart.

So what I need is to get a Diagram object from an IGraphicalEditPart.

What I have done to get it for the state machine:

private Diagram getDiagramFromSelection(EditPart selectedEditPart)
 {
	EditPart parentEditPart = selectedEditPart.getParent();
	while (!(parentEditPart instanceof PackageEditPart)) 
	{
		parentEditPart = parentEditPart.getParent();
	}
		
	return ((PackageEditPart) parentEditPart).getDiagramView();		
}


This isn't working on an EditPart obtained from a BDD.

So I tried different things like:

DiagramEditPart diagramEditPart = ...  ;
final Diagram diagram = (Diagram) diagramEditPart.resolveSemanticElement();


or getting the parent and treating it as a package, but navigating it while debugging I noticed that it is a LinkLFDiagramRootEditPart.

I hope someone can Help me

Dylan
Re: How to get Diagram from EditPart [message #1807829 is a reply to message #1807827] Mon, 10 June 2019 12:43 Go to previous message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 913
Registered: February 2011
Senior Member
Hi Dylan,

This should work in all cases:

IGraphicalEditPart gep = ...;
View view = gep.getNotationView();
Diagram diagram = view.getDiagram();


HTH,
Camille


Camille Letavernier
Previous Topic:Stereotype Icons in State Chart Diagram
Next Topic:Eclipse/papyrus crash
Goto Forum:
  


Current Time: Mon Dec 16 01:46:19 GMT 2019

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

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

Back to the top