Book a Demo

Author Topic: Connector not visible in other diagrams [solved]  (Read 5004 times)

misterk

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Connector not visible in other diagrams [solved]
« on: April 19, 2013, 01:11:04 am »
Hello,

I'm using Java to create Elements and Connector in a package and in a diagram.

This is working fine.

When I open the model with EA, I can see my components and the link between them.

But when I'm in EA (version 9.3), something is not working:
In fact, when I create a new diagram, and drag and drop my two components in the new diagram. The components are well shown, but the link is not there.

When I'm under the diagram created with java, I can see in the properties "Related/Links" of the elements that I'm able to see a menu option called "Hide Relation".
This option is not there when I'm in the diagram created with EA.

-----------

The structure of the tree of Project Browser looks like this:
Model (created with java)
- Package 1 (created with java)
  - Package 11 (created with java)
    - Diagram 1 (created with java)
    - Diagram 2 (created with EA)
    - component A (created with java)
    - component B (created with java)

component A and B are visible in Diagram 1 and 2.
A link (an assembly relationship) is created and visible in diagram 1, but not in diagram 2.

----

Code: [Select]
       Element sourceElement = FindElement(source.getName(), p);
        Element destinationElement = FindElement(destination.getName(), p);
          
        Connector connector = sourceElement.GetConnectors().AddNew("", "Assembly");
          
        connector.SetName(linkName);
        connector.SetSupplierID(sourceElement.GetElementID());
        connector.SetClientID(destinationElement.GetElementID());        
        connector.SetDiagramID(diagram.GetDiagramID());
        connector.Update();
        sourceElement.Refresh();
        destinationElement.Refresh();        
        p.GetConnectors().Refresh();
        
        DiagramLink diagramLink = diagram.GetDiagramLinks().AddNew("", "");
        diagramLink.SetConnectorID(connector.GetConnectorID());
        diagramLink.SetDiagramID(diagram.GetDiagramID());
        diagramLink.SetIsHidden(false);
        diagramLink.Update();        
                
        diagram.GetDiagramLinks().Refresh();
        diagram.Update();

---
When I export the diagrams in XML :

I have something different with the link created through java, that if I do it directly with EA.

it's:
Code: [Select]
<extendedProperties virtualInheritance="0" diagram="EAID_47AD417E_1566_4a1a_AD9F_044E03D0A165" privatedata5="EDGE=4;SX=35;SY=13;EX=35;EY=13;"/>

from:
Code: [Select]
<connector xmi:idref="EAID_DF7A2A95_49FE_40a1_833F_F3730877F11C">
      <source xmi:idref="EAID_58E24A71_430A_440f_838E_70A82B15F12A">
            <model ea_localid="4" type="Component" name="composant B"/>
            <role visibility="Public" targetScope="instance"/>
            <type aggregation="none" containment="Unspecified"/>
            <constraints/>
            <modifiers isOrdered="false" changeable="none" isNavigable="false"/>
            <style value="Navigable=Unspecified;Union=0;Derived=0;AllowDuplicates=0;Owned=0;"/>
            <documentation/>
            <xrefs/>
            <tags/>
      </source>
      <target xmi:idref="EAID_C9DAE6DC_167D_4e21_BFC9_915116491B30">
            <model ea_localid="3" type="Component" name="composant A"/>
            <role visibility="Public" targetScope="instance"/>
            <type aggregation="none" containment="Unspecified"/>
            <constraints/>
            <modifiers isOrdered="false" changeable="none" isNavigable="true"/>
            <style value="Navigable=Navigable;Union=0;Derived=0;AllowDuplicates=0;Owned=0;"/>
            <documentation/>
            <xrefs/>
            <tags/>
      </target>
      <model ea_localid="1"/>
      <properties ea_type="Assembly" direction="Source -&gt; Destination"/>
      <documentation/>
      <appearance linemode="3" linecolor="-1" linewidth="0" seqno="0" headStyle="0" lineStyle="0"/>
      <labels mt="lien"/>
      <extendedProperties virtualInheritance="0" diagram="EAID_47AD417E_1566_4a1a_AD9F_044E03D0A165" privatedata5="EDGE=4;SX=35;SY=13;EX=35;EY=13;"/>
      <style/>
      <xrefs/>
      <tags/>
</connector>

when I replace that line with :
Code: [Select]
<extendedProperties virtualInheritance="0" />
and import it back in EA, my link is working again.

So I would like to know what I've done wrong (or not done) in Java so that I have this extendedProperties that makes my link not visible in other diagrams, and not even able to change that through EA.

Thanks in advance for any help on this.
Regards,
Kevin


« Last Edit: April 22, 2013, 11:19:18 pm by misterk »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector not visible in other diagrams
« Reply #1 on: April 19, 2013, 05:10:12 am »
The only thing that helps is to issue a Repository.RefreshModelView(0). This will reload the entire model showing the new connectors. Unfortunately it forces a save for all changed diagrams and you are asked to save for each of them. RefreshOpenDiagrams did not seem to have any effect.

q.

misterk

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connector not visible in other diagrams
« Reply #2 on: April 19, 2013, 08:09:38 pm »
Thanks for your answer.
It helped me with another bug actually, yet my main issue is not solved.

I've tried to create (in java) two elements connected with a connector in two different diagrams.

Yet I'm not able to see the new diagramLink in the second Diagram.
I'm well able to see the new diagramObject of each element in the second Diagram.

Any idea?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector not visible in other diagrams
« Reply #3 on: April 19, 2013, 08:42:27 pm »
DiagramLinks are not automatically created for each visible relation diagram. Only if you modify the connector on the diagram in some way (color, style, whatever) then EA creates the DiagramLink.

Since a couple of versions the Diagram.DiagramLinks collection should be complete though. So that collection contains DiagramLinks that are not actually found in the database.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Connector not visible in other diagrams
« Reply #4 on: April 19, 2013, 09:19:12 pm »
Geert, you are right and wrong. DiagramLinks are just needed to change the individual appearance or to suppress them. If none are present, EA renders a default appearance. The issue here is that repository and diagram renderer get out of synch. I see that as a design flaw of EA (you see that directly with Undo, which is possible with diagrams, but not with elements).

misterk, I have no clue what happens there. I tried it here and a RefreshModelView works. It's the same as closing EA and opening it manually. Is the connection still invisible after reloading the project. If so, you should check the contents of t_diagramlinks. Likely there is some entry which actually suppresses the connector.

q.

misterk

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connector not visible in other diagrams
« Reply #5 on: April 19, 2013, 11:38:25 pm »
By looking at the VB examples of the SDK (I was not aware of them), I removed some code:

Code: [Select]
connector.SetClientID(destinationElement.GetElementID());        
       connector.SetDiagramID(diagram.GetDiagramID());

and also the code with the diagramLink, and now it's working.

Thanks for your help (it helped me find some documentation, so this was very helpful)! :-)