Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Non-Emf Diagram Loading
Non-Emf Diagram Loading [message #990626] Thu, 13 December 2012 13:53 Go to next message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Hi,

at the moment I'm stuck and hope that you can help me.

The project is to build a visualization for a non-emf model.

I had a look at the tutorial, at the FAQ and several topics in this forum, especially the Non-Emf example.
But somehow I'm stuck and do not really know what to do.

Business model: can be edited by a separate (text) editor

Want I want to achieve:
Load:
-- load model (use my own loading mechanism)
-- load view information (use Graphiti)
if there is none, create one.
-- hook these things together

Save:
-- save model (use my own loading mechanism)
-- save view information (use Graphiti)

But I'm failing to implement the basic framework.

What I implemented:
according to eclipse help:
* DomainModelChangeListener
* DiagramEditor (registered it as extension point, extension *.tim)
* NotificationService (without overriding any method)
according to forum:
* IndependenceSolver

But then I had a closer look at DiagramEditor and discovered the "Behavior" mechanism.
So in order to load my business model I should probably extend the DefaultPersistencyBehavior.

I'm trying to do that at the moment but as I said, I'm stuck. I want to load my business model, but I don't really know how to create a Diagram using the provided AddFeatures.
Can somebody perhaps help me and explain what I have to do.

Thanks a lot!

Cheers,
Tim

[Updated on: Tue, 18 December 2012 08:34]

Report message to a moderator

Re: Non-Emf Diagram Loading [message #991178 is a reply to message #990626] Mon, 17 December 2012 15:43 Go to previous messageGo to next message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Hi again,

made a bit of progress for one of the mentioned points: Load a model. At least I hope that Smile

For testing purposes I just try to load one single object, created at the beginning
of the loadDiagram method.

public class CDPersistencyBehavior extends DefaultPersistencyBehavior {

	public CDPersistencyBehavior(DiagramEditor diagramEditor) {
		super(diagramEditor);
	}

	@Override
	public Diagram loadDiagram(URI uri) {

		ClassObject textObject = new ClassObject("TestAdd");

		if (uri != null) {

			// final TransactionalEditingDomain editingDomain = diagramEditor
			// .getEditingDomain();

			// Create the diagram and its file
			Diagram diagram = Graphiti.getPeCreateService().createDiagram(
					"CDDiagramType", "Testing", true); //$NON-NLS-1$

			IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager()
					.createDiagramTypeProvider(diagram,
							"demo.cd.diagram.CDDiagramTypeProvider"); //$NON-NLS-1$

			IFeatureProvider fp = dtp.getFeatureProvider();

			AddContext ac = new AddContext();
			ac.setTargetContainer(diagram);
			ac.setNewObject(textObject);
			ac.setLocation(10, 10);
			ac.setSize(50, 50);

			PictogramElement pe = fp.addIfPossible(ac);

			CDPatternFeatureProvider cpfp = (CDPatternFeatureProvider) fp;
			CDIndependenceSolver cdis = cpfp.getCDIndependenceSolver();

			cdis.printMap();
			cdis.printClasses();

			return diagram;
		}
		return null;

		// return super.loadDiagram(uri);
	}

	@Override
	public void saveDiagram(IProgressMonitor monitor) {
		super.saveDiagram(monitor);
	}

}


It seems to add the class correctly to the Independence Solver.
Unfortunately, it is not shown in the diagram.

Even adding a object from the palette does not work any longer.

I guess, I made a mistake Smile Any help is appreciated.

Another topic related question:
How would I manage to load (and save, see other topic) the "view" information,
load the model separately and hook these together?
Is it even possible to do that? How can I (conceptually) achieve this?

Thanks a lot!

[Updated on: Tue, 18 December 2012 08:36]

Report message to a moderator

Re: Non-Emf Diagram Loading [message #991300 is a reply to message #990626] Tue, 18 December 2012 12:17 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Tim,

my answers below.

Michael


"Tim E." schrieb im Newsbeitrag news:kacml2$u3f$1@xxxxxxxxe.org...
....
>But then I had a closer look at DiagramEditor and discovered the "Behavior"
>mechanism.
>So in order to load my business model I should probably extend the
>DefaultPersistencyBehavior.

That's the right place to do that.

>I'm trying to do that at the moment but as I said, I'm stuck. I want to
>load my business model, but I don't really know how to create a Diagram
>using the >provided AddFeatures.

Usually you simply create a new empty diagram of your type (either via the
examples.common wizard our using your own functionality. Using your own
functionality will also enable you to add stuff to the diagram while
creating it. The tutorial has a "Create diagram with all classes"
functionality registered in the project explorer classes node. The coding
for this can be found here:
http://git.eclipse.org/c/gmp/org.eclipse.gmp.graphiti.git/tree/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/handlers
Re: Non-Emf Diagram Loading [message #991862 is a reply to message #991300] Thu, 20 December 2012 11:23 Go to previous message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Thanks for the help, but unfortunately we decided yesterday not to use Graphiti and use GEF instead.

Thanks anyway,
Tim
Previous Topic:Non-EMF Diagram Saving (only view information)
Next Topic:JFace Error
Goto Forum:
  


Current Time: Sun Sep 21 06:18:57 GMT 2014

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

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