Example #1
0
        protected override void ExpandTreeDown()
        {
            UseWaitCursor = true;

            bool bCreateRootProjectNode = false;

            if (mRequiredClassifications.Count > 0)
            {
                bCreateRootProjectNode = true;
            }
            else
            {
                // Fixes a crash at startup when the project is totally empty
                if (MogPropertyList.Count > 0)
                {
                    // Check if the specified property is the Inclusion property
                    MOG_Property testProperty = MogPropertyList[0] as MOG_Property;
                    if (testProperty != null)
                    {
                        // Check if this is the 'FilterInclusion' property?
                        if (string.Compare("FilterInclusions", testProperty.mPropertyKey, true) == 0)
                        {
                            // Show the normal tree anytime we had an inclusion filter yet nothing was found
                            bCreateRootProjectNode = true;
                        }
                    }
                }
            }

            // Check if we decided to create the root project node?
            if (bCreateRootProjectNode)
            {
                Enabled = true;
                string   adamNodeName = MOG_ControllerProject.GetProjectName();
                TreeNode rootNode     = new TreeNode(adamNodeName, new TreeNode[] { new TreeNode(Blank_Node_Text) });
                rootNode.Checked            = NodesDefaultToChecked;
                rootNode.ImageIndex         = MogUtil_AssetIcons.GetClassIconIndex(adamNodeName);
                rootNode.SelectedImageIndex = rootNode.ImageIndex;
                rootNode.Tag  = new Mog_BaseTag(rootNode, rootNode.Text);
                rootNode.Name = rootNode.Text;
                ((Mog_BaseTag)rootNode.Tag).PackageNodeType = PackageNodeTypes.Class;
                Nodes.Add(rootNode);

                rootNode.Expand();
            }
            else
            {
                Enabled = false;
                Nodes.Add(NothingReturned_Text);
            }

            UseWaitCursor = false;
        }
 private void CreateChangePropertiesSubMenu(string propertyPath, TreeNode parentNode, string section, MOG_PropertiesIni ripMenu)
 {
     for (int i = 0; i < ripMenu.CountProperties(section, "MenuItem"); i++)
     {
         MOG_Property property = ripMenu.GetPropertyByIndex(section, "MenuItem", i);
         if (property != null)
         {
             string menuItem = property.mPropertyKey;
             if (propertyPath.Length == 0)
             {
                 CreateChangePropertiesMenuItem(menuItem, parentNode, section, menuItem, ripMenu);
             }
             else
             {
                 CreateChangePropertiesMenuItem(propertyPath + "/" + menuItem, parentNode, section, menuItem, ripMenu);
             }
         }
     }
 }
		/// <summary>
		/// Create Package for each platform in this Project
		/// </summary>
		private MOG_Filename CreatePackageForPlatform(NodeLabelEditEventArgs e, MOG_Filename packageName, TreeNode parent)
		{
			// Initialize our ArrayList for MOG_Property objects
			ArrayList targetSyncPath = null;

			// If our node name already exists, return...
			if (!ValidateNewNodeName(e, packageName))
			{
				return null;
			}

			// If our targetSyncPath is null, even after we try to get a valid one, return...
			if (targetSyncPath == null &&
				(targetSyncPath = GetValidTargetSyncPath(e, packageName)) == null)
			{
				return null;
			}

            MOG_Property syncTargetPathProperty = targetSyncPath[0] as MOG_Property;

            // Create the new package
            MOG_Filename createdPackageFilename = MOG_ControllerProject.CreatePackage(packageName, syncTargetPathProperty.mValue);
			if (createdPackageFilename == null)
			{
				return null;
			}

            RenameNode(e, createdPackageFilename);

			// Post the projects new assets
			string jobLabel = "NewPackageCreated." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp();
			MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), jobLabel);

			// Return our created package
			return createdPackageFilename;
		}
Example #4
0
        public static MOG_Property RepairProperty(MOG_Property propertyObject)
        {
            MOG_Property fixedPropertyObject = null;

            string key             = propertyObject.mKey;
            string section         = propertyObject.mSection;
            string propertySection = propertyObject.mPropertySection;
            string propertyKey     = propertyObject.mPropertyKey;
            string propertyValue   = propertyObject.mPropertyValue;

            MOG_Property tempProperty           = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment("", "", "", "");
            MOG_Property tempPackageProperty    = MOG_PropertyFactory.MOG_Relationships.New_PackageAssignment("", "", "");
            MOG_Property tempSourceFileProperty = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile("");

            // Check if this property is a package relationship?
            if (string.Compare(section, tempPackageProperty.mSection, true) == 0)
            {
                string assetName = MOG_ControllerPackage.GetPackageName(propertyKey);
                string groups    = MOG_ControllerPackage.GetPackageGroups(propertyKey);
                string objects   = MOG_ControllerPackage.GetPackageObjects(propertyKey);

                // Remap various properties making sure we correct any problem areas
                MOG_Filename assetFilename = null;

                // Check if this property is a SourceFile relationship?
                if (string.Compare(propertySection, tempSourceFileProperty.mPropertySection, true) == 0)
                {
                    // Check if the specified file is within the library?
                    if (MOG_ControllerLibrary.IsPathWithinLibrary(propertyKey))
                    {
                        // Map this library file to a real asset name
                        assetFilename = MOG_ControllerProject.MapFilenameToLibraryAssetName(assetName, MOG_ControllerProject.GetPlatformName());
                        if (assetFilename != null)
                        {
                            fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(assetFilename.GetFullFilename());
                        }
                    }
                }
                else
                {
                    // Try to find the assetname for the specified asset
                    ArrayList assets = MOG_ControllerProject.MapFilenameToAssetName(assetName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory());
                    if (assets == null || assets.Count == 0)
                    {
                        // The package could not be found
                        if (string.Compare(propertySection, tempPackageProperty.mPropertySection, true) == 0)
                        {
                            // Check if we actually had something specified?
                            if (assetName.Length > 0)
                            {
                                // Set the deafult packageFilename info
                                string assetClassification = "";
                                string assetPlatformName   = "All";
                                string assetLabel          = DosUtils.PathGetFileNameWithoutExtension(assetName);
                                string syncTargetPath      = DosUtils.PathGetDirectoryPath(assetName);

                                // Check if the assetName was already a valid MOG_Filename?
                                MOG_Filename packageFilename = new MOG_Filename(assetName);
                                if (packageFilename.GetAssetClassification().Length > 0)
                                {
                                    assetClassification = MOG_Filename.AppendAdamObjectNameOnClassification(packageFilename.GetAssetClassification());
                                }
                                if (packageFilename.GetAssetPlatform().Length > 0)
                                {
                                    assetPlatformName = packageFilename.GetAssetPlatform();
                                }
                                if (packageFilename.GetAssetLabel().Length > 0)
                                {
                                    assetLabel = packageFilename.GetAssetLabel();
                                }

                                // Prompt user to complete the unknown information about this packageFile
                                string         message = "MOG has detected a new package assignment to a previously non-existing package.  Please complete the following red fields so that a proper package can be created in MOG.";
                                PackageCreator creator = new PackageCreator();
                                creator.Classification = assetClassification;
                                creator.PackageName    = assetLabel;
                                creator.SyncTarget     = syncTargetPath;
                                creator.Platform       = assetPlatformName;
                                if (creator.ShowDialog() == DialogResult.OK)
                                {
                                    // Use this newly created packageFilename as our assetFilename to be fixed
                                    assetFilename = creator.AssetName;
                                }
                                else
                                {
                                    // The PackageName is invalid
                                    message = "New Package Not Created.\n" +
                                              "The user chose not to create a new package.";
                                    MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                                }
                            }
                            else
                            {
                                // The PackageName is invalid
                                string message = "Invalid PackageName specified.\n" +
                                                 "The packaged asset was not assigned to a package.";
                                MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                            }
                        }
                    }
                    else
                    {
                        // Always use the first one
                        assetFilename = assets[0] as MOG_Filename;
                        MOG_ControllerProject.MapFilenameToAssetName_WarnAboutAmbiguousMatches(assetName, assets);
                    }

                    // Now do we finally have a package asset name?
                    if (assetFilename != null)
                    {
                        // Replace the propertyObject with the fixed up one
                        fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment(propertySection, assetFilename.GetAssetFullName(), groups, objects);
                    }
                }
            }

            // Check if we fixed the property?
            if (fixedPropertyObject != null)
            {
                return(fixedPropertyObject);
            }
            return(propertyObject);
        }
Example #5
0
        private ArrayList ExcludeClassifications(ArrayList classificationList, string nodeClassification)
        {
            ArrayList excludedClassificationList = new ArrayList();

            // Check if we have any properties associated with this tree?
            if (MogPropertyList.Count > 0)
            {
                // Get the list of excluded classifications for this node classification
                ArrayList excludedClassifications = MOG_DBAssetAPI.GetClassificationChildren(nodeClassification, "", MogPropertyList, true);
                if (excludedClassifications != null)
                {
                    excludedClassificationList.AddRange(excludedClassifications);
                }

                // Not sure if this really is the best place for this logic but exclusions are hooked to the hip of inclusions...
                // Check if the specified property is the Inclusion property
                MOG_Property testProperty = MogPropertyList[0] as MOG_Property;
                if (testProperty != null)
                {
                    // Check if this is the 'FilterInclusion' property?
                    if (string.Compare("FilterInclusions", testProperty.mPropertyKey, true) == 0)
                    {
                        // Obtain the list of assets this filter is specifically excluded from
                        ArrayList exclusionPropertyList = new ArrayList();
                        exclusionPropertyList.Add(MOG.MOG_PropertyFactory.MOG_Classification_InfoProperties.New_FilterExclusions(testProperty.mPropertyValue));
                        // Get the list of excluded classifications for this node classification
                        ArrayList excludedCLassifications = MOG_DBAssetAPI.GetClassificationChildren(nodeClassification, "", exclusionPropertyList);
                        if (excludedCLassifications != null)
                        {
                            excludedClassificationList.AddRange(excludedCLassifications);
                        }
                    }
                }
            }

            // Check for any explicitly specified exclusions?
            if (ExclusionList.Length > 0)
            {
                foreach (string classification in classificationList)
                {
                    string testClassification = MOG_Filename.JoinClassificationString(nodeClassification, classification);
                    if (StringUtils.IsFiltered(testClassification, ExclusionList))
                    {
                        // Remove this asset from the list
                        excludedClassificationList.Add(classification);
                    }
                }
            }

            // Remove the identified classifications to be excluded
            foreach (string excludedClassification in excludedClassificationList)
            {
                // Check if this excludedclassification is listed in our list?
                foreach (string classification in classificationList)
                {
                    if (string.Compare(classification, excludedClassification, true) == 0)
                    {
                        // Remove this asset from the list
                        classificationList.Remove(classification);
                        break;
                    }
                }
            }

            return(classificationList);
        }
Example #6
0
        /// <summary>
        /// Update an existing ListView node for the asset manager inboxes
        /// </summary>
        /// <param name="pProperties"></param>
        /// <param name="nodeColor"></param>
        /// <returns></returns>
        public static void UpdateListViewItem(ListViewItem item, MOG_Filename asset, string status, MOG_Properties pProperties)
        {
            string date    = "";
            string size    = "";
            string creator = "";
            string owner   = "";
            string group   = "";
            string target  = "";

            // Check if we have a properties?
            if (pProperties != null)
            {
                // If we have a valid gameDataController, set our platform scope
                if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    // Set our current platform
                    pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
                }

                // Gather the following info from our properties
                date    = MOG_Time.FormatTimestamp(pProperties.CreatedTime, "");
                size    = guiAssetController.FormatSize(pProperties.Size);
                creator = pProperties.Creator;
                owner   = pProperties.Owner;
                group   = pProperties.Group;

                // Check if this is a packaged asset?
                if (pProperties.IsPackagedAsset)
                {
                    // Check if we have have any package assignments in our propeerties?
                    ArrayList packages = pProperties.GetPackages();
                    if (packages.Count == 0)
                    {
                        // Indicate this is a packaged asset w/o any package assignments
                        target = "Missing package assignment...";
                    }
                    else if (packages.Count == 1)
                    {
                        MOG_Property package          = packages[0] as MOG_Property;
                        MOG_Filename packageName      = new MOG_Filename(MOG_ControllerPackage.GetPackageName(package.mPropertyKey));
                        string       packageGroupPath = MOG_ControllerPackage.GetPackageGroups(package.mPropertyKey);
                        string       displayString    = MOG_ControllerPackage.CombinePackageAssignment(packageName.GetAssetLabel(), packageGroupPath, "");
                        target = "{Package} " + displayString + "  in  " + MOG_Filename.GetAdamlessClassification(packageName.GetAssetClassification());
                    }
                    else
                    {
                        target = "{Package} " + packages.Count + " Assignments...";
                    }
                }
                else if (pProperties.SyncFiles)
                {
                    // Get the formatted SyncTarget of this asset
                    target = MOG_Tokens.GetFormattedString("{Workspace}\\" + pProperties.SyncTargetPath, asset, pProperties.GetPropertyList());
                }
            }

            item.Text = asset.GetAssetLabel();

            // Populate the item's SubItems
            // I tried for a long time to be smart here and use ColumnNameFind(thisListView.Columns, "Name") but
            // I kept running into walls because this function is used by a lot of workers outside of the ListView's thread.
            // So, I gave up and am just going to do it the ugly brute force way!  YUCK!!
            item.SubItems[(int)AssetBoxColumns.NAME].Text       = asset.GetAssetLabel();
            item.SubItems[(int)AssetBoxColumns.CLASS].Text      = asset.GetAssetClassification();
            item.SubItems[(int)AssetBoxColumns.TARGETPATH].Text = target;
            item.SubItems[(int)AssetBoxColumns.DATE].Text       = date;
            item.SubItems[(int)AssetBoxColumns.SIZE].Text       = size;
            item.SubItems[(int)AssetBoxColumns.PLATFORM].Text   = asset.GetAssetPlatform();
            item.SubItems[(int)AssetBoxColumns.STATE].Text      = status;
            item.SubItems[(int)AssetBoxColumns.CREATOR].Text    = creator;
            item.SubItems[(int)AssetBoxColumns.RESPPARTY].Text  = owner;
            item.SubItems[(int)AssetBoxColumns.OPTIONS].Text    = "";
            item.SubItems[(int)AssetBoxColumns.FULLNAME].Text   = asset.GetEncodedFilename();
            item.SubItems[(int)AssetBoxColumns.BOX].Text        = asset.GetBoxName();
            item.SubItems[(int)AssetBoxColumns.GROUP].Text      = group;

            // Set the item's Icons
            item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(asset.GetEncodedFilename(), pProperties);

            if (MogMainForm.MainApp != null &&
                MogMainForm.MainApp.mAssetManager != null)
            {
                // mAssetStatus.GetStatusInfo() is sort of a black sheep and should maybe become static
                item.StateImageIndex = MogMainForm.MainApp.mAssetManager.mAssetStatus.GetStatusInfo(status).IconIndex;
            }

            // Set the item's color
            item.ForeColor = MOG_AssetStatus.GetColor(status);
            // Check if this is a local item that has been blessed?
            if (asset.IsLocal() &&
                string.Compare(status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Blessed), true) == 0)
            {
                // Mark local blessed items with light gray
                item.ForeColor = Color.LightGray;
            }
        }
        /// <summary>
        /// Refresh an assets status from a ViewUpdate Command
        /// </summary>
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            lock (mAssetManager)
            {
                ListView currentViewAdd = mAssetManager.IsolateListView(add.GetBoxName(), add.GetFilenameType(), add.GetUserName());
                ListView currentViewDel = mAssetManager.IsolateListView(del.GetBoxName(), del.GetFilenameType(), del.GetUserName());

                // Don't continue if we don't have a valid add and del box
                if ((currentViewAdd == null) && (currentViewDel == null))
                {
                    return;
                }

                // Begin the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.BeginUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.BeginUpdate();
                }

                string status = command.GetDescription();

                mAssetManager.mainForm.mSoundManager.PlayStatusSound("AssetEvents", status);

                try
                {
                    // Obtain the properties from the command
                    MOG_Properties pProperties  = null;
                    string[]       commandProps = command.GetVeriables().Split("$".ToCharArray());
                    if (commandProps != null)
                    {
                        ArrayList realProps = new ArrayList();

                        // Convert the commandProps into a list of real Properties
                        for (int i = 0; i < commandProps.Length; i++)
                        {
                            // Confirm this appears to be a valid prop?
                            if (commandProps[i].StartsWith("["))
                            {
                                MOG_Property commandProp = new MOG_Property(commandProps[i]);

                                // Make sure the property was initialized correctly?
                                if (commandProp.mSection.Length > 0 &&
                                    commandProp.mKey.Length > 0)
                                {
                                    // Add this realProp
                                    realProps.Add(commandProp);
                                }
                            }
                        }

                        // Construct the pProperties from the realProps
                        pProperties = new MOG_Properties(realProps);

                        // If we have a valid gameDataController, set our platform scope
                        if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                        {
                            pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
                        }
                    }

                    // Check if we are just updating an item in the same list?
                    if (currentViewAdd == currentViewDel)
                    {
                        // Check to see if this item already exists?
                        int targetIndex = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                        int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                        if (sourceIndex != -1)
                        {
                            // Update the existing item
                            ListViewItem item = currentViewAdd.Items[sourceIndex];
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);

                            // If there was also a target index, we need to delete it because the source became the target.
                            if (targetIndex != -1 &&
                                targetIndex != sourceIndex)
                            {
                                ListViewItem removeItem = currentViewAdd.Items[targetIndex];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                removeItem.StateImageIndex = 0;

                                currentViewAdd.Items.Remove(removeItem);
                            }
                        }
                        // Special case when we are dealing with a renamed file
                        else if (targetIndex != -1 && sourceIndex == -1)
                        {
                            // Get the old item
                            ListViewItem item = currentViewDel.Items[targetIndex];

                            // Update it to the new renamed item
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                        }
                        else
                        {
                            // Add a new item
                            CreateListViewItem(currentViewAdd, add, status, pProperties);
                            // Make sure we always keep our tab's text up-to-date
                            mAssetManager.UpdateAssetManagerTabText(add);
                        }
                    }
                    else
                    {
                        // Looks like we may need to do both the add and the remove
                        // Check if we have the currentViewDel?
                        if (currentViewDel != null)
                        {
                            int index = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                            if (index != -1)
                            {
                                ListViewItem item = currentViewDel.Items[index];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                item.StateImageIndex = 0;

                                // Remove the item from the list
                                currentViewDel.Items.Remove(item);

                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(del);
                            }
                        }

                        // Check if we have the currentViewAdd?
                        if (currentViewAdd != null)
                        {
                            // Check to see if this item already exists?
                            int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                            if (sourceIndex != -1)
                            {
                                // Update the existing item
                                ListViewItem item = currentViewAdd.Items[sourceIndex];
                                guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                            }
                            else
                            {
                                // Add a new item
                                CreateListViewItem(currentViewAdd, add, status, pProperties);
                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(add);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportSilent("RefreshBox", ex.Message, ex.StackTrace);
                }

                // End the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.EndUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.EndUpdate();
                }
            }
        }