//---------------------------------------------------------------------------------------------
        // updateActionParameter(EA.Repository rep, EA.Element actionPin)
        //---------------------------------------------------------------------------------------------
        public static bool UpdateActionPinParameter(EA.Repository rep, EA.Element action)
        {
            foreach (EA.Element actionPin in action.EmbeddedElements)
            {
                // pin target for the return type of the action
                if (actionPin.Name == "target")
                {
                    //// return type
                    //Int32 parTypeID = Util.getTypeID(rep, m.ReturnType);
                    //if (parTypeID != 0)
                    //{
                    //    //pin.Name = par.
                    //    pin.ClassfierID = parTypeID;
                    //    EA.Element el = rep.GetElementByID(parTypeID);
                    //    pin.Update(); // do it before update table
                    //    Util.setElementPDATA1(rep, pin, el.ElementGUID);// set PDATA1

                    //}
                }
                else
                {
                    // get type of synchronized parameter
                    // if parameter isn't synchronized it will not work
                    string type = Util.GetParameterType(rep, actionPin.ElementGUID);
                    if (type == "")
                    {
                        string txt = "No type is available for action:'" + action.Name + "'";
                        rep.WriteOutput("ifm_addin", txt, 0);
                    }
                    else
                    {
                        Int32 parTypeId = Util.GetTypeId(rep, type);
                        if (parTypeId != 0)
                        {
                            //pin.Name = par.
                            EA.Element el = rep.GetElementByID(parTypeId);
                            Util.SetElementPdata1(rep, actionPin, el.ElementGUID);// PDATA1 setzen
                        }
                    }
                }
            }

            return true;
        }
예제 #2
0
파일: MyAddin.cs 프로젝트: jotab/add_in
        //
        private void showProperties(EA.Repository repository)
        {
            outputTabActive(repository);
            repository.WriteOutput(OUTPUT_NAME, "Tags created:\n", 0);
            Diagram dia = repository.GetCurrentDiagram();
            for (short i = 0; i < dia.DiagramLinks.Count; i++)
            {
                DiagramLink diaLink = dia.DiagramLinks.GetAt(i);
                Connector con = repository.GetConnectorByID(diaLink.ConnectorID);

            }

            /*foreach (Package model in repository.Models)
             repository.WriteOutput(OUTPUT_NAME, "\n\nName of all Elements: ", 0);
                    foreach (Element element in package.Elements)
                    {
                        repository.WriteOutput(OUTPUT_NAME, element.Name, 0);
                    }
                }
            }*/
        }
        public static bool GetLatest(EA.Repository rep, EA.Package pkg, bool recursive, ref int count, int level, ref int errorCount)
        {
            if (pkg.IsControlled)
            {
                level = level + 1;
                // check if checked out

                string path = GetVccFilePath(rep, pkg);
                string fText;
                //rep.WriteOutput("Debug", "Path:" + pkg.Name + path, 0);
                var sLevel = new string(' ', level * 2);
                rep.WriteOutput("Debug", sLevel + (count+1).ToString(",0") + " Work for:" + path, 0);
                if (path != "")
                {
                    count = count + 1;
                    rep.ShowInProjectView(pkg);
                    // delete a potential write protection
                    try
                    {
                        var fileInfo = new FileInfo(path);
                        var attributes = (FileAttributes)(fileInfo.Attributes - FileAttributes.ReadOnly);
                        System.IO.File.SetAttributes(fileInfo.FullName, attributes);
                        System.IO.File.Delete(path);
                    }
                    catch (FileNotFoundException e)
                    {
                        fText = path + " " + e.Message;
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }
                    catch (DirectoryNotFoundException e)
                    {
                        fText = path + " " + e.Message;
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }
                    // get latest
                    try
                    {
                        // to make sure pkg is the correct reference
                        // new load of pkg after GetLatest
                        string pkgGuid = pkg.PackageGUID;
                        pkg.VersionControlGetLatest(true);
                        pkg = rep.GetPackageByGuid(pkgGuid);
                        count = count + 1;
                    }
                    catch
                    {
                        fText = path + " " + pkg.GetLastError();
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }

                }
                else
                {
                    fText = pkg.XMLPath + " invalid path";
                    rep.WriteOutput("Debug", fText, 0);
                    errorCount = errorCount + 1;

                }
            }

            //rep.WriteOutput("Debug", "Recursive:" +recursive.ToString(), 0);
            if (recursive)
            {
                //rep.WriteOutput("Debug","Recursive count:" + pkg.Packages.Count.ToString(), 0);
                // over all contained packages
                foreach (EA.Package pkgNested in pkg.Packages)
                {
                    //rep.WriteOutput("Debug", "Recursive:"+ pkgNested.Name, 0);
                    GetLatest(rep, pkgNested, true, ref count, level, ref errorCount);

                }
            }
            return true;

        }
예제 #4
0
파일: Main.cs 프로젝트: razr/ea-audio
        // Called when user makes a selection in the menu.
        // This is your main exit point to the rest of your Add-in
        public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
        {
            switch( ItemName )
            {
                case "&Audio Configuration":

                    String writerString;

                    writerString = "Please select an audio diagram";

                    Repository.CreateOutputTab("Audio Configuration");
                    Repository.EnsureOutputVisible("Audio Configuration");
                    Repository.ClearOutput("Audio Configuration");

                    /* works on currently selected diagram */

                    if (Repository.GetTreeSelectedItemType() == EA.ObjectType.otDiagram)
                    {
                        EA.Diagram theDiagram;

                        theDiagram = (EA.Diagram)Repository.GetTreeSelectedObject();
                        writerString = "Name = " + theDiagram.Name.ToString() + " " + theDiagram.Type.ToString() + System.Environment.NewLine;
                        Repository.WriteOutput("Audio Configuration", writerString, 0);

                        foreach (EA.DiagramObject theDiagramObject in theDiagram.DiagramObjects)
                        {
                            EA.Element theElement = Repository.GetElementByID(theDiagramObject.ElementID);

                            /* consider only instances */
                            if (theElement.ClassfierID != 0)
                            {
                                // get classifier, in our case it is sink or source classes
                                EA.Element theClassfierElement = Repository.GetElementByID(theElement.ClassfierID);

                                writerString = theElement.Name.ToString() + " " + theClassfierElement.Name.ToString();
                                //writerString = theDiagramObject.ObjectType.ToString() + System.Environment.NewLine;
                                Repository.WriteOutput("Audio Configuration", writerString, 0);

                                writerString = theElement.RunState;
                                Repository.WriteOutput("Audio Configuration", writerString, 0);

                                // parse embedded elements
                                foreach (EA.Element theEmbeddedElement in theElement.EmbeddedElements)
                                {
                                    writerString = "\t" + theEmbeddedElement.Name.ToString();
                                    Repository.WriteOutput("Audio Configuration", writerString, 0);
                                    foreach (EA.Connector theConnector in theEmbeddedElement.Connectors)
                                    {
                                        writerString = "\t\t" + theConnector.Name.ToString();
                                        Repository.WriteOutput("Audio Configuration", writerString, 0);
                                    }
                                }
                            }
                        }
                    }

                    break;
                case "&Menu2":

                    break;
                case "About...":
                    Form1 anAbout = new Form1();
                    anAbout.ShowDialog();
                    break;
            }
        }
        public static string GetVccRootPath(EA.Repository rep, EA.Package pkg)
        {
            string rootPath = "";
            var pattern = new Regex(@"VCCFG=[^;]+");
            Match regMatch = pattern.Match(pkg.Flags);
            if (regMatch.Success)
            {
                // get VCCFG
                var uniqueId = regMatch.Value.Substring(6);
                // get path for UiqueId
                Environment.CurrentDirectory = Environment.GetEnvironmentVariable(@"appdata");
                string s1 = @"Sparx Systems\EA\paths.txt";
                TextReader tr = new StreamReader(s1);
                string line = "";
                pattern = new Regex(@"(id=" + uniqueId + @").+(path=[^;]+)");
                while ((line = tr.ReadLine()) != null)
                {

                    regMatch = pattern.Match(line);
                    if (regMatch.Success)
                    {
                        rootPath = regMatch.Groups[2].Value;
                        rootPath = rootPath.Substring(5);
                        break;
                    }
                }
                tr.Close();
                if (rootPath == "")
                {
                    rep.WriteOutput("Debug", "VCCFG=... not found in" + s1 + " " + pkg.Name, 0);
                }
                return rootPath;
            }            
            else
            {
                rep.WriteOutput("Debug", "VCCFG=... not found:" + pkg.Name, 0);
                return "";
            }

        }