Book a Demo

Author Topic: RefactorEA  (Read 22022 times)

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: RefactorEA
« Reply #30 on: June 09, 2009, 06:13:27 am »
Quote
H
Martin:
This is an open source project...and so a partnership like yours would be immensely appreciated. Perhaps we can move to Source Forge as a source repository or something...what do you think?

I'm in a very large company, so unfortunately, it may take a couple of months till we decide to get into it (which I believe will happen) then I'll try to release the more generic parts.

I hope we get to it.
Recursion definition:
If you don’t understand the definition read "Recursion definition".

cube1us

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: RefactorEA
« Reply #31 on: June 11, 2009, 07:36:27 am »
FYI, I thru C# 2008 Express on my machine, and after discarding the FGS stuff owing to its Office dependencies to simplify things, I was able to confirm that both suggestions I had fixed the bugs I found.

Relevant code snippits:

 if (_target != null)
            {
                if (_target.ElementID == A.ElementID)
                    _source = B;
                else
                    _source = A;
            }


This fixes the problem where it said it could not merge an element onto itself.

       private void MergeConnectors()
        {

            int changed = 0;
            
            for (short i = 0; i < _source.Connectors.Count; i++)
            {
                try
                {
                    EA.Connector c = (EA.Connector)_source.Connectors.GetAt(i);

                    //  If the connector already points to the target, leave it alone,
                    //  as there might be a connector between source and target.

                    if (c.ClientID == _target.ElementID ||
                        c.SupplierID == _target.ElementID)
                        continue;


                    /*
                        EA.Connector newConnector = (EA.Connector)_target.Connectors.AddNew(c.Name, c.Type);
                     */

                    ++changed;

                    if (c.ClientID == _source.ElementID)
                    {
                        /*
                        newConnector.ClientID = _target.ElementID;
                        newConnector.SupplierID = c.SupplierID;
                         */
                        c.ClientID = _target.ElementID;
                    }
                    else if (c.SupplierID == _source.ElementID)
                    {
                        /*
                        newConnector.ClientID = c.ClientID;
                        newConnector.SupplierID = _target.ElementID;
                         */
                        c.SupplierID = _target.ElementID;
                    }

                    /*
                    _source.Connectors.DeleteAt(i, true); i--;
                    _source.Update();
                    

                    if (ShouldAddConnector(newConnector))
                        newConnector.Update();
                     */

                    c.Update();
                }
                catch
                {
                    //log and continue
                }
            }

            MessageBox.Show("Changed Elements: " + changed);

            
        }

The above makes merges successfully using the simpler method we discussed earlier, and also throws up a dialog box containing the numbrer of changes (should say changed connectors).

In brief testing, I was unable to break the merge with these chnages in place -- but I am only using the simplest of test cases.