private string getNodeText(IO2Trace o2TraceToLoad) { string nodeText = ""; if (tracePropertyToUseAsNodeText == "SourceCode") { nodeText = Files_WinForms.getLineFromSourceCode(o2TraceToLoad.file, o2TraceToLoad.lineNumber); if (nodeText == "") { nodeText = "[no source code available]"; } //Files.getLineFromSourceCode(o2TraceToLoad.file, o2TraceToLoad.lineNumber) : } else { nodeText = PublicDI.reflection.getProperty(tracePropertyToUseAsNodeText, o2TraceToLoad).ToString(); } if (nodeText == "") { nodeText = (o2TraceToLoad.signature != "") ? o2TraceToLoad.signature : o2TraceToLoad.method; } // hack to deal with encoded quotes nodeText = nodeText.Replace(""", "\""); return(nodeText); }
public static String getLineFromSourceCode(CallInvocation ciCallInvocation, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { List <string> lsSourceCode = Files_WinForms.loadSourceFileIntoList( fadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces[ciCallInvocation.fn_id - 1].value); return(Files.getLineFromSourceCode(ciCallInvocation.line_number, lsSourceCode)); }
private void btnPauseResume_Click(object sender, EventArgs e) { // If the thread exists if (thrDownload != null) { if (btnPauseResume.Text == "Pause") { // The Pause/Resume button was set to Pause, thus pause the download goPause = true; // Now that the download was paused, turn the button into a resume button btnPauseResume.Text = "Resume"; // Close the web response and the streams webResponse.Close(); strResponse.Close(); strLocal.Close(); // Abort the thread that's downloading thrDownload.Abort(); } else { // The Pause/Resume button was set to Resume, thus resume the download goPause = false; // Now that the download was resumed, turn the button into a pause button btnPauseResume.Text = "Pause"; long startPoint = 0; if (File.Exists(txtPath.Text)) { startPoint = Files_WinForms.getFileSize(txtPath.Text); } else { MessageBox.Show("The file you choosed to resume doesn't exist.", "Could not resume", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Let the user know we are connecting to the server lblProgress.Text = "Download Resuming"; // Create a new thread that calls the Download() method thrDownload = new Thread(Download); // Start the thread, and thus call Download() thrDownload.Start(startPoint); // Enable the Pause/Resume button btnPauseResume.Enabled = true; } } else { MessageBox.Show("A download does not appear to be in progress.", "Could not pause", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static string sourceCodeLine(this MethodMapping methodMapping) { if (methodMapping.File.fileExists()) { var sourceCodeLine = Files_WinForms.getLineFromSourceCode(methodMapping.File, methodMapping.Start_Line.uInt()); if (methodMapping.SourceCode.contains(sourceCodeLine) || sourceCodeLine.contains(methodMapping.SourceCode)) { return(sourceCodeLine.trim()); } ; } return(methodMapping.SourceCode); }
private void deleteEmptyJarStubs() { var filesToDelete = new List <string>(); foreach (var file in directoryWithJarStubFiles.getFiles()) { var fileSize = Files_WinForms.getFileSize(file); if (fileSize == 0) { filesToDelete.Add(file); } } Files_WinForms.deleteFiles(filesToDelete, true); }
private static bool deleteFilesMappedToFromSelectedNodeTag(TreeView targetTreeView) { if (targetTreeView.SelectedNode != null) { var filesToDelete = new List <string>(); if (targetTreeView.SelectedNode.Tag is string) { filesToDelete.Add((string)targetTreeView.SelectedNode.Tag); } else if (targetTreeView.SelectedNode.Tag is List <string> ) { filesToDelete.AddRange((List <string>)targetTreeView.SelectedNode.Tag); } if (filesToDelete.Count > 0) { return(Files_WinForms.deleteFiles(filesToDelete, true /*askUserForConfirmation*/)); } } return(false); }
public static String fromAssessmentFile_get_DbId(String sAssessmentFile) { const int iMaxFileSize = 1024 * 1024 * 20; long fileSize = Files_WinForms.getFileSize(sAssessmentFile); if (fileSize > iMaxFileSize) // { "Skipping fromAssessmentFile_get_DbId since file size is bigger that {0}: {1}".error(iMaxFileSize, fileSize); return(""); } try { var xdAssessmentFile = new XmlDocument(); xdAssessmentFile.Load(sAssessmentFile); XmlNodeList xnlAssessmentStats = xdAssessmentFile.GetElementsByTagName("AssessmentStats"); foreach (XmlNode xnNode in xnlAssessmentStats) { if (xnNode.Attributes["language_type"] != null) { switch (xnNode.Attributes["language_type"].Value) // hack to fix the fact that .net projects give a language_type=4 { case "4": return("3"); default: return(xnNode.Attributes["language_type"].Value); // the other ones seem to be ok } } } } catch (Exception ex) { "fromAssessmentFile_get_DbId: {0}".error(ex.Message); } return(""); }
public void showMappingsOnTreeView(string viewFilter) { O2Thread.mtaThread( () => { double totalFilesSizeInMb = 0; this.invokeOnThread( () => { loadedFiles.Clear(); lbSelectedFile.Text = ""; //var nodesWithMappings = new TreeView().Nodes; progressBarLoadFiles.Maximum = getNumberOfFilesLoaded(mappingsOfLoadedFiles); lbNumberOfFilesLoaded.Text = "0"; progressBarLoadFiles.Value = 0; lbStatus.Text = "Mapping Files"; }); var tempTreeNodeCollection = new List <TreeNode>(); foreach (string extension in mappingsOfLoadedFiles.Keys) { // create new extension node as a folder var extensionNode = new TreeNode(extension, folderIcon, folderIcon); // set its color depending on the items on the extensionsFilter list // make the node contains reference to its files extensionNode.Tag = mappingsOfLoadedFiles[extension]; foreach (string file in mappingsOfLoadedFiles[extension]) { if (File.Exists(file)) { if (viewFilter == "" || RegEx.findStringInString(file, viewFilter)) { var fileSize = (cbShowFileSizes.Checked) ? " : {0:#,###,###.0} kb".format(Files_WinForms.getFileSize(file) / (double)1024) : ""; var nodeText = Path.GetFileName(file) + fileSize; var newNode = O2Forms.newTreeNode(nodeText, file, fileIcon, file); newNode.ToolTipText = file; extensionNode.Nodes.Add(newNode); loadedFiles.Add(file); } } } if (extensionNode.Nodes.Count > 0) { double filesSizeInMb = Files_WinForms.getFilesSize(mappingsOfLoadedFiles[extension]) / (double)(1024 * 1024); totalFilesSizeInMb += filesSizeInMb; var filesSizeText = (cbShowFileSizes.Checked) ? " : {0:#,###,###.0} Mb".format(filesSizeInMb) : ""; extensionNode.Text = "{0} ({1} files) {2}".format(extension, mappingsOfLoadedFiles[extension].Count, filesSizeText); //tvFileMappings.Nodes.Add(extensionNode); tempTreeNodeCollection.Add(extensionNode); } this.invokeOnThread( () => { progressBarLoadFiles.Value += mappingsOfLoadedFiles[extension].Count; lbNumberOfFilesLoaded.Text = progressBarLoadFiles.Value.ToString(); }); } this.invokeOnThread(() => lbStatus.Text = "Populate TreeView"); O2Thread.mtaThread( () => this.invokeOnThread( () => { //foreach(TreeNode node in tempTreeNodeCollection) tvFileMappings.Nodes.Clear(); tvFileMappings.Sorted = true; tvFileMappings.Visible = false; tvFileMappings.Nodes.AddRange(tempTreeNodeCollection.ToArray()); applyColorsToRootNodes(); tvFileMappings.Visible = true; lbSelectedFile.Text = "Size: {0:#,###,###.0} Mb".format(totalFilesSizeInMb); lbStatus.Text = "Load Complete"; setLbNumberOfFilesSelectedText(); })); }); }
private void deleteJarStubs() { Files_WinForms.deleteFiles(directoryWithJarStubFiles.getFiles(), true); }