Skip to content
Browse files

Issue #11 - commented out registering selection monitoring event and …

…all setting the time internal variables. Instead they are obtained right before opening the dialog. Added acquisition of current project through VSX means instead of DTE. Removed context menu item "Add django view". Addition is done using "Add / New item" now.
  • Loading branch information...
1 parent faa86b9 commit 2c1d1d074672a95f49d03f89978c64871beff099 @sivanov-hill30 sivanov-hill30 committed
View
26 NDjangoDesigner/Commands/AddViewCommand.cs
@@ -42,10 +42,10 @@ private static void Execute(object sender, EventArgs e)
/// <summary>
///
/// </summary>
- private static void ExecuteForNewItem(string newFileName)
+ private static void ExecuteForNewItem(string newFileName, string viewsFolderName)
{
- viewDialog = new AddViewDlg();
- viewDialog.FillDialogControls();
+ viewDialog = new AddViewDlg();
+ viewDialog.FillDialogControls(viewsFolderName);
viewDialog.ViewName = newFileName;
viewDialog.ViewNameEnabled = false;
@@ -89,20 +89,16 @@ void IWizard.RunFinished()
/// <param name="customParams">The custom parameters with which to perform parameter replacement in the project.</param>
void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
- //List<string> l1 =
- // new List<string>(),
- // l2 = new List<string>();
-
- //foreach (UIHierarchyItem item in (((DTE2)automationObject).ToolWindows.SolutionExplorer.SelectedItems as Array))
- //{
- // ProjectItem prjItem = item.Object as ProjectItem;
- // string prjPath = prjItem.Properties.Item("FullPath").Value.ToString();
+ List<string> l1 = new List<string>();
-
- // l1.Add(prjPath);
- //}
+ foreach (UIHierarchyItem item in (((DTE2)automationObject).ToolWindows.SolutionExplorer.SelectedItems as Array))
+ {
+ ProjectItem prjItem = item.Object as ProjectItem;
+ l1.Add(prjItem.Properties.Item("FullPath").Value.ToString());
+ }
+
// "$rootname$" is always present
- ExecuteForNewItem(replacementsDictionary["$rootname$"]);
+ ExecuteForNewItem(replacementsDictionary["$rootname$"], l1[0]);
// NOTE!
// 1 - Item in template XML must have its parameter ReplaceParameters being set to "true" in order for this to function!
View
11 NDjangoDesigner/Commands/AddViewDlg.cs
@@ -25,6 +25,12 @@ public AddViewDlg()
WriteItemDirectly = true;
}
+ public void FillDialogControls(string viewsFolderName)
+ {
+ wizard.ViewsFolderName = viewsFolderName;
+ FillDialogControls();
+ }
+
public void FillDialogControls()
{
wizard.Update();
@@ -79,6 +85,11 @@ public string ModelToExtend
comboModel.SelectedItem.ToString(); }
}
+ public string ViewsFolderName
+ {
+ set { wizard.ViewsFolderName = value; }
+ }
+
// PRIVATE PROPERTIES
private bool IsInheritance
View
53 NDjangoDesigner/Commands/ViewWizard.cs
@@ -80,6 +80,12 @@ Project CurrentProject
TemplateDirectory templatesDir;
#endregion
+ public string ViewsFolderName
+ {
+ get { return viewsFolderName; }
+ set { viewsFolderName = value; }
+ }
+
int IVsSelectionEvents.OnCmdUIContextChanged(uint dwCmdUICookie, int fActive)
{
return VSConstants.S_OK;
@@ -230,24 +236,35 @@ public List<Assembly> GetReferences()
private void GetCurrentProject()
{
- foreach (Project project in dte.Solution.Projects)
- if (project.Name == projectName)
- {
- curProject = project;
- break;
- }
- else if (project.ProjectItems != null)
- LoopItems(project);
- }
- private void LoopItems(Project project)
- {
- foreach (ProjectItem item in project.ProjectItems)
- if (item.Name == projectName)
- {
- curProject = item.SubProject;
- break;
- }
-
+ // foreach (Project project in dte.Solution.Projects)
+ // if (project.Name == projectName)
+ // {
+ // curProject = project;
+ // break;
+ // }
+ // else if (project.ProjectItems != null)
+ // LoopItems(project);
+ //}
+ //private void LoopItems(Project project)
+ //{
+ // foreach (ProjectItem item in project.ProjectItems)
+ // if (item.Name == projectName)
+ // {
+ // curProject = item.SubProject;
+ // break;
+ // }
+ IntPtr ppHier;
+ uint pitemid;
+ IVsMultiItemSelect ppMIS;
+ IntPtr ppSC;
+ GlobalServices.SelectionTracker.GetCurrentSelection(out ppHier, out pitemid, out ppMIS, out ppSC);
+ var o = (IVsHierarchy)Marshal.GetObjectForIUnknown(ppHier);
+ Marshal.Release(ppHier);
+ object pvar;
+ if (o.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out pvar) == VSConstants.S_OK)
+ {
+ curProject = pvar as EnvDTE.Project;
+ }
}
public IEnumerable<string> GetTemplates(string root)
{
View
16 NDjangoDesigner/NDjangoDesignerPackage.cs
@@ -58,14 +58,14 @@ private void ShowAddView(object sender, EventArgs e)
protected override void Initialize()
{
base.Initialize();
- var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
- if (null != mcs)
- {
- //CommandID addViewCommandID = new CommandID(GuidList.guidNDjangoDesignerCmdSet, (int)GuidList.cmdidNDjangoDesigner);
- //OleMenuCommand cmd = new OleMenuCommand(ShowAddView, addViewCommandID);
- mcs.AddCommand(new AddViewCommand());
- }
- viewDialog = new AddViewDlg();
+ //var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
+ //if (null != mcs)
+ //{
+ // //CommandID addViewCommandID = new CommandID(GuidList.guidNDjangoDesignerCmdSet, (int)GuidList.cmdidNDjangoDesigner);
+ // //OleMenuCommand cmd = new OleMenuCommand(ShowAddView, addViewCommandID);
+ // mcs.AddCommand(new AddViewCommand());
+ //}
+ //viewDialog = new AddViewDlg();
((IComponentModel)GetGlobalService(typeof(SComponentModel))).DefaultCompositionService.SatisfyImportsOnce(this);

0 comments on commit 2c1d1d0

Please sign in to comment.
Something went wrong with that request. Please try again.