Book a Demo

Author Topic: Set Feature Visibility through Automation  (Read 4299 times)

Kevin Winchester

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Set Feature Visibility through Automation
« on: September 26, 2007, 09:24:22 am »
Is there any way to access the Set Feature Visibility functionality through the automation interface?

I am creating diagrams and would like to adjust the visibility of attributes and operations on some elements on the diagram.
Kevin Winchester

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Set Feature Visibility through Automation
« Reply #1 on: September 27, 2007, 03:18:56 am »
Each feature (Attribute and Method) has a Visibility attribute that can be set to the exact name of the required visibility (case sensitive).

In the case of embedded elements you can set the Visibility attribute of the (embedded) element itself.

Remember to call Update() after making such a change.

HTH, David
No, you can't have it!

Kevin Winchester

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Set Feature Visibility through Automation
« Reply #2 on: September 27, 2007, 03:28:58 am »
I'm sorry, I don't think I was clear enough in my original post.

The Visibility property on attributes and methods is for making the feature Public or Private.  I am looking for a way to adjust the appearance of the feature on a diagram.

If I right-click an element on a diagram, there is a "Set Feature Visibility" menu item that brings up a dialog that can show or hide various element features on the diagram.  It does not affect the element itself (or its features), it only affects the diagram.

Is there any way to access this functionality from the automation interface?
Kevin Winchester

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Set Feature Visibility through Automation
« Reply #3 on: September 27, 2007, 03:42:47 am »
Yes Kevin, there is...

However, you will need to dig a bit. Take a look at the Diagram class. There are three boolean properties for this: ShowPublic, ShowPrivate, and ShowProtected.

There is also a ShowPackageContentsproperty that shows package details - I think this is the same as checking the Package box of Visible Class Members on the Features tab of the diagram Properties dialog. Note that this is not the ShowDetails
property, which controls whether the diagram notes are displayed. This seems to always default to true for diagrams created through automation, so you need to turn it off for each diagram if you normally don't show these.

If you need to modify the Property Methods setting via automation, that's a bit of a mystery. I suspect - without proof - that it might be found in the StyleEx or ExtendedStyle strings. If so, you'll need to figure out how to parse these by trial and error. Try reading through some test diagrams with the setting both ways, and see whether you come up with anything. If you do, please report back here and let us know the secrets.

David
No, you can't have it!

Kevin Winchester

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Set Feature Visibility through Automation
« Reply #4 on: September 27, 2007, 05:14:30 am »
Thanks for the help, but I don't think the Diagram class will give me what I need.  I am looking for a way to show attributes on some elements in a diagram but not on others.  Therefore, I do not want to affect the entire diagram.

If there was an easy way to do it, I would expect it to be in the DiagramObject class, but there doesn't seem to be much in there except position and z-order properties.

I guess I will just have to work with what I have.

Thanks again for the help,
Kevin
Kevin Winchester

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Set Feature Visibility through Automation
« Reply #5 on: September 27, 2007, 05:28:00 am »
You can still do this, but with considerable work.

Take a look at the Set Feature Visibility function - not through automation, but via a right-click on an element using the UI.

The resulting settings affect the entire element - I don't think you can set visibility on a per-feature basis.

Now look through the back end database - try opening a copy of the project with MS Access - and see where and how this information has been stored. Once again, you'll have to parse, modify and restore the string on your own.

Please note that if the information you want is in one of the PDATA fields you have to use a workaround. The EA API can read these fields using the MiscData(x) property, but it is read-only via the API. You will have to open the database some other way and insert the updated data. You should also refresh the diagram (and perhaps the containing package) afterwards if your automation project has a visible interface.

David
No, you can't have it!