public PythonProject(ProjectCreateInformation info, XmlElement projectOptions)
 {
     if (info != null) {
         Name = info.ProjectName;
         Configurations.Add (CreateConfiguration ("Debug"));
         Configurations.Add (CreateConfiguration ("Release"));
         foreach (PythonCompilerParameters parameter in Configurations) {
             parameter.OutputDirectory = Path.Combine (info.BinPath, parameter.Name);
             parameter.OutputAssembly  = Name;
         }
     }
 }
 public Project CreateSingleFileProject(string file)
 {
     ILanguageBinding binding = Runtime.Languages.GetBindingPerFileName (file);
     if (binding != null) {
         ProjectCreateInformation info = new ProjectCreateInformation ();
         info.ProjectName = Path.GetFileNameWithoutExtension (file);
         info.CombinePath = Path.GetDirectoryName (file);
         Project project = CreateProject (binding.Language, info, null);
         project.ProjectFiles.Add (new ProjectFile (file));
         return project;
     }
     return null;
 }
        public string CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            StringParserService stringParserService = Runtime.StringParserService;

            Type type = Type.GetType (typeName);

            if (type == null) {
                Runtime.MessageService.ShowError(String.Format (GettextCatalog.GetString ("Can't create project with type : {0}"), typeName));
                return String.Empty;
            }

            CombineEntry entry = (CombineEntry) Activator.CreateInstance (type);
            entry.InitializeFromTemplate (template);

            string newProjectName = stringParserService.Parse (name, new string[,] {
                {"ProjectName", projectCreateInformation.ProjectName}
            });

            entry.Name = newProjectName;

            IFileFormat fileFormat = Runtime.ProjectService.FileFormats.GetFileFormatForObject (entry);
            if (fileFormat == null)
                throw new InvalidOperationException ("Can't find a file format for the type: " + type);

            string fileName = fileFormat.GetValidFormatName (Path.Combine (projectCreateInformation.ProjectBasePath, newProjectName));

            using (IProgressMonitor monitor = Runtime.TaskService.GetSaveProgressMonitor ()) {
                if (File.Exists (fileName)) {
                    if (Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("Project file {0} already exists, do you want to overwrite\nthe existing file ?"), fileName),  GettextCatalog.GetString ("File already exists"))) {
                        entry.Save (fileName, monitor);
                    }
                } else {
                    entry.Save (fileName, monitor);
                }
            }

            return fileName;
        }
        public DotNetProject(string languageName, ProjectCreateInformation info, XmlElement projectOptions)
        {
            string binPath;
            if (info != null) {
                Name = info.ProjectName;
                binPath = info.BinPath;
            } else {
                binPath = ".";
            }

            language = languageName;
            languageBinding = FindLanguage (language);

            DotNetProjectConfiguration configuration = (DotNetProjectConfiguration) CreateConfiguration ("Debug");
            configuration.CompilationParameters = languageBinding.CreateCompilationParameters (projectOptions);
            Configurations.Add (configuration);

            configuration = (DotNetProjectConfiguration) CreateConfiguration ("Release");
            configuration.DebugMode = false;
            configuration.CompilationParameters = languageBinding.CreateCompilationParameters (projectOptions);
            Configurations.Add (configuration);

            foreach (DotNetProjectConfiguration parameter in Configurations) {
                parameter.OutputDirectory = Path.Combine (binPath, parameter.Name);
                parameter.OutputAssembly  = Name;

                if (projectOptions != null) {
                    if (projectOptions.Attributes["Target"] != null) {
                        parameter.CompileTarget = (CompileTarget)Enum.Parse(typeof(CompileTarget), projectOptions.Attributes["Target"].InnerText);
                    }
                    if (projectOptions.Attributes["PauseConsoleOutput"] != null) {
                        parameter.PauseConsoleOutput = Boolean.Parse(projectOptions.Attributes["PauseConsoleOutput"].InnerText);
                    }
                }
            }
        }
        public string CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            StringParserService stringParserService = Runtime.StringParserService;
            FileUtilityService fileUtilityService = Runtime.FileUtilityService;

            if (projectOptions.GetAttribute ("language") == "") {
                if (defaultLanguage == null || defaultLanguage == "")
                    throw new InvalidOperationException ("Language not specified in template");
                projectOptions.SetAttribute ("language", defaultLanguage);
            }

            Project_ project = Runtime.ProjectService.CreateProject (projectType, projectCreateInformation, projectOptions);

            if (project == null) {
                Runtime.MessageService.ShowError(String.Format (GettextCatalog.GetString ("Can't create project with type : {0}"), projectType));
                return String.Empty;
            }

            string newProjectName = stringParserService.Parse(name, new string[,] {
                {"ProjectName", projectCreateInformation.ProjectName}
            });

            project.Name = newProjectName;

            // Add References
            foreach (ProjectReference projectReference in references) {
                project.ProjectReferences.Add(projectReference);
            }

            foreach (FileDescriptionTemplate file in resources) {
                string fileName = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + stringParserService.Parse(file.Name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} });

                ProjectFile resource = new ProjectFile (fileName);
                resource.BuildAction = BuildAction.EmbedAsResource;
                project.ProjectFiles.Add(resource);

                if (File.Exists(fileName)) {
                    if (!Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("File {0} already exists, do you want to overwrite\nthe existing file ?"), fileName), GettextCatalog.GetString ("File already exists"))) {
                        continue;
                    }
                }

                try {
                    if (!Directory.Exists(Path.GetDirectoryName(fileName))) {
                        Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                    }
                    StreamWriter sr = File.CreateText(fileName);
                    sr.Write(stringParserService.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}}));
                    sr.Close();
                } catch (Exception ex) {
                    Runtime.MessageService.ShowError(ex, String.Format (GettextCatalog.GetString ("File {0} could not be written."), fileName));
                }
            }

            // Add Files
            foreach (FileDescriptionTemplate file in files) {
                string fileName = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + stringParserService.Parse(file.Name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} });

                project.ProjectFiles.Add(new ProjectFile(fileName));

                if (File.Exists(fileName)) {
                    if (!Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("File {0} already exists, do you want to overwrite\nthe existing file ?"), fileName), GettextCatalog.GetString ("File already exists"))) {
                        continue;
                    }
                }

                try {
                    if (!Directory.Exists(Path.GetDirectoryName(fileName))) {
                        Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                    }
                    StreamWriter sr = File.CreateText(fileName);
                    sr.Write(stringParserService.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}}));
                    sr.Close();
                } catch (Exception ex) {
                    Runtime.MessageService.ShowError(ex, String.Format (GettextCatalog.GetString ("File {0} could not be written."), fileName));
                }
            }

            // Save project
            string projectLocation = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + newProjectName + ".mdp";

            using (IProgressMonitor monitor = Runtime.TaskService.GetSaveProgressMonitor ()) {
                if (File.Exists(projectLocation)) {
                    if (Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("Project file {0} already exists, do you want to overwrite\nthe existing file ?"), projectLocation),  GettextCatalog.GetString ("File already exists"))) {
                        project.Save (projectLocation, monitor);
                    }
                } else {
                    project.Save (projectLocation, monitor);
                }
            }

            return projectLocation;
        }
 protected virtual DotNetProject CreateProject(string languageName, ProjectCreateInformation info, XmlElement projectOptions)
 {
     return new DotNetProject (languageName, info, projectOptions);
 }
 public Project CreateProject(ProjectCreateInformation info, XmlElement projectOptions)
 {
     string lang = projectOptions.GetAttribute ("language");
     return CreateProject (lang, info, projectOptions);
 }
        void OpenEvent(object sender, EventArgs e)
        {
            if (!btn_new.Sensitive) {
                return;
            }

            if (TemplateView.CurrentlySelected != null) {
                Runtime.Properties.SetProperty("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)TemplateView.CurrentlySelected).Name);
                //Runtime.Properties.SetProperty("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
            }

            string solution = txt_subdirectory.Text;
            string name     = txt_name.Text;
            string location = entry_location.Path;

            if(solution.Equals("")) solution = name; //This was empty when adding after first combine

            //The one below seemed to be failing sometimes.
            if(solution.IndexOfAny("$#@!%^&*/?\\|'\";:}{".ToCharArray()) > -1) {
                Runtime.MessageService.ShowError(dialog, GettextCatalog.GetString ("Illegal project name. \nOnly use letters, digits, space, '.' or '_'."));
                return;
            }

            if ((solution != null && solution.Trim () != ""
                && (!fileUtilityService.IsValidFileName (solution) || solution.IndexOf(System.IO.Path.DirectorySeparatorChar) >= 0)) ||
                !fileUtilityService.IsValidFileName(name)     || name.IndexOf(System.IO.Path.DirectorySeparatorChar) >= 0 ||
                !fileUtilityService.IsValidFileName(location)) {
                Runtime.MessageService.ShowError(dialog, GettextCatalog.GetString ("Illegal project name.\nOnly use letters, digits, space, '.' or '_'."));
                return;
            }

            if (Runtime.ProjectService.GetProject (name) != null) {
                Runtime.MessageService.ShowError(dialog, GettextCatalog.GetString ("A Project with that name is already in your Project Space"));
                return;
            }

            Runtime.Properties.SetProperty (
                "MonoDevelop.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir",
                chk_combine_directory.Active);

            if (TemplateView.CurrentlySelected != null && name.Length != 0) {
                ProjectTemplate item = (ProjectTemplate) TemplateView.CurrentlySelected;

                try
                {
                    System.IO.Directory.CreateDirectory (ProjectSolution);
                }
                catch (IOException ioException)
                {
                    Runtime.MessageService.ShowError (dialog, String.Format (GettextCatalog.GetString ("Could not create directory {0}. File already exists."), ProjectSolution));
                    return;
                }
                catch (UnauthorizedAccessException accessException)
                {
                    Runtime.MessageService.ShowError (dialog, String.Format (GettextCatalog.GetString ("You do not have permission to create to {0}"), ProjectSolution));
                    return;
                }

                ProjectCreateInformation cinfo = new ProjectCreateInformation ();

                cinfo.CombinePath     = ProjectLocation;
                cinfo.ProjectBasePath = ProjectSolution;
            //				cinfo.Description     = Runtime.StringParserService.Parse(item.Template.Description);

                cinfo.ProjectName     = name;
            //				cinfo.ProjectTemplate = item.Template;

                NewCombineLocation = item.CreateProject (cinfo);
                if (NewCombineLocation == null || NewCombineLocation.Length == 0)
                    return;

                if (openCombine)
                    item.OpenCreatedCombine();

                // TODO :: THIS DOESN'T WORK !!!
                NewProjectLocation = System.IO.Path.ChangeExtension(NewCombineLocation, ".mdp");

                //DialogResult = DialogResult.OK;
                if (OnOked != null)
                    OnOked (null, null);
                dialog.Destroy ();
            }
        }
        public string CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            Combine newCombine     = new Combine();
            string  newCombineName = Runtime.StringParserService.Parse(name, new string[,] {
                {"ProjectName", projectCreateInformation.ProjectName}
            });

            newCombine.Name = newCombineName;

            string oldCombinePath = projectCreateInformation.CombinePath;
            string oldProjectPath = projectCreateInformation.ProjectBasePath;
            if (relativeDirectory != null && relativeDirectory.Length > 0 && relativeDirectory != ".") {
                projectCreateInformation.CombinePath     = projectCreateInformation.CombinePath + Path.DirectorySeparatorChar + relativeDirectory;
                projectCreateInformation.ProjectBasePath = projectCreateInformation.CombinePath + Path.DirectorySeparatorChar + relativeDirectory;
                if (!Directory.Exists(projectCreateInformation.CombinePath)) {
                    Directory.CreateDirectory(projectCreateInformation.CombinePath);
                }
                if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) {
                    Directory.CreateDirectory(projectCreateInformation.ProjectBasePath);
                }
            }

            // Create sub projects
            foreach (ICombineEntryDescriptor entryDescriptor in entryDescriptors) {
                newCombine.AddEntry (entryDescriptor.CreateEntry (projectCreateInformation, defaultLanguage), null);
            }

            projectCreateInformation.CombinePath = oldCombinePath;
            projectCreateInformation.ProjectBasePath = oldProjectPath;

            // Save combine
            using (IProgressMonitor monitor = Runtime.TaskService.GetSaveProgressMonitor ()) {
                string combineLocation = Runtime.FileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.CombinePath) + newCombineName + ".mds";
                if (File.Exists(combineLocation)) {
                    IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService));
                    if (messageService.AskQuestion(String.Format (GettextCatalog.GetString ("Solution file {0} already exists, do you want to overwrite\nthe existing file ?"), combineLocation))) {
                        newCombine.Save (combineLocation, monitor);
                    }
                } else {
                    newCombine.Save (combineLocation, monitor);
                }

                newCombine.Dispose();
                return combineLocation;
            }
        }
 public IProject CreateProject(ProjectCreateInformation info, XmlElement projectOptions)
 {
     return new PythonProject(info, projectOptions);
 }
 public Project CreateProject(string type, ProjectCreateInformation info, XmlElement projectOptions)
 {
     foreach (ProjectBindingCodon projectBinding in projectBindings) {
         if (projectBinding.ProjectBinding.Name == type) {
             Project project = projectBinding.ProjectBinding.CreateProject (info, projectOptions);
             return project;
         }
     }
     return null;
 }
 public void Run(ProjectCreateInformation projectCreateInformation)
 {
     Runtime.FileService.OpenFile (projectCreateInformation.ProjectBasePath + Path.DirectorySeparatorChar + fileName);
 }
        public string CreateProject(ProjectCreateInformation projectCreateInformation)
        {
            this.projectCreateInformation = projectCreateInformation;

            if (wizardpath != null) {
            //              TODO: WIZARD
                IProperties customizer = new DefaultProperties();
                customizer.SetProperty("ProjectCreateInformation", projectCreateInformation);
                customizer.SetProperty("ProjectTemplate", this);
                //WizardDialog wizard = new WizardDialog("Project Wizard", customizer, wizardpath);
                //if (wizard.ShowDialog() == DialogResult.OK) {
                //	lastCombine = combineDescriptor.CreateCombine(projectCreateInformation, this.languagename);
                //} else {
                //	return null;
                //}
            } else {
                lastCombine = combineDescriptor.CreateEntry (projectCreateInformation, this.languagename);
            }

            return lastCombine;
        }