Author Topic: Diagram Update/Refresh/Reload  (Read 12136 times)

JanosK

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Diagram Update/Refresh/Reload
« on: August 18, 2009, 11:57:09 pm »
Hi there,
i'm stuck in this rather simple seeming issue of changing the appearance of diagram elements by automation. Triggered by an Add-in menu event, i'm changing the style of all DiagramObjects by doing as follows in C#:

Code: [Select]
EA.Diagram diagram = Repository.GetCurrentDiagram();
Collection objects = diagram.DiagramObjects;

foreach (Object o in objects)
{
   IDiagramObject dObject = (IDiagramObject) o;
   dObject.Style = "BCol=35723;BFol=9342520;LCol=9342520;LWth=10;";
  
   dObject.Update();
}
diagram.Update();
objects.Refresh();

The new style though is only applied to the diagram elements, when i reopen it or choose "Reload '<Diagram>'" from the tabs context-menu.

What am i doing wrong, or which "reload/update/refresh" on which elements might be missing?

By the way: I'm working with EA 7.1.831. I will have access to EA 7.5 in a couple of days.

Hints and help are much appreciated!
Thanks

Janosch

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #1 on: August 19, 2009, 12:54:45 am »
There are methods to reload the current or (I think) all open diagrams. Check the Project class.

Note: The Diagram.Update() method merely saves new values to the EA schema. It does not 'update' the display of an open diagram.
« Last Edit: August 19, 2009, 12:55:55 am by Midnight »
No, you can't have it!

JanosK

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #2 on: August 19, 2009, 07:32:08 pm »
Hi,
thank you very much for your quick response!

Some more things arise:

First, using
"Repository.GetProjectInterface().ReloadProject();"
as you've suggested, unfortunately doesn't seem to perform the desired update. I can tell, that the project is somehow reloaded (there is some one or two seconds of processing), but the diagram itself remains unchanged. When i do the mouse-context-menu "Reload '<Diagram>'", the diagram changes.
I've tried this Project.ReloadProject() in several combinations with and without the Diagram.Update() and the DiagramObject.Update().

Second, updating the entire project isn't actually what i desire... Looking at the one or two seconds mentioned above, which it takes to reload a (mostly empty!) project, i wonder what the possibility of changing the style is actually good for in the end. Why can i change the appearance of an object, but cannot actually apply the change to the UI?

Is there no other way to redisplay a diagram, rather than reloading the entire thing?

Thanks for your help!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #3 on: August 19, 2009, 08:46:57 pm »
Yes Janosch...

I think I mentioned this in my response to another of your posts. There is a method to reload a selected diagram.

You can also refresh the current model view (which might not be relevant here). There is also one to refresh all open diagrams. Once again you will need to look through the SDK documentation. These methods are part of the Repository class.

[Hint: note the different terminology above; this will help you with the method names.]

David
No, you can't have it!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Update/Refresh/Reload
« Reply #4 on: August 19, 2009, 08:47:26 pm »
I think David was referring to the method Repository.ReloadDiagram

From EA help:
Quote
ReloadDiagram (long DiagramID)
  
 Reloads a specified diagram. This would commonly be used to refresh a visible diagram after code import/export or other batch process where the diagram requires complete refreshing.

Parameters:

DiagramID: Long - the ID of the diagram to be reloaded.


Geert

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #5 on: August 19, 2009, 08:56:28 pm »
That's one of the ones I was referring to. As to the others, I am hoping that a bit of hands-on research will help readers get more used to the documentation. It takes a bit of practice before you develop a feel for where methods might (or should) be. Once you have the knack you can usually find these things (if they are there at all). But there is no substitute for doing it yourself a few times...
No, you can't have it!

JanosK

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #6 on: August 19, 2009, 08:56:37 pm »
Thanks David and Geert,
looking through the SDK was what i've been doing all day - only now i've found it, and it works beautifully!

Code: [Select]
Repository.ReloadDiagram(Repository.GetCurrentDiagram().DiagramID);
Thanks again!
Cheers Janosch

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Update/Refresh/Reload
« Reply #7 on: August 19, 2009, 09:54:49 pm »
Quote
That's one of the ones I was referring to. As to the others, I am hoping that a bit of hands-on research will help readers get more used to the documentation. It takes a bit of practice before you develop a feel for where methods might (or should) be. Once you have the knack you can usually find these things (if they are there at all). But there is no substitute for doing it yourself a few times...

Sorry David,

I was already editing my response when you replied. I agree with your mild RTFM attitude though ;)

Geert

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #8 on: August 20, 2009, 09:03:16 am »
Certainly not a problem Geert.

And I did not mean to have Janosch burning all day going through the documentation; it is very easy to end up doing so. That was why I provided hints...
No, you can't have it!

JanosK

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Diagram Update/Refresh/Reload
« Reply #9 on: August 20, 2009, 07:13:48 pm »
Thanks for your support guys. It's good to find people who help, and even think about how they can help!
Cheers