Book a Demo

Author Topic: Show/Hide Namespace in Diagram  (Read 7418 times)

Earnfried

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Show/Hide Namespace in Diagram
« on: January 07, 2020, 09:30:49 pm »
Hello everybody & happy new year!

I'm trying to toggle following diagram property via script: Diagram -> Properties -> Diagram: Appearance: Show Namespace.
I took a look into ExtendedStyle and StyleEx of the Diagram but couldn't find a difference in the strings. I found out when i check the property: "Fully Qualified Namespace" in the string "ShowFQN=1" appears.

In a different topic i found a hint to hide the namespace with using a template/mdg. This i good to prevent this for further diagrams. I started doing that, but I don't now what is the Attribute Name so i wasn't able to continue there too.

Any ideas?

Best regards

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Show/Hide Namespace in Diagram
« Reply #1 on: January 07, 2020, 09:44:45 pm »
The best way to find out is to start a profiler that catches all SQL commands to the database.
Then make the change, and inspect the SQL commands

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #2 on: January 07, 2020, 09:49:36 pm »
Not sure about the question, but ShowFQN=1 turns it on and ShowFQN=0 turns it off. Diagrams need to be closed/opened (eventually a reload will also do) after applying the change.

q.

Earnfried

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #3 on: January 07, 2020, 11:22:05 pm »
Hello and thanks for the fast reply!

@qwerty
My algorithm which is toggling ShowFQN=1/0 is working. Im reloading the diagram afterwards and i can see the changes. The problem is that this tag only toggles the Fully Qualified Namespace and not the Namespace.

@Geert
Alright. Any tool suggestions? I have the .EAP and no SQL Server setup.

Best regards


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Show/Hide Namespace in Diagram
« Reply #4 on: January 08, 2020, 01:18:08 am »
Tool suggestions? MS SQL Server

There is a free edition available for download from Microsoft.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #5 on: January 08, 2020, 01:38:37 am »
Hi Earnfried, and welcome to the forum.

Also, welcome to the wonderful world of EA hacking. Please check your sense of logic at the door.


If you're building an MDG Technology, you can right-click your custom diagram type (the one with the «stereotype» stereotype, not the «metaclass» one) and select Edit with Profile Helper. The profile helper allows you to set the various properties without having to know what the corresponding attributes are called.

Unfortunately, there's no option to specify "Show Namespace" in the profile helper. This probably means you can't specify this in an MDG Technology, but you could try a couple of likely-sounding attribute names and see if one works. You might get lucky.


Looking in the API, the ShowFQN sub-property of Diagram.StyleEx (as opposed to Diagram.ExtendedStyle, of course) corresponds to the "Fully Qualified Namespace" option in the diagram properties dialog, as you've observed.

However, the main option "Show Namespace" is not in Diagram.StyleEx but has its own property in the Diagram object: it's Diagram.HighlightImports. This isn't obvious, but it is actually mentioned in the API documentation. (The reason I bring it up is not to say RTFM but rather to remark on the fact that this particular idiosyncracy is documented -- this is not the norm when dealing with EA.)

Here's a simple diagram-context script you can use to check some diagram properties. You can add the others if you're interested, they're all listed on the page I linked above.
Code: (VBScript) [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

sub OnDiagramScript()
dim diagram as EA.Diagram
set diagram = Repository.GetCurrentDiagram()

if not diagram is nothing then
Repository.EnsureOutputVisible("Script")
Session.Output "HighlightImports: " & diagram.HighlightImports
Session.Output "ExtendedStyle: " & diagram.ExtendedStyle
Session.Output "StyleEx: " & diagram.StyleEx
else
Session.Prompt "This script requires a diagram to be visible", promptOK
end if
end sub

OnDiagramScript

One thing you may notice is that if you run this script in a completely new diagram, the complex properties are empty. EA doesn't fill them in until you change something in the diagram (eg add an element).

Why? Well, because.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #6 on: January 08, 2020, 04:59:39 am »
@qwerty
My algorithm which is toggling ShowFQN=1/0 is working. Im reloading the diagram afterwards and i can see the changes. The problem is that this tag only toggles the Fully Qualified Namespace and not the Namespace.


Not sure how you would do that manually. Can you show/hide the namespace manually somehow at all?

q.

pvickers

  • EA User
  • **
  • Posts: 44
  • Karma: +7/-0
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #7 on: January 09, 2020, 04:58:09 am »
Building on the earlier content in this thread regarding profiling SQL commands...

In addition to SQL Server, I have set up SQL profiling using PostgreSQL. (I use PostgreSQL for my Sparx EA repository.)

If you are working with an environment you control, simply edit the postgresql.conf file to set the log_statement parameter:
Log_statement = ‘all’ (default is none…it will generally be commented out in the configuration file.)

After restarting PostgreSQL the new setting will be effective.
From this point, all SQL will be captured and saved to the postgresql log file.

But be aware this could generate a great deal of output to the log on a very active system.

Regards,
Perry



Earnfried

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #8 on: January 13, 2020, 09:37:16 pm »
Hi Earnfried, and welcome to the forum.

Also, welcome to the wonderful world of EA hacking. Please check your sense of logic at the door.


If you're building an MDG Technology, you can right-click your custom diagram type (the one with the «stereotype» stereotype, not the «metaclass» one) and select Edit with Profile Helper. The profile helper allows you to set the various properties without having to know what the corresponding attributes are called.

Unfortunately, there's no option to specify "Show Namespace" in the profile helper. This probably means you can't specify this in an MDG Technology, but you could try a couple of likely-sounding attribute names and see if one works. You might get lucky.


Looking in the API, the ShowFQN sub-property of Diagram.StyleEx (as opposed to Diagram.ExtendedStyle, of course) corresponds to the "Fully Qualified Namespace" option in the diagram properties dialog, as you've observed.

However, the main option "Show Namespace" is not in Diagram.StyleEx but has its own property in the Diagram object: it's Diagram.HighlightImports. This isn't obvious, but it is actually mentioned in the API documentation. (The reason I bring it up is not to say RTFM but rather to remark on the fact that this particular idiosyncracy is documented -- this is not the norm when dealing with EA.)

Here's a simple diagram-context script you can use to check some diagram properties. You can add the others if you're interested, they're all listed on the page I linked above.
Code: (VBScript) [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

sub OnDiagramScript()
dim diagram as EA.Diagram
set diagram = Repository.GetCurrentDiagram()

if not diagram is nothing then
Repository.EnsureOutputVisible("Script")
Session.Output "HighlightImports: " & diagram.HighlightImports
Session.Output "ExtendedStyle: " & diagram.ExtendedStyle
Session.Output "StyleEx: " & diagram.StyleEx
else
Session.Prompt "This script requires a diagram to be visible", promptOK
end if
end sub

OnDiagramScript

One thing you may notice is that if you run this script in a completely new diagram, the complex properties are empty. EA doesn't fill them in until you change something in the diagram (eg add an element).

Why? Well, because.

HTH,


/Uffe

Uffe! Thank you alot!!! Actually I'm embarrassed because i read through the documentation and did not see this part, but it is exactly what i was searching for. It's is also good to know that the complex diagrams properties are empty in a new created diagram.



Not sure how you would do that manually. Can you show/hide the namespace manually somehow at all?

q.

You can toggle the Namespace manually in the diagram properties. Via script it is very easy to toggle since Uffe told us there is the 'HighlightImports' attribut.
Toggling the Fully Qualified Namespace is manually toggable in the diagram properties at the same place as the Namespace. To toggle disable or toggle it via script needs an adaption of the Extended Style string (as shown in the code below)

Code: [Select]
function DisableEStereotypeInDiagram()
{
    var currentDiagram as EA.Diagram;
    currentDiagram = Repository.GetCurrentDiagram();

    if (currentDiagram != null) {
var extendedStyle = currentDiagram.ExtendedStyle;

if(extendedStyle.includes('HideEStereo')){
extendedStyle = extendedStyle.replace(/\bHideEStereo=\b\d/g, 'HideEStereo=1');
} else {
extendedStyle += 'HideEStereo=1;';
}

currentDiagram.ExtendedStyle = extendedStyle;
currentDiagram.Update;
Repository.ReloadDiagram(currentDiagram.DiagramID);
}
}

The code is about hiding the Fully Qualified Namespace and makes use of an Javascript Polyfill:

Code: [Select]
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number')
  start = 0;

if (start + search.length > this.length)
  return false;
else
  return this.indexOf(search, start) !== -1;
};

Building on the earlier content in this thread regarding profiling SQL commands...

In addition to SQL Server, I have set up SQL profiling using PostgreSQL. (I use PostgreSQL for my Sparx EA repository.)

If you are working with an environment you control, simply edit the postgresql.conf file to set the log_statement parameter:
Log_statement = ‘all’ (default is none…it will generally be commented out in the configuration file.)

After restarting PostgreSQL the new setting will be effective.
From this point, all SQL will be captured and saved to the postgresql log file.

But be aware this could generate a great deal of output to the log on a very active system.

Regards,
Perry




Thanks Perry for your input here. The problem is that I don't have a SQL Server running. I'm just working with the .EAP file and have to set this up. I will take a look when I have some spare time left.

Thanks to all of you!

Best regards

Earnfried

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Show/Hide Namespace in Diagram
« Reply #9 on: January 14, 2020, 12:48:39 am »
t_diagram.showforeign is the other tickmark.

q.