diff options
author | Matt Ward <matt.ward@xamarin.com> | 2015-08-03 18:02:23 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@xamarin.com> | 2015-08-03 18:02:23 +0300 |
commit | b7f79af476ab361b68fe58afe67179bd26e867ac (patch) | |
tree | 083dfc5252c2ad847efb6e5d7a595f7a1f131f6c /main/src/core/MonoDevelop.Ide | |
parent | 96fa486ff7d864c650715e723dc83af55268bd81 (diff) |
[Ide] Handle projects not always displayed when selecting template.
The New Project dialog supports project templates that are hidden
when File - New - Solution is selected but visible when Add - Add New
Project is selected. This causes problems when selecting the last
created project if one of these project templates is selected.
Previously if a project was created from a template that is only
displayed when adding a new project to a solution then the correct
project template would be selected on re-opeing the New Project
dialog only if adding a new project to the solution. When creating
a new solution the New Project dialog would not be able to find the
project template, since it is not shown, and would fall back to
selecting the first project template it can find.
Now with this commit the New Project dialog will save two last
created projects if the project template is only displayed when
adding a new project to an existing solution. So when opening the
New Project dialog to create a new solution and the previously created
project template is not visible it will show the last project that
was created when creating a new solution instead of selecting the
first project template it can find. If the project is visible in
both cases then only one project template is remembered by the New
Project dialog.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs index 2fbcc8421d..0575503856 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs @@ -57,8 +57,10 @@ namespace MonoDevelop.Ide.Projects const string CreateGitIgnoreFilePropertyName = "Dialogs.NewProjectDialog.CreateGitIgnoreFile";
const string CreateProjectSubDirectoryPropertyName = "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir";
const string CreateProjectSubDirectoryInExistingSolutionPropertyName = "Dialogs.NewProjectDialog.AutoCreateProjectSubdirInExistingSolution";
- const string LastSelectedCategoryPropertyName = "Dialogs.NewProjectDialog.LastSelectedCategoryPath";
- const string LastSelectedTemplatePropertyName = "Dialogs.NewProjectDialog.LastSelectedTemplate";
+ const string NewSolutionLastSelectedCategoryPropertyName = "Dialogs.NewProjectDialog.LastSelectedCategoryPath";
+ const string NewSolutionLastSelectedTemplatePropertyName = "Dialogs.NewProjectDialog.LastSelectedTemplate";
+ const string NewProjectLastSelectedCategoryPropertyName = "Dialogs.NewProjectDialog.AddNewProjectLastSelectedCategoryPath";
+ const string NewProjectLastSelectedTemplatePropertyName = "Dialogs.NewProjectDialog.AddNewProjectLastSelectedTemplate";
const string SelectedLanguagePropertyName = "Dialogs.NewProjectDialog.SelectedLanguage";
List<TemplateCategory> templateCategories;
@@ -91,22 +93,56 @@ namespace MonoDevelop.Ide.Projects string DefaultSelectedCategoryPath {
get {
- return PropertyService.Get<string> (LastSelectedCategoryPropertyName, null);
+ return GetDefaultPropertyValue (NewProjectLastSelectedCategoryPropertyName,
+ NewSolutionLastSelectedCategoryPropertyName);
}
set {
- PropertyService.Set (LastSelectedCategoryPropertyName, value);
+ SetDefaultPropertyValue (NewProjectLastSelectedCategoryPropertyName,
+ NewSolutionLastSelectedCategoryPropertyName,
+ value);
}
}
string DefaultSelectedTemplate {
get {
- return PropertyService.Get<string> (LastSelectedTemplatePropertyName, null);
+ return GetDefaultPropertyValue (NewProjectLastSelectedTemplatePropertyName,
+ NewSolutionLastSelectedTemplatePropertyName);
}
set {
- PropertyService.Set (LastSelectedTemplatePropertyName, value);
+ SetDefaultPropertyValue (NewProjectLastSelectedTemplatePropertyName,
+ NewSolutionLastSelectedTemplatePropertyName,
+ value);
}
}
+ string GetDefaultPropertyValue (string newProjectPropertyName, string newSolutionPropertyName)
+ {
+ if (!IsNewSolution) {
+ string propertyValue = PropertyService.Get<string> (newProjectPropertyName, null);
+ if (!string.IsNullOrEmpty (propertyValue))
+ return propertyValue;
+ }
+ return PropertyService.Get<string> (newSolutionPropertyName, null);
+ }
+
+ void SetDefaultPropertyValue (string newProjectPropertyName, string newSolutionPropertyName, string value)
+ {
+ SolutionTemplateVisibility visibility = GetSelectedTemplateVisibility ();
+ if (IsNewSolution || visibility != SolutionTemplateVisibility.NewProject) {
+ PropertyService.Set (newSolutionPropertyName, value);
+ PropertyService.Set (newProjectPropertyName, null);
+ } else if (visibility == SolutionTemplateVisibility.NewProject) {
+ PropertyService.Set (newProjectPropertyName, value);
+ }
+ }
+
+ SolutionTemplateVisibility GetSelectedTemplateVisibility ()
+ {
+ if (SelectedTemplate != null)
+ return SelectedTemplate.Visibility;
+ return SolutionTemplateVisibility.All;
+ }
+
public bool IsNewSolution {
get { return projectConfiguration.CreateSolution; }
}
|