public override void locate(EA.Repository rep) { rep.ShowInProjectView(_dia); }
public static void OpenBehaviorForElement(EA.Repository repository, EA.Element el) { // find the diagram if (el.Diagrams.Count > 0) { // get the diagram var dia = (EA.Diagram)el.Diagrams.GetAt(0); // open diagram repository.OpenDiagram(dia.DiagramID); } // no diagram found, select element repository.ShowInProjectView(el); }
/// <summary> /// Update VC (Version Control state of a controlled package: /// - Returns user name of user who have checked out the package /// - Updates the package flags /// </summary> /// <param name="rep">Repository</param> /// <param name="pkg">Package to check</param> public static string UpdateVc(EA.Repository rep, EA.Package pkg) { string userNameLockedPackage = ""; if (pkg.IsVersionControlled) { // find VC=...; // replace by: VC=currentState(); string flags = pkg.Flags; // remove check out flags flags = Regex.Replace(flags, @"VC=[^;]*;", ""); flags = Regex.Replace(flags, @"CheckedOutTo=[^;]*;", ""); var svnHandle = new Svn(rep, pkg); userNameLockedPackage = svnHandle.GetLockingUser(); if (userNameLockedPackage != "") flags = flags + "CheckedOutTo=" + userNameLockedPackage + ";"; try { SetVcFlags(rep, pkg, flags); rep.ShowInProjectView(pkg); } catch (Exception e) { string s = e.Message + " ;" + pkg.GetLastError(); s = s + "!"; MessageBox.Show(s, @"Error UpdateVC state"); } } return userNameLockedPackage; }
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; }
//-------------------------------------------------------------------------------- // createActivityForOperation //-------------------------------------------------------------------------------- // Create an Activity Diagram for the operation public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos=100) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // create a package with the name of the operation var pkgTrg = (EA.Package)pkgSrc.Packages.AddNew(m.Name, ""); pkgTrg.TreePos = treePos; pkgTrg.Update(); pkgSrc.Packages.Refresh(); EA.Element frame = null; // frame beneath package if (ActivityIsSimple == false) { // create Class Activity Diagram in target package var pkgActDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Activity"); pkgActDia.Update(); pkgTrg.Diagrams.Refresh(); // add frame in Activity diagram var frmObj = (EA.DiagramObject)pkgActDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", ""); frame = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram"); frame.Update(); frmObj.ElementID = frame.ElementID; //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; frmObj.Update(); pkgTrg.Elements.Refresh(); pkgActDia.DiagramObjects.Refresh(); } // create activity with the name of the operation var act = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Activity"); if (ActivityIsSimple == false) { act.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!"; } act.StereotypeEx = m.StereotypeEx; act.Update(); pkgTrg.Elements.Refresh(); // create activity diagram beneath Activity var actDia = (EA.Diagram)act.Diagrams.AddNew(m.Name, "Activity"); // update diagram properties actDia.ShowDetails = 0; // hide details // scale page to din A4 actDia.StyleEx = actDia.StyleEx.Length > 0 ? actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1") : "HideQuals=1;"; // Hide Qualifier actDia.ExtendedStyle = actDia.ExtendedStyle.Length > 0 ? actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1") : "ScalePI=1;"; actDia.Update(); act.Diagrams.Refresh(); // put the activity on the diagram Util.AddSequenceNumber(rep, actDia); var actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", ""); actObj.ElementID = act.ElementID; actObj.Sequence = 1; actObj.Update(); Util.SetSequenceNumber(rep, actDia, actObj, "1"); actDia.DiagramObjects.Refresh(); // add default nodes (init/final) CreateDefaultElementsForActivity(rep, actDia, act); if (ActivityIsSimple == false) { // Add Heading to diagram Util.AddSequenceNumber(rep, actDia); var noteObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=40;r=700;t=25;b=50", ""); var note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text"); note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType; note.Update(); noteObj.ElementID = note.ElementID; noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; noteObj.Sequence = 1; noteObj.Update(); Util.SetSequenceNumber(rep, actDia, noteObj, "1"); } pkgTrg.Elements.Refresh(); actDia.DiagramObjects.Refresh(); // Link Operation to activity Util.SetBehaviorForOperation(rep, m, act); // Set show behavior Util.SetShowBehaviorInDiagram(rep, m); // add parameters to activity UpdateParameterFromOperation(rep, act, m); int pos = 0; foreach (EA.Element actPar in act.EmbeddedElements) { if (! actPar.Type.Equals("ActivityParameter")) continue; Util.VisualizePortForDiagramobject(pos, actDia, actObj, actPar, null); pos = pos + 1; } if (ActivityIsSimple == false) { // link Overview frame to diagram Util.SetFrameLinksToDiagram(rep, frame, actDia); frame.Update(); } // select operation rep.ShowInProjectView(m); return true; }