Book a Demo

Author Topic: problem with using "connectors"  (Read 4594 times)

ami

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
problem with using "connectors"
« on: January 31, 2011, 05:08:57 pm »
Hi,
using "connector" type with diagrams is useless...
I noticed that using "connectors" while building a diagram - although using the right ID's of elements in the connectors both tips- wont build the diagram.
how come?
do I have to use elements from type "diagramObject" and "diagramLinks"?
« Last Edit: January 31, 2011, 07:07:19 pm by amivaknin »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: problem with using "connectors"
« Reply #1 on: January 31, 2011, 07:38:30 pm »
Ami,

You need to make sure the connector exists between the two elements (use Element.Connectors.AddNew() to create one) and then add the elements to the diagram.
This should be done by adding DiagramObjects to the Diagram.DiagramObjects collection.
If both elements are shown on the diagram the relation between the two elements will automatically be shown.
You only need Diagram.DiagramLinks to add specific formatting to (or hide) the connectors.

If you post your code it will be easier for us to help you.

Geert

ami

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: problem with using "connectors"
« Reply #2 on: January 31, 2011, 07:54:40 pm »
Hi geert,

here is my code:

int rowIndex = m_DataGridViewSteps.SelectedRows[0].Index;

for (short i = 0; i < m_ListActivities[rowIndex - 1].Connectors.Count; i++)
                {
                    if (((Connector)m_ListActivities[rowIndex - 1].Connectors.GetAt(i)).ClientID != m_ListActivities[rowIndex - 1].ElementID)// if the connector is not pointing to m_ListActivities[rowIndex - 1]
                    {
                        ((Connector)m_ListActivities[rowIndex - 1].Connectors.GetAt(i)).ClientID = m_ListActivities[rowIndex + 1].ElementID;// skip and connect to next one

                        ((Connector)m_ListActivities[rowIndex - 1].Connectors.GetAt(i)).Update();

                        break;
                    }
                }
                for (short i = 0; i < m_ListActivities[rowIndex].Connectors.Count; i++)
                {
                    if (((Connector)m_ListActivities[rowIndex].Connectors.GetAt(i)).SupplierID == m_ListActivities[rowIndex].ElementID)
                    {
                        m_ListActivities[rowIndex].Connectors.DeleteAt(i, true);// delete the connector pointing out from selected element

                        break;
                    }
                }

                m_DataGridViewSteps.Rows.RemoveAt(rowIndex);// remove from grid

                for (short i = 0; i < m_ElemUseCase.Elements.Count; i++)
                {
                    if (m_ListActivities[rowIndex].ElementGUID == ((Element)m_ElemUseCase.Elements.GetAt(i)).ElementGUID)
                    {
                        m_ElemUseCase.Elements.DeleteAt(i, true);// remove element from tree

                        break;
                    }
                }
                m_ListActivities.RemoveAt(rowIndex);// remove from list


I'm using a List<> holding all the diagram elements(the diagram is for sure a chain diagram).

ami

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: problem with using "connectors"
« Reply #3 on: February 06, 2011, 05:46:17 pm »
anyone? help?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: problem with using "connectors"
« Reply #4 on: February 07, 2011, 06:46:04 pm »
Ami,

I'm seeing your code now, but I still don't know what you want it to do, and where the problem is.

Geert

ami

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: problem with using "connectors"
« Reply #5 on: February 07, 2011, 07:08:06 pm »
Geert,

this job is done...
my problem is that:
I have an array<> holding all my elements, (the array represents a diagram shaped like a linked list).
I'm trying to add new element to the diagram and getting some exception

"The server threw an exception. (exception from HRESULT: 0x80010105(RPC_E_SERVERFAULT))."

and the code is:

Element newElem = (Element)m_ElemUseCase.Elements.AddNew("NewElement", "Activity");
newElem.Update();
Connector con2 = (Connector)newElem.Connectors.AddNew("Con", "Transition");//create connector from new element to one below
con2.ClientID = m_ListActivities[rowIndex].ElementID;
con2.SupplierID = m_ListActivities[rowIndex + 1].ElementID;
con2.Update();



from some reason this exception raises...
can you halp me with this problem?

thanks!