Ejemplo n.º 1
0
        private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label != null && e.Label.Length > 0)
            {
                JsonFileData jsonFileData = e.Node.Tag as JsonFileData;
                ModuleFile   moduleFile   = jsonFileData.GetModuleFile();
                string       oldAlias     = moduleFile.FullAlias;
                Module       mod          = moduleFile.Module;
                string       newAlias     = mod.Name + ":" + e.Label;

                // Update the references to use the new alias.
                foreach (FileData reference in jsonFileData.ReferencedByFileData.Values)
                {
                    if (reference.FlatFileData != null)
                    {
                        string updatedFlatFile = reference.FlatFileData.Replace(oldAlias, newAlias);
                        reference.TrySetFlatFileData(updatedFlatFile);
                        reference.TrySaveFile();
                    }
                }

                mod.AddToManifest(e.Label, moduleFile.OriginalPath);
                mod.RemoveFromManifest("aliases", moduleFile.Name);
                mod.WriteManifestToFile();
                Reload();
            }
            else
            {
                e.CancelEdit = true;
            }
        }
Ejemplo n.º 2
0
        private bool CanAddFineVersion(FileData file)
        {
            JsonFileData jsonFileData = file as JsonFileData;

            if (jsonFileData == null)
            {
                return(false); // Don't know how to clone something not jsonFileData
            }

            ModuleFile moduleFile = jsonFileData.GetModuleFile();

            if (moduleFile == null || moduleFile.IsFineVersion || jsonFileData.JsonType != JSONTYPE.ENTITY)
            {
                return(false); // can only make fine version of a module file
            }

            string fineFullAlias = moduleFile.FullAlias + ":fine";

            if (ModuleDataManager.GetInstance().GetModuleFile(fineFullAlias) != null)
            {
                return(false); // fine already exists
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void treeView_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            TreeNode node = e.Node;

            if (node.Tag != null)
            {
                JsonFileData jsonFileData = node.Tag as JsonFileData;
                if (jsonFileData != null && jsonFileData.GetModuleFile() != null)
                {
                    return; // okay to edit aliases
                }
            }

            e.CancelEdit = true;
        }
Ejemplo n.º 4
0
        private void makeFineVersionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode     = treeView.SelectedNode;
            FileData selectedFileData = ModuleDataManager.GetInstance().GetSelectedFileData(treeView.SelectedNode);

            if (!CanAddFineVersion(selectedFileData))
            {
                return;
            }

            JsonFileData          jsonFileData = selectedFileData as JsonFileData;
            ModuleFile            moduleFile   = jsonFileData.GetModuleFile();
            CloneObjectParameters parameters   = new CloneObjectParameters();

            parameters.AddStringReplacement(moduleFile.ShortName, moduleFile.ShortName + "_fine");
            parameters.AddAliasReplacement(moduleFile.ShortName + "_fine", moduleFile.ShortName + ":fine");
            HashSet <string>          dependencies = ModuleDataManager.GetInstance().PreviewCloneDependencies(selectedFileData, parameters);
            PreviewCloneAliasCallback callback     = new PreviewCloneAliasCallback(this, selectedFileData, parameters);
            PreviewCloneDialog        dialog       = new PreviewCloneDialog("Creating " + moduleFile.ShortName + ":fine", dependencies, callback);

            dialog.ShowDialog();
        }