示例#1
0
        public void UpdateNodeText(string text)
        {
            if (currentNode != null)
            {
                object item = ((NodeInstance)currentNode.Tag).Instance.Item;

                if (item is IHasFullyQualifiedName)
                {
                    currentNode.Text = ((IHasFullyQualifiedName)item).FullyQualfiedName;
                }
                else
                {
                    currentNode.Text = text;
                }

                if (item is Symbol)
                {
                    string newSymbolName    = ((Symbol)item).Name;
                    string newStructureName = ((Symbol)item).Structure;

                    // Update the symbol list if it has changed.
                    if (symbolName != newSymbolName)
                    {
                        // TODO: Yuck.  Clean this up so the model is king, and drives any controller, and remove the inc/dec from the respective view!
                        ApplicationController.SymbolListController.
                        IfNotNull(ctrl => ctrl.ReplaceSymbol(symbolName, newSymbolName)).
                        Else(() =>
                        {
                            ApplicationModel.DecrementSymbolReference(symbolName);
                            ApplicationModel.IncrementSymbolReference(newSymbolName);
                        });
                        symbolName = newSymbolName;
                    }

                    if (structureName != newStructureName)
                    {
                        ApplicationController.StructureListController.
                        IfNotNull(ctrl => ctrl.ReplaceStructure(structureName, newStructureName)).
                        Else(() =>
                        {
                            ApplicationModel.DecrementStructureReference(structureName);
                            ApplicationModel.IncrementStructureReference(newStructureName);
                        });
                        structureName = newStructureName;
                    }

                    // If the symbol being selected already exists, copy over the current structure here as well.
                    // TODO: What happens if the referencing structure changes?  We need to update all the types with that reference.
                    // TODO: Verify that we're at a child node -- we can't have duplicate top level symbols.
                    if (ApplicationModel.SymbolRefCount[newSymbolName] > 1)
                    {
                        CopySymbolStructure(currentNode, newSymbolName);
                    }
                }
            }
        }