Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Custom "New diagram" wizard
Custom "New diagram" wizard [message #800051] Thu, 16 February 2012 16:23 Go to next message
Stefan WülfrathFriend
Messages: 18
Registered: February 2012
Junior Member
Hi,

I had no luck with searching the forums for my question, so I may ask:

I've created my own diagram type, type providers and so on and now I want to create a "New File" wizard which allows the user to create a new diagram file of my diagram type. (instead of using the Graphiti Sample Diagram Wizard)

What do I have to do to achieve this?

Thank your very much for your help!

Best regards,
Stefan
Re: Custom "New diagram" wizard [message #800107 is a reply to message #800051] Thu, 16 February 2012 17:48 Go to previous message
Josef Pohl is currently offline Josef PohlFriend
Messages: 82
Registered: January 2012
Member
Hi Stefan,

Maybe I can help here since I had to deal with this relatively recently.

What I did was modified the CreateDiagramWithAllClassesHandler and the associated AddAllClassesCommand classes.

a) I registered a new context menu with the plugin referencing the new handler (CreateDiagram).
b) I had to write my own little get project and create file name routine in the new CreateDiagram class. Otherwise the code was very similar to the CreateDiagramWithAllClassesHandler.
c) In my new AddDiagram class (replacing AddAllClassesCommand), I created a resource
for my model (which I do not think is necessary if you want to use the default diagram resource). And then, essentially I created an empty diagram by eliminating anything that referred to adding EClasses from another resource set.

I had a top level element that I needed to add to a resource set and save independently which is why I created a separate resource set. I also linked it to the diagram there. (here is that snippet)

		createdResource = editingDomain.getResourceSet().createResource(uri);
		createdResource.getContents().add(diagram);
		
		
		final SafetyCase sc = XxegsnFactory.eINSTANCE.createSafetyCase();
		PictogramLink link = PictogramsFactory.eINSTANCE.createPictogramLink();

		
		diagram.setLink(link);

		createdModelResource = editingDomain.getResourceSet().createResource(uriModel);
		createdModelResource.getContents().add(sc);
		
		link.getBusinessObjects().add(sc);


I think the hardest thing (for me anyway) was trying to get the project information, but if you search around I put up a solution to how I did that.

I am sure there is a better way to go about this (as there always is).

I hope this helps. Feel free to contact me if you have any further questions.

Joe
Previous Topic:addGraphicalRepresentation returns null in dark mode
Next Topic:Connection decorators do not get deleted
Goto Forum:
  


Current Time: Fri Apr 19 03:57:07 GMT 2024

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

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

Back to the top