Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Diagram properties(how to set/change gridsize, snaptogrid, etc)
Diagram properties [message #714086] Tue, 09 August 2011 19:06 Go to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
I didn't find any docs/samples about how to set the diagram properties (at creation time; both for setting some global default values for a particular diagram type, and/or by letting the user change it) or by seeing/changing the values for a created diagram: gridsize, snaptogrid, etc.
Re: Diagram properties [message #714268 is a reply to message #714086] Wed, 10 August 2011 07:50 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
You can override the method IDiagramTypeProvider#init(Diagram diagram, IDiagramEditor diagramEditor).

BR,
Matthias

Re: Diagram properties [message #714393 is a reply to message #714268] Wed, 10 August 2011 13:18 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Matthias Gorning wrote on Wed, 10 August 2011 04:50
You can override the method IDiagramTypeProvider#init(Diagram diagram, IDiagramEditor diagramEditor).



That was my first try:

	@Override
	public void init(Diagram diagram, IDiagramEditor diagramEditor) {
		super.init(diagram, diagramEditor);
		diagram.setGridUnit(10);
	}


but it does not work, it throws an exception "Cannot modify resource set without a write transaction".

Re: Diagram properties [message #714464 is a reply to message #714393] Wed, 10 August 2011 15:01 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Ok, I see, changes to the diagram must be transactional (EMF-wise), so something like this works :

		final TransactionalEditingDomain ed = TransactionUtil.getEditingDomain(diagram);
		ed.getCommandStack().execute(new RecordingCommand(ed) {
			protected void doExecute() {
				diagram.setGridUnit(myGridUnit);
			}
		});


This could be used to change the gridsize from some menu (in a Handler). But I don't think this should go inside a DiagramTypeProvider.init() : it would set the property each time a diagram was opened, which is not one would normally want (and besides, it would cause the editor to open always dirty).

To set a diagram property at creation time, i.e., where/how to invoke Graphiti.getPeCreateService().createDiagram(), seems to fit into a bigger task: customize a diagram creation (including, perhaps, a creation Wizard). I have not seen docs about this (perhaps it's not very much Graphiti specific?). I'll take a look into BPMN2DiagramCreator.
Re: Diagram properties [message #714687 is a reply to message #714464] Thu, 11 August 2011 09:24 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Hernan,

maybe it is best to do the basic configuration for the diagram
in a place analogous to CreateDiagramWizard#performFinish
in the example.common plugin.
Wherever you generate your diagram (in almost al cases a toolset would
have its own wizard) you can set the respective attributes immediately
after the creation of the diagram object...

Does it work for you?
Best, Tim
Re: Diagram properties [message #714783 is a reply to message #714687] Thu, 11 August 2011 13:49 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Tim Kaiser wrote on Thu, 11 August 2011 06:24
Hi Hernan,

maybe it is best to do the basic configuration for the diagram
in a place analogous to CreateDiagramWizard#performFinish
in the example.common plugin.


Yes, this seems to be the way. I had totally missed this class...
Thanks!

I'not sure about the example.common plugin : I had assumed that it simply had some "support" classes for the tutorial, but (as far as I see) this CreateDiagramWizard is not used. Is this plugin just a collection of example-utility code, to read-copy-paste? Is one supposed to learn about its contents by just browsing them, or are they used in some other (i.e., apart from the tutorial) Graphiti examples? The plugin is not supposed to be included in a final product, right?

Re: Diagram properties [message #715715 is a reply to message #714783] Mon, 15 August 2011 09:31 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Hernan,

yes, the commons plugin builds a basis for the tutorial,
but basically it can be consulted as a reference for common
tasks which building a product on top of graphiti would involve.

We use the diagram wizard for testing. But if we build a product on graphiti
we would craft a specific wizard for that product where our diagram wizard may serve as starting point.

We don't want to include things as these in the framework because it is nearly impossible to build, e.g., a generic diagram wizard. Only the toolsmith (you!) can know how this wizard should work and look like etc. The same reasoning applies for file handling. The toolsmith has to decide where and how to store the files, if he wants to seperate diagram from model etc. So any serious graphiti development would involve something like buidling your own commons plugin, i guess.

Does it make sense?

Best, Tim
Re: Diagram properties [message #715793 is a reply to message #715715] Mon, 15 August 2011 15:05 Go to previous message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Yes, thanks.
Previous Topic:Putting it all together
Next Topic:Nested GA inside FixedPointAnchors?
Goto Forum:
  


Current Time: Thu Mar 28 23:53:28 GMT 2024

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

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

Back to the top