public static void RemoveEntity(EntitySave entityToRemove) { TreeNode treeNode = GlueState.Self.Find.TreeNodeForDirectory( FileManager.GetDirectory(entityToRemove.Name)); for (int i = 0; i < treeNode.Nodes.Count; i++) { EntityTreeNode entityTreeNode = treeNode.Nodes[i] as EntityTreeNode; if (entityTreeNode != null && entityTreeNode.EntitySave == entityToRemove) { treeNode.Nodes.RemoveAt(i); break; } } }
public TreeNode NamedObjectTreeNode(NamedObjectSave namedObjectSave) { IElement container = namedObjectSave.GetContainer(); if (container is ScreenSave) { ScreenTreeNode screenTreeNode = GlueState.Self.Find.ScreenTreeNode((ScreenSave)container); return(screenTreeNode.GetTreeNodeFor(namedObjectSave)); } else if (container is EntitySave) { EntityTreeNode entityTreeNode = GlueState.Self.Find.EntityTreeNode((EntitySave)container); return(entityTreeNode.GetTreeNodeFor(namedObjectSave)); } else { return(null); } }
public TreeNode ReferencedFileSaveTreeNode(ReferencedFileSave referencedFileSave) { IElement container = referencedFileSave.GetContainer(); if (container == null) { return(TreeNodeByTagIn(referencedFileSave, ElementViewWindow.GlobalContentFileNode.Nodes)); } else if (container is ScreenSave) { ScreenTreeNode screenTreeNode = GlueState.Self.Find.ScreenTreeNode((ScreenSave)container); return(screenTreeNode.GetTreeNodeFor(referencedFileSave)); } else if (container is EntitySave) { EntityTreeNode entityTreeNode = GlueState.Self.Find.EntityTreeNode((EntitySave)container); return(entityTreeNode.GetTreeNodeFor(referencedFileSave)); } return(null); }
static void MoveEntityToDirectory(EntityTreeNode treeNodeMoving, TreeNode targetNode) { bool succeeded = true; EntitySave entitySave = treeNodeMoving.EntitySave; string newRelativeDirectory = targetNode.GetRelativePath(); string newName = newRelativeDirectory.Replace("/", "\\") + entitySave.ClassName; // modify data and files succeeded = GlueCommands.Self.GluxCommands.MoveEntityToDirectory(entitySave, newRelativeDirectory); // adjust the UI if (succeeded) { treeNodeMoving.Parent.Nodes.Remove(treeNodeMoving); targetNode.Nodes.Add(treeNodeMoving); treeNodeMoving.GeneratedCodeFile = newName + ".Generated.cs"; treeNodeMoving.CodeFile = newName + ".cs"; treeNodeMoving.Text = FileManager.RemovePath(newName); } // Generate and save if (succeeded) { // 7: Save it! GlueCommands.Self.ProjectCommands.MakeGeneratedCodeItemsNested(); CodeWriter.GenerateCode(entitySave); GluxCommands.Self.SaveGlux(); GlueCommands.Self.ProjectCommands.SaveProjects(); GlueState.Self.CurrentElement = entitySave; } }
private void CreateEntityTreeNodes() { //ProjectManager.GlueProjectSave.Entities[78].NamedObjects[9].UpdateCustomProperties(); // Let's make this faster. //foreach (EntitySave entity in ProjectManager.GlueProjectSave.Entities) // Actually, the contained functions may show popups, and if 2 simultaneous popups // are shown, one can cancel the other out and this can cause Glue to freeze. This means // we can't parallel foreah it //Parallel.ForEach(ProjectManager.GlueProjectSave.Entities, (entity) => foreach (EntitySave entity in ProjectManager.GlueProjectSave.Entities) { entity.UpdateCustomProperties(); entity.UpdateFromBaseType(); } for (int i = 0; i < ProjectManager.GlueProjectSave.Entities.Count; i++) { EntitySave entitySave = ProjectManager.GlueProjectSave.Entities[i]; // This is so fast that we no longer need to show the // user details - and not doing it will make things even faster //SetInitWindowText("Creating Entity: " + entitySave.Name); EntityTreeNode entityTreeNode = GlueState.Self.Find.EntityTreeNode(entitySave.Name); #region If there is no EntityTreeNode if (entityTreeNode == null) { // See if the file exists string fileToSearchFor = FileManager.RelativeDirectory + entitySave.Name + ".cs"; if (System.IO.File.Exists(fileToSearchFor)) { // If we got here that means there's probably not a build item for this file MessageBox.Show("The Glue project has the following Entity:\n" + entitySave.Name + "\n" + "but this file is not part of Visual Studio. This file may have been removed manually or " + "there may have been some saving error. You should close Glue, manually add this and the Generated file " + "to Visual Studio, then restart Glue."); MainGlueWindow.Self.HasErrorOccurred = true; } else { MultiButtonMessageBox mbmb = new MultiButtonMessageBox(); mbmb.MessageText = "Could not find the file name\n\n" + fileToSearchFor + "\n\nwhich is used by the entity\n\n" + entitySave.Name + "\n\n" + "What would you like to do?"; mbmb.AddButton("Create a new custom code file", DialogResult.Yes); mbmb.AddButton("Delete this Entity", DialogResult.No); mbmb.AddButton("Do nothing. The Entity will not show up in Glue until this problem is fixed.", DialogResult.Cancel); DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self); switch (result) { case DialogResult.Yes: if (entityTreeNode == null) { entityTreeNode = ElementViewWindow.AddEntity(entitySave); } CodeWriter.GenerateAndAddElementCustomCode(entitySave); //entityTreeNode.GenerateCode(ProjectManager.EntityTemplateCode); break; case DialogResult.No: ProjectManager.GlueProjectSave.Entities.RemoveAt(i); i--; continue; //break; case DialogResult.Cancel: // do nothing continue; //break; } System.Windows.Forms.MessageBox.Show("Could not create the EntitySave for " + entitySave.Name + " because the following file doesn't exist\n\n" + fileToSearchFor); } //mGlueProjectSave.Entities.RemoveAt(i); //i--; } #endregion entityTreeNode.EntitySave = entitySave; CheckForMissingCustomFile(entityTreeNode); entityTreeNode.UpdateReferencedTreeNodes(); // moved above //entityTreeNode.EntitySave.UpdateCustomProperties(); //entityTreeNode.EntitySave.UpdateFromBaseType(); } }
public static void UpdateAllDerivedElementFromBaseValues(bool regenerateCode) { if (EditorLogic.CurrentEntitySave != null) { List <EntitySave> derivedEntities = ObjectFinder.Self.GetAllEntitiesThatInheritFrom(EditorLogic.CurrentEntitySave.Name); List <NamedObjectSave> nosList = ObjectFinder.Self.GetAllNamedObjectsThatUseEntity(EditorLogic.CurrentEntitySave.Name); for (int i = 0; i < derivedEntities.Count; i++) { EntitySave entitySave = derivedEntities[i]; nosList.AddRange(ObjectFinder.Self.GetAllNamedObjectsThatUseEntity(entitySave.Name)); entitySave.UpdateFromBaseType(); // Update the tree nodes EntityTreeNode treeNode = GlueState.Self.Find.EntityTreeNode(entitySave); treeNode.UpdateReferencedTreeNodes(); if (regenerateCode) { CodeWriter.GenerateCode(entitySave); } } foreach (NamedObjectSave nos in nosList) { nos.UpdateCustomProperties(); IElement element = nos.GetContainer(); if (element != null) { CodeWriter.GenerateCode(element); } } } else if (EditorLogic.CurrentScreenSave != null) { List <ScreenSave> derivedScreens = ObjectFinder.Self.GetAllScreensThatInheritFrom(EditorLogic.CurrentScreenSave.Name); for (int i = 0; i < derivedScreens.Count; i++) { ScreenSave screenSave = derivedScreens[i]; screenSave.UpdateFromBaseType(); ScreenTreeNode treeNode = GlueState.Self.Find.ScreenTreeNode(screenSave); treeNode.UpdateReferencedTreeNodes(); if (regenerateCode) { CodeWriter.GenerateCode(screenSave); } } } else { if (EditorLogic.CurrentNamedObject == null) { // This means the value is being set on the Screen itself throw new NotImplementedException(); } } }
public TreeNode MoveEntityOn(EntityTreeNode treeNodeMoving, TreeNode targetNode) { TreeNode newTreeNode = null; #region Moving the Entity into (or out of) a directory if (targetNode.IsDirectoryNode() || targetNode.IsRootEntityNode()) { MoveEntityToDirectory(treeNodeMoving, targetNode); } #endregion #region Moving an Entity onto another element to create an instance else if (targetNode.IsEntityNode() || targetNode.IsScreenNode() || targetNode.IsRootNamedObjectNode()) { bool isValidDrop = true; // Make sure that we don't drop an Entity into its own Objects if (targetNode.IsRootNamedObjectNode()) { if (treeNodeMoving == targetNode.GetContainingElementTreeNode()) { isValidDrop = false; } } if (isValidDrop) { newTreeNode = MoveEntityOntoElement(treeNodeMoving, targetNode, newTreeNode); } } #endregion #region Moving an Entity onto a NamedObject (currently supports only Lists) else if (targetNode.IsNamedObjectNode()) { // Allow drop only if it's a list or Layer NamedObjectSave targetNamedObjectSave = targetNode.Tag as NamedObjectSave; if (!targetNamedObjectSave.IsList && !targetNamedObjectSave.IsLayer) { MessageBox.Show("The target is not a List or Layer so we can't add an Object to it.", "Target not valid"); } if (targetNamedObjectSave.IsLayer) { TreeNode parent = targetNode.Parent; newTreeNode = MoveEntityOn(treeNodeMoving, parent); // this created a new NamedObjectSave. Let's put that on the Layer DragDropManager.Self.MoveNamedObject(newTreeNode, targetNode); } else { // Make sure that the two types match string listType = targetNamedObjectSave.SourceClassGenericType; bool isOfTypeOrInherits = listType == treeNodeMoving.EntitySave.Name || treeNodeMoving.EntitySave.InheritsFrom(listType); if (isOfTypeOrInherits == false) { MessageBox.Show("The target list type is of type\n\n" + listType + "\n\nBut the Entity is of type\n\n" + treeNodeMoving.EntitySave.Name + "\n\nCould not add an instance to the list", "Could not add instance"); } else { NamedObjectSave namedObject = new NamedObjectSave(); namedObject.InstanceName = FileManager.RemovePath(treeNodeMoving.EntitySave.Name) + "1"; StringFunctions.MakeNameUnique <NamedObjectSave>( namedObject, targetNamedObjectSave.ContainedObjects); // Not sure if we need to set this or not, but I think // any instance added to a list will not be defined by base namedObject.DefinedByBase = false; NamedObjectSaveExtensionMethodsGlue.AddNamedObjectToCurrentNamedObjectList(namedObject); ElementViewWindow.GenerateSelectedElementCode(); // Don't save the Glux, the caller of this method will take care of it // GluxCommands.Self.SaveGlux(); } } } #endregion else if (targetNode.IsGlobalContentContainerNode()) { AskAndAddAllContainedRfsToGlobalContent(treeNodeMoving.SaveObject); } return(newTreeNode); }
public static EntityTreeNode AddEntity(EntitySave entitySave, bool generateCode = true) { Section.GetAndStartContextAndTime("Constructor"); EntityTreeNode treeNode = new EntityTreeNode(FileManager.RemovePath(entitySave.Name)); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Code file"); treeNode.CodeFile = entitySave.Name + ".cs"; Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Add node"); TreeNode treeNodeToAddTo = null; bool succeeded = true; if (entitySave.Name.StartsWith("Entities/") == false && entitySave.Name.StartsWith("Entities\\") == false) { GlueGui.ShowMessageBox( "The Entity named " + entitySave.Name + " must have a name that starts with \"Entities/\""); succeeded = false; } if (succeeded) { string containingDirectory = FileManager.MakeRelative(FileManager.GetDirectory(entitySave.Name)); if (containingDirectory == "Entities/") { treeNodeToAddTo = mEntityNode; } else { string directory = containingDirectory.Substring("Entities/".Length); treeNodeToAddTo = GlueState.Self.Find.TreeNodeForDirectoryOrEntityNode( directory, mEntityNode); if (treeNodeToAddTo == null && !string.IsNullOrEmpty(directory)) { // If it's null that may mean the directory doesn't exist. We should make it string absoluteDirectory = ProjectManager.MakeAbsolute(containingDirectory); if (!Directory.Exists(absoluteDirectory)) { Directory.CreateDirectory(absoluteDirectory); } AddDirectoryNodes(FileManager.RelativeDirectory + "Entities/", mEntityNode); // now try again treeNodeToAddTo = GlueState.Self.Find.TreeNodeForDirectoryOrEntityNode( directory, mEntityNode); } } // Someone in the chat room got a crash on the Add call. Not sure why // so adding these to help find out what's up. if (treeNodeToAddTo == null) { throw new NullReferenceException("treeNodeToAddTo is null. This is bad"); } if (treeNode == null) { throw new NullReferenceException("treeNode is null. This is bad"); } treeNodeToAddTo.Nodes.Add(treeNode); treeNodeToAddTo.Nodes.SortByTextConsideringDirectories(); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Set generated"); string generatedFile = entitySave.Name + ".Generated.cs"; if (FileManager.FileExists(generatedFile)) { treeNode.GeneratedCodeFile = generatedFile; } Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Sort"); SortEntities(); Section.EndContextAndTime(); treeNode.EntitySave = entitySave; } return(treeNode); }
public static EntityTreeNode AddEntity(EntitySave entitySave, bool generateCode = true) { Section.GetAndStartContextAndTime("Constructor"); EntityTreeNode treeNode = new EntityTreeNode(FileManager.RemovePath(entitySave.Name)); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Code file"); treeNode.CodeFile = entitySave.Name + ".cs"; Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Add node"); TreeNode treeNodeToAddTo = null; bool succeeded = true; if (entitySave.Name.StartsWith("Entities/") == false && entitySave.Name.StartsWith("Entities\\") == false) { GlueGui.ShowMessageBox( "The Entity named " + entitySave.Name + " must have a name that starts with \"Entities/\""); succeeded = false; } if (succeeded) { string containingDirectory = FileManager.MakeRelative(FileManager.GetDirectory(entitySave.Name)); if (containingDirectory == "Entities/") { treeNodeToAddTo = mEntityNode; } else { string directory = containingDirectory.Substring("Entities/".Length); treeNodeToAddTo = GlueState.Self.Find.TreeNodeForDirectoryOrEntityNode( directory, mEntityNode); if (treeNodeToAddTo == null && !string.IsNullOrEmpty(directory)) { // If it's null that may mean the directory doesn't exist. We should make it string absoluteDirectory = ProjectManager.MakeAbsolute(containingDirectory); if (!Directory.Exists(absoluteDirectory)) { Directory.CreateDirectory(absoluteDirectory); } AddDirectoryNodes(FileManager.RelativeDirectory + "Entities/", mEntityNode); // now try again treeNodeToAddTo = GlueState.Self.Find.TreeNodeForDirectoryOrEntityNode( directory, mEntityNode); } } // Someone in the chat room got a crash on the Add call. Not sure why // so adding these to help find out what's up. if (treeNodeToAddTo == null) { throw new NullReferenceException("treeNodeToAddTo is null. This is bad"); } if (treeNode == null) { throw new NullReferenceException("treeNode is null. This is bad"); } treeNodeToAddTo.Nodes.Add(treeNode); treeNodeToAddTo.Nodes.SortByTextConsideringDirectories(); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Set generated"); string generatedFile = entitySave.Name + ".Generated.cs"; if (FileManager.FileExists(generatedFile)) { treeNode.GeneratedCodeFile = generatedFile; } Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Sort"); SortEntities(); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Tag"); treeNode.EntitySave = entitySave; //UpdateNodeToListIndex(entitySave); Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Generate code"); if (generateCode && !string.IsNullOrEmpty(treeNode.GeneratedCodeFile)) { CodeWriter.GenerateCode(entitySave); } Section.EndContextAndTime(); } return treeNode; }
public static TreeNode MoveEntityOn(EntityTreeNode treeNodeMoving, TreeNode targetNode) { TreeNode newTreeNode = null; #region Moving the Entity into (or out of) a directory if (targetNode.IsDirectoryNode() || targetNode.IsRootEntityNode()) { MoveEntityToDirectory(treeNodeMoving, targetNode); } #endregion #region Moving an Entity onto another element to create an instance else if (targetNode.IsEntityNode() || targetNode.IsScreenNode() || targetNode.IsRootNamedObjectNode()) { bool isValidDrop = true; // Make sure that we don't drop an Entity into its own Objects if (targetNode.IsRootNamedObjectNode()) { if(treeNodeMoving == targetNode.GetContainingElementTreeNode()) { isValidDrop = false; } } if (isValidDrop) { newTreeNode = MoveEntityOntoElement(treeNodeMoving, targetNode, newTreeNode); } } #endregion #region Moving an Entity onto a NamedObject (currently supports only Lists) else if (targetNode.IsNamedObjectNode()) { // Allow drop only if it's a list or Layer NamedObjectSave targetNamedObjectSave = targetNode.Tag as NamedObjectSave; if (!targetNamedObjectSave.IsList && !targetNamedObjectSave.IsLayer) { MessageBox.Show("The target is not a List or Layer so we can't add an Object to it.", "Target not valid"); } if (targetNamedObjectSave.IsLayer) { TreeNode parent = targetNode.Parent; newTreeNode = MoveEntityOn(treeNodeMoving, parent); // this created a new NamedObjectSave. Let's put that on the Layer MoveNamedObject(newTreeNode, targetNode); } else { // Make sure that the two types match string listType = targetNamedObjectSave.SourceClassGenericType; if (listType != treeNodeMoving.EntitySave.Name) { MessageBox.Show("The target list type is of type\n\n" + listType + "\n\nBut the Entity is of type\n\n" + treeNodeMoving.EntitySave.Name + "\n\nCould not add an instance to the list", "Could not add instance"); } else { NamedObjectSave namedObject = new NamedObjectSave(); namedObject.InstanceName = FileManager.RemovePath(listType) + "1"; StringFunctions.MakeNameUnique<NamedObjectSave>( namedObject, targetNamedObjectSave.ContainedObjects); // Not sure if we need to set this or not, but I think // any instance added to a list will not be defined by base namedObject.DefinedByBase = false; NamedObjectSaveExtensionMethodsGlue.AddNamedObjectToCurrentNamedObjectList(namedObject); ElementViewWindow.GenerateSelectedElementCode(); // Don't save the Glux, the caller of this method will take care of it // GluxCommands.Self.SaveGlux(); } } } #endregion else if (targetNode.IsGlobalContentContainerNode()) { AskAndAddAllContainedRfsToGlobalContent(treeNodeMoving.SaveObjectAsElement); } return newTreeNode; }
static void MoveEntityToDirectory(EntityTreeNode treeNodeMoving, TreeNode targetNode) { bool succeeded = true; // Things to do: // 1 Move the TreeNode from one parent TreeNode to another // 2 Move the .cs and .generated.cs file from one folder to another // 3 Remove the BuildItems from the project and add them back in in the VisualStudio project // 4 Change the EntitySave's name // 5 Change namespaces // 6 Find all NamedObjectSaves that are use this Entity and re-generate the Elements, and also see if anything uses it as a base // 7 Save everything! EntitySave entitySave = treeNodeMoving.EntitySave; string targetDirectory = FileManager.RelativeDirectory + targetNode.GetRelativePath(); string oldName = entitySave.Name; string newName = targetNode.GetRelativePath().Replace("/", "\\") + entitySave.ClassName; succeeded = MoveEntityCodeFilesToDirectory(entitySave, targetDirectory); if (succeeded) { // 1: Move it from one node to another treeNodeMoving.Parent.Nodes.Remove(treeNodeMoving); targetNode.Nodes.Add(treeNodeMoving); // 2: Move the .cs files // Also handled above. treeNodeMoving.GeneratedCodeFile = newName + ".Generated.cs"; treeNodeMoving.CodeFile = newName + ".cs"; } if(succeeded) { // 4: Change the Entity's name entitySave.Name = newName; treeNodeMoving.Text = FileManager.RemovePath(newName); } if (succeeded) { // Do this after changing the name of the Entity so // namespaces come over properly succeeded = UpdateNamespaceOnCodeFiles(entitySave); } if(succeeded) { // 5: Change namespaces string newNamespace = ProjectManager.ProjectNamespace + "." + FileManager.MakeRelative(targetDirectory).Replace("/", "."); newNamespace = newNamespace.Substring(0, newNamespace.Length - 1); string customFileContents = FileManager.FromFileText(FileManager.RelativeDirectory + newName + ".cs"); customFileContents = CodeWriter.ReplaceNamespace(customFileContents, newNamespace); FileManager.SaveText(customFileContents, FileManager.RelativeDirectory + newName + ".cs"); // Generated will automatically have its namespace changed when it is re-generated // 6: Find all objects referending this NamedObjectSave and re-generate the code if (entitySave.CreatedByOtherEntities) { // Vic says: I'm tired. For now just ignore the directory. Fix this when it becomes a problem. FactoryCodeGenerator.UpdateFactoryClass(entitySave); } List<NamedObjectSave> namedObjects = ObjectFinder.Self.GetAllNamedObjectsThatUseEntity(oldName); // Let's get all the TreeNodes to regenerate. // We want to store them in a list so we only generate // each tree node once. List<BaseElementTreeNode> treeNodesForElementsToRegenerate = new List<BaseElementTreeNode>(); foreach (NamedObjectSave nos in namedObjects) { if (nos.SourceClassGenericType == oldName) { nos.SourceClassGenericType = newName; } if (nos.SourceClassType == oldName) { nos.SourceClassType = newName; } IElement element = nos.GetContainer(); BaseElementTreeNode treeNode = GlueState.Self.Find.ElementTreeNode(element); if (!treeNodesForElementsToRegenerate.Contains(treeNode)) { treeNodesForElementsToRegenerate.Add(treeNode); } } foreach (EntitySave esToTestForInheritance in ProjectManager.GlueProjectSave.Entities) { if (esToTestForInheritance.BaseEntity == oldName) { esToTestForInheritance.BaseEntity = newName; BaseElementTreeNode treeNode = GlueState.Self.Find.EntityTreeNode(esToTestForInheritance); if (!treeNodesForElementsToRegenerate.Contains(treeNode)) { treeNodesForElementsToRegenerate.Add(treeNode); } } } foreach (BaseElementTreeNode treeNode in treeNodesForElementsToRegenerate) { CodeWriter.GenerateCode(treeNode.SaveObjectAsElement); } // 7: Save it! ProjectLoader.Self.MakeGeneratedItemsNested(); CodeWriter.GenerateCode(treeNodeMoving.SaveObjectAsElement); GluxCommands.Self.SaveGlux(); ProjectManager.SaveProjects(); } }
private static TreeNode MoveEntityOntoElement(EntityTreeNode treeNodeMoving, TreeNode targetNode, TreeNode newTreeNode) { EntitySave entitySaveMoved = treeNodeMoving.EntitySave; #region Get the IElement elementToCreateIn IElement elementToCreateIn = null; if (targetNode.IsRootNamedObjectNode()) { BaseElementTreeNode baseElementTreeNode = targetNode.Parent as BaseElementTreeNode; elementToCreateIn = baseElementTreeNode.SaveObjectAsElement; } else { elementToCreateIn = ((BaseElementTreeNode)targetNode).SaveObjectAsElement; } #endregion DialogResult result = MessageBox.Show("Create a new Object in\n\n" + elementToCreateIn.Name + "\n\nusing\n\n\t" + entitySaveMoved.Name + "?", "Create new Object?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { NamedObjectSave newNamedObject = CreateNewNamedObjectInElement(elementToCreateIn, entitySaveMoved); newTreeNode = GlueState.Self.Find.NamedObjectTreeNode(newNamedObject); } return newTreeNode; }
static void MoveEntityToDirectory(EntityTreeNode treeNodeMoving, TreeNode targetNode) { bool succeeded = true; EntitySave entitySave = treeNodeMoving.EntitySave; string newRelativeDirectory = targetNode.GetRelativePath(); string newName = newRelativeDirectory.Replace("/", "\\") + entitySave.ClassName; // modify data and files succeeded = GlueCommands.Self.GluxCommands.MoveEntityToDirectory(entitySave, newRelativeDirectory); // adjust the UI if (succeeded) { treeNodeMoving.Parent.Nodes.Remove(treeNodeMoving); targetNode.Nodes.Add(treeNodeMoving); treeNodeMoving.GeneratedCodeFile = newName + ".Generated.cs"; treeNodeMoving.CodeFile = newName + ".cs"; treeNodeMoving.Text = FileManager.RemovePath(newName); } // Generate and save if (succeeded) { // 7: Save it! ProjectLoader.Self.MakeGeneratedItemsNested(); CodeWriter.GenerateCode(entitySave); GluxCommands.Self.SaveGlux(); ProjectManager.SaveProjects(); GlueState.Self.CurrentElement = entitySave; } }
private static TreeNode MoveEntityOntoElement(EntityTreeNode treeNodeMoving, TreeNode targetNode, TreeNode newTreeNode) { EntitySave entitySaveMoved = treeNodeMoving.EntitySave; #region Get the IElement elementToCreateIn IElement elementToCreateIn = null; if (targetNode.IsRootNamedObjectNode()) { BaseElementTreeNode baseElementTreeNode = targetNode.Parent as BaseElementTreeNode; elementToCreateIn = baseElementTreeNode.SaveObjectAsElement; } else { elementToCreateIn = ((BaseElementTreeNode)targetNode).SaveObjectAsElement; } #endregion // We used to ask the user if they're sure, but this isn't a destructive action so just do it: //DialogResult result = // MessageBox.Show("Create a new Object in\n\n" + elementToCreateIn.Name + "\n\nusing\n\n\t" + entitySaveMoved.Name + "?", "Create new Object?", MessageBoxButtons.YesNo); NamedObjectSave newNamedObject = CreateNewNamedObjectInElement(elementToCreateIn, entitySaveMoved); newTreeNode = GlueState.Self.Find.NamedObjectTreeNode(newNamedObject); return newTreeNode; }