private bool UpdateMembers(UmlType cl, Type tpcl) { classes[tpcl] = cl; name_to_class[tpcl.FullName] = cl; if (cl is UmlClass) { // nested UmlClass ucl = (UmlClass)cl; foreach (Type t in tpcl.GetNestedTypes()) { if (ucl.Types == null) { ucl.Types = new ArrayList(); } UmlType found = UpdateTypeInArray(ucl.Types, t, t.Name); if (!UpdateMembers(found, t)) { return(false); } } } return(true); }
public UmlAttribute(Tag tag, UmlClass classobj) : base(tag) { type = tag.ParseType (); commentsKey = Comments.Key (classobj.Name, name); }
public void Apply(ObjectState v) { State t = v as State; X = t.x; Y = t.y; show_members = t.b1; show_vars = t.b2; show_properties = t.b3; show_full_qual = t.b4; show_method_signatures = t.b5; show_only_public = t.b6; stereo = t.stereo; if (t.members != null) { members = new ArrayList(t.members.Count); foreach (GuiMember m in t.members) { members.Add(m.Clone()); } } else { members = null; } fillHash(); name = t.name; st = parent.proj.model.GetObject(name) as UmlClass; RefreshContent(); SetHidden(t.hidden); }
private UmlInstanceType GetUmlType(DiagramTypeElement diagramElement) { UmlInstanceType t = null; if (diagramElement.Type is InterfaceElement) { t = new UmlInterface(); var data = new UmlInterfaceData(); data.Owner = diagramElement; t.DataSource = data; } if (diagramElement.Type is ClassElement) { t = new UmlClass(); var data = new UmlClassData(); data.Owner = diagramElement; t.DataSource = data; } if (diagramElement.Type is EnumElement) { t = new UmlEnum(); var data = new UmlEnumData(); data.Owner = diagramElement; t.DataSource = data; } return(t); }
public void Import(object o, EventArgs ev) { if (st == null) { return; } switch ((o as FlatMenuItem).Index) { case 0: // ancestor & interfaces x_coord_counter = X; ancest = true; if (st.BaseObjects != null) { foreach (string s in st.BaseObjects) { UmlClass imp_cl = parent.proj.model.GetObject(s) as UmlClass; if (imp_cl != null) { ImportClass(imp_cl); } } } break; case 1: // successors ancest = false; x_coord_counter = X; parent.proj.model.Visit(new UmlObject.Visitor(VisitClassAndImport), null); break; default: return; } }
private UmlType UpdateTypeInArray(ArrayList Types, Type t, string typename) { // resolve kind UmlKind kind = UmlKind.Class; if (t.IsInterface) { kind = UmlKind.Interface; } else if (t.IsEnum) { kind = UmlKind.Enum; } else if (t.IsValueType) { kind = UmlKind.Struct; } // search existing or create a new UmlType found = null; foreach (UmlType e in Types) { if (e.name.Equals(typename)) { found = e; break; } } recreate: if (found == null) { if (kind == UmlKind.Enum) { found = new UmlEnum(); } else { found = new UmlClass(); ((UmlClass)found).kind = kind; } found.name = typename; Types.Add(found); } else { if (found.Kind == UmlKind.Enum && kind != UmlKind.Enum || found.Kind != UmlKind.Enum && kind == UmlKind.Enum) { Types.Remove(found); found = null; goto recreate; } if (found.Kind != UmlKind.Enum) { ((UmlClass)found).kind = kind; } found.Deleted = false; } return(found); }
public UmlDiagramClassOperation AddOperationFromModel(UmlClass umlClass, UmlOperation umlOperation) { var umlDiagramClass = modelToDiagramClasses[umlClass]; var umlDiagramClassOperation = new UmlDiagramClassOperation(umlOperation, umlClass); umlDiagramClass.Operations.Add(umlDiagramClassOperation); return(umlDiagramClassOperation); }
public UmlDiagramClassAttribute AddAttributeFromModel(UmlClass umlClass, UmlAttribute umlAttribute) { var umlDiagramClass = modelToDiagramClasses[umlClass]; var umlDiagramClassAttribute = new UmlDiagramClassAttribute(umlAttribute); umlDiagramClass.Attributes.Add(umlDiagramClassAttribute); return(umlDiagramClassAttribute); }
public void ImportClass(UmlClass cl) { if (parent.FindClass(cl) == null) { GuiClass gc = GuiElementFactory.CreateClass(parent, x_coord_counter, ancest ? Y - 100 : Y + Height + 100, cl); x_coord_counter += 20 + gc.Width; } }
// // TODO: SubClass from UmlAssociationRelation. Same in model. // public UmlAggregationRelation( UmlClass startClass, UmlClass endClass, string name = null, string startMultiplicity = "1", string endMultiplicity = "1" ) : base(startClass, endClass, name, startMultiplicity, endMultiplicity) { }
public static GuiClass fromUML(UmlClass st) { GuiClass s = new GuiClass(); s.name = st.UniqueName; s.st = st; s.Created(); return(s); }
public void AddMethodNodeFromModel(UmlClass umlClass, UmlMethodNode umlMethodNode, UmlMethodLink umlMethodLink) { UmlDiagramClass umlDiagramClass = GetDiagramClass(umlClass); var umlDiagramMethodNode = new UmlDiagramMethodNode(umlMethodNode); var umlDiagramMethodLink = new UmlDiagramMethodLink(umlMethodLink, umlDiagramClass, umlDiagramMethodNode); AddMethodNode(umlDiagramMethodNode); AddMethodLink(umlDiagramMethodLink); }
public void AddNoteFromModel(UmlClass umlClass, UmlNote umlNote, UmlNoteLink umlNoteLink) { UmlDiagramClass umlDiagramClass = GetDiagramClass(umlClass); var umlDiagramNote = new UmlDiagramNote(umlNote); var umlDiagramNoteLink = new UmlDiagramNoteLink(umlNoteLink, umlDiagramClass, umlDiagramNote); AddNote(umlDiagramNote); AddNoteLink(umlDiagramNoteLink); }
public static GuiClass CreateClass(StaticView parent, int x, int y, UmlClass cl) { GuiClass c = GuiClass.fromUML(cl); c.X = x; c.Y = y; parent.AddObject(c, UmlModel.GetUniversal(cl)); return(c); }
public void EditedName(string name) { ObjectState before = GetState(); this.name = name; st = parent.proj.model.GetObject(name) as UmlClass; RefreshContent(); parent.Undo.Push(new StateOperation(this, before, GetState()), false); }
public void RemoveAttributeFromModel(UmlClass umlClass, UmlAttribute attributeToRemove) { var umlDiagramClass = modelToDiagramClasses[umlClass]; var attributesToRemove = umlDiagramClass.Attributes.Where(u => u.UmlAttribute == attributeToRemove).ToList(); foreach (var attribute in attributesToRemove) { umlDiagramClass.Attributes.Remove(attribute); } }
public void RemoveOperationFromModel(UmlClass umlClass, UmlOperation operationToRemove) { var umlDiagramClass = modelToDiagramClasses[umlClass]; var operationsToRemove = umlDiagramClass.Operations.Where(u => u.UmlOperation == operationToRemove).ToList(); foreach (var operation in operationsToRemove) { umlDiagramClass.Operations.Remove(operation); } }
public void CreateModelNote(UmlClass umlClass, string note) { UmlNote umlNote; UmlNoteLink umlNoteLink; Model.CreateNoteFromDiagram(umlClass, note, out umlNote, out umlNoteLink); if (umlNote != null && umlNoteLink != null) { AddNoteFromModel(umlClass, umlNote, umlNoteLink); } }
public UmlAttribute(UmlBlock block, UmlClass classobj) : base(block) { if (name.Contains (":")) { string[] p = name.Split (":").TrimAll ().ToArray (); name = p [0]; type = p [1]; } Comments.AddTo (commentsKey = Comments.Key (classobj.Name, name), block.comments); }
public void CreateModelMethodNode(UmlClass umlClass, string methodName) { UmlMethodNode umlMethodNode; UmlMethodLink umlMethodLink; Model.CreateMethodNodeFromDiagram(umlClass, methodName, out umlMethodNode, out umlMethodLink); if (umlMethodNode != null && umlMethodLink != null) { AddMethodNodeFromModel(umlClass, umlMethodNode, umlMethodLink); } }
public UmlOperation CreateModelOperation(UmlClass umlClass, string name, string type) { // TODO: check if operation is already in the model var umlOperation = new UmlOperation(name, type); umlClass.Operations.Add(umlOperation); // // Exception for now: immediately create the operation in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // AddOperationFromModel(umlClass, umlOperation); return(umlOperation); }
public GuiClass FindClass(UmlClass cl) { foreach (GuiObject obj in active_objects) { GuiClass gcl = obj as GuiClass; if (gcl != null && gcl.st == cl) { return(gcl); } } return(null); }
public UmlAttribute CreateModelAttribute(UmlClass umlClass, string name, string type) { // TODO: check if attribute is already in the model var umlAttribute = new UmlAttribute(name, type); umlClass.Attributes.Add(umlAttribute); // // Exception for now: immediately create the attribute in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // AddAttributeFromModel(umlClass, umlAttribute); return(umlAttribute); }
public UmlRelation CreateModelRelation( RelationType relationType, UmlClass startClass, UmlClass endClass, bool oneToN, string name = null ) { UmlRelation umlRelation = null; switch (relationType) { case RelationType.Inheritance: umlRelation = Model.GetOrCreateInheritanceRelation(true, startClass, endClass); break; case RelationType.ImplementsInterface: umlRelation = Model.GetOrCreateImplementsInterfaceRelation(true, startClass, endClass); break; case RelationType.Aggregation: umlRelation = Model.GetOrCreateAggregationRelation(true, startClass, endClass, name); umlRelation.StartMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Composition: umlRelation = Model.GetOrCreateCompositionRelation(true, startClass, endClass, name); umlRelation.StartMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Association: umlRelation = Model.GetOrCreateAssociationRelation(true, startClass, endClass, name); umlRelation.EndMultiplicity = oneToN ? "N" : "1"; break; case RelationType.Dependence: umlRelation = Model.GetOrCreateDependenceRelation(true, startClass, endClass, name); umlRelation.EndMultiplicity = oneToN ? "N" : "1"; break; } if (umlRelation != null) { // // Exception for now: immediately create the relation in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // //AddRelationFromModel(umlRelation); } return(umlRelation); }
public UmlRelation( UmlClass startClass, UmlClass endClass, string name = null, string startMultiplicity = "1", string endMultiplicity = "1" ) : base(startClass, endClass) { Label = name; StartClass.AddRelation(this); EndClass.AddRelation(this); StartMultiplicity = startMultiplicity; EndMultiplicity = endMultiplicity; }
public void TheDeleteElementTest() { // Given Element element = new UmlClass(); Drawing drawing = new Drawing(); drawing.Add(element); // When drawing.DeleteElement(element); // Then Assert.AreEqual(0, drawing.GetCloneOfElements().Count); }
public void RemoveModelOperation(UmlClass umlClass, string name, string type = null) { IEnumerable <UmlOperation> operationsToRemove = umlClass.Operations.Where(o => o.Name == name && (type == null || o.Type == type)).ToList(); foreach (var operation in operationsToRemove) { umlClass.Operations.Remove(operation); // // Exception for now: immediately remove the operation in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // RemoveOperationFromModel(umlClass, operation); } }
public void RemoveModelAttribute(UmlClass umlClass, string name, string type = null) { IEnumerable <UmlAttribute> attributesToRemove = umlClass.Attributes.Where(o => o.Name == name && (type == null || o.Type == type)).ToList(); foreach (var attribute in attributesToRemove) { umlClass.Attributes.Remove(attribute); // // Exception for now: immediately remove the attribute in the diagram too. This should happen via an event from the model, // but for now, we do it directly. // RemoveAttributeFromModel(umlClass, attribute); } }
public UmlMethod(UmlBlock block, UmlClass classobj) : base(block) { parseParams (); if (name.Contains (":")) { string[] p = name.Split (":").TrimAll ().ToArray (); name = p [0]; returntype = p [1]; } else { returntype = ""; } Comments.AddTo (commentsKey = Comments.Key (classobj.Name, name, parameters.Unique () + returntype), block.comments); }
public UmlDiagramClass(UmlClass umlClass, UmlDiagram umlDiagram) { Class = umlClass; this.umlDiagram = umlDiagram; SyncAttributesAndOperationsFromModel(); attributes.CollectionChanged += (sender, args) => NotifyPropertyChanged(() => HasAttributes); properties.CollectionChanged += (sender, args) => NotifyPropertyChanged(() => HasProperties); operations.CollectionChanged += (sender, args) => NotifyPropertyChanged(() => HasOperations); relations = new ObservableCollection <UmlDiagramRelation>(); Relations = new ReadOnlyObservableCollection <UmlDiagramRelation>(relations); CloseCommand = new DelegateCommand(OnExecuteCloseCommand); }
private void BuildClass(StringBuilder stringBuilder, UmlClass umlClass) { string stereotype = umlClass.HasStereotype? $" << {umlClass.Stereotype} >>" : string.Empty; stringBuilder.AppendLine($"class {umlClass.Name}{stereotype}"); stringBuilder.AppendLine("{"); foreach (var umlField in umlClass.UmlFields) { BuildField(stringBuilder, umlField); } foreach (var umlMethod in umlClass.UmlMethods) { BuildMethod(stringBuilder, umlMethod); } stringBuilder.AppendLine("}"); }
public UmlAttribute(CSharpBlock block, UmlClass classobj) : base(block) { name = name.Split ('=') [0].TrimAll (); if (name.Contains (" ")) { string[] p = name.CleanGenerics () .Split (new char[]{' '}, StringSplitOptions.RemoveEmptyEntries); type = p [0]; name = ""; for (int i = 0; i < p.Length; ++i) { name += i == 0 ? "" : " " + p [i]; } } name = name.TrimAll (); commentsKey = Comments.Key (classobj.Name, name); }
/// <summary> /// Add a class that already exists in the Model to the diagram. /// </summary> private void AddClassFromModel(UmlClass umlClass) { var umlDiagramClass = new UmlDiagramClass(umlClass, this) { ShowsMembers = ShowsMembers }; CheckForTags(umlDiagramClass); Model.FillMethodsFromClass(umlClass); umlDiagramClass.SyncAttributesAndOperationsFromModel(); modelToDiagramClasses[umlClass] = umlDiagramClass; umlDiagramClass.Pos = new Point(rand.NextDouble() * 300, rand.NextDouble() * 300); AddClass(umlDiagramClass); // // Add any relation that should be visible in the diagram now. // // // Don't just add all umlClass.Relations, only the ones that are connected to an // already shown class. // foreach (var umlDiagramClass2 in Classes) { List <UmlRelation> umlRelations = Model.Relations.Where( r => r.StartClass == umlClass && r.EndClass == umlDiagramClass2.Class || r.StartClass == umlDiagramClass2.Class && r.EndClass == umlClass ).ToList(); foreach (var umlRelation in umlRelations) { UmlDiagramRelation umlDiagramRelation = GetDiagramRelation(umlRelation); if (umlDiagramRelation == null) { AddRelationFromModel(umlRelation); } } } NotifyPropertyChanged(() => ClassNames); }
void get_children(UmlObject obj, ArrayList to) { if (obj is UmlProject) { obj = ((UmlProject)obj).root; } UmlTypeHolder from = obj as UmlTypeHolder; if (from == null) { return; } UmlNamespace ns = from as UmlNamespace; if (ns != null && ns.SubNamespaces != null) { foreach (UmlObject s in ns.SubNamespaces) { to.Add(s); } } foreach (UmlObject s in ((UmlTypeHolder)from).Types) { to.Add(s); } if (from is UmlClass) { UmlClass cl = (UmlClass)from; if (cl.Members != null) { foreach (UmlObject m in cl.Members) { to.Add(m); } } } }
public UmlMethod(Tag tag, UmlClass classobj) : base(tag) { Tag[] paramtags = VSParser.ExtractTags (ref tag.Content, "parameter"); returntype = "void"; List<string> parameterlist = new List<string> (); foreach (Tag proptag in paramtags) { string type = proptag.ParseType (); if (proptag.Params.ContainsKey ("direction") && proptag.Params ["direction"].ToLower () == "return") { returntype = type; } else { if (type == "void") parameterlist.Add (proptag.Name); else parameterlist.Add (type + " " + proptag.Name); } } parameters = parameterlist.ToArray (); commentsKey = Comments.Key (classobj.Name, name, parameters.Unique () + returntype); }
public UmlMethod(CSharpBlock block, UmlClass classobj) : base(block) { parseParams (); if (name.Contains (" ")) { string[] p = name.CleanGenerics () .Split (new char[]{' '}, StringSplitOptions.RemoveEmptyEntries); returntype = p [0]; name = ""; for (int i = 0; i < p.Length; ++i) { name += i == 0 ? "" : " " + p [i]; } } if (name == "") { name = returntype; returntype = ""; } if (returntype == "void") returntype = ""; name = name.TrimAll (); commentsKey = Comments.Key (classobj.Name, name, parameters.Unique () + returntype); }
public string ToCSharpCode(int padding, Virtuality virt, UmlClass inClass) { if (virt == CSharpUML.Virtuality.None) virt = Virtuality; string paddingStr = String.Concat (Enumerable.Repeat (" ", padding)); List<string> lines = new List<string> (); lines.AddRange (Comments.CSharpComments (commentsKey, paddingStr)); string uml = paddingStr; // public, virtual string _keywords = Comments.GetCommentParameter (commentsKey, "keywords"); if (_keywords != null) uml += _keywords.TrimAll ().ToCode ("", " "); else if (inClass != null && inClass.type == ClassType.Interface) uml += ""; else uml += Publicity.ToCode ("", " ") + virt.ToCode ("", " "); // return type string _returntype = Comments.GetCommentParameter (commentsKey, "returntype"); if (_returntype != null) uml += _returntype.ToCSharpType () + " "; else if (IsContructor) uml += ""; else if (returntype.Length > 0) uml += returntype.ToCSharpType ().ToCode ("", " "); else uml += "void "; // name string _name = Comments.GetCommentParameter (commentsKey, "name"); if (_name != null) uml += _name; else uml += name; // index operator [ ] if (name == "this") { uml += " [" + string.Join (", ", parameters) + "]"; lines.Add (uml); lines.Add (paddingStr + "{"); lines.Add (paddingStr + " " + "get { throw new System.NotImplementedException(); }"); lines.Add (paddingStr + " " + "set { throw new System.NotImplementedException(); }"); lines.Add (paddingStr + "}"); } // normal method else { uml += " ("; string _parameters = Comments.GetCommentParameter (commentsKey, "parameters"); if (_parameters != null) { uml += _parameters; } else { for (int i = 0; i < parameters.Length; ++i) { if (i > 0) uml += ", "; if (parameters [i].Contains (" ")) { String[] p = parameters [i].Split (new char[] { ' ' }, 2); uml += p [0].ToCSharpType () + " " + p [1]; } else uml += parameters [i].ToCSharpType () + " " + parameters [i].ToLower (); } } uml += ")"; if (uml.Contains ("ModelFactory") && uml.Contains ("Func<")) uml = paddingStr + "public ModelFactory (Func<GameScreen, GameModelInfo, GameModel> createModel)"; string _base = Comments.GetCommentParameter (commentsKey, "base"); if (_base != null) uml += "\n" + paddingStr + " : base(" + _base.TrimAll () + ")"; if (inClass.type == ClassType.Interface) { lines.Add (uml + ";"); } else { lines.Add (uml); lines.Add (paddingStr + "{"); lines.Add (paddingStr + " " + "throw new System.NotImplementedException();"); lines.Add (paddingStr + "}"); } } return string.Join ("\n", lines); }
public string ToCSharpCode(int padding, Virtuality virt, UmlClass inClass) { if (virt == CSharpUML.Virtuality.None) virt = Virtuality; string paddingStr = String.Concat (Enumerable.Repeat (" ", padding)); List<string> lines = new List<string> (); lines.AddRange (Comments.CSharpComments (commentsKey, paddingStr)); string uml = paddingStr + ((inClass != null && inClass.type == ClassType.Interface) ? "" : Publicity.ToCode ("", " ") + Virtuality.ToCode ("", " ")); uml += type.ToCSharpType () + " " + name + " { get; set; }"; lines.Add (uml); return string.Join ("\n", lines); }
private UmlType UpdateTypeInArray( ArrayList Types, Type t, string typename ) { // resolve kind UmlKind kind = UmlKind.Class; if( t.IsInterface ) kind = UmlKind.Interface; else if( t.IsEnum ) kind = UmlKind.Enum; else if( t.IsValueType ) kind = UmlKind.Struct; // search existing or create a new UmlType found = null; foreach( UmlType e in Types ) if( e.name.Equals( typename ) ) { found = e; break; } recreate: if( found == null ) { if( kind == UmlKind.Enum ) { found = new UmlEnum(); } else { found = new UmlClass(); ((UmlClass)found).kind = kind; } found.name = typename; Types.Add( found ); } else { if( found.Kind == UmlKind.Enum && kind != UmlKind.Enum || found.Kind != UmlKind.Enum && kind == UmlKind.Enum ) { Types.Remove( found ); found = null; goto recreate; } if( found.Kind != UmlKind.Enum ) { ((UmlClass)found).kind = kind; } found.Deleted = false; } return found; }