Book a Demo

Author Topic: Display linked files in diagrams  (Read 3931 times)

Rouven

  • EA User
  • **
  • Posts: 48
  • Karma: +0/-0
    • View Profile
Display linked files in diagrams
« on: December 17, 2013, 08:52:14 pm »
Hello everyone,

my project is currently experimenting with linking files to certain model elements, e.g. CSV files that show an actual data load for a table modeled in EA. What I have found so far is (1) the navigation to the files using the property dialogs, and (2) the possibility to include this file link as a separate tab on the object details in HTML documentation.

My question now is towards a more visual approach. What myself and also the model consumers welcomed so far is if they can use the diagrams to navigate the entire model. So my question at this point is: is there an automated or scriptable way to visualize and maybe even open the linked files on/from the (e.g. class) diagrams? I could not find something like a files compartment, nor did I find a chance to link to the file with a hyperlink unless repeating the entire file link.

Do you have any suggestions?

Thanks in advance & happy holidays,
best regards
Rouven

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Display linked files in diagrams
« Reply #1 on: December 17, 2013, 09:12:29 pm »
Hi,

make a browser script and you have the specification at the right mouse.

Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

' ---------------------------------------------------------------
' Show specification
' ---------------------------------------------------------------
' Browser, Diagram, Model Search
' ---------------------------------------------------------------
' Display files\web addresses according to the file property of an element (instance, class, port,..).
' If the classifier has a type it also outputs the type of the classfier.
' ---------------------------------------------------------------
' 13.02.2013 Created
'
' Diagram Script main function
'
sub OnDiagramScript()

      dim selectedElement as EA.Element ' to use intelli sense for Element
      dim classifier As EA.Element ' to use intelli sense for Element
      dim el As EA.Element
      
      dim file As EA.File
      dim filename
    dim err
      dim id      
      dim guid

    ' Get context element
      Set selectedElement = Repository.GetContextObject()
      
      dim objShell
      Set objShell = CreateObject( "WScript.Shell" )

      ' Element selected
      if not selectedElement is nothing AND selectedElement.ObjectType = otElement then

            display(selectedElement) ' Display all files of element
      end if
      ' Element Type = Package  (don't works, because package don't support .Files)
      'if not selectedElement is nothing AND selectedElement.ObjectType = otPackage then
      '      display(selectedElement) ' Display all files of element
      'end if
      
      if not selectedElement is nothing AND selectedElement.ObjectType = otElement then
            ' if type exists check this type also for embedded elements (Instance, Object, Port)
            id = selectedElement.ClassfierID
            if id > 0 then
               set classifier = Repository.GetElementByID(id)
               display(classifier) ' Display all files of element
            end if
            ' if type exists check this type also (Instance, Object, Port)
            guid = selectedElement.MiscData(0)
            if  Len(guid) = 38 then
               set classifier = Repository.GetElementByGuid(guid)
               display(classifier) ' Display all files of element
          end If
      end if
      
      

end sub

'----------------------------------------------------------------
' display the files of the classifier
'----------------------------------------------------------------
sub display(classifier)
      dim file As EA.File
      
      dim objShell
      dim filename
      Set objShell = CreateObject( "WScript.Shell" )
      for each file in classifier.Files
              filename = """" & file.Name & """"
              err = objShell.run( filename,1,false )
              if err <> 0 then
                  Session.Output "Filename:" & filename & "  " & err
              End If
      next
      Set objShell = Nothing

end sub
OnDiagramScript


Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Rouven

  • EA User
  • **
  • Posts: 48
  • Karma: +0/-0
    • View Profile
Re: Display linked files in diagrams
« Reply #2 on: December 18, 2013, 04:38:41 am »
Hi Helmut,

thank you very much for your input, it looks like a feasible way to launch the files, which is already helpful.
My other concern was whether I could somehow display the filename on the diagram, similar to enabling the constraint feature and making constraints visible. If anybody has some input on that, that would be great!

Best regards,
Rouven

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Display linked files in diagrams
« Reply #3 on: December 18, 2013, 06:19:40 am »
Hi Rouven,

it should be possible by shape script.

Personally I would just indicate that there is/are files/web addresses to link to. Linked documents are a good example to visualize that there is at least one link available.

I would also consider another way. Use EA artifacts to store links to files/web address. Link these elements to the elements you want to document (e.g. a <<dependency>>). This has the  following advantages:
  • You see which element has a link to a document
  • With alias and keywords you may create powerful searches for documents (part of alias / keyword)
  • The search you can put in a diagram to get the results by a simple click (all documents for subsystem A, ..)

With that you can use EA as an integration platform for requirements and a lot more.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)