public MessageActorWidget(Type actorType, MessageFlowRenderer messageRelationsRenderer) : base() { this.messageFlowRenderer = messageRelationsRenderer; ActorType = actorType; ActorTypeName = CodeControlEditorHelper.GetActualTypeName(ActorType); sentMessageLogs = new Dictionary <Type, List <LoggedMessage> >(); handledMessageLogs = new Dictionary <Type, List <LoggedMessage> >(); }
protected override void ShowContextMenu() { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Open " + ModelType.ToString() + ".cs"), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(ModelType); }); menu.ShowAsContext(); }
private void AddContextMenuActors(GenericMenu menu, string listName, List <MessageActorWidget> actors) { if (actors.Count == 0) { menu.AddDisabledItem(new GUIContent(listName)); return; } foreach (MessageActorWidget actor in actors) { menu.AddItem(new GUIContent(listName + "/" + actor.ActorType.ToString() + ".cs"), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(actor.ActorType); }); } }
protected override void ShowContextMenu() { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Open " + typeName + ".cs"), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(ModelType); }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Hide"), false, delegate() { modelRelationsRenderer.RemoveModelRelationsWidget(this); }); menu.ShowAsContext(); }
public static List <Type> GetAllModelTypes() { List <Type> types = new List <Type>(); foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in asm.GetTypes()) { if (CodeControlEditorHelper.IsDerived(type, typeof(Model)) && type != typeof(ModelProxy)) { types.Add(type); } } } return(types); }
protected override void ShowContextMenu() { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Open " + ActorTypeName + ".cs"), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(ActorType); }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Hide"), false, delegate() { messageFlowRenderer.RemoveActor(this); }); if (!messageFlowRenderer.ContainsIndirectActors(this)) { menu.AddDisabledItem(new GUIContent("Hide Indirect")); } else { menu.AddItem(new GUIContent("Hide Indirect"), false, delegate() { messageFlowRenderer.RemoveIndirectActors(this); }); } if (!messageFlowRenderer.ContainsUnrelatedActors(this)) { menu.AddDisabledItem(new GUIContent("Hide Unrelated")); } else { menu.AddItem(new GUIContent("Hide Unrelated"), false, delegate() { messageFlowRenderer.RemoveUnrelatedActors(this); }); } menu.AddSeparator(""); AddContextMenuLoggedMessages(menu, "Sent Messages", "To ", sentMessageLogs); AddContextMenuLoggedMessages(menu, "Received Messages", "From ", handledMessageLogs); menu.ShowAsContext(); }
public ModelRelationsWidget(Type modelType, ModelRelationsRenderer modelRelationsRenderer) : base() { ModelType = modelType; this.modelRelationsRenderer = modelRelationsRenderer; typeName = CodeControlEditorHelper.GetActualTypeName(modelType); }
public ModelStructuresRenderer() { rootNodes = new List <ModelTypeWidgetNode>(); // Create a rootNode for all types List <Type> types = CodeControlEditorHelper.GetAllModelTypes(); List <TypeAggregation> takenTypes = new List <TypeAggregation>(); foreach (Type type in types) { ModelTypeWidgetNode node = new ModelTypeWidgetNode(type); rootNodes.Add(node); List <TypeAggregation> aggregatedTypes = node.GetAggregatedTypes(); foreach (TypeAggregation aggregatedType in aggregatedTypes) { takenTypes.Add(aggregatedType); } } // Remove rootNodes that are aggregated in other rootNodes while (true) { bool rootNodeRemoved = false; for (int i = rootNodes.Count - 1; i >= 0; i--) { List <TypeAggregation> takenInTypes = takenTypes.FindAll(x => x.Child == rootNodes[i].TypeWidget.ModelType); foreach (TypeAggregation aggregation in takenInTypes) { // Check if the parent of this rootNode would remain in other rootNodes if this would be removed bool parentWillRemain = rootNodes.Find(x => x.TypeWidget.ModelType == aggregation.Parent) != null; if (!parentWillRemain) { foreach (ModelTypeWidgetNode rootNode in rootNodes) { if (rootNode == rootNodes[i]) { continue; } List <TypeAggregation> aggregatedTypes = rootNode.GetAggregatedTypes(); foreach (TypeAggregation aggregatedType in aggregatedTypes) { if (aggregatedType.Child == aggregation.Parent) { parentWillRemain = true; break; } } if (parentWillRemain) { break; } } } if (parentWillRemain) { rootNodes.RemoveAt(i); i = rootNodes.Count - 1; rootNodeRemoved = true; break; } } } if (!rootNodeRemoved) { break; } } // Position rootNodes float maxWidth = 0; float totalHeight = 0; foreach (ModelTypeWidgetNode rootNode in rootNodes) { rootNode.SetPosition(new Vector2(ModelTypeWidget.Width * .5f, ModelTypeWidget.Height * .5f + totalHeight)); maxWidth = Mathf.Max(maxWidth, rootNode.Width); totalHeight += rootNode.Height + marginVert; } boundingBox = new Rect(0, 0, maxWidth, totalHeight); }
public bool IsActualType(Type type) { return(CodeControlEditorHelper.GetActualTypeName(type) == TypeName); }
public ModelActorWidget(Type modelType, ModelRelationsWidget modelRelationsWidget) : base() { ModelType = modelType; this.modelRelationsWidget = modelRelationsWidget; TypeName = CodeControlEditorHelper.GetActualTypeName(modelType); }
private void AddContextMenuLoggedMessages(GenericMenu menu, string listName, string messageActorPrefix, Dictionary <Type, List <LoggedMessage> > logs) { if (logs.Count == 0) { menu.AddDisabledItem(new GUIContent(listName)); return; } const string typelessMessagesName = "Typeless Messages"; foreach (KeyValuePair <Type, List <LoggedMessage> > pair in logs) { bool isTypeless = pair.Key == typeof(Message); string typeName = isTypeless ? typelessMessagesName : pair.Key.ToString(); // Check if there is no nameless message of a typed message if (!isTypeless) { menu.AddItem(new GUIContent(listName + "/" + typeName + "/Open " + typeName + ".cs"), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(pair.Key); }); menu.AddSeparator(listName + "/" + typeName + "/"); } // Make sure the nameless message shows first List <LoggedMessage> sortedLogMessages = new List <LoggedMessage>(); LoggedMessage namelessMessage = pair.Value.Find(x => x.MessageName == ""); if (namelessMessage != null) { sortedLogMessages.Add(namelessMessage); } sortedLogMessages.AddList <LoggedMessage>(pair.Value.FindAll(x => x.MessageName != "")); int messageIndex = 0; foreach (LoggedMessage logMessage in sortedLogMessages) { // If this message is nameless, show title as nameless if (logMessage.MessageName == "") { menu.AddDisabledItem(new GUIContent(listName + "/" + typeName + "/Nameless Message")); } else { menu.AddDisabledItem(new GUIContent(listName + "/" + typeName + "/" + '"' + logMessage.MessageName + '"')); } foreach (MessageActorWidget actor in logMessage.AssociatedActors) { string itemName = messageActorPrefix + actor.ActorTypeName + ".cs"; // Add blank spaces as postfix to force the ContextMenu to show these items more than once for (int i = 0; i < messageIndex; i++) { itemName += ' '; } menu.AddItem(new GUIContent(listName + "/" + typeName + "/" + itemName), false, delegate() { CodeControlEditorHelper.OpenCodeOfType(actor.ActorType); }); } if (pair.Value.IndexOf(logMessage) < pair.Value.Count - 1) { menu.AddSeparator(listName + "/" + typeName + "/"); } messageIndex++; } } }