コード例 #1
0
 private static void onTggRuleDoubleClicked(EA.Repository Repository, EA.Element doubleClickedElement)
 {
     EA.Diagram ruleDiag    = doubleClickedElement.Diagrams.GetAt(0) as EA.Diagram;
     EA.Diagram currentDiag = Repository.GetCurrentDiagram();
     if (currentDiag != null)
     {
         Navigator.addAnchorEntry(ruleDiag.DiagramID, Repository.GetCurrentDiagram().DiagramID);
         Repository.OpenDiagram(ruleDiag.DiagramID);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create Activity in Diagram context. Optionally you can pass your own diagram context.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="methodName"></param>
        /// <param name="diaContext">Context of the activity to add, the location of the passed diagram</param>
        /// <returns></returns>
        public static EA.Element CreateInDiagramContext(EA.Repository rep, string methodName, EA.Diagram diaContext = null)
        {
            EA.Element act = GetActivityFromMethodName(rep, methodName, verbose: false);
            if (act == null)
            {
                // Create Activity
                if (MessageBox.Show($"No Activity '{methodName}' exists in model.\r\n Create Activity?", "Create Activity?",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var dia = diaContext ?? rep.GetCurrentDiagram();
                    if (dia != null)
                    {
                        if (dia.ParentID > 0)
                        {
                            EA.Element parentEl = rep.GetElementByID(dia.ParentID);
                            act = (EA.Element)parentEl.Elements.AddNew(methodName, "Activity");
                            parentEl.Elements.Refresh();
                        }
                        else
                        {
                            EA.Package pkg = rep.GetPackageByID(dia.PackageID);
                            act = (EA.Element)pkg.Elements.AddNew(methodName, "Activity");
                            pkg.Elements.Refresh();
                        }

                        act.Update();
                    }
                }
            }

            return(act);
        }
コード例 #3
0
        public void EA_OnPostNewDiagramObject(EA.Repository Repository, EA.EventProperties Info)
        {
            EA.Diagram currentDiagram = Repository.GetCurrentDiagram();
            Repository.SaveDiagram(currentDiagram.DiagramID);

            int objectID = int.Parse(Info.Get(0).Value.ToString());
            // EA.Element newElement = Repository.GetElementByID(objectID);
        }
コード例 #4
0
        private void TestPropertiesDialog(EA.Repository repository)
        {
            int diagramId = repository.GetCurrentDiagram().DiagramID;

            // there is no current diagram
            if (diagramId == 0)
            {
                return;
            }
            repository.OpenDiagramPropertyDlg(diagramId);
        }
コード例 #5
0
 /// <summary>
 /// Get the current Diagram with it's selected objects and connectors.
 /// </summary>
 /// <param name="rep"></param>
 public EaDiagram(EA.Repository rep)
 {
     _rep = rep;
     _dia = _rep.GetCurrentDiagram();
     if (_dia == null)
     {
         return;
     }
     foreach (EA.DiagramObject obj in  _dia.SelectedObjects)
     {
         _selectedObjects.Add(obj);
     }
     _selectedConnector = _dia.SelectedConnector;
 }
コード例 #6
0
        public bool EA_OnContextItemDoubleClicked(EA.Repository Repository, string GUID, EA.ObjectType ObjectType)
        {
            if (ObjectType == EA.ObjectType.otConnector)// && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
            {
                EA.Connector conn = Repository.GetConnectorByGuid(GUID);

                if (goatAddinMainViewModel.EditAssociationCommand.CanExecute(conn))
                {
                    goatAddinMainViewModel.EditAssociationCommand.Execute(conn);

                    if (goatAddinMainViewModel.EditAssociationCommand.Result &&
                        (Repository.GetCurrentDiagram()?.SelectedConnector.ConnectorGUID == conn.ConnectorGUID))
                    {
                        Repository.SaveDiagram(Repository.GetCurrentDiagram().DiagramID);
                        Repository.ReloadDiagram(Repository.GetCurrentDiagram().DiagramID);
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
ファイル: EAUtil.cs プロジェクト: SvenPeldszus/emoflon-tool
        /// <summary>
        /// deletes the connector con
        /// </summary>
        /// <param name="con"></param>
        /// <param name="Repository"></param>
        public static void deleteConnector(EA.Connector con, EA.Repository Repository)
        {
            EA.Element client  = Repository.GetElementByID(con.ClientID);
            EA.Diagram actDiag = Repository.GetCurrentDiagram();
            short      i       = 0;

            foreach (EA.Connector actLink in client.Connectors)
            {
                if (actLink.ConnectorID == con.ConnectorID)
                {
                    client.Connectors.Delete(i);
                }
                i++;
            }
            Repository.ReloadDiagram(actDiag.DiagramID);
        }
コード例 #8
0
 private static Boolean handleContextItemDoubleClick(EA.Repository Repository, EA.ObjectType ot, EA.Element elem, Boolean handledByAddin)
 {
     if (ot == EA.ObjectType.otElement)
     {
         if (elem.Stereotype == SDMModelingMain.SDMAnchorStereotype)
         {
             EA.Diagram currentDiagram = Repository.GetCurrentDiagram();
             if (currentDiagram != null)
             {
                 Navigator.jumpToAnchorPredecessor(Repository, currentDiagram.DiagramID);
                 handledByAddin = true;
             }
         }
     }
     return(handledByAddin);
 }
コード例 #9
0
        public void EA_OnNotifyContextItemModified(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(Repository, false);

            EA.Diagram actDiag = Repository.GetCurrentDiagram();

            if (ot == EA.ObjectType.otElement)
            {
                EA.Element element = Repository.GetElementByGuid(GUID);
                if (element.Stereotype.ToLower() == TGGModelingMain.TggRuleStereotype.ToLower())
                {
                    onNotifyTggRuleModified(sqlRepository, element);
                }
                else if (element.Stereotype.ToLower() == TGGModelingMain.TggCorrespondenceTypeStereotype.ToLower())
                {
                    onNotifyCorrespondenceTypeModified(sqlRepository, element);
                }
            }
            if (ot == EA.ObjectType.otPackage)
            {
                EA.Package pkg = Repository.GetPackageByGuid(GUID);
                if (pkg.Element != null && pkg.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype)
                {
                    onNotifyTGGOutermostPackageModified(sqlRepository, pkg);
                }
                else if (pkg.Element.Stereotype == TGGModelingMain.TggRulePackageStereotype)
                {
                    onNotifyTGGRulePackageModified(sqlRepository, pkg);
                }
            }

            if (ot == EA.ObjectType.otConnector)
            {
                EA.Connector con = Repository.GetConnectorByGuid(GUID);
                if (actDiag != null)
                {
                    if (con.Type == ECOREModelingMain.EReferenceConnectorType && con.Stereotype == "" && actDiag.MetaType == TGGModelingMain.TggSchemaDiagramMetatype[0])
                    {
                        onNotifyEReferenceModified(sqlRepository, con);
                    }
                }
            }
        }
コード例 #10
0
        public bool EA_OnContextItemDoubleClicked(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            EALastBroadcastMethodId = EAOnContextItemDoubleClicked;
            preventCascade          = true;

            SQLRepository sqlRepository = new SQLRepository(Repository, false);

            EA.Element elem = Repository.GetElementByGuid(GUID);

            Boolean sdmContextItemDoubleClicked = sdmModeling.EA_OnContextItemDoubleClicked(Repository, GUID, ot);
            Boolean tggContextItemDoubleClicked = tggModeling.EA_OnContextItemDoubleClicked(Repository, GUID, ot);
            Boolean handledByAddin = sdmContextItemDoubleClicked || tggContextItemDoubleClicked;

            //run rulechecks if we handled the double clicked context item
            if (handledByAddin)
            {
                consistencyModule.dispatchSingleObject(Repository, GUID, ot);

                EA.Diagram currentDiagram = Repository.GetCurrentDiagram();
                if (currentDiagram != null)
                {
                    Repository.ReloadDiagram(currentDiagram.DiagramID);
                }

                preventCascade = false;



                return(true);
            }

            //general double click handling
            handledByAddin = handleContextItemDoubleClick(Repository, ot, elem, handledByAddin);

            preventCascade = false;

            return(handledByAddin);
        }
コード例 #11
0
        public bool EA_OnPreNewConnector(EA.Repository Repository, EA.EventProperties Info)
        {
            String type       = Info.Get("Type").Value.ToString();
            String stereoType = Info.Get("Stereotype").Value.ToString();

            EA.Diagram curDiag    = Repository.GetCurrentDiagram();
            int        clientId   = int.Parse(Info.Get("ClientID").Value.ToString());
            int        supplierId = int.Parse(Info.Get("SupplierID").Value.ToString());

            if (TGGModelingMain.TggSchemaDiagramMetatype.Contains(curDiag.MetaType))
            {
                if (type == "Dependency" && stereoType == "tggLink")
                {
                    createTGGLink(Repository, Info, this);
                    return(false);
                }
                else if (type == Main.EAAssociationType)
                {
                    //EA.Element client = Repository.GetElementByID(clientId);
                    EA.Element supplier = Repository.GetElementByID(supplierId);
                    if (supplier.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
                    {
                        return(false);
                    }
                }
            }
            else if (TGGModelingMain.TggRuleDiagramMetatype.Contains(curDiag.MetaType))
            {
                if (type == Main.EAAssociationType && stereoType == "tggCorrLink")
                {
                    createCorrespondenceObjectWithLinks(Repository, Info);
                    return(false);
                }
            }

            return(true);
        }
コード例 #12
0
        public void testPropertiesDialog(EA.Repository repository)
        {
            int diagramID = repository.GetCurrentDiagram().DiagramID;

            repository.OpenDiagramPropertyDlg(diagramID);
        }
コード例 #13
0
        /// <summary>
        /// Defines what happens if the user doubleclicks on SDM related Elements.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="GUID"></param>
        /// <param name="ot"></param>
        /// <returns>True if the EA Dialogs should not be openend. False if the standard EA Dialogs should be opened.
        /// </returns>
        public bool EA_OnContextItemDoubleClicked(EA.Repository repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(repository, false);

            EA.Diagram   actDiag = repository.GetCurrentDiagram();
            SQLMethod    meth    = sqlRepository.GetMethodByGuid(GUID);
            SQLElement   elem    = sqlRepository.GetElementByGuid(GUID);
            SQLConnector con     = sqlRepository.GetConnectorByGuid(GUID);

            if (actDiag != null)
            {
                if (ECOREModelingMain.EcoreDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod)
                {
                    SQLElement methParent;
                    SQLElement container;

                    if (!openSelectedMethodSDM(actDiag, meth, sqlRepository, out methParent, out container))
                    {
                        if (methParent.Stereotype == ECOREModelingMain.EClassStereotype)
                        {
                            CreateSDMDialog createSdmDialog = new CreateSDMDialog();
                            if (createSdmDialog.ShowDialog() == DialogResult.OK)
                            {
                                createStoryDiagram(meth, repository, actDiag);
                            }
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else if (SdmDiagramMetatype.Contains(actDiag.MetaType))
                {
                    repository.SaveDiagram(actDiag.DiagramID);
                    if (elem != null)
                    {
                        if (elem.Stereotype == SDMModelingMain.ObjectVariableStereotype)
                        {
                            ObjectVariable ov = new ObjectVariable(elem, sqlRepository);
                            OvDialog       objectVariableDialogue = new OvDialog(sqlRepository, ov);
                            objectVariableDialogue.ShowDialog();
                            return(true);
                        }

                        else if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype || elem.Stereotype == SDMModelingMain.StatementNodeStereotype)
                        {
                            SQLTaggedValue extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName);
                            if (extractedTag == null)
                            {
                                SQLTaggedValue oldExtractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, "evacuated");
                                if (oldExtractedTag != null)
                                {
                                    EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, oldExtractedTag.Value);
                                }
                                else
                                {
                                    EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "false");
                                }
                                extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName);
                            }

                            if (extractedTag != null && extractedTag.Value == Main.TrueValue)
                            {
                                SQLDiagram diagram = (SQLDiagram)elem.Diagrams.GetAt(0);
                                Navigator.addAnchorEntry(diagram.DiagramID, actDiag.DiagramID);
                                repository.OpenDiagram(diagram.DiagramID);
                            }
                            else
                            {
                                if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype)
                                {
                                    ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StoryNode(sqlRepository, elem), sqlRepository);
                                }
                                else if (elem.Stereotype == SDMModelingMain.StatementNodeStereotype)
                                {
                                    ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StatementNode(sqlRepository, elem), sqlRepository);
                                }
                            }
                            return(true);
                        }

                        else if (elem.Stereotype == SDMModelingMain.StopNodeStereotype)
                        {
                            StopNode     stopNode  = new StopNode(sqlRepository, elem);
                            StopNodeForm sNodeForm = new StopNodeForm(stopNode, sqlRepository);
                            return(true);
                        }

                        else if (elem.Stereotype == TGGModelingMain.CSPConstraintStereotype)
                        {
                            SDMCSPDialog sdmCspDialog = new SDMCSPDialog(elem, sqlRepository);
                            sdmCspDialog.ShowDialog();

                            return(true);
                        }
                    }
                    if (con != null)
                    {
                        if (con.Stereotype == SDMModelingMain.LinkVariableStereotype)
                        {
                            LinkVariablePropertiesForm linkVariableDialogue = new LinkVariablePropertiesForm(new LinkVariable(con, sqlRepository), sqlRepository, true);
                            return(true);
                        }
                        else if (con.Type == Main.EAControlFlowType)
                        {
                            ActivityEdge activityEdge = new ActivityEdge(sqlRepository, con);
                            ActivityEdgePropertiesForm activityEdgeDialog = new ActivityEdgePropertiesForm(activityEdge, repository);
                            return(true);
                        }
                        else if (con.Stereotype == SDMModelingMain.BindingExpressionLinkStereotype)
                        {
                            SQLElement     targetElement = sqlRepository.GetElementByID(con.SupplierID);
                            ObjectVariable ov            = new ObjectVariable(targetElement, sqlRepository);

                            OvDialog ovDialog = new OvDialog(sqlRepository, ov);
                            ovDialog.showTab(2);
                            ovDialog.ShowDialog();
                            return(true);
                        }
                    }
                    if (ot == EA.ObjectType.otDiagram)
                    {
                        EA.Diagram     diag         = (EA.Diagram)repository.GetDiagramByGuid(GUID);
                        EA.Element     activity     = null;
                        SQLTaggedValue evacuatedTag = null;
                        if (diag.ParentID != 0)
                        {
                            activity     = repository.GetElementByID(diag.ParentID);
                            evacuatedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sqlRepository.GetElementByID(activity.ElementID), Main.MoflonExtractedStoryPatternTaggedValueName);
                        }

                        if (evacuatedTag != null && evacuatedTag.Value == Main.TrueValue)
                        {
                            StoryNode            activityNode       = new StoryNode(sqlRepository, sqlRepository.GetElementByID(activity.ElementID));
                            ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(activityNode, sqlRepository);
                            return(true);
                        }
                    }
                    //sqlRepository.ReloadDiagram(actDiag.DiagramID);
                }
                else if (TGGModelingMain.TggRulesDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod)
                {
                    EA.TaggedValue aTag       = null;
                    EA.Element     methParent = repository.GetElementByID(meth.ParentID);
                    EA.Element     container  = null;
                    foreach (EA.Element sdmContainer in methParent.Elements)
                    {
                        if (sdmContainer.Stereotype == SDMModelingMain.SdmContainerStereotype)
                        {
                            aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName);
                            if (aTag.Value == meth.MethodGUID.ToString())
                            {
                                container = sdmContainer;
                                break;
                            }
                        }
                    }
                    EA.Diagram sdmDiagg = null;
                    if (container != null)
                    {
                        foreach (EA.Diagram sdmDiag in container.Diagrams)
                        {
                            sdmDiagg = sdmDiag;
                            repository.OpenDiagram(sdmDiag.DiagramID);
                            return(true);
                        }
                    }
                    if (sdmDiagg == null && container == null)  // no SDM Diagram exists
                    {
                        if (methParent.Stereotype == TGGModelingMain.TggRuleStereotype)
                        {
                            createStoryDiagram(meth, repository, actDiag);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #14
0
        /// <summary>
        /// Called when user makes a selection in the menu.
        /// This is your main exit point to the rest of your Add-in
        /// </summary>
        /// <param name="repository">the repository</param>
        /// <param name="location">the location of the menu</param>
        /// <param name="MenuName">the name of the menu</param>
        /// <param name="itemName">the name of the selected menu item</param>
        public override void EA_MenuClick(EA.Repository repository, string location, string MenuName, string itemName)
        {
            EA.Package    pkg        = null;
            EA.ObjectType oType      = repository.GetContextItemType();
            EA.Diagram    diaCurrent = repository.GetCurrentDiagram();
            EA.Connector  conCurrent = null;
            EA.Element    el         = null;


            if (diaCurrent != null)
            {
                conCurrent = diaCurrent.SelectedConnector;
            }
            switch (itemName)
            {
            case MenuAbout:
                About fAbout = new About();
                fAbout.setVersion(Release);     // set release / version
                fAbout.ShowDialog();

                break;


            case MenuMksGetNewest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    mks.GetNewest();
                }

                break;

            case MenuMksGetHistory:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    MessageBox.Show(mks.ViewHistory(), "mks");
                }
                break;


            case MenuMksUndoCheckOut:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks    mks = new Mks(repository, pkg);
                    string msg = mks.UndoCheckout();
                    if (msg != "")
                    {
                        MessageBox.Show(mks.UndoCheckout(), "mks");
                    }
                }
                break;

            // Change name to synomym
            // - Package, recursive
            // - Class
            case MenuChangeClassNameToSynonym:
                // Class recursive
                if (oType.Equals(EA.ObjectType.otElement))
                {
                    el = (EA.Element)repository.GetContextObject();
                    Util.ChangeClassNameToSynonyms(repository, el);
                }
                // Package recursiv
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ChangePackageClassNameToSynonyms(repository, pkg);
                }

                break;



            //

            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVc(repository, pkg);
                }
                break;

            //   For all nested packages:
            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcModeRecursive:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVcRecursive(repository, pkg);
                }
                break;



            case MenuGetVcLatest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatest", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, false, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;
                    repository.WriteOutput("Debug", "End GetLatest " + span.Minutes + " minutes. " + s, 0);
                }

                break;

            case MenuGetVcLatestRecursive:
                if (oType.Equals(EA.ObjectType.otPackage) || oType.Equals(EA.ObjectType.otNone))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatestRecursive", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, true, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;

                    repository.WriteOutput("Debug", "End GetLatestRecursive in " + span.Hours + ":" + span.Minutes + " hh:mm. " + s, 0);
                }

                break;

            case MenuGetVcModeAll:
                //Repository.VersionControlResynchPkgStatuses(false);
                // over all packages
                foreach (EA.Package pkg1 in repository.Models)
                {
                    Util.UpdateVc(repository, pkg1);
                }

                break;

            case MenuGetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    // Get the revision
                    Regex  pattern  = new Regex(@"Revision:[^\$]+");
                    Match  regMatch = pattern.Match(pkg.Notes);
                    string revision = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        revision = regMatch.Value;
                        // add new string
                    }
                    // Get date
                    pattern  = new Regex(@"Date:[^\$]+");
                    regMatch = pattern.Match(pkg.Notes);
                    string date = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        date = regMatch.Value;
                        // add new string
                    }
                    string msg = revision + "  " +
                                 date + "\r\n" +
                                 "Path: " + Util.GetFilePath(repository, pkg) +
                                 "\r\n\r\n" + pkg.Flags + "\r\n" +
                                 Util.GetVCstate(pkg, true);

                    MessageBox.Show(msg, "State");
                }
                break;



            case MenuCopyGuidToClipboard:
                string str  = "";
                string str1 = "";
                string str2 = "";

                if (conCurrent != null)
                {    // Connector
                    EA.Connector con = conCurrent;
                    str = con.ConnectorGUID + " " + con.Name + ' ' + con.Type + "\r\n" +

                          "\r\n Connector: Select ea_guid As CLASSGUID, connector_type As CLASSTYPE,* from t_connector con where ea_guid = '" + con.ConnectorGUID + "'" +

                          "\r\n\r\nSelect o.ea_guid As CLASSGUID, o.object_type As CLASSTYPE,o.name As Name, o.object_type AS ObjectType, o.PDATA1, o.Stereotype, " +
                          "\r\n                       con.Name, con.connector_type, con.Stereotype, con.ea_guid As ConnectorGUID, dia.Name As DiagrammName, dia.ea_GUID As DiagramGUID," +
                          "\r\n                       o.ea_guid, o.Classifier_GUID,o.Classifier " +
                          "\r\nfrom (((t_connector con INNER JOIN t_object o              on con.start_object_id   = o.object_id) " +
                          "\r\nINNER JOIN t_diagramlinks diaLink  on con.connector_id      = diaLink.connectorid ) " +
                          "\r\nINNER JOIN t_diagram dia           on diaLink.DiagramId     = dia.Diagram_ID) " +
                          "\r\nINNER JOIN t_diagramobjects diaObj on diaObj.diagram_ID     = dia.Diagram_ID and o.object_id = diaObj.object_id " +
                          "\r\nwhere         con.ea_guid = '" + con.ConnectorGUID + "' " +
                          "\r\nAND dialink.Hidden  = 0 ";
                    Clipboard.SetText(str);
                    break;
                }
                if (oType.Equals(EA.ObjectType.otElement))
                {    // Element
                    el = (EA.Element)repository.GetContextObject();
                    string pdata1       = el.get_MiscData(0);
                    string pdata1String = "";
                    if (pdata1.EndsWith("}"))
                    {
                        pdata1String = "/" + pdata1;
                    }
                    else
                    {
                        pdata1       = "";
                        pdata1String = "";
                    }
                    string classifier = Util.GetClassifierGuid(repository, el.ElementGUID);
                    str = el.ElementGUID + ":" + classifier + pdata1String + " " + el.Name + ' ' + el.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + el.ElementGUID + "'";
                    if (classifier != "")
                    {
                        if (el.Type.Equals("ActionPin"))
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, 'Parameter' As CLASSTYPE,* from t_operationparams op where ea_guid = '" + classifier + "'";
                        }
                        else
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + classifier + "'";
                        }
                    }
                    if (pdata1 != "")
                    {
                        str = str + "\r\n PDATA1:  Select ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + pdata1 + "'";
                    }

                    // Look for diagram object
                    EA.Diagram curDia = repository.GetCurrentDiagram();
                    if (curDia != null)
                    {
                        foreach (EA.DiagramObject diaObj in curDia.DiagramObjects)
                        {
                            if (diaObj.ElementID == el.ElementID)
                            {
                                str = str + "\r\n\r\n" +
                                      "select * from t_diagramobjects where object_id = " + diaObj.ElementID.ToString();
                                break;
                            }
                        }
                    }
                }

                if (oType.Equals(EA.ObjectType.otDiagram))
                {    // Element
                    EA.Diagram dia = (EA.Diagram)repository.GetContextObject();
                    str = dia.DiagramGUID + " " + dia.Name + ' ' + dia.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, diagram_type As CLASSTYPE,* from t_diagram dia where ea_guid = '" + dia.DiagramGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otPackage))
                {    // Element
                    pkg = (EA.Package)repository.GetContextObject();
                    str = pkg.PackageGUID + " " + pkg.Name + ' ' + " Package " + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, 'Package' As CLASSTYPE,* from t_package pkg where ea_guid = '" + pkg.PackageGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otAttribute))
                {    // Element
                    str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = typAttr.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = Format(typAttr.object_id))";
                    }
                    EA.Attribute attr = (EA.Attribute)repository.GetContextObject();
                    str = attr.AttributeID + " " + attr.Name + ' ' + " Attribute " + "\r\n" +
                          "\r\n " +
                          "\r\nSelect ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE,* from t_attribute attr where ea_guid = '" + attr.AttributeGUID + "'" +
                          "\r\n Class has Attributes:" +
                          "\r\nSelect attr.ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE, " +
                          "\r\n       o.Name As Class, o.object_type, " +
                          "\r\n       attr.Name As AttrName, attr.Type As Type, " +
                          "\r\n       typAttr.Name " +
                          "\r\n   from (t_object o INNER JOIN t_attribute attr on (o.object_id = attr.object_id)) " +
                          "\r\n                   " + str1 +
                          "\r\n   where attr.ea_guid = '" + attr.AttributeGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otMethod))
                {    // Element
                    str1 = "LEFT JOIN t_object parTyp on (par.classifier = parTyp.object_id))";
                    str2 = "LEFT JOIN t_object opTyp on (op.classifier = opTyp.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = " LEFT JOIN t_object parTyp on (par.classifier = Format(parTyp.object_id))) ";
                        str2 = " LEFT JOIN t_object opTyp  on (op.classifier  = Format(opTyp.object_id))";
                    }

                    EA.Method op = (EA.Method)repository.GetContextObject();
                    str = op.MethodGUID + " " + op.Name + ' ' + " Operation " +
                          "\r\nOperation may have type " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,opTyp As OperationType, op.Name As OperationName, typ.Name As TypName,*" +
                          "\r\n   from t_operation op LEFT JOIN t_object typ on (op.classifier = typ.object_id)" +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,* " +
                          "\r\n    from t_operation op INNER JOIN t_object o on (o.object_id = op.object_id)" +
                          "\r\n    where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation has Parameters/Typ and may have operationtype" +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,op.Name As ClassName, op.Name As OperationName, opTyp.Name As OperationTyp, par.Name As ParName,parTyp.name As ParTypeName " +
                          "\r\n   from ((t_operation op INNER JOIN t_operationparams par on (op.OperationID = par.OperationID) )" +
                          "\r\n                        " + str1 +
                          "\r\n                        " + str2 +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "' " +
                          "\r\n  Order by par.Pos ";
                }
                Clipboard.SetText(str);
                break;

            // delete undefined referencee
            case MenuDeleteExternalReference:
                if (diaCurrent != null)
                {
                    foreach (EA.DiagramObject diaObj in diaCurrent.SelectedObjects)
                    {
                        EA.Element el1 = repository.GetElementByID(diaObj.ElementID);
                        string     s   = String.Format("External Reference of diagram '{0}', name:'{1}' ID={2} GUID='{3}' deleted", diaCurrent.Name, el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                else
                {
                    foreach (EA.Element el1 in repository.GetTreeSelectedElements())
                    {
                        string s = String.Format("External Reference of tree, name:'{0}' ID={1} GUID='{2}' deleted", el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                break;

            // Recursive delete undefined referencee
            case MenuDeleteExternalReferenceRecursive:
                pkg = null;
                if (oType.Equals(EA.ObjectType.otNone))
                {
                    oType = repository.GetTreeSelectedItemType();
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetTreeSelectedObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetTreeSelectedObject();
                    }
                }
                else
                {
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetContextObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetContextObject();
                    }
                }
                if (pkg != null)
                {
                    RecursivePackages.doRecursivePkg(repository,
                                                     pkg,
                                                     null,                        // Packages
                                                     SetDeleteUndefinedReference, // Elements
                                                     null,                        // Diagrams
                                                     null);
                }
                if (el != null)
                {
                    RecursivePackages.doRecursiveEl(repository,
                                                    el,
                                                    SetDeleteUndefinedReference, // Elements
                                                    null,                        // Diagrams
                                                    null);
                }

                break;
            }
        }
コード例 #15
0
        private static Boolean createTGGLink(EA.Repository Repository, EA.EventProperties Info, TGGModelingMain modelingMain)
        {
            SQLRepository sqlRep = new SQLRepository(Repository, false);

            int clientID   = int.Parse(Info.Get("ClientID").Value.ToString());
            int supplierID = int.Parse(Info.Get("SupplierID").Value.ToString());

            SQLElement client   = sqlRep.GetElementByID(clientID);
            SQLElement supplier = sqlRep.GetElementByID(supplierID);

            DomainType clientDomain   = TGGModelingUtil.getDomainOfEClass(sqlRep, client);
            DomainType supplierDomain = TGGModelingUtil.getDomainOfEClass(sqlRep, supplier);

            SQLElement source = null;
            SQLElement target = null;

            if (clientDomain == DomainType.SOURCE || supplierDomain == DomainType.TARGET)
            {
                source = client;
                target = supplier;
            }
            else if (clientDomain == DomainType.TARGET || supplierDomain == DomainType.SOURCE)
            {
                source = supplier;
                target = client;
            }
            else
            {
                //could not define the domains, this is an arbitrary choice
                source = client;
                target = supplier;
            }


            EA.Diagram curDiagram = Repository.GetCurrentDiagram();
            EA.Package tggPackage = Repository.GetPackageByID(curDiagram.PackageID);

            EA.Element tggLink = tggPackage.Elements.AddNew(source.Name + "To" + target.Name, Main.EAClassType) as EA.Element;
            tggLink.StereotypeEx = TGGModelingMain.TggCorrespondenceTypeStereotype;
            tggLink.Update();
            modelingMain.EA_OnNotifyContextItemModified(Repository, tggLink.ElementGUID, EA.ObjectType.otElement);

            EA.Connector connectorToSource = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToSource.SupplierID              = source.ElementID;
            connectorToSource.Direction               = Main.EASourceTargetDirection;
            connectorToSource.SupplierEnd.Role        = "source";
            connectorToSource.SupplierEnd.Navigable   = "Navigable";
            connectorToSource.SupplierEnd.Cardinality = "1";
            connectorToSource.SupplierEnd.IsNavigable = true;

            connectorToSource.Update();
            tggLink.Connectors.Refresh();
            modelingMain.EA_OnNotifyContextItemModified(Repository, connectorToSource.ConnectorGUID, EA.ObjectType.otConnector);

            EA.Connector connectorToTarget = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector;
            connectorToTarget.SupplierID              = target.ElementID;
            connectorToTarget.Direction               = Main.EASourceTargetDirection;
            connectorToTarget.SupplierEnd.Role        = "target";
            connectorToTarget.SupplierEnd.Cardinality = "1";
            connectorToTarget.SupplierEnd.Navigable   = "Navigable";
            connectorToTarget.SupplierEnd.IsNavigable = true;

            connectorToTarget.Update();
            tggLink.Connectors.Refresh();
            modelingMain.EA_OnNotifyContextItemModified(Repository, connectorToTarget.ConnectorGUID, EA.ObjectType.otConnector);

            //create a new diagram object
            Repository.SaveDiagram(curDiagram.DiagramID);
            EA.DiagramObject sourceDiagObj = null;
            EA.DiagramObject targetDiagObj = null;

            curDiagram.DiagramObjects.Refresh();
            foreach (EA.DiagramObject diagObj in curDiagram.DiagramObjects)
            {
                if (diagObj.ElementID == source.ElementID)
                {
                    sourceDiagObj = diagObj;
                }
                else if (diagObj.ElementID == target.ElementID)
                {
                    targetDiagObj = diagObj;
                }

                if (sourceDiagObj != null && targetDiagObj != null)
                {
                    continue;
                }
            }

            int sourceLeft   = (sourceDiagObj == null) ? 0 : sourceDiagObj.left;
            int sourceRight  = (sourceDiagObj == null) ? 0 : sourceDiagObj.right;
            int sourceBottom = (sourceDiagObj == null) ? 0 : sourceDiagObj.bottom;
            int sourceTop    = (sourceDiagObj == null) ? 0 : sourceDiagObj.top;

            int targetLeft   = (targetDiagObj == null) ? 0 : targetDiagObj.left;
            int targetRight  = (targetDiagObj == null) ? 0 : targetDiagObj.right;
            int targetBottom = (targetDiagObj == null) ? 0 : targetDiagObj.bottom;
            int targetTop    = (targetDiagObj == null) ? 0 : targetDiagObj.top;

            EA.DiagramObject tggLinkDiagObj = curDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject;
            tggLinkDiagObj.ElementID = tggLink.ElementID;
            tggLinkDiagObj.Update();
            tggLinkDiagObj.left   = (sourceLeft + targetLeft) / 2;
            tggLinkDiagObj.right  = (sourceRight + targetRight) / 2;
            tggLinkDiagObj.bottom = (sourceBottom + targetBottom) / 2;
            tggLinkDiagObj.top    = (sourceTop + targetTop) / 2;
            tggLinkDiagObj.Update();
            curDiagram.DiagramObjects.Refresh();

            Repository.ReloadDiagram(curDiagram.DiagramID);

            tggPackage.Elements.Refresh();


            return(true);
        }
コード例 #16
0
 public EA.Diagram GetCurrentDiagram()
 {
     return(eaRepository.GetCurrentDiagram());
 }
コード例 #17
0
        //-------------------------------------------------------------------------------------------------
        // get Parameter from operation
        // visualize them on diagram / activity
        //-------------------------------------------------------------------------------------------------
        private static bool GetParameterFromOperation(EA.Repository rep, EA.Element act, EA.Method m)
        {
            if (m == null)
            {
                return(false);
            }
            if (act.Locked)
            {
                return(false);
            }
            if (!act.Type.Equals("Activity"))
            {
                return(false);
            }

            EA.Element parTrgt = null;

            // If diagram is active visualize on diagram
            EA.Diagram curDia = rep.GetCurrentDiagram();

            // delete all old "Activity Paramaeter"
            if (act.EmbeddedElements.Count > 0)
            {
                for (short i = (short)(act.EmbeddedElements.Count - 1); i >= 0; --i)
                {
                    EA.Element embeddedEl = (EA.Element)act.EmbeddedElements.GetAt(i);
                    if (embeddedEl.Type.Equals("ActivityParameter"))
                    {
                        act.EmbeddedElements.Delete(i);
                    }
                }
                act.EmbeddedElements.Refresh();
                act.Update();
            }

            // return code
            if (!m.ReturnType.Equals("void"))
            {
                // create an Parameter for Activity (in fact an element with properties)
                parTrgt       = (EA.Element)act.EmbeddedElements.AddNew("Return", "Parameter");
                parTrgt.Alias = "return:" + m.ReturnType;
                if (m.ClassifierID != "")
                {
                    parTrgt.ClassifierID = Convert.ToInt32(m.ClassifierID);
                }
                parTrgt.Update();
                act.EmbeddedElements.Refresh();


                if (curDia != null)
                {
                    // "l=120;r=145;t=785;b=805", "");
                    EA.DiagramObject diaObj = (EA.DiagramObject)curDia.DiagramObjects.AddNew("l=140;t=780;", "");
                    diaObj.ElementID = parTrgt.ElementID;
                    diaObj.Update();
                    curDia.DiagramObjects.Refresh();
                    rep.ReloadDiagram(curDia.DiagramID);
                }
            }

            // over all parameters
            int top  = 300;
            int left = 45;

            foreach (EA.Parameter parSrc in m.Parameters)
            {
                // create an Parameter for Activity (in fact an element with properties)
                parTrgt = (EA.Element)act.EmbeddedElements.AddNew(parSrc.Position + "_" + parSrc.Name, "Parameter");
                // get classifier/type


                if (parSrc.ClassifierID != "")
                {
                    parTrgt.ClassifierID = Convert.ToInt32(parSrc.ClassifierID);
                }
                parTrgt.Notes = parSrc.Notes;
                parTrgt.Alias = "par_" + parSrc.Position + ":" + parSrc.Type;
                parTrgt.Update();

                // If diagram is active visualize on diagram
                if (curDia != null)
                {
                    // "l=120;r=145;t=785;b=805", "");
                    EA.DiagramObject diaObj = (EA.DiagramObject)curDia.DiagramObjects.AddNew($"l={left};t={top};", "");
                    diaObj.ElementID = parTrgt.ElementID;
                    diaObj.Update();
                    curDia.DiagramObjects.Refresh();
                    rep.ReloadDiagram(curDia.DiagramID);
                    top = top + 50;
                }
            }
            act.EmbeddedElements.Refresh();

            return(true);
        }
コード例 #18
0
        public bool EA_OnContextItemDoubleClicked(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(Repository, false);

            EA.Diagram currentDiagram = Repository.GetCurrentDiagram();
            if (currentDiagram != null)
            {
                Repository.SaveDiagram(currentDiagram.DiagramID);
            }

            if (ot == EA.ObjectType.otPackage)
            {
                EA.Package doubleClickedPackage = Repository.GetPackageByGuid(GUID);
                if (doubleClickedPackage.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype)
                {
                    return(onTggSchemaPackageDoubleClicked(sqlRepository, doubleClickedPackage));
                }
            }

            if (ot == EA.ObjectType.otElement)
            {
                EA.Element doubleClickedElement = Repository.GetElementByGuid(GUID);
                if (doubleClickedElement.Stereotype == TGGModelingMain.TggLinkStereotype)
                {
                    if (doubleClickedElement.Diagrams.Count > 0)
                    {
                        onTggLinkDoubleClicked(Repository, doubleClickedElement);
                        return(true);
                    }
                }

                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype)
                {
                    onTggOvDoubleClicked(sqlRepository, doubleClickedElement);
                    return(true);
                }
                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
                {
                    onTggCorrespondenceDoubleClicked(sqlRepository, doubleClickedElement);
                    return(true);
                }

                else if (doubleClickedElement.Stereotype == CSPConstraintStereotype || doubleClickedElement.Stereotype == "TGGCsp")
                {
                    if (currentDiagram != null && TggRuleDiagramMetatype.Contains(currentDiagram.MetaType))
                    {
                        onCSPConstraintDoubleClicked(sqlRepository, doubleClickedElement);
                        return(true);
                    }
                }
                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggRuleStereotype)
                {
                    if (doubleClickedElement.Diagrams.Count > 0)
                    {
                        onTggRuleDoubleClicked(Repository, doubleClickedElement);
                        return(true);
                    }
                }
            }
            if (ot == EA.ObjectType.otConnector)
            {
                if (currentDiagram != null && TGGModelingMain.TggRuleDiagramMetatype.Contains(currentDiagram.MetaType))
                {
                    EA.Connector doubleClickedConnector = Repository.GetConnectorByGuid(GUID);
                    if (doubleClickedConnector.Stereotype == TGGModelingMain.TggLinkVariableStereotype || doubleClickedConnector.Stereotype == SDMModelingMain.LinkVariableStereotype)
                    {
                        onTggLvDoubleClicked(sqlRepository, sqlRepository.GetConnectorByID(doubleClickedConnector.ConnectorID));
                        return(true);
                    }
                }
            }
            return(false);
        }