Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Some issues saving a diagram (Read 7115 times)
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Some issues saving a diagram
Jun 6th, 2009 at 6:37am
Print Post  
Hi guys!
First of all - great job!
We are at the end of our project and still very happy with the feature you provided us with this component.

However, we still have something to iron out, can you please help us on these:

When you save a diagram on the server site, calling the SaveToXml() method, the following things doesn't seem to be preserved:

1. There is some kind of Id, which I can use to identify nodes, when you call the toString() on a shape node on the client side I get something like:

com.mindfusion.diagramming.ShapeNode@187b287

is this an autogenerated id for the class by the applet, or it is generated by the diagram itself? I can't seem to find it on the client side.

2. The shape displayName property doesn't seem to be persisted in the resulting xml document.
If we SaveToXml() and then call the LoadFromXml() with the XmlDocument object we had created by the SaveToXml() method, all we have is RoundRectangles (we are using custom shape libraries).

Can you please enlight us how to solve those two problems?

Thanks in advance and kudos for the work you did!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #1 - Jun 7th, 2009 at 8:16am
Print Post  
Hi Pavel,

Thanks for the kind words 8)

1. It seems that's some kind of address in the Java Runtime memory space, and the default toString() implementation simply returns the type name + address. You can't use this as a persistent id because the object will be created at a different memory location when you load a diagram file. Instead, you could keep some long-int counter as a value of the Diagram's tag property, assign it to each item's tag when a new item is created, and increment it. Then you'll be sure that the item's tag is a unique value for this diagram.

2. SaveToXml() only saves the Shape IDs in the XML file. When you call LoadFromXml(), the control expects that shapes with IDs loaded from the XML have been already defined, or otherwise it falls back to the diagram's DefaultShape. Furthermore, shape definitions are not preserved in the view state, so you must define the shapes or load the shape library at each request to the page that calls LoadFromXml. We could add some option to store shape definitions in the view state, but NetDiagram already uses it heavily, and saving the shapes definitions there will add several more kilobytes to it.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #2 - Jun 8th, 2009 at 7:22am
Print Post  
Stoyo, first of all - thanks for replying my post, I really appreciate it.

However, I had no luck saving the custom shapes.
I tried to assign

ShapeLibraryLocation to my diagram prior calling SaveToXml() but when I open the resulting XML in XML Editor the Shape Id tag still says RoundRect.

Am I missing something? Not to bother you - can you please tell me if there is a demo somewhere so I can read it myself?

Reguards,
Pavel
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #3 - Jun 8th, 2009 at 10:16am
Print Post  
Hi Pavel,

In addition to setting the LibraryLocation property (if using JavaApplet mode), you must also call ShapeLibrary.LoadFrom on the server side. You can find more information here:
http://mindfusion.eu/Forum/YaBB.pl?board=netdg_disc;action=display;num=123496172...

At this time shape libraries are not loaded automatically on the server side and you must call LoadFrom specifying a local file path on the server; we'll try to add some support for doing that automatically when a ShapeLibraryLocation is set to a relative path.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #4 - Jun 9th, 2009 at 12:52pm
Print Post  
Still, no luck.
The issue is not the loading of the xml, but saving it, as when I open the xml it says RoundRect.

Can anyone attach a simple project to guide me?

Thanks in advance!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #5 - Jun 9th, 2009 at 2:53pm
Print Post  
We'll add some support for loading shape libraries automatically in a couple of days.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #6 - Jun 10th, 2009 at 9:32am
Print Post  
Hi Pavel,

With this version it should be enough just to set ShapeLibraryLocation to a relative path:

https://mindfusion.eu/_beta/netdiag302.zip

The applet resolves the location value relatively to the .jar file URL, and the server code resolves it relatively to the .aspx page local path.

This example loads a shape library by setting ShapeLibraryLocation:

https://mindfusion.eu/_samples/ShapelibTest.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #7 - Jun 11th, 2009 at 12:57pm
Print Post  
Hi, Stoyan!
Thanks for your sample code, it works perfectly, but our project is a bit more complex.
We have a dropdown with all the diagram types.

The form contains a dropdown, a button, a diagramview and a shapelistbox.

When you change the dropdown value and click the button I want to load the shapes in the shape listbox and clear the diagram, allowing the user to start over a new diagram of other type.

I couldn't seem to make this even with your code (my best try was to be able to add the shapes to the shapelistbox but the default shapes are also there).

I did a lot of code with JDiagram but most of it was at the client side so I was thinking I know them well Embarrassed

I reviewed the documentation again but found nothing that can give me a clue on how to achieve my desired behaviour. Can you please help us again?

Does the ShapeListBox has something to do with the ShapeLibrary class?
If so - are the static methods responsible for loading the shapes into a shared location from where the shapelibrary / shape diagram can read them or instance is needed to be passed to some property perhaps?

Does it have some method to clear the items and then load the new?

Is the ShapeLibraryLocation responsible for the load / clear of the shapes inside the ShapeListBox?

Sorry for asking so much but I am eager to know everything as our project is already in a final phase, the logics are built, everything is almost ready, we are only missing the save / load functionality.

Any information will be highly appreciated.

Here is my latest try on the demo you sent.

https://chameleonbulgaria.com/ShapeLibTestDD.zip
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #8 - Jun 11th, 2009 at 3:56pm
Print Post  
Hi Pavel,

Seems we haven't anticipated changing shape libraries dynamically through the ShapeLibraryLocation property... One problem is that the shapelist's ShapeLibraryLocation it is not saved in the view-state, and it uses only the shape library set through the asp markup attribute; we'll try to fix that tomorrow.

Another thing, for your requirements you might have to add all custom shapes to a single shape library, and assign it to the DiagramView.ShapeLibraryLocation - this will ensure that all shapes are available when loading diagram files. You can still keep some subsets of the shapes in individual libraries for displaying them in the shape listbox.

Stoyan
  
Back to top
 
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #9 - Jun 11th, 2009 at 6:54pm
Print Post  
Stoyan, thanks for your timely response.

Our client will probably acquire a copy of the controls tomorrow and we will target to have everything in place next week so it is not "for yesterday" symptom Smiley.

Just take your time and write back when possible.

It is a lot more important to me that the support is great - always responds back on time.

Thank you!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #10 - Jun 12th, 2009 at 7:19am
Print Post  
Hi Pavel,

This zip file contains an updated sample project, and fixed assemblies in the bin folder:
https://mindfusion.eu/_samples/ShapelibTest.zip

The new assemblies now save ShapeListBox.ShapeLibraryLocation in the view-state, which fixes the problem where the shapelistbox would not preserve the library selected in the combo box.

The example now shows pre-loading all shapes in order to enable loading files created with any of the separate shape libraries. This will work only if you know all shapes that will be used in the application in advance. Otherwise you might have to handle the AppletStarted client-side event to pre-load the libraries through the applet's API.

For the 3.0.3 release we'll think of some option for saving the shape definitions in the diagram files, so they don't depend that much on the custom shapes being already loaded.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #11 - Jun 14th, 2009 at 11:30am
Print Post  
Hi, Stoyan!

Sorry I wasn't able to test your solution. I will do this now.

My case doesn't require me to have shapes from different libraries at the same time.

I need to save a diagram that have only shapes from the library that is currently loaded, so I think your solution would work.

I will test it and report back.

Thanks for helping us on time once again.
  
Back to top
WWW  
IP Logged
 
donchevp
YaBB Newbies
*
Offline


Simply a bulgarian developer
...

Posts: 7
Joined: Feb 18th, 2009
Re: Some issues saving a diagram
Reply #12 - Jun 18th, 2009 at 11:27am
Print Post  
Hi, Stoyan!

We just finished our project, everything is working now.

Thanks for your efforts helping us!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some issues saving a diagram
Reply #13 - Jun 18th, 2009 at 11:44am
Print Post  
Hi Pavel,

Great to hear that 8)

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint