/// <summary> /// Get a FileModel for a file /// </summary> /// <param name="fileName"></param> /// <returns></returns> static public FileModel FindFile(string fileName) { // the file is in a known classpath foreach (PathModel aPath in pathes.Values) { if (fileName.StartsWith(aPath.Path)) { DebugConsole.Trace("File in: " + aPath.Path); return(aPath.GetFile(fileName)); } } // else, orphan file DebugConsole.Trace("File in: (orphan)"); return(orphans.GetFile(fileName)); }
private void ConvertToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = outlineTreeView.SelectedNode; if (node == null || current == null || current.Classpath == null) { return; } ResolvedPath resolved = ResolvePath(node); string package = resolved.package; PathModel thePath = resolved.model; if (thePath == null) { return; } if (node is TypeTreeNode) { string filename = (node.Tag as string).Split('@')[0]; FileModel theModel = thePath.GetFile(filename); if (theModel == null) { return; } saveFileDialog.Title = TextHelper.GetString("Title.SaveIntrinsicAs"); saveFileDialog.FileName = Path.GetFileName(filename); saveFileDialog.DefaultExt = Path.GetExtension(filename); if (PluginBase.CurrentProject != null) { saveFileDialog.InitialDirectory = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath); } if (saveFileDialog.ShowDialog() == DialogResult.OK) { try { WriteIntrinsic(theModel, saveFileDialog.FileName); } catch (Exception ex) { ErrorManager.ShowError(ex); } } } else { folderBrowserDialog.ShowNewFolderButton = true; folderBrowserDialog.UseDescriptionForTitle = true; folderBrowserDialog.Description = TextHelper.GetString("Title.SelectIntrinsicTargetFolder"); if (PluginBase.CurrentProject != null) { folderBrowserDialog.SelectedPath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath); } if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { try { string sourcePath = Path.Combine(thePath.Path, package.Replace('.', Path.DirectorySeparatorChar)); string targetPath = folderBrowserDialog.SelectedPath + Path.DirectorySeparatorChar; string packagep = (package.Length > 0) ? package + "." : ""; thePath.ForeachFile((aModel) => { if (aModel.Package == package || aModel.Package.StartsWithOrdinal(packagep)) { if (aModel.FileName.StartsWithOrdinal(sourcePath)) { WriteIntrinsic(aModel, aModel.FileName.Replace(sourcePath, targetPath)); } } return(true); }); } catch (Exception ex) { ErrorManager.ShowError(ex); } } } }