private void LibraryExploreButton_Click(object sender, EventArgs e) { if (MOG_ControllerLibrary.GetWorkingDirectory() != "") { guiCommandLine.ShellSpawn(MOG_ControllerLibrary.GetWorkingDirectory()); } }
private void LibraryListView_BeforeLabelEdit(object sender, LabelEditEventArgs e) { ListViewItem renamedAsset = LibraryListView.Items[e.Item]; string fullName = GetItemFullName(renamedAsset); // We can only rename assets that are not checked into MOG if (fullName.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory()) == false) { e.CancelEdit = true; } }
override public void Refresh() { // We only need to call the ListView's Deinitialize becasue the TreeView will eventually cause it to be repopulated LibraryListView.DeInitialize(); // Refresh the tree view LibraryTreeView.DeInitialize(); LibraryTreeView.Initialize(); // Show our sync target this.LibraryTargetTextBox.Text = "(" + MOG_ControllerLibrary.GetWorkingDirectory() + ")"; this.LibraryTargetTextBox.Tag = MOG_ControllerLibrary.GetWorkingDirectory(); base.Refresh(); }
private void LibraryTreeView_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { base.Refresh(); // We do not allow any items to be shown in classifications that are not in the library folder if (e.Node.FullPath.ToLower().IndexOf("library") != -1) { LibraryListView.Populate(e.Node.FullPath); } else { LibraryListView.LibraryListView.Items.Clear(); } LibraryTargetTextBox.Text = "(" + MOG_ControllerLibrary.GetWorkingDirectory() + ")" + "\\" + e.Node.FullPath.Replace("~", "\\"); }
private void LibraryBrowseButton_Click(object sender, System.EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.RootFolder = Environment.SpecialFolder.Desktop; dialog.ShowNewFolderButton = true; dialog.SelectedPath = MOG_ControllerLibrary.GetWorkingDirectory(); dialog.Description = "Select a location to be the Library target."; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { MOG_ControllerLibrary.SetWorkingDirectory(dialog.SelectedPath); LibraryTargetTextBox.Text = "(" + MOG_ControllerLibrary.GetWorkingDirectory() + ")"; LibraryTargetTextBox.Tag = MOG_ControllerLibrary.GetWorkingDirectory(); MogUtils_Settings.MogUtils_Settings.SaveSetting("Library", "TargetDirectory", dialog.SelectedPath); } }
public void RefreshItem(MOG_Command command) { // No reason to bother if they have no library working directory if (MOG_ControllerLibrary.GetWorkingDirectory().Length == 0) { return; } // Make sure this contains an encapsulated command? MOG_Command encapsulatedCommand = command.GetCommand(); if (encapsulatedCommand != null) { // No reason to bother if they are in a different project if (string.Compare(MOG_ControllerProject.GetProjectName(), encapsulatedCommand.GetProject(), true) != 0) { return; } // Check if this encapsulatedCommand contains a valid assetFilename? if (encapsulatedCommand.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { // No reason to bother if this asset's classification doesn't match their mCurrentClassification if (string.Compare(CurrentClassification, encapsulatedCommand.GetAssetFilename().GetAssetClassification(), true) != 0) { return; } } // Can we find the asset node of this file? int itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName()); if (itemid == -1) { // Check if this was a post command? if (encapsulatedCommand.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_Post) { // Create a new item ListViewItem item = CreateListViewItemForAsset(encapsulatedCommand.GetAssetFilename()); if (item != null) { LibraryListView.Items.Add(item); itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName()); } } } // Now check if we finally found our itemid? if (itemid != -1) { ListViewItem item = LibraryListView.Items[itemid]; if (item != null) { int classificationIdx = FindColumn("Classification"); int nameIdx = FindColumn("Name"); int statusIdx = FindColumn("Status"); int userIdx = FindColumn("User"); int commentIdx = FindColumn("Comment"); int localFileIdx = FindColumn("LocalFile"); int repositoryFileIdx = FindColumn("RepositoryFile"); int localTimestampIdx = FindColumn("Local Timestamp"); int serverTimestampIdx = FindColumn("Server Timestamp"); int fullname = FindColumn("Fullname"); int extensionIdx = FindColumn("Extension"); // Determin the type of encapsulated command switch (encapsulatedCommand.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: UpdateItem(item); break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: string status = ""; string comment = encapsulatedCommand.GetDescription(); string username = encapsulatedCommand.GetUserName(); if (String.Compare(MOG_ControllerProject.GetUserName(), encapsulatedCommand.GetUserName(), true) == 0) { status = "CheckedOut"; } else { status = "Locked"; } item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(item.SubItems[repositoryFileIdx].Text); item.SubItems[commentIdx].Text = comment; item.SubItems[userIdx].Text = username; item.SubItems[statusIdx].Text = status; UpdateListViewItemColors(item, status); break; case MOG_COMMAND_TYPE.MOG_COMMAND_Post: item.SubItems[repositoryFileIdx].Text = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(encapsulatedCommand.GetAssetFilename()); UpdateItem(item); break; case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject: // Make sure to remove this file just incase it had been previously synced MOG_ControllerLibrary.Unsync(encapsulatedCommand.GetAssetFilename()); // Proceed to delete this item RemoveItem(itemid); break; } // Update the item's colors UpdateListViewItemColors(item, item.SubItems[statusIdx].Text); } } } }
public void Populate(string classification) { CurrentClassification = classification; mCurrentClassificationProperties = new MOG_Properties(CurrentClassification); // For speed purposes, create 3 HybridDictionary lists // Populate the files that exist on the local hardrive string drivePath = Path.Combine(MOG_ControllerLibrary.GetWorkingDirectory(), MOG_Filename.GetClassificationPath(classification)); string[] files = new string[] { }; if (DosUtils.DirectoryExistFast(drivePath)) { files = Directory.GetFiles(drivePath); } HybridDictionary filesOnDisk = new HybridDictionary(); foreach (string file in files) { filesOnDisk[Path.GetFileName(file)] = file; } // Populate the assets that exist in MOG ArrayList assets = MOG_ControllerAsset.GetAssetsByClassification(classification); HybridDictionary assetsInMOG = new HybridDictionary(); foreach (MOG_Filename asset in assets) { assetsInMOG[asset.GetAssetLabel()] = asset; } // Create a master list HybridDictionary masterList = new HybridDictionary(); foreach (string file in filesOnDisk.Values) { masterList[Path.GetFileName(file)] = Path.GetFileName(file); } foreach (MOG_Filename asset in assetsInMOG.Values) { masterList[asset.GetAssetLabel()] = asset.GetAssetLabel(); } // Rebuild our LibraryListView LibraryListView.BeginUpdate(); mLibrarySortManager.SortEnabled = false; LibraryListView.Items.Clear(); foreach (string file in masterList.Keys) { // Check if this file is in MOG? if (assetsInMOG.Contains(file)) { MOG_Filename asset = assetsInMOG[file] as MOG_Filename; // Create the ListView item for this asset ListViewItem item = CreateListViewItemForAsset(asset); LibraryListView.Items.Add(item); } else { string fullFilename = filesOnDisk[file] as string; bool bIsValid = true; // Check the classification's inclusion filter. if (mCurrentClassificationProperties.FilterInclusions.Length > 0) { MOG.FilePattern inclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterInclusions); if (inclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == false) { bIsValid = false; } } // Check the classification's exclusion filter. if (mCurrentClassificationProperties.FilterExclusions.Length > 0) { MOG.FilePattern exclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterExclusions); if (exclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == true) { bIsValid = false; } } // Check if we determined this to be a valid file to show? if (bIsValid) { ListViewItem item = CreateListViewItemForFile(fullFilename); UpdateListViewItemColors(item, "Unknown"); LibraryListView.Items.Add(item); } } } mLibrarySortManager.SortEnabled = true; LibraryListView.EndUpdate(); // Check if we have a mLastTopItem specified? if (mLastTopItem.Length > 0) { LibraryListView.TopItem = LibraryListView.FindItemWithText(mLastTopItem); mLastTopItem = ""; } }
/// <summary> /// Scans the local branches data to locate all binaries that do not have a counterpart in the project database /// </summary> private bool LocateNonMogAssetsScanFiles(BackgroundWorker worker, string path, ArrayList rogueFiles, HybridDictionary MergeableAssets, string targetProjectPath, MOG_Properties classificationProperties) { // Check if this is a library path? if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 && path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase)) { // Build us our library classification for this library path string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path); // Check if this library classification exists? if (MOG_ControllerProject.IsValidClassification(classification)) { // Obtain the properties for this library classification classificationProperties = new MOG_Properties(classification); } } // Get all the files withing this directory FileInfo [] files = DosUtils.FileGetList(path, "*.*"); if (files != null) { // For each file, check to see if we have a DB link for that filename foreach (FileInfo file in files) { if (worker.CancellationPending) { return(false); } try { // Check to see if we have a DB link for that filename if (MergeableAssets.Contains(file.FullName) == false) { // Check if we have a classificationProperties? if (classificationProperties != null) { // Make sure this does not violate the classification filters // Check the classification's inclusion filter. if (classificationProperties.FilterInclusions.Length > 0) { FilePattern inclusions = new FilePattern(classificationProperties.FilterInclusions); if (inclusions.IsFilePatternMatch(file.FullName) == false) { // Skip this file as it is not included continue; } } // Check the classification's exclusion filter. if (classificationProperties.FilterExclusions.Length > 0) { FilePattern exclusions = new FilePattern(classificationProperties.FilterExclusions); if (exclusions.IsFilePatternMatch(file.FullName) == true) { // Skip this file as it is excluded continue; } } } // Make sure it is not hidden if (Convert.ToBoolean(file.Attributes & FileAttributes.Hidden) == false) { // If no match was found, add to our list of rogue assets rogueFiles.Add(file.FullName); } } } catch { // Needed just in case we have some files larger than 260 in length } } } // Now check all these subDirs DirectoryInfo [] dirs = DosUtils.DirectoryGetList(path, "*.*"); if (dirs != null) { foreach (DirectoryInfo dir in dirs) { // Make sure it is not hidden if (Convert.ToBoolean(dir.Attributes & FileAttributes.Hidden) == false) { // Scan their respective files if (!LocateNonMogAssetsScanFiles(worker, dir.FullName, rogueFiles, MergeableAssets, targetProjectPath, classificationProperties)) { return(false); } } } } return(true); }
private void LocateNonMogAssets_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string path = e.Argument as string; // Determin our workspaceDirectory and platformName string workspaceDirectory = ""; string relativePath = ""; string platformName = ""; // Check if this is a library path? if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 && path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase)) { // Determin proper settings for the library workspaceDirectory = MOG_ControllerLibrary.GetWorkingDirectory(); relativePath = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray()); platformName = "All"; // Get the list of known MOG files within the workspace string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path); ArrayList containedAssets = MOG_DBAssetAPI.GetAllAssetsByParentClassification(classification); foreach (MOG_Filename thisAsset in containedAssets) { string thisPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(thisAsset.GetAssetClassification()); string thisFilename = Path.Combine(thisPath, thisAsset.GetAssetLabel()); mKnownSyncFiles.Add(thisFilename, thisFilename); mKnownSyncFiles_ArrayList.Add(thisFilename); } } // Check if this is a workspace path? else { workspaceDirectory = MOG_ControllerSyncData.DetectWorkspaceRoot(path); if (workspaceDirectory.Length > 0) { relativePath = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray()); MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController(); if (sync != null) { platformName = sync.GetPlatformName(); // Get the list of known MOG files within the workspace ArrayList allFiles = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(platformName); foreach (string thisFile in allFiles) { // Trim thisFile just in case it has an extra '\' at the beginning (Needed for BioWare's formulaic sync target booboo) string tempFile = thisFile.Trim("\\".ToCharArray()); // Check if this relative directory matches? if (tempFile.StartsWith(relativePath, StringComparison.CurrentCultureIgnoreCase)) { string filename = Path.Combine(workspaceDirectory, tempFile); mKnownSyncFiles[filename] = filename; mKnownSyncFiles_ArrayList.Add(filename); } } } } } // Continue as long as we got at least one asset from the database ArrayList rogueFiles = new ArrayList(); LocateNonMogAssetsScanFiles(worker, path, rogueFiles, mKnownSyncFiles, path, null); e.Result = rogueFiles; }