示例#1
0
        private void tvClassifications_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            classTreeNode newSelectedNode = e.Node as classTreeNode;

            if (newSelectedNode != null)
            {
                this.propertyGrid.SelectedObject = newSelectedNode.props;
// MIGRATION: why would you want to do this?
//				if (newSelectedNode.IsNewClass)
//					newSelectedNode = newSelectedNode;
            }
        }
示例#2
0
        private ArrayList BuildClassificationTree(MOG_Project proj)
        {
            ArrayList nodeList = new ArrayList();

            foreach (string rootName in proj.GetRootClassificationNames())
            {
                classTreeNode rootNode = BuildClassificationTree_Helper(rootName, proj);
                nodeList.Add(rootNode);
            }

            return(nodeList);
        }
示例#3
0
        private classTreeNode BuildClassificationTree_Helper(string className, MOG_Project proj)
        {
            // create a new class treenode
            classTreeNode classNode = new classTreeNode(className.Substring(className.LastIndexOf("~") + 1));                   // extract only last part of the name

            foreach (string subclassName in proj.GetSubClassificationNames(className))
            {
                classNode.Nodes.Add(BuildClassificationTree_Helper(className + "~" + subclassName, proj));
            }

            return(classNode);
        }
示例#4
0
        private void tvClassifications_MouseDown2(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            classTreeNode newSelectedNode = this.tvClassifications.GetNodeAt(e.X, e.Y) as classTreeNode;

            if (newSelectedNode == null)
            {
                return;
            }

            this.tvClassifications.SelectedNodes.Clear();
            this.tvClassifications.SelectedNodes.Add(newSelectedNode);

            PopulateClassNodeProps(newSelectedNode);
        }
示例#5
0
        private void PopulateClassNodeProps(classTreeNode ctn)
        {
            if (ctn != null)
            {
                // Get the classification's properties that we can edit
                ctn.props = MOG_Properties.OpenClassificationProperties(ctn.FullPath);
                ctn.props.SetImmeadiateMode(true);

                this.propertyGrid.SelectedObject = ctn.props;
// MIGRATION: whatever
//                if (ctn.IsNewClass)
//					ctn = ctn;
            }
        }
示例#6
0
        // helps CountClassifications()
        private int CountClassifications_helper(classTreeNode tn)
        {
            int count = 0;

            if (!tn.IsAssetFilenameNode)
            {
                count = 1;                              // count tn
            }
            foreach (classTreeNode subNode in tn.Nodes)
            {
                count += CountClassifications_helper(subNode);
            }

            return(count);
        }
示例#7
0
        private void CreateAllExtantClasses_Helper(MOG_Project proj, classTreeNode ctn)
        {
            if (ctn == null || ctn.TreeView == null)
            {
                return;
            }

            string fullClass = ctn.FullPath.Replace(ctn.TreeView.PathSeparator, "~");

            proj.ClassificationAdd(fullClass);

            foreach (classTreeNode subNode in ctn.Nodes)
            {
                CreateAllExtantClasses_Helper(proj, subNode);
            }
        }
示例#8
0
        // remove a class node
        private void RemoveClassificationNode(classTreeNode node)
        {
            if (node == null || node.TreeView == null)
            {
                return;
            }

            if (ClassTreeContainsAssets(node.FullPath))
            {
                // can't remove it because it's got children
                MOG_Prompt.PromptResponse("Unable to Remove Classification", "This Classification cannot be removed becuase it or its Subclassifications contain Assets.\nThese Assets must be removed before the Classification can be deleted.\nYou can use the 'Generate Report' feature in the MOG Client to remove this Classification's Assets.", "", MOGPromptButtons.OK, MOG_ALERT_LEVEL.CRITICAL);
                return;
            }

            // make sure they know what they're doing
            if (Utils.ShowMessageBoxConfirmation("Are you sure you want to remove this Classification and all its Subclassifications (if any)?", "Confirm Classification Removal") != MOGPromptResult.Yes)
            {
                return;
            }

            if (this.immediateMode)
            {
                // kill it no matter what
                MOG_ControllerProject.GetProject().ClassificationRemove(node.FullPath);
                node.Remove();
                return;
            }


            if (node.IsNewClass)
            {
                // this is a new node, so it hasn't been saved to the DB yet -- so just remove its node and that's that
                node.Remove();
                if (this.newClasses.Contains(node))
                {
                    this.newClasses.Remove(node);
                }
            }
            else
            {
                // add it to the remove list so we'll remove it from the databse/INIs
                node.props.Classification = node.FullPath;
                this.removedClasses.Add(node);
                node.Remove();
            }
        }
示例#9
0
        public void LoadAssetTree(TreeNodeCollection nodes)
        {
            this.sourceNodes = nodes;

            this.tvClassifications.Nodes.Clear();

            this.tvClassifications.BeforeExpand += new TreeViewCancelEventHandler(tvClassifications_BeforeExpand);
            this.tvClassifications.MouseDown    += new MouseEventHandler(tvClassifications_MouseDown);
            this.tvClassifications.AfterSelect  += new TreeViewEventHandler(tvClassifications_AfterSelect);

            // populate first level
            foreach (AssetTreeNode atn in nodes)
            {
                classTreeNode classNode = EncodeNode(atn, null);
                this.tvClassifications.Nodes.Add(classNode);

                classNode.Expand();
            }
        }
示例#10
0
        public void LoadProjectClassifications2(MOG_Project proj)
        {
            if (proj != null)
            {
                this.tvClassifications.Nodes.Clear();
                this.newClasses.Clear();

                this.imageList      = new ImageList();
                this.imageArrayList = new ArrayList();

                this.tvClassifications.Enabled = true;


                foreach (string rootClassName in proj.GetRootClassificationNames())
                {
                    classTreeNode rootClassNode = new classTreeNode(rootClassName);
                    if (proj.GetSubClassificationNames(rootClassName).Count > 0)
                    {
                        rootClassNode.Nodes.Add(new classTreeNode("DUMMY_NODE"));
                    }

                    this.tvClassifications.Nodes.Add(rootClassNode);
                }

                // setup events
                this.tvClassifications.MouseDown    -= new MouseEventHandler(tvClassifications_MouseDown);
                this.tvClassifications.MouseDown    += new MouseEventHandler(tvClassifications_MouseDown2);
                this.tvClassifications.AfterSelect  += new TreeViewEventHandler(tvClassifications_AfterSelect2);
                this.tvClassifications.BeforeExpand += new TreeViewCancelEventHandler(tvClassifications_BeforeExpand);

                // expand the first level of nodes
                foreach (TreeNode tn in this.tvClassifications.Nodes)
                {
                    tn.Expand();
                }
            }
            else
            {
                // disable everything
                this.tvClassifications.Nodes.Add(new classTreeNode("<NO CURRENT PROJECT>"));
                this.tvClassifications.Enabled = false;
            }
        }
示例#11
0
        protected override void AddClassificationNode(classTreeNode parentNode)
        {
            if (parentNode == null)
            {
                if (this.tvClassifications.Nodes.Count > 0)
                {
                    parentNode = this.tvClassifications.Nodes[0] as classTreeNode;
                }
                else
                {
                    return;
                }
            }

            if (!parentNode.IsAssetFilenameNode)
            {
                base.AddClassificationNode(parentNode);
            }
        }
示例#12
0
        private void tvClassifications_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            classTreeNode newSelectedNode = this.tvClassifications.GetNodeAt(e.X, e.Y) as classTreeNode;

            this.tvClassifications.SelectedNodes.Clear();
            this.tvClassifications.SelectedNodes.Add(newSelectedNode);

            if (newSelectedNode != null)
            {
                this.propertyGrid.SelectedObject = newSelectedNode.props;
                //if (newSelectedNode.IsNewClass)
                //	newSelectedNode = newSelectedNode;
            }
            else
            {
                MOG_Prompt.PromptResponse("", "Selected node has no properties object");
            }

            //if (this.tvClassifications.SelectedNodes[0] != null  &&  this.tvClassifications.SelectedNodes[0] is classTreeNode)
            //	this.propertyGrid.SelectedObject = ((classTreeNode)this.tvClassifications.SelectedNodes[0]).props;
        }
示例#13
0
        private void PopulateNode(classTreeNode ctn)
        {
            if (ctn != null)
            {
                if (ctn.props == null)
                {
                    // need to get a brand new props
                    if (ctn.IsAssetFilenameNode)
                    {
                        // Get a new properties that we can edit
                        MOG_Filename assetFilename = new MOG_Filename(ctn.FullPath);
                        ctn.props = MOG_Properties.OpenAssetProperties(assetFilename);

                        // Setup SyncTargetPath Property
                        string assetDirectoryPath = MOG.CONTROLLER.CONTROLLERASSET.MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, ctn.importFiles);
                        if (assetDirectoryPath.Length > this.projectRootPath.Length)
                        {
                            string desiredSyncTargetPath = assetDirectoryPath.Substring(this.projectRootPath.Length + 1);
                            ctn.props.SyncTargetPath = desiredSyncTargetPath;
                        }

                        // Make sure we trigger the propertyGrid to redisplay this new props
                        this.propertyGrid.SelectedObject = ctn.props;
                    }
                    else
                    {
                        // Get the classification's properties that we can edit
                        ctn.props = MOG_Properties.OpenClassificationProperties(ctn.FullPath);
                        ctn.props.SetImmeadiateMode(true);

                        // build synctargetpath
                        if (ctn.assetTreeNode != null &&
                            ctn.assetTreeNode.FileFullPath != "" &&                                     // "" indicates don't set sync data path
                            ctn.assetTreeNode.FileFullPath != "<empty>")                                // "<empty>" indicates don't set sync data path
                        {
                            string syncDataPath = ctn.assetTreeNode.FileFullPath;
                            if (syncDataPath.ToLower().StartsWith(this.projectRootPath.ToLower()))
                            {
                                syncDataPath = syncDataPath.Substring(this.projectRootPath.Length).Trim("\\".ToCharArray());
                            }

                            // Check if the syncTargetPath was resolved to nothing?
                            if (syncDataPath == "")
                            {
                                // Force the syncTargetPath to 'Nothing' so it will resemble the resolved syncDataPath and not simply inherit
                                syncDataPath = "Nothing";
                            }

                            ctn.props.SyncTargetPath = syncDataPath;
                        }

                        // Make sure we trigger the propertyGrid to redisplay this new props
                        this.propertyGrid.SelectedObject = ctn.props;
                    }
                }
                else
                {
                    // need to update the existing props
                    if (ctn.props.PopulateInheritance())
                    {
                        // Make sure we trigger the propertyGrid to redisplay this updated props
                        this.propertyGrid.SelectedObject = ctn.props;
                    }
                }
            }
        }
示例#14
0
        private void tvClassifications_AfterSelect(object sender, TreeViewEventArgs e)
        {
            classTreeNode ctn = e.Node as classTreeNode;

            PopulateNode(ctn);
        }
示例#15
0
        private void tvClassifications_AfterSelect2(object sender, TreeViewEventArgs e)
        {
            classTreeNode newSelectedNode = e.Node as classTreeNode;

            PopulateClassNodeProps(newSelectedNode);
        }
示例#16
0
        private void CreateAssetConfigs_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MOG_ControllerProject.LoginUser("Admin");

            // Construct a new common timestamp for all of these assets
            string timestamp = MOG_Time.GetVersionTimestamp();

            // Activate the properties cache to help save time during the importation process
            MOG_Properties.ActivatePropertiesCache(true);

            for (int nodeIndex = 0; nodeIndex < assetFilenameNodes.Count; nodeIndex++)
            {
                classTreeNode tn = assetFilenameNodes[nodeIndex] as classTreeNode;

                string fullAssetName = tn.FullPath;                //tn.Parent.FullPath + tn.Text;
                string fileList      = Utils.ArrayListToString(tn.importFiles, "");

                // Check if this is a library asset?
                bool bIsInLibrary = false;
                if (tn.TreeView != null)
                {
                    string fullPath = tn.FullPath + tn.TreeView.PathSeparator;
                    string testPath = tn.TreeView.PathSeparator + "Library" + tn.TreeView.PathSeparator;
                    if (fullPath.IndexOf(testPath, 0, StringComparison.CurrentCultureIgnoreCase) != -1)
                    {
                        bIsInLibrary = true;
                    }
                }

                MOG_Filename repositoryName = null;
                if (bIsInLibrary && tn.importFiles.Count > 0)
                {
                    // Use the timestamp of the file (Needed for out-of-date checks with library assets)
                    String   libraryTimestamp = "";
                    FileInfo file             = new FileInfo(tn.importFiles[0] as string);
                    if (file != null && file.Exists)
                    {
                        libraryTimestamp = MOG_Time.GetVersionTimestamp(file.LastWriteTime);
                    }
                    repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), libraryTimestamp);
                }
                else
                {
                    // Use the common timestamp for all the assets
                    repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), timestamp);
                }

                MOG_Filename createdAssetFilename = null;

                string message = "Importing:\n" +
                                 "     " + repositoryName.GetAssetClassification() + "\n" +
                                 "     " + repositoryName.GetAssetName();
                worker.ReportProgress(nodeIndex * 100 / assetFilenameNodes.Count, message);

                if (worker.CancellationPending)
                {
                    if (Utils.ShowMessageBoxConfirmation("Are you sure you want to cancel asset importation?", "Cancel Asset Importation?") == MOGPromptResult.Yes)
                    {
                        return;
                    }
                }

                try
                {
                    string dirScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles);

                    // Construct our list non-inherited asset assuming none
                    ArrayList props = null;
                    if (tn.props != null)
                    {
                        // Ask the tn.props for the list of non-inherited properties
                        props = tn.props.GetNonInheritedProperties();
                    }
                    else
                    {
                        props = new ArrayList();

                        // Setup SyncTargetPath Property
                        string assetDirectoryScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles);
                        if (assetDirectoryScope.Length > this.projectRootPath.Length)
                        {
                            string syncTargetPath = assetDirectoryScope.Substring(this.projectRootPath.Length + 1);
                            props.Add(MOG.MOG_PropertyFactory.MOG_Sync_OptionsProperties.New_SyncTargetPath(syncTargetPath));
                        }
                    }

                    // Proceed to import the asset
                    createdAssetFilename = MOG_ControllerAsset.CreateAsset(repositoryName, dirScope, tn.importFiles, null, props, false, false);
                    if (createdAssetFilename == null)
                    {
                        // it's probably a network problem (TODO: Check for sure)

                        // build a list of files for error message
                        string files = "\n\nFiles contained in " + tn.Text + "\n";
                        foreach (string fname in tn.importFiles)
                        {
                            files += "\t" + fname + "\n";
                        }

                        MOGPromptResult r = MOG_Prompt.PromptResponse("Import Error", "Importation of " + tn.FullPath + " failed.  Please ensure that the file is accessible and click Retry." + files, MOGPromptButtons.AbortRetryIgnore);
                        if (r == MOGPromptResult.Retry)
                        {
                            --nodeIndex;                                        // stay on the same node (continue auto-increments)
                            continue;
                        }
                        else if (r == MOGPromptResult.Abort)
                        {
                            RaiseAssetImport_Finish();
                            MOG_Prompt.PromptResponse("Cancelled", "Importation Cancelled", Environment.StackTrace, MOGPromptButtons.OK, MOG_ALERT_LEVEL.MESSAGE);
                            return;
                        }
                        else if (r == MOGPromptResult.Ignore)
                        {
                            continue;
                        }
                    }

                    // Schedule this asset for posting under this project name
                    MOG_ControllerProject.AddAssetForPosting(createdAssetFilename, MOG_ControllerProject.GetProjectName());
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportMessage("Create Asset", "Could not correctly create asset.\nMessage=" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                    continue;
                }
            }

            // Shut off the properties cache
            MOG_Properties.ActivatePropertiesCache(false);
        }
示例#17
0
        private ArrayList BuildClassTreeFromClassNames(ArrayList classNames)
        {
            ArrayList classNodes = new ArrayList();

            if (classNames == null)
            {
                return(classNodes);
            }

            // now, sort them into ArrayLists based on how many tildes (~) they have
            int       numTildes  = 0;                   // start with no tildes (i.e., the root classifications)
            ArrayList classLists = new ArrayList();

            while (classNames.Count > 0)
            {
                ArrayList classList = new ArrayList();
                foreach (string className in classNames)
                {
                    if (CountTildes(className) == numTildes)
                    {
                        classList.Add(className);
                    }
                }

                // now, remove all the class names with 'numTildes' tildes from allClassNames
                foreach (string className in classList)
                {
                    classNames.Remove(className);
                }

                // add classList to our list of lists
                classLists.Add(classList);

                ++numTildes;
            }


            // okay, now we have an ArrayList of ArrayLists, each of which contains the class names with the number of blah blah blah
            util_MapList nodeMap = new util_MapList();

            for (int i = 0; i < classLists.Count; i++)
            {
                ArrayList classList = (ArrayList)classLists[i];
                foreach (string className in classList)
                {
                    if (i == 0)
                    {
                        // root nodes are a special case
                        classTreeNode rootNode = new classTreeNode(className);
                        rootNode.ImageIndex         = BLUEDOT_INDEX;
                        rootNode.SelectedImageIndex = BLUEDOT_INDEX;

                        rootNode.ForeColor = Color.Red;
                        nodeMap.Add(className.ToLower(), rootNode);                                     // add so we can look up the node later by its classification
                        classNodes.Add(rootNode);                                                       // add it to return value
                    }
                    else
                    {
                        // try to look up parent node
                        string parentClassName = GetParentClassName(className);
                        string classLeafName   = GetLeafClassName(className);

                        classTreeNode parentNode = nodeMap.Get(parentClassName.ToLower()) as classTreeNode;

                        if (parentNode != null)
                        {
                            // if we found a parent node, add a new node representing className to it, otherwise ignore
                            classTreeNode classNode = new classTreeNode(classLeafName);
                            classNode.ImageIndex         = ARROW_INDEX;
                            classNode.SelectedImageIndex = ARROW_INDEX;
                            classNode.ForeColor          = Color.Red;
                            parentNode.Nodes.Add(classNode);
                            nodeMap.Add(className.ToLower(), classNode);                                        // add for lookup later (to add children to this node)
                        }
                    }
                }
            }

            return(classNodes);
        }