Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: MrArvidsson on August 11, 2016, 05:40:52 pm
-
Hi hive mind!
I have a massive number of connectors where I need to change the label visibility for parts of the labels. (Note that I'm restricted by being in an add-on free v12 environment for this effort.)
Is there a way to change the default?
Is there a way to change the setting project-wide?
What's your recommendation for doing mass changes of (for example) Middle Bottom Label visibility?
-
I guess the best approach is to write a script doing that for you, where admittedly I don't know what you mean by "visibility for parts of the labels".
q.
-
Mass changes are often easiest (and fastest) by executing update queries in the database.
I'm not sure about the default settings. You should certainly check what you can do with the template package too.
Geert
-
What connectors are they? The middle bottom label usually shows the stereotype. If it's one of your own stereotypes, you can add a shape script to hide or change the label, and the shape script will be applied for all connectors with the same stereotype. Something like
label middlebottomlabel
{
print("");
}
-
Thank you for the feedback! Appreciate you taking the time to share your knowledge.
Mostly it's for the Information Flow connector to hide/show the <flow> stereotype. It would be very handy to be able to toggle, but I'd settle for hiding it.
I'll see if I can get direct access to the DB to do this as a SQL-update.
-
I guess you'll have a hard time with a pure SQL. You need to locate
LMT=CX=...:CY=...:<etc>:HDN=0:<etc>;in t_diagramlinks.geometry and replace then HDN=0 with HDN=1. So it's a string between LMT= and the next semicolon where you need to change the HDN attribute.
q.
-
I guess you'll have a hard time with a pure SQL. You need to locate
LMT=CX=...:CY=...:<etc>:HDN=0:<etc>;in t_diagramlinks.geometry and replace then HDN=0 with HDN=1. So it's a string between LMT= and the next semicolon where you need to change the HDN attribute.
q.
Not easy, but I've done more complicated stuff with SQL in the past.
If you don't have direct DB access you can still use Repository.Execute(SQLString) in a script.
Geert
-
Mostly it's for the Information Flow connector to hide/show the <flow> stereotype.
<<flow>> is a keyword, not a stereotype. It's a necessary part of the UML syntax. If you hide it, how will you distinguish an information flow from a dependency?
-
Mostly it's for the Information Flow connector to hide/show the <flow> stereotype.
<<flow>> is a keyword, not a stereotype. It's a necessary part of the UML syntax. If you hide it, how will you distinguish an information flow from a dependency?
Could you make the text colour the same as the background colour via a script or other mechanism?
-
You can change them all on a diagram using a script, see http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1398959952/9#9 which covers this. The script toggles them, but you could change it to always hide the information.
-
Mostly it's for the Information Flow connector to hide/show the <flow> stereotype.
<<flow>> is a keyword, not a stereotype. It's a necessary part of the UML syntax. If you hide it, how will you distinguish an information flow from a dependency?
Thank you for clarifying my sloppy wording. The client wants to hide the keyword when sharing Information Flow Diagrams with business people in the organization because the keyword just creates clutter in the diagram that doesn't give value to the target audience.
If we can't make it a toggle it's considered a reasonable casulty turn if off permanently and for diagram workers to have to check closer, compared to the value of ease of reading for diagram consumers.
-
If you refer to my posting above then, it sounds like two scripts, one to turn the label off and one to the label on would help you. In addition if you want to apply to multiple diagrams then depending on how many, you might want to make the script navigate the model and select all diagrams of the appropriate type.
There is a bit of a learning curve to scripting but it is worthwhile in the longer term.
PS - If you are new to scripting then create a dummy model to learn scripting - get the script working as you want and then use on the master model (and possibly take a copy first as a backup plan).
-
Okay so making the scripts to turn middle label on and off in a single diagram is done, tested, validated and deployed. Thanks for all the help with this!
Next layer of time saving would be to with the same aim (hide the label) address all diagrams in the structure. Either model wide, or from one package and everything under it.
Does anyone know of or have an example script that does pretty much anything with the diagrams in the model, or under a package? It would be immensely helpful.
Cheers,
Anders
-
Depends on what you need and the way you're on. Package.Diagrams and Element.Diagrams give you the respective API so you can deal with them.
q.
-
The script below will hide labels in a diagram depending on which flags are chosen:
option explicit
!INC Local Scripts.EAConstants-VBScript
' Script Name: LabelVisibility
' Author: Rupert Ryan
' Purpose: Changes label visibility across all diagram objects
' Date: 19/02/2018
'
Dim LLB 'Label Left (source) Bottom Source Role
Dim LLT 'Label Left (source) Top Source Multiplicity
Dim LMT 'Label Middle Top Name
Dim LMB 'Label Middle Bottom Stereotype
Dim LRT 'Label Right (dest) Top Dest Role
Dim LRB 'Label Right (dest) Bottom Dest Multiplicity
Dim IRHS 'Information Flows realized (dest)
Dim ILHS 'Information Flows realized (source)
LLB = 1
LLT = 0
LMT = 1
LMB = 1
LRT = 1
LRB = 1
IRHS = 1
ILHS = 1
dim geometryupdate
Dim hidden
Sub diagramconnector()
Dim currentDiagram
Set currentDiagram = repository.GetCurrentDiagram()
Dim diagramlink
Dim j
Dim diagramlinks As EA.Collection
Dim dirty
dirty = false
If currentDiagram.diagramlinks.Count > 0 Then
For j = 0 To currentDiagram.diagramlinks.Count - 1
Set diagramlink = currentDiagram.diagramlinks.GetAt(j)
labellist (diagramlink.geometry)
diagramlink.geometry = geometryupdate
diagramlink.Update
dirty = true
Next
End If
if dirty then
repository.ReloadDiagram currentDiagram.DiagramID
end if
End Sub
Sub labellist(geometry)
Dim strArray
Dim intCount
strArray = Split(geometry, ";")
For intCount = LBound(strArray) To UBound(strArray)
hidden = InStr(1, Trim(strArray(intCount)), "HDN")
If Not hidden = 0 Then
strArray(intCount) = labelhide(Trim(strArray(intCount)),hidden)
geometryupdate = Join(strArray, ";")
Else
End If
Next
End Sub
Function labelhide(label,hidden)
Dim strArray
Dim intCount
strArray = Split(label, ":")
Dim toggle
toggle = Mid(label, hidden + 4, 1)
Select Case Mid(strArray(0), 1, 4)
Case "$LLB"
toggle = LLB
Case "LLT="
toggle = LLT
Case "LMT="
toggle = LMT
Case "LMB="
toggle = LMB
Case "LRT="
toggle = LRT
Case "LRB="
toggle = LRB
Case "IRHS"
toggle = IRHS
Case "ILHS"
toggle = ILHS
End Select
labelhide = replace(label, Mid(label, hidden + 4, 1), toggle)
End Function
diagramconnector
Thanks,
Rupert