diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/OpenDialogCommand.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/OpenDialogCommand.cs index a2a19391af..809cb20bc1 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/OpenDialogCommand.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/OpenDialogCommand.cs @@ -1,18 +1,18 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using ICSharpCode.Core; -// -//namespace ICSharpCode.WixBinding -//{ -// public class OpenDialogCommand : AbstractMenuCommand -// { -// public override void Run() -// { -// if (SetupDialogListPad.Instance != null) { -// SetupDialogListPad.Instance.OpenSelectedDialog(); -// } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.Core; + +namespace ICSharpCode.WixBinding +{ + public class OpenDialogCommand : AbstractMenuCommand + { + public override void Run() + { + if (SetupDialogListPad.Instance != null) { + SetupDialogListPad.Instance.OpenSelectedDialog(); + } + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ViewDialogXmlCommand.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ViewDialogXmlCommand.cs index 705bc4c908..9cb208e22a 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ViewDialogXmlCommand.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Commands/ViewDialogXmlCommand.cs @@ -1,62 +1,62 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.IO; -//using System.Xml; -// -//using ICSharpCode.Core; -//using ICSharpCode.NRefactory; -//using ICSharpCode.SharpDevelop; -// -//namespace ICSharpCode.WixBinding -//{ -// public class ViewDialogXmlCommand : AbstractMenuCommand -// { -// public override void Run() -// { -// // Get currently selected setup dialog. -// SetupDialogListViewItem selectedDialogListItem = SetupDialogListPad.Instance.SelectedDialog; -// if (selectedDialogListItem == null) { -// return; -// } -// -// SetupDialogErrorListViewItem errorDialogListItem = selectedDialogListItem as SetupDialogErrorListViewItem; -// if (errorDialogListItem == null) { -// ViewDialogXml(selectedDialogListItem.FileName, selectedDialogListItem.Id); -// } else { -// FileService.JumpToFilePosition(errorDialogListItem.FileName, errorDialogListItem.Line, errorDialogListItem.Column); -// } -// } -// -// static void ViewDialogXml(string fileName, string dialogId) -// { -// // Find dialog xml in text. -// Location location = GetDialogElementLocation(fileName, dialogId); -// -// // Jump to text. -// if (!location.IsEmpty) { -// FileService.JumpToFilePosition(fileName, location.Y, location.X); -// } else { -// MessageService.ShowErrorFormatted(StringParser.Parse("${res:ICSharpCode.WixBinding.ViewDialogXml.DialogIdNotFoundMessage}"), new string[] {dialogId, Path.GetFileName(fileName)}); -// } -// } -// -// /// -// /// Gets the dialog element location given the filename and the dialog id. -// /// -// static Location GetDialogElementLocation(string fileName, string id) -// { -// try { -// WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); -// using (TextReader reader = workbenchTextFileReader.Create(fileName)) { -// WixDocumentReader wixReader = new WixDocumentReader(reader); -// return wixReader.GetStartElementLocation("Dialog", id); -// } -// } catch (XmlException ex) { -// WixBindingService.ShowErrorInErrorList(fileName, ex); -// } -// return Location.Empty; -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Xml; + +using ICSharpCode.Core; +using ICSharpCode.NRefactory; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.WixBinding +{ + public class ViewDialogXmlCommand : AbstractMenuCommand + { + public override void Run() + { + // Get currently selected setup dialog. + SetupDialogListViewItem selectedDialogListItem = SetupDialogListPad.Instance.SelectedDialog; + if (selectedDialogListItem == null) { + return; + } + + SetupDialogErrorListViewItem errorDialogListItem = selectedDialogListItem as SetupDialogErrorListViewItem; + if (errorDialogListItem == null) { + ViewDialogXml(selectedDialogListItem.FileName, selectedDialogListItem.Id); + } else { + FileService.JumpToFilePosition(errorDialogListItem.FileName, errorDialogListItem.Line, errorDialogListItem.Column); + } + } + + static void ViewDialogXml(string fileName, string dialogId) + { + // Find dialog xml in text. + TextLocation location = GetDialogElementLocation(fileName, dialogId); + + // Jump to text. + if (!location.IsEmpty) { + FileService.JumpToFilePosition(fileName, location.Line, location.Column); + } else { + MessageService.ShowErrorFormatted(StringParser.Parse("${res:ICSharpCode.WixBinding.ViewDialogXml.DialogIdNotFoundMessage}"), new string[] {dialogId, Path.GetFileName(fileName)}); + } + } + + /// + /// Gets the dialog element location given the filename and the dialog id. + /// + static TextLocation GetDialogElementLocation(string fileName, string id) + { + try { + WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); + using (TextReader reader = workbenchTextFileReader.Create(fileName)) { + WixDocumentReader wixReader = new WixDocumentReader(reader); + return wixReader.GetStartElementLocation("Dialog", id); + } + } catch (XmlException ex) { + WixBindingService.ShowErrorInErrorList(fileName, ex); + } + return TextLocation.Empty; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogControlsSideTab.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogControlsSideTab.cs index 686c407563..63a9560a64 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogControlsSideTab.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogControlsSideTab.cs @@ -1,53 +1,53 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Drawing.Design; -//using System.IO; -//using System.Reflection; -// -//using ICSharpCode.Core; -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.FormsDesigner.Gui; -//using ICSharpCode.SharpDevelop.Gui; -//using ICSharpCode.SharpDevelop.Widgets.SideBar; -// -//namespace ICSharpCode.WixBinding -//{ -// public sealed class SetupDialogControlsSideTab : SideTabDesigner -// { -// SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService) -// : base(sideBar, category, toolboxService) -// { -// } -// -// /// -// /// Creates a new instance of the SetupDialogControlsSideTab class. -// /// -// public static SetupDialogControlsSideTab CreateSideTab() -// { -// ComponentLibraryLoader loader = new ComponentLibraryLoader(); -// loader.LoadToolComponentLibrary(ToolComponentLibraryFileName); -// -// // Fix WixBinding assembly hint path. -// Category category = (Category)loader.Categories[0]; -// foreach (ToolComponent toolComponent in category.ToolComponents) { -// toolComponent.HintPath = StringParser.Parse(toolComponent.HintPath); -// } -// return new SetupDialogControlsSideTab(WixDialogDesigner.SetupDialogControlsToolBox, category, ToolboxProvider.ToolboxService); -// } -// -// /// -// /// Gets the file that contains the list of controls supported by the Wix dialog -// /// designer. -// /// -// static string ToolComponentLibraryFileName { -// get { -// Assembly assembly = typeof(SetupDialogControlsSideTab).Assembly; -// string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty); -// string directory = Path.GetDirectoryName(assemblyFilename); -// return Path.Combine(directory, "SetupDialogControlLibrary.sdcl"); -// } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Drawing.Design; +using System.IO; +using System.Reflection; + +using ICSharpCode.Core; +using ICSharpCode.FormsDesigner; +using ICSharpCode.FormsDesigner.Gui; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Widgets.SideBar; + +namespace ICSharpCode.WixBinding +{ + public sealed class SetupDialogControlsSideTab : SideTabDesigner + { + SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService) + : base(sideBar, category, toolboxService) + { + } + + /// + /// Creates a new instance of the SetupDialogControlsSideTab class. + /// + public static SetupDialogControlsSideTab CreateSideTab() + { + ComponentLibraryLoader loader = new ComponentLibraryLoader(); + loader.LoadToolComponentLibrary(ToolComponentLibraryFileName); + + // Fix WixBinding assembly hint path. + Category category = (Category)loader.Categories[0]; + foreach (ToolComponent toolComponent in category.ToolComponents) { + toolComponent.HintPath = StringParser.Parse(toolComponent.HintPath); + } + return new SetupDialogControlsSideTab(WixDialogDesigner.SetupDialogControlsToolBox, category, ToolboxProvider.ToolboxService); + } + + /// + /// Gets the file that contains the list of controls supported by the Wix dialog + /// designer. + /// + static string ToolComponentLibraryFileName { + get { + Assembly assembly = typeof(SetupDialogControlsSideTab).Assembly; + string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty); + string directory = Path.GetDirectoryName(assemblyFilename); + return Path.Combine(directory, "SetupDialogControlLibrary.sdcl"); + } + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs index 39c1cd68e4..f146bcb279 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs @@ -1,193 +1,193 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.IO; -//using System.Xml; -// -//using ICSharpCode.Core; -//using ICSharpCode.Core.WinForms; -//using ICSharpCode.SharpDevelop; -//using ICSharpCode.SharpDevelop.Project; -//using ICSharpCode.SharpDevelop.Workbench; -// -//namespace ICSharpCode.WixBinding -//{ -// public class SetupDialogListPad : AbstractPadContent -// { -// SetupDialogListView setupDialogListView; -// bool disposed; -// static SetupDialogListPad instance; -// -// public SetupDialogListPad() -// { -// instance = this; -// -// setupDialogListView = new SetupDialogListView(); -// setupDialogListView.ContextMenuStrip = MenuService.CreateContextMenu(setupDialogListView, "/SharpDevelop/Pads/WixSetupDialogListPad/ContextMenu"); -// setupDialogListView.ItemActivate += SetupDialogListViewItemActivate; -// setupDialogListView.Enter += SetupDialogListViewEnter; -// -// // Show dialogs in currently open wix project. -// ShowDialogList(); -// -// ProjectService.CurrentProjectChanged += CurrentProjectChanged; -// } -// -// static public SetupDialogListPad Instance { -// get { -// return instance; -// } -// } -// -// public override object Control { -// get { -// return setupDialogListView; -// } -// } -// -// public override void Dispose() -// { -// if (!disposed) { -// disposed = true; -// setupDialogListView.Dispose(); -// setupDialogListView = null; -// ProjectService.CurrentProjectChanged -= CurrentProjectChanged; -// } -// } -// -// /// -// /// Opens the selected dialog and displays it in the designer. -// /// -// public void OpenSelectedDialog() -// { -// SetupDialogListViewItem selectedDialog = SelectedDialog; -// if (selectedDialog != null) { -// SetupDialogErrorListViewItem errorItem = selectedDialog as SetupDialogErrorListViewItem; -// if (errorItem == null) { -// OpenDialog(selectedDialog.FileName, selectedDialog.Id); -// } else { -// FileService.JumpToFilePosition(errorItem.FileName, errorItem.Line, errorItem.Column); -// } -// } -// } -// -// /// -// /// Gets the selected dialog list view item. -// /// -// public SetupDialogListViewItem SelectedDialog { -// get { -// if (setupDialogListView.SelectedItems.Count > 0) { -// return (SetupDialogListViewItem)(setupDialogListView.SelectedItems[0]); -// } -// return null; -// } -// } -// -// /// -// /// Adds all the dialog ids from all the files in the project to the list view. -// /// -// /// -// /// If an error occurs an error item is added to the list. The error -// /// list is only cleared the first time an error occurs -// /// since there may be multiple errors, one in each Wix file. -// /// Also we do not clear the error list unless we have an error -// /// so any previously added errors from a build, for example, are not -// /// cleared unless we have to. -// /// -// void ShowDialogList() -// { -// // Make sure we do not leave any errors in the error list from a previous call. -// if (setupDialogListView.HasErrors) { -// WixBindingService.ClearErrorList(); -// } -// -// setupDialogListView.Items.Clear(); -// -// WixProject openWixProject = ProjectService.CurrentProject as WixProject; -// if (openWixProject != null) { -// bool clearedErrorList = false; -// foreach (FileProjectItem wixFile in openWixProject.WixFiles) { -// if (File.Exists(wixFile.FileName)) { -// try { -// AddDialogListItems(wixFile.FileName); -// } catch (XmlException ex) { -// // Clear the error list the first time only. -// if (!clearedErrorList) { -// clearedErrorList = true; -// WixBindingService.ClearErrorList(); -// } -// setupDialogListView.AddError(wixFile.FileName, ex); -// WixBindingService.AddErrorToErrorList(wixFile.FileName, ex); -// } -// } -// } -// if (clearedErrorList) { -// WixBindingService.ShowErrorList(); -// } -// } -// } -// -// /// -// /// Adds dialog ids to the list. -// /// -// void AddDialogListItems(string fileName) -// { -// WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); -// using (TextReader reader = workbenchTextFileReader.Create(fileName)) { -// WixDocumentReader wixReader = new WixDocumentReader(reader); -// setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds()); -// } -// } -// -// void CurrentProjectChanged(object source, ProjectEventArgs e) -// { -// ShowDialogList(); -// } -// -// void SetupDialogListViewItemActivate(object source, EventArgs e) -// { -// OpenSelectedDialog(); -// } -// -// /// -// /// When the setup dialog list gets focus update the list of dialogs since -// /// the Wix document may have changed. -// /// -// void SetupDialogListViewEnter(object source, EventArgs e) -// { -// UpdateDialogList(); -// } -// -// /// -// /// Opens the specified dialog id into the designer. -// /// -// static void OpenDialog(string fileName, string dialogId) -// { -// // Open the Wix file. -// IViewContent viewContent = FileService.OpenFile(fileName); -// -// // Show the designer. -// WixDialogDesigner designer = WixDialogDesigner.GetDesigner(viewContent); -// if (designer != null) { -// designer.OpenDialog(dialogId); -// } else { -// LoggingService.Debug("Could not open Wix dialog designer for: " + fileName); -// } -// } -// -// /// -// /// Updates the list if the Wix documents can be read otherwise the list -// /// items are unchanged for that document. -// /// -// void UpdateDialogList() -// { -// try { -// setupDialogListView.BeginUpdate(); -// ShowDialogList(); -// } finally { -// setupDialogListView.EndUpdate(); -// } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Xml; + +using ICSharpCode.Core; +using ICSharpCode.Core.WinForms; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Workbench; + +namespace ICSharpCode.WixBinding +{ + public class SetupDialogListPad : AbstractPadContent + { + SetupDialogListView setupDialogListView; + bool disposed; + static SetupDialogListPad instance; + + public SetupDialogListPad() + { + instance = this; + + setupDialogListView = new SetupDialogListView(); + setupDialogListView.ContextMenuStrip = MenuService.CreateContextMenu(setupDialogListView, "/SharpDevelop/Pads/WixSetupDialogListPad/ContextMenu"); + setupDialogListView.ItemActivate += SetupDialogListViewItemActivate; + setupDialogListView.Enter += SetupDialogListViewEnter; + + // Show dialogs in currently open wix project. + ShowDialogList(); + + ProjectService.CurrentProjectChanged += CurrentProjectChanged; + } + + static public SetupDialogListPad Instance { + get { + return instance; + } + } + + public override object Control { + get { + return setupDialogListView; + } + } + + public override void Dispose() + { + if (!disposed) { + disposed = true; + setupDialogListView.Dispose(); + setupDialogListView = null; + ProjectService.CurrentProjectChanged -= CurrentProjectChanged; + } + } + + /// + /// Opens the selected dialog and displays it in the designer. + /// + public void OpenSelectedDialog() + { + SetupDialogListViewItem selectedDialog = SelectedDialog; + if (selectedDialog != null) { + SetupDialogErrorListViewItem errorItem = selectedDialog as SetupDialogErrorListViewItem; + if (errorItem == null) { + OpenDialog(selectedDialog.FileName, selectedDialog.Id); + } else { + FileService.JumpToFilePosition(errorItem.FileName, errorItem.Line, errorItem.Column); + } + } + } + + /// + /// Gets the selected dialog list view item. + /// + public SetupDialogListViewItem SelectedDialog { + get { + if (setupDialogListView.SelectedItems.Count > 0) { + return (SetupDialogListViewItem)(setupDialogListView.SelectedItems[0]); + } + return null; + } + } + + /// + /// Adds all the dialog ids from all the files in the project to the list view. + /// + /// + /// If an error occurs an error item is added to the list. The error + /// list is only cleared the first time an error occurs + /// since there may be multiple errors, one in each Wix file. + /// Also we do not clear the error list unless we have an error + /// so any previously added errors from a build, for example, are not + /// cleared unless we have to. + /// + void ShowDialogList() + { + // Make sure we do not leave any errors in the error list from a previous call. + if (setupDialogListView.HasErrors) { + WixBindingService.ClearErrorList(); + } + + setupDialogListView.Items.Clear(); + + WixProject openWixProject = ProjectService.CurrentProject as WixProject; + if (openWixProject != null) { + bool clearedErrorList = false; + foreach (FileProjectItem wixFile in openWixProject.WixFiles) { + if (File.Exists(wixFile.FileName)) { + try { + AddDialogListItems(wixFile.FileName); + } catch (XmlException ex) { + // Clear the error list the first time only. + if (!clearedErrorList) { + clearedErrorList = true; + WixBindingService.ClearErrorList(); + } + setupDialogListView.AddError(wixFile.FileName, ex); + WixBindingService.AddErrorToErrorList(wixFile.FileName, ex); + } + } + } + if (clearedErrorList) { + WixBindingService.ShowErrorList(); + } + } + } + + /// + /// Adds dialog ids to the list. + /// + void AddDialogListItems(string fileName) + { + WorkbenchTextFileReader workbenchTextFileReader = new WorkbenchTextFileReader(); + using (TextReader reader = workbenchTextFileReader.Create(fileName)) { + WixDocumentReader wixReader = new WixDocumentReader(reader); + setupDialogListView.AddDialogs(fileName, wixReader.GetDialogIds()); + } + } + + void CurrentProjectChanged(object source, ProjectEventArgs e) + { + ShowDialogList(); + } + + void SetupDialogListViewItemActivate(object source, EventArgs e) + { + OpenSelectedDialog(); + } + + /// + /// When the setup dialog list gets focus update the list of dialogs since + /// the Wix document may have changed. + /// + void SetupDialogListViewEnter(object source, EventArgs e) + { + UpdateDialogList(); + } + + /// + /// Opens the specified dialog id into the designer. + /// + static void OpenDialog(string fileName, string dialogId) + { + // Open the Wix file. + IViewContent viewContent = FileService.OpenFile(fileName); + + // Show the designer. + WixDialogDesigner designer = WixDialogDesigner.GetDesigner(viewContent); + if (designer != null) { + designer.OpenDialog(dialogId); + } else { + LoggingService.Debug("Could not open Wix dialog designer for: " + fileName); + } + } + + /// + /// Updates the list if the Wix documents can be read otherwise the list + /// items are unchanged for that document. + /// + void UpdateDialogList() + { + try { + setupDialogListView.BeginUpdate(); + ShowDialogList(); + } finally { + setupDialogListView.EndUpdate(); + } + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs index 625808255b..c1509e44be 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs @@ -1,296 +1,302 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.ObjectModel; -//using System.IO; -//using System.Xml; -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.NRefactory; -//using ICSharpCode.SharpDevelop; -//using ICSharpCode.SharpDevelop.Editor; -//using ICSharpCode.SharpDevelop.Gui; -//using ICSharpCode.SharpDevelop.Project; -//using ICSharpCode.SharpDevelop.Refactoring; -// -//namespace ICSharpCode.WixBinding -//{ -// public class WixDialogDesigner : FormsDesignerViewContent, IWixDialogDesigner -// { -// string dialogId = String.Empty; -// WixProject wixProject; -// -// /// -// /// Ignore the dialog id in the text editor if the OpenDialog method is called -// /// and the designer is not being opened by the user clicking the Design tab. -// /// -// bool ignoreDialogIdSelectedInTextEditor; -// -// public WixDialogDesigner(IViewContent view) -// : this(view, new WixDialogDesignerLoaderProvider(), new WixDialogDesignerGenerator()) -// { -// } -// -// public WixDialogDesigner(IViewContent view, WixDialogDesignerLoaderProvider designerLoaderProvider, WixDialogDesignerGenerator designerGenerator) -// : base(view, designerLoaderProvider, designerGenerator) -// { -// designerLoaderProvider.Designer = this; -// } -// -// /// -// /// Gets the WixDialogDesigner from the primary view. -// /// -// /// The wix dialog designer view that is attached as a -// /// secondary view; if the primary view -// /// has no such designer attached. -// public static WixDialogDesigner GetDesigner(IViewContent view) -// { -// foreach (IViewContent secondaryView in view.SecondaryViewContents) { -// WixDialogDesigner designer = secondaryView as WixDialogDesigner; -// if (designer != null) { -// return designer; -// } -// } -// return null; -// } -// -// /// -// /// Attempts to open the Wix dialog from the document currently -// /// associated with this designer. -// /// -// /// The id of the dialog that will be opened. -// public void OpenDialog(string id) -// { -// JumpToDialogElement(id); -// if (base.Host != null) { -// // Reload so the correct dialog is displayed. -// MergeAndUnloadDesigner(); -// DialogId = id; -// ReloadDesignerFromMemory(); -// } else { -// // Need to open the designer. -// DialogId = id; -// OpenDesigner(); -// } -// } -// -// protected override void LoadInternal(OpenedFile file, Stream stream) -// { -// if (file == this.PrimaryFile) { -// // The FormsDesignerViewContent normally operates independently of any -// // text editor. The following statements connect the forms designer -// // directly to the underlying XML text editor so that the caret positioning -// // and text selection operations done by the WiX designer actually -// // become visible in the text editor. -// if (!this.SourceCodeStorage.ContainsFile(file)) { -// ITextEditor editor = ((ITextEditorProvider)this.PrimaryViewContent).TextEditor; -// this.SourceCodeStorage.AddFile(file, editor.Document, ParserService.DefaultFileEncoding, true); -// } -// -// try { -// if (!ignoreDialogIdSelectedInTextEditor) { -// string dialogId = GetDialogIdSelectedInTextEditor(); -// if (dialogId == null) { -// dialogId = GetFirstDialogIdInTextEditor(); -// JumpToDialogElement(dialogId); -// } -// DialogId = dialogId; -// } -// wixProject = GetProject(); -// } catch (XmlException ex) { -// // Let the Wix designer loader try to load the XML and generate -// // an error message. -// DialogId = "InvalidXML"; -// AddToErrorList(ex); -// } -// } -// base.LoadInternal(file, stream); -// } -// -// #region Switch...WithoutSaveLoad -// -// // These four methods prevent the text editor from doing a full save/load -// // cycle when switching views. This allows the text editor to keep its -// // selection and caret position. -// -// public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) -// { -// return (newView == this) || (newView == this.PrimaryViewContent); -// } -// -// public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) -// { -// if (newView != this) { -// this.MergeAndUnloadDesigner(); -// } -// } -// -// public override bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) -// { -// return (this.DesignerCodeFile != null) && -// ((oldView == this) || (oldView == this.PrimaryViewContent)); -// } -// -// public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) -// { -// if (oldView != this) { -// this.ReloadDesignerFromMemory(); -// } -// } -// -// #endregion -// -// /// -// /// Gets the Wix document filename. -// /// -// public string DocumentFileName { -// get { return PrimaryFileName; } -// } -// -// /// -// /// Gets the wix project containing the document open in the designer. -// /// -// public WixProject Project { -// get { return wixProject; } -// } -// -// /// -// /// Gets the Wix document xml. -// /// -// public string GetDocumentXml() -// { -// return DesignerCodeFileContent; -// } -// -// /// -// /// Gets or sets the dialog id currently being designed. -// /// -// public string DialogId { -// get { return dialogId; } -// set { dialogId = value; } -// } -// -// /// -// /// Finds the WixDialogDesigner in the current window's secondary views -// /// and switches to it. -// /// -// void OpenDesigner() -// { -// try { -// ignoreDialogIdSelectedInTextEditor = true; -// WorkbenchWindow.ActiveViewContent = this; -// } finally { -// ignoreDialogIdSelectedInTextEditor = false; -// } -// } -// -// /// -// /// From the current cursor position in the text editor determine the -// /// selected dialog id. -// /// -// string GetDialogIdSelectedInTextEditor() -// { -// ITextEditor textEditor = ActiveTextEditor; -// if (textEditor != null) { -// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); -// return wixReader.GetDialogId(textEditor.Caret.Line); -// } -// return null; -// } -// -// /// -// /// Gets the first dialog id in the file. -// /// -// string GetFirstDialogIdInTextEditor() -// { -// ITextEditor textEditor = ActiveTextEditor; -// if (textEditor != null) { -// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); -// ReadOnlyCollection ids = wixReader.GetDialogIds(); -// if (ids.Count > 0) { -// return ids[0]; -// } -// } -// return null; -// } -// -// /// -// /// Gets the active text area control. -// /// -// ITextEditor ActiveTextEditor { -// get { -// ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider; -// if (provider != null) { -// return provider.TextEditor; -// } -// return null; -// } -// } -// -// void AddToErrorList(XmlException ex) -// { -// TaskService.ClearExceptCommentTasks(); -// TaskService.Add(new Task(this.PrimaryFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error)); -// WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); -// } -// -// /// -// /// Cannot use ProjectService.CurrentProject since it is possible to switch -// /// to the designer without selecting the project. -// /// -// WixProject GetProject() -// { -// Solution openSolution = ProjectService.OpenSolution; -// if (openSolution != null) { -// foreach (IProject project in openSolution.Projects) { -// if (project.IsFileInProject(this.PrimaryFileName)) { -// return project as WixProject; -// } -// } -// } -// return null; -// } -// -// /// -// /// Jumps to dialog element with corresponding dialog id. This is only used -// /// when the user opens a dialog from the Setup dialogs window or the cursor -// /// was not near a dialog when the designer was switched to. Jumping to the -// /// dialog selected ensures that when the user switches back, if they did -// /// not make any changes, then the dialog xml is displayed. -// /// -// void JumpToDialogElement(string dialogId) -// { -// try { -// if (dialogId != null) { -// ITextEditor textEditor = ActiveTextEditor; -// if (textEditor != null) { -// WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); -// Location location = wixReader.GetStartElementLocation("Dialog", dialogId); -// textEditor.JumpTo(location.Y, 1); -// } -// } -// } catch (XmlException) { -// // Ignore -// } -// } -// -// static SharpDevelopSideBar setupDialogControlsToolBox; -// -// public static SharpDevelopSideBar SetupDialogControlsToolBox { -// get { -// WorkbenchSingleton.AssertMainThread(); -// if (setupDialogControlsToolBox == null) { -// setupDialogControlsToolBox = new SharpDevelopSideBar(); -// setupDialogControlsToolBox.Tabs.Add(SetupDialogControlsSideTab.CreateSideTab()); -// setupDialogControlsToolBox.ActiveTab = setupDialogControlsToolBox.Tabs[0]; -// } -// return setupDialogControlsToolBox; -// } -// } -// -// -// public override object ToolsContent { -// get { return SetupDialogControlsToolBox; } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.ObjectModel; +using System.IO; +using System.Xml; +using ICSharpCode.FormsDesigner; +using ICSharpCode.NRefactory; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Refactoring; +using ICSharpCode.SharpDevelop.Workbench; + +namespace ICSharpCode.WixBinding +{ + public class WixDialogDesigner : FormsDesignerViewContent, IWixDialogDesigner + { + string dialogId = String.Empty; + WixProject wixProject; + + /// + /// Ignore the dialog id in the text editor if the OpenDialog method is called + /// and the designer is not being opened by the user clicking the Design tab. + /// + bool ignoreDialogIdSelectedInTextEditor; + + public WixDialogDesigner(IViewContent view) + : this(view, new WixDialogDesignerLoaderProvider()) + { + } + + public WixDialogDesigner(IViewContent view, WixDialogDesignerLoaderProvider designerLoaderProvider) + : base(view, designerLoaderProvider) + { + } + + /// + /// Gets the WixDialogDesigner from the primary view. + /// + /// The wix dialog designer view that is attached as a + /// secondary view; if the primary view + /// has no such designer attached. + public static WixDialogDesigner GetDesigner(IViewContent view) + { + foreach (IViewContent secondaryView in view.SecondaryViewContents) { + WixDialogDesigner designer = secondaryView as WixDialogDesigner; + if (designer != null) { + return designer; + } + } + return null; + } + + /// + /// Attempts to open the Wix dialog from the document currently + /// associated with this designer. + /// + /// The id of the dialog that will be opened. + public void OpenDialog(string id) + { + JumpToDialogElement(id); + if (base.Host != null) { + // Reload so the correct dialog is displayed. + MergeAndUnloadDesigner(); + DialogId = id; + ReloadDesignerFromMemory(); + } else { + // Need to open the designer. + DialogId = id; + OpenDesigner(); + } + } + + protected override void LoadInternal(OpenedFile file, Stream stream) + { + if (file == this.PrimaryFile) { + // The FormsDesignerViewContent normally operates independently of any + // text editor. The following statements connect the forms designer + // directly to the underlying XML text editor so that the caret positioning + // and text selection operations done by the WiX designer actually + // become visible in the text editor. + if (!this.SourceCodeStorage.ContainsFile(file)) { + ITextEditor editor = ((ITextEditorProvider)this.PrimaryViewContent).TextEditor; + this.SourceCodeStorage.AddFile(file, editor.Document, SD.FileService.DefaultFileEncoding, true); + } + + try { + if (!ignoreDialogIdSelectedInTextEditor) { + string dialogId = GetDialogIdSelectedInTextEditor(); + if (dialogId == null) { + dialogId = GetFirstDialogIdInTextEditor(); + JumpToDialogElement(dialogId); + } + DialogId = dialogId; + } + wixProject = GetProject(); + } catch (XmlException ex) { + // Let the Wix designer loader try to load the XML and generate + // an error message. + DialogId = "InvalidXML"; + AddToErrorList(ex); + } + } + base.LoadInternal(file, stream); + } + + #region Switch...WithoutSaveLoad + + // These four methods prevent the text editor from doing a full save/load + // cycle when switching views. This allows the text editor to keep its + // selection and caret position. + + public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) + { + return (newView == this) || (newView == this.PrimaryViewContent); + } + + public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) + { + if (newView != this) { + this.MergeAndUnloadDesigner(); + } + } + + public override bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) + { + return (this.DesignerCodeFile != null) && + ((oldView == this) || (oldView == this.PrimaryViewContent)); + } + + public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) + { + if (oldView != this) { + this.ReloadDesignerFromMemory(); + } + } + + #endregion + + /// + /// Gets the Wix document filename. + /// + public string DocumentFileName { + get { return PrimaryFileName; } + } + + /// + /// Gets the wix project containing the document open in the designer. + /// + public WixProject Project { + get { return wixProject; } + } + + /// + /// Gets the Wix document xml. + /// + public string GetDocumentXml() + { + return DesignerCodeFileContent; + } + + public ITextEditor PrimaryViewContentTextEditor { + get { + return PrimaryViewContent.GetRequiredService(); + } + } + + /// + /// Gets or sets the dialog id currently being designed. + /// + public string DialogId { + get { return dialogId; } + set { dialogId = value; } + } + + /// + /// Finds the WixDialogDesigner in the current window's secondary views + /// and switches to it. + /// + void OpenDesigner() + { + try { + ignoreDialogIdSelectedInTextEditor = true; + WorkbenchWindow.ActiveViewContent = this; + } finally { + ignoreDialogIdSelectedInTextEditor = false; + } + } + + /// + /// From the current cursor position in the text editor determine the + /// selected dialog id. + /// + string GetDialogIdSelectedInTextEditor() + { + ITextEditor textEditor = ActiveTextEditor; + if (textEditor != null) { + WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); + return wixReader.GetDialogId(textEditor.Caret.Line); + } + return null; + } + + /// + /// Gets the first dialog id in the file. + /// + string GetFirstDialogIdInTextEditor() + { + ITextEditor textEditor = ActiveTextEditor; + if (textEditor != null) { + WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); + ReadOnlyCollection ids = wixReader.GetDialogIds(); + if (ids.Count > 0) { + return ids[0]; + } + } + return null; + } + + /// + /// Gets the active text area control. + /// + ITextEditor ActiveTextEditor { + get { + ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider; + if (provider != null) { + return provider.TextEditor; + } + return null; + } + } + + void AddToErrorList(XmlException ex) + { + TaskService.ClearExceptCommentTasks(); + TaskService.Add(new SDTask(this.PrimaryFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error)); + SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); + } + + /// + /// Cannot use ProjectService.CurrentProject since it is possible to switch + /// to the designer without selecting the project. + /// + WixProject GetProject() + { + ISolution openSolution = ProjectService.OpenSolution; + if (openSolution != null) { + foreach (IProject project in openSolution.Projects) { + if (project.IsFileInProject(this.PrimaryFileName)) { + return project as WixProject; + } + } + } + return null; + } + + /// + /// Jumps to dialog element with corresponding dialog id. This is only used + /// when the user opens a dialog from the Setup dialogs window or the cursor + /// was not near a dialog when the designer was switched to. Jumping to the + /// dialog selected ensures that when the user switches back, if they did + /// not make any changes, then the dialog xml is displayed. + /// + void JumpToDialogElement(string dialogId) + { + try { + if (dialogId != null) { + ITextEditor textEditor = ActiveTextEditor; + if (textEditor != null) { + WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text); + TextLocation location = wixReader.GetStartElementLocation("Dialog", dialogId); + textEditor.JumpTo(location.Line, 1); + } + } + } catch (XmlException) { + // Ignore + } + } + + static SharpDevelopSideBar setupDialogControlsToolBox; + + public static SharpDevelopSideBar SetupDialogControlsToolBox { + get { + SD.MainThread.VerifyAccess(); + if (setupDialogControlsToolBox == null) { + setupDialogControlsToolBox = new SharpDevelopSideBar(); + setupDialogControlsToolBox.Tabs.Add(SetupDialogControlsSideTab.CreateSideTab()); + setupDialogControlsToolBox.ActiveTab = setupDialogControlsToolBox.Tabs[0]; + } + return setupDialogControlsToolBox; + } + } + + + public override object ToolsContent { + get { return SetupDialogControlsToolBox; } + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerDisplayBinding.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerDisplayBinding.cs index 95449bf96b..7b26d28b22 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerDisplayBinding.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerDisplayBinding.cs @@ -32,8 +32,7 @@ namespace ICSharpCode.WixBinding public IViewContent[] CreateSecondaryViewContent(IViewContent view) { - //return new IViewContent[] {new WixDialogDesigner(view)}; - return null; + return new IViewContent[] {new WixDialogDesigner(view)}; } bool IsViewTextEditorProvider(IViewContent view) diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs index 3c2e0104de..36c48ce96b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs @@ -1,122 +1,78 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.CodeDom; -//using System.CodeDom.Compiler; -//using System.Collections; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.Reflection; -//using System.Xml; -// -//using ICSharpCode.Core; -//using ICSharpCode.NRefactory.TypeSystem; -//using ICSharpCode.SharpDevelop.Editor; -//using Microsoft.CSharp; -// -//namespace ICSharpCode.WixBinding -//{ -// /// -// /// Simplified designer generator interface that the WixDesignerLoader calls -// /// when flushing the changes. -// /// -// public interface IWixDialogDesignerGenerator -// { -// /// -// /// Passes the updated dialog element and its original id to the generator -// /// so the wix document can be updated. -// /// -// /// The dialog id is passed since it becomes the name of the -// /// form and this can be changed from the designer. -// void MergeFormChanges(string dialogId, XmlElement dialogElement); -// } -// -// public class WixDialogDesignerGenerator : IDesignerGenerator, IWixDialogDesignerGenerator -// { -// FormsDesignerViewContent view; -// ITextEditor textEditor; -// -// public CodeDomProvider CodeDomProvider { -// get { return new CSharpCodeProvider(); } -// } -// -// public FormsDesignerViewContent ViewContent { -// get { return view; } -// } -// -// public IEnumerable GetSourceFiles(out OpenedFile designerCodeFile) -// { -// designerCodeFile = view.PrimaryFile; -// return new [] {designerCodeFile}; -// } -// -// public void Attach(FormsDesignerViewContent view) -// { -// this.view = view; -// textEditor = ((ITextEditorProvider)view.PrimaryViewContent).TextEditor; -// } -// -// public void Detach() -// { -// view = null; -// } -// -// /// -// /// Merges the changes made to the wix document by overwriting the dialog element. -// /// -// void IWixDialogDesignerGenerator.MergeFormChanges(string dialogId, XmlElement dialogElement) -// { -// DomRegion region = GetTextEditorRegionForDialogElement(dialogId); -// if (region.IsEmpty) { -// ThrowDialogElementCouldNotBeFoundError(dialogId); -// } -// -// WixTextWriter writer = new WixTextWriter(textEditor.Options); -// WixDialogElement wixDialogElement = (WixDialogElement)dialogElement; -// string newDialogXml = wixDialogElement.GetXml(writer); -// -// WixDocumentEditor editor = new WixDocumentEditor(textEditor); -// editor.Replace(region, newDialogXml); -// } -// -// DomRegion GetTextEditorRegionForDialogElement(string dialogId) -// { -// IDocument document = view.DesignerCodeFileDocument; -// WixDocumentReader wixReader = new WixDocumentReader(document.Text); -// return wixReader.GetElementRegion("Dialog", dialogId); -// } -// -// void ThrowDialogElementCouldNotBeFoundError(string dialogId) -// { -// string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); -// string message = String.Format(messageFormat, dialogId); -// throw new FormsDesignerLoadException(message); -// } -// -// public void MergeFormChanges(CodeCompileUnit unit) -// { -// } -// -// public void NotifyComponentRenamed(object component, string newName, string oldName) -// { -// } -// -// public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position) -// { -// file = null; -// position = 0; -// return false; -// } -// -// public ICollection GetCompatibleMethods(EventDescriptor edesc) -// { -// return new ArrayList(); -// } -// -// public ICollection GetCompatibleMethods(EventInfo edesc) -// { -// return new ArrayList(); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.CodeDom; +using System.CodeDom.Compiler; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using System.Xml; + +using ICSharpCode.Core; +using ICSharpCode.FormsDesigner; +using ICSharpCode.NRefactory.Editor; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.SharpDevelop.Editor; +using Microsoft.CSharp; + +namespace ICSharpCode.WixBinding +{ + /// + /// Simplified designer generator interface that the WixDesignerLoader calls + /// when flushing the changes. + /// + public interface IWixDialogDesignerGenerator + { + /// + /// Passes the updated dialog element and its original id to the generator + /// so the wix document can be updated. + /// + /// The dialog id is passed since it becomes the name of the + /// form and this can be changed from the designer. + void MergeFormChanges(string dialogId, XmlElement dialogElement); + } + + public class WixDialogDesignerGenerator : IWixDialogDesignerGenerator + { + readonly IWixDialogDesigner view; + + public WixDialogDesignerGenerator(IWixDialogDesigner view) + { + this.view = view; + } + + /// + /// Merges the changes made to the wix document by overwriting the dialog element. + /// + void IWixDialogDesignerGenerator.MergeFormChanges(string dialogId, XmlElement dialogElement) + { + DomRegion region = GetTextEditorRegionForDialogElement(dialogId); + if (region.IsEmpty) { + ThrowDialogElementCouldNotBeFoundError(dialogId); + } + + var textEditor = view.PrimaryViewContentTextEditor; + WixTextWriter writer = new WixTextWriter(textEditor.Options); + WixDialogElement wixDialogElement = (WixDialogElement)dialogElement; + string newDialogXml = wixDialogElement.GetXml(writer); + + WixDocumentEditor editor = new WixDocumentEditor(textEditor); + editor.Replace(region, newDialogXml); + } + + DomRegion GetTextEditorRegionForDialogElement(string dialogId) + { + WixDocumentReader wixReader = new WixDocumentReader(view.GetDocumentXml()); + return wixReader.GetElementRegion("Dialog", dialogId); + } + + void ThrowDialogElementCouldNotBeFoundError(string dialogId) + { + string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); + string message = String.Format(messageFormat, dialogId); + throw new FormsDesignerLoadException(message); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoader.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoader.cs index 46abe970e6..20a5d5bb38 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoader.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoader.cs @@ -1,155 +1,148 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.ComponentModel; -//using System.ComponentModel.Design.Serialization; -//using System.Security.Permissions; -//using System.Windows.Forms; -//using System.Xml; -// -//using ICSharpCode.Core; -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.FormsDesigner.Services; -// -//namespace ICSharpCode.WixBinding -//{ -// [PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")] -// [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] -// public class WixDialogDesignerLoader : BasicDesignerLoader, IComponentCreator -// { -// WixDialog wixDialog; -// IWixDialogDesignerGenerator generator; -// IFileLoader fileLoader; -// IWixDialogDesigner designer; -// -// public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator) -// : this(designer, generator, new DefaultFileLoader()) -// { -// } -// -// /// -// /// Creates a new WixDialogDesignerLoader that will load the specified -// /// dialog id from the Wix xml. -// /// -// public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator, IFileLoader fileLoader) -// { -// this.designer = designer; -// this.generator = generator; -// this.fileLoader = fileLoader; -// -// if (designer == null) { -// throw new ArgumentNullException("designer"); -// } -// if (generator == null) { -// throw new ArgumentNullException("generator"); -// } -// } -// -// public IWixDialogDesigner Designer { -// get { return designer; } -// } -// -// public IWixDialogDesignerGenerator Generator { -// get { return generator; } -// } -// -// public override void BeginLoad(IDesignerLoaderHost host) -// { -// VerifyDesignerHasDialogId(); -// -// GetDialogElement(); -// VerifyDialogElementFound(); -// -// AddServicesToHost(host); -// -// base.BeginLoad(host); -// } -// -// void VerifyDesignerHasDialogId() -// { -// if (DesignerHasDialogId) { -// ThrowNoDialogSelectedInDocumentException(); -// } -// } -// -// bool DesignerHasDialogId { -// get { return designer.DialogId == null; } -// } -// -// void ThrowNoDialogSelectedInDocumentException() -// { -// string message = StringParser.Parse("${res:ICSharpCode.WixBinding.WixDialogDesigner.NoDialogSelectedInDocumentMessage}"); -// throw new FormsDesignerLoadException(message); -// } -// -// void GetDialogElement() -// { -// WixDocument document = CreateWixDocument(); -// document.LoadXml(designer.GetDocumentXml()); -// wixDialog = document.CreateWixDialog(designer.DialogId, new WorkbenchTextFileReader()); -// } -// -// WixDocument CreateWixDocument() -// { -// WixDocument document = new WixDocument(designer.Project, fileLoader); -// document.FileName = designer.DocumentFileName; -// return document; -// } -// -// void VerifyDialogElementFound() -// { -// if (wixDialog == null) { -// ThrowDialogIdNotFoundException(designer.DialogId); -// } -// } -// -// void ThrowDialogIdNotFoundException(string dialogId) -// { -// string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); -// string message = String.Format(messageFormat, designer.DialogId); -// throw new FormsDesignerLoadException(message); -// } -// -// void AddServicesToHost(IDesignerLoaderHost host) -// { -// host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host)); -// host.AddService(typeof(INameCreationService), new XmlDesignerNameCreationService(host)); -// host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host)); -// } -// -// /// -// /// Creates a component of the specified type. -// /// -// public IComponent CreateComponent(Type componentClass, string name) -// { -// return base.LoaderHost.CreateComponent(componentClass, name); -// } -// -// /// -// /// Updates the dialog xml element and then passes this to the generator so the -// /// Wix document is updated. -// /// -// protected override void PerformFlush(IDesignerSerializationManager serializationManager) -// { -// XmlElement updatedDialogElement = GenerateNewDialogElementFromDesignedForm(); -// MergeDialogChangesIntoFullWixDocument(updatedDialogElement); -// } -// -// XmlElement GenerateNewDialogElementFromDesignedForm() -// { -// Form form = (Form)base.LoaderHost.RootComponent; -// return wixDialog.UpdateDialogElement(form); -// } -// -// void MergeDialogChangesIntoFullWixDocument(XmlElement updatedDialogElement) -// { -// generator.MergeFormChanges(designer.DialogId, updatedDialogElement); -// } -// -// protected override void PerformLoad(IDesignerSerializationManager serializationManager) -// { -// wixDialog.CreateDialog(this); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.Security.Permissions; +using System.Windows.Forms; +using System.Xml; + +using ICSharpCode.Core; +using ICSharpCode.FormsDesigner; +using ICSharpCode.FormsDesigner.Services; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.WixBinding +{ + [PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")] + [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] + public class WixDialogDesignerLoader : BasicDesignerLoader, IComponentCreator + { + WixDialog wixDialog; + IWixDialogDesignerGenerator generator; + IFileLoader fileLoader; + IWixDialogDesigner designer; + + /// + /// Creates a new WixDialogDesignerLoader that will load the specified + /// dialog id from the Wix xml. + /// + public WixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator = null, IFileLoader fileLoader = null) + { + if (designer == null) { + throw new ArgumentNullException("designer"); + } + + this.designer = designer; + this.generator = generator ?? new WixDialogDesignerGenerator(designer); + this.fileLoader = fileLoader ?? new DefaultFileLoader(); + } + + public IWixDialogDesigner Designer { + get { return designer; } + } + + public IWixDialogDesignerGenerator Generator { + get { return generator; } + } + + public override void BeginLoad(IDesignerLoaderHost host) + { + VerifyDesignerHasDialogId(); + + GetDialogElement(); + VerifyDialogElementFound(); + + AddServicesToHost(host); + + base.BeginLoad(host); + } + + void VerifyDesignerHasDialogId() + { + if (DesignerHasDialogId) { + ThrowNoDialogSelectedInDocumentException(); + } + } + + bool DesignerHasDialogId { + get { return designer.DialogId == null; } + } + + void ThrowNoDialogSelectedInDocumentException() + { + string message = StringParser.Parse("${res:ICSharpCode.WixBinding.WixDialogDesigner.NoDialogSelectedInDocumentMessage}"); + throw new FormsDesignerLoadException(message); + } + + void GetDialogElement() + { + WixDocument document = CreateWixDocument(); + document.LoadXml(designer.GetDocumentXml()); + wixDialog = document.CreateWixDialog(designer.DialogId, new WorkbenchTextFileReader()); + } + + WixDocument CreateWixDocument() + { + WixDocument document = new WixDocument(designer.Project, fileLoader); + document.FileName = designer.DocumentFileName; + return document; + } + + void VerifyDialogElementFound() + { + if (wixDialog == null) { + ThrowDialogIdNotFoundException(designer.DialogId); + } + } + + void ThrowDialogIdNotFoundException(string dialogId) + { + string messageFormat = StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"); + string message = String.Format(messageFormat, designer.DialogId); + throw new FormsDesignerLoadException(message); + } + + void AddServicesToHost(IDesignerLoaderHost host) + { + host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host)); + host.AddService(typeof(INameCreationService), new XmlDesignerNameCreationService(host)); + host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host)); + } + + /// + /// Creates a component of the specified type. + /// + public IComponent CreateComponent(Type componentClass, string name) + { + return base.LoaderHost.CreateComponent(componentClass, name); + } + + /// + /// Updates the dialog xml element and then passes this to the generator so the + /// Wix document is updated. + /// + protected override void PerformFlush(IDesignerSerializationManager serializationManager) + { + XmlElement updatedDialogElement = GenerateNewDialogElementFromDesignedForm(); + MergeDialogChangesIntoFullWixDocument(updatedDialogElement); + } + + XmlElement GenerateNewDialogElementFromDesignedForm() + { + Form form = (Form)base.LoaderHost.RootComponent; + return wixDialog.UpdateDialogElement(form); + } + + void MergeDialogChangesIntoFullWixDocument(XmlElement updatedDialogElement) + { + generator.MergeFormChanges(designer.DialogId, updatedDialogElement); + } + + protected override void PerformLoad(IDesignerSerializationManager serializationManager) + { + wixDialog.CreateDialog(this); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoaderProvider.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoaderProvider.cs index 54fed7702b..f47a85a2ae 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoaderProvider.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerLoaderProvider.cs @@ -1,35 +1,25 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.ComponentModel.Design.Serialization; -//using ICSharpCode.FormsDesigner; -// -//namespace ICSharpCode.WixBinding -//{ -// public class WixDialogDesignerLoaderProvider : IDesignerLoaderProvider -// { -// IWixDialogDesigner designer; -// -// public WixDialogDesignerLoaderProvider() -// { -// } -// -// public DesignerLoader CreateLoader(IDesignerGenerator generator) -// { -// return new WixDialogDesignerLoader(designer, generator as IWixDialogDesignerGenerator); -// } -// -// /// -// /// Gets or sets the designer that the loader provider should use. -// /// -// public IWixDialogDesigner Designer { -// get { -// return designer; -// } -// set { -// designer = value; -// } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.ComponentModel.Design.Serialization; +using System.Diagnostics; +using ICSharpCode.FormsDesigner; +using ICSharpCode.SharpDevelop.Workbench; + +namespace ICSharpCode.WixBinding +{ + public class WixDialogDesignerLoaderProvider : IDesignerLoaderProvider + { + public DesignerLoader CreateLoader(FormsDesignerViewContent viewContent) + { + return new WixDialogDesignerLoader((IWixDialogDesigner)viewContent); + } + + public IReadOnlyList GetSourceFiles(FormsDesignerViewContent viewContent) + { + return new[] { viewContent.PrimaryFile }; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/IWixDialogDesigner.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/IWixDialogDesigner.cs index e527983487..298f535a09 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/IWixDialogDesigner.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/IWixDialogDesigner.cs @@ -2,6 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.NRefactory.Editor; +using ICSharpCode.SharpDevelop.Editor; namespace ICSharpCode.WixBinding { @@ -28,5 +30,10 @@ namespace ICSharpCode.WixBinding /// being designed. /// WixProject Project {get;} + + /// + /// Gets the text editor in the primary view content. + /// + ITextEditor PrimaryViewContentTextEditor { get; } } } diff --git a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin index 9fb517359e..abaf9029b0 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin +++ b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin @@ -7,7 +7,7 @@ - + @@ -157,16 +157,16 @@ - + - + - + diff --git a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj index bf45f26cb4..672b978a21 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj +++ b/src/AddIns/BackendBindings/WixBinding/Project/WixBinding.csproj @@ -251,6 +251,11 @@ ICSharpCode.SharpDevelop.Widgets False + + {9E951B9F-6AC2-4537-9D0B-0AE7C026D5A1} + FormsDesigner + False + diff --git a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NameCreationServiceValidNameTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NameCreationServiceValidNameTests.cs index 65c069d113..d9a15e6623 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NameCreationServiceValidNameTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/NameCreationServiceValidNameTests.cs @@ -1,94 +1,94 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.ComponentModel; -//using System.Windows.Forms; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.DialogLoading -//{ -// /// -// /// Unit tests for the XmlDesignerLoader.NameCreationService.ValidName method. -// /// -// [TestFixture] -// public class NameCreationServiceValidNameTests -// { -// XmlDesignerNameCreationService nameCreationService; -// MockDesignerLoaderHost loaderHost; -// -// [SetUp] -// public void Init() -// { -// loaderHost = new MockDesignerLoaderHost(); -// nameCreationService = new XmlDesignerNameCreationService(loaderHost); -// } -// -// [Test] -// public void NullName() -// { -// Assert.IsFalse(nameCreationService.IsValidName(null)); -// } -// -// [Test] -// public void EmptyString() -// { -// Assert.IsFalse(nameCreationService.IsValidName(String.Empty)); -// } -// -// [Test] -// public void FirstCharIsDigit() -// { -// Assert.IsFalse(nameCreationService.IsValidName("8")); -// } -// -// [Test] -// public void FirstCharIsUnderscore() -// { -// Assert.IsTrue(nameCreationService.IsValidName("_")); -// } -// -// [Test] -// public void FirstCharIsNonDigit() -// { -// Assert.IsFalse(nameCreationService.IsValidName("a*")); -// } -// -// -// [Test] -// public void SecondCharIsUnderscore() -// { -// Assert.IsTrue(nameCreationService.IsValidName("a_")); -// } -// -// [Test] -// public void SecondCharIsNonDigit() -// { -// Assert.IsFalse(nameCreationService.IsValidName("a$")); -// } -// -// [Test] -// [ExpectedException(typeof(Exception), ExpectedMessage = "Invalid name 9")] -// public void ValidateNameThrowsExceptionWhenFirstCharIsDigit() -// { -// nameCreationService.ValidateName("9"); -// } -// -// [Test] -// public void FirstTextBoxName() -// { -// Assert.AreEqual("textBox1", nameCreationService.CreateName(typeof(TextBox))); -// } -// -// [Test] -// public void SecondTextBoxName() -// { -// Component component = new Component(); -// loaderHost.Container.Add(component, "textBox1"); -// Assert.AreEqual("textBox2", nameCreationService.CreateName(typeof(TextBox))); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.FormsDesigner; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.ComponentModel; +using System.Windows.Forms; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.DialogLoading +{ + /// + /// Unit tests for the XmlDesignerLoader.NameCreationService.ValidName method. + /// + [TestFixture] + public class NameCreationServiceValidNameTests + { + XmlDesignerNameCreationService nameCreationService; + MockDesignerLoaderHost loaderHost; + + [SetUp] + public void Init() + { + loaderHost = new MockDesignerLoaderHost(); + nameCreationService = new XmlDesignerNameCreationService(loaderHost); + } + + [Test] + public void NullName() + { + Assert.IsFalse(nameCreationService.IsValidName(null)); + } + + [Test] + public void EmptyString() + { + Assert.IsFalse(nameCreationService.IsValidName(String.Empty)); + } + + [Test] + public void FirstCharIsDigit() + { + Assert.IsFalse(nameCreationService.IsValidName("8")); + } + + [Test] + public void FirstCharIsUnderscore() + { + Assert.IsTrue(nameCreationService.IsValidName("_")); + } + + [Test] + public void FirstCharIsNonDigit() + { + Assert.IsFalse(nameCreationService.IsValidName("a*")); + } + + + [Test] + public void SecondCharIsUnderscore() + { + Assert.IsTrue(nameCreationService.IsValidName("a_")); + } + + [Test] + public void SecondCharIsNonDigit() + { + Assert.IsFalse(nameCreationService.IsValidName("a$")); + } + + [Test] + [ExpectedException(typeof(Exception), ExpectedMessage = "Invalid name 9")] + public void ValidateNameThrowsExceptionWhenFirstCharIsDigit() + { + nameCreationService.ValidateName("9"); + } + + [Test] + public void FirstTextBoxName() + { + Assert.AreEqual("textBox1", nameCreationService.CreateName(typeof(TextBox))); + } + + [Test] + public void SecondTextBoxName() + { + Component component = new Component(); + loaderHost.Container.Add(component, "textBox1"); + Assert.AreEqual("textBox2", nameCreationService.CreateName(typeof(TextBox))); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/BitmapCreatedByDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/BitmapCreatedByDesignerLoaderTestFixture.cs index f2a419dd58..a723dfd2a0 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/BitmapCreatedByDesignerLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/BitmapCreatedByDesignerLoaderTestFixture.cs @@ -1,97 +1,103 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.FormsDesigner.Services; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.ComponentModel.Design.Serialization; -//using System.Windows.Forms; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that a WixDialogDesignerLoader creates bitmaps specified in the Wix XML. -// /// -// [TestFixture] -// public class BitmapCreatedByDesignerLoaderTestFixture : DialogLoadingTestFixtureBase, IWixDialogDesigner -// { -// Form formCreated; -// MockDesignerLoaderHost loaderHost; -// -// [TestFixtureSetUp] -// public void SetUpFixture() -// { -// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator(), this); -// loaderHost = new MockDesignerLoaderHost(); -// loader.BeginLoad(loaderHost); -// IComponent rootComponent = loaderHost.RootComponent; -// formCreated = (Form)rootComponent; -// } -// -// [TestFixtureTearDown] -// public void TearDownFixture() -// { -// if (formCreated != null) { -// formCreated.Dispose(); -// } -// } -// -// [Test] -// public void DialogBitmapFileNameRequested() -// { -// Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\DialogBitmap.bmp", BitmapFileNamesRequested[0]); -// } -// -// [Test] -// public void BannerBitmapFileNameRequested() -// { -// Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\BannerBitmap.bmp", BitmapFileNamesRequested[1]); -// } -// -// string IWixDialogDesigner.DialogId { -// get { -// return "WelcomeDialog"; -// } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return GetWixXml(); -// } -// -// string IWixDialogDesigner.DocumentFileName { -// get { -// return @"C:\Projects\Setup\Setup.wxs"; -// } -// } -// -// WixProject IWixDialogDesigner.Project { -// get { -// WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); -// project.SetProperty("DefineConstants", "DATADIR=Bitmaps"); -// return project; -// } -// } -// -// string GetWixXml() -// { -// return "\r\n" + -// "\t\r\n" + -// "\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\t\t\r\n" + -// "\t\t\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\r\n" + -// "\t\t\r\n" + -// "\t\t\r\n" + -// "\t\r\n" + -// ""; -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.FormsDesigner; +using ICSharpCode.FormsDesigner.Services; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.Windows.Forms; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that a WixDialogDesignerLoader creates bitmaps specified in the Wix XML. + /// + [TestFixture] + public class BitmapCreatedByDesignerLoaderTestFixture : DialogLoadingTestFixtureBase, IWixDialogDesigner + { + Form formCreated; + MockDesignerLoaderHost loaderHost; + + [TestFixtureSetUp] + public void SetUpFixture() + { + WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, fileLoader: this); + loaderHost = new MockDesignerLoaderHost(); + loader.BeginLoad(loaderHost); + IComponent rootComponent = loaderHost.RootComponent; + formCreated = (Form)rootComponent; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + if (formCreated != null) { + formCreated.Dispose(); + } + } + + [Test] + public void DialogBitmapFileNameRequested() + { + Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\DialogBitmap.bmp", BitmapFileNamesRequested[0]); + } + + [Test] + public void BannerBitmapFileNameRequested() + { + Assert.AreEqual(@"C:\Projects\Setup\Bitmaps\BannerBitmap.bmp", BitmapFileNamesRequested[1]); + } + + string IWixDialogDesigner.DialogId { + get { + return "WelcomeDialog"; + } + } + + string IWixDialogDesigner.GetDocumentXml() + { + return GetWixXml(); + } + + string IWixDialogDesigner.DocumentFileName { + get { + return @"C:\Projects\Setup\Setup.wxs"; + } + } + + WixProject IWixDialogDesigner.Project { + get { + WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); + project.SetProperty("DefineConstants", "DATADIR=Bitmaps"); + return project; + } + } + + ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { + get { + throw new NotImplementedException(); + } + } + + string GetWixXml() + { + return "\r\n" + + "\t\r\n" + + "\t\t\r\n" + + "\t\t\t\r\n" + + "\t\t\t\t\r\n" + + "\t\t\t\t\r\n" + + "\t\t\t\r\n" + + "\t\t\r\n" + + "\t\t\r\n" + + "\t\t\r\n" + + "\t\r\n" + + ""; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/CanAttachToFileNameTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/CanAttachToFileNameTests.cs index b4481d0714..11a4958ba5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/CanAttachToFileNameTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/CanAttachToFileNameTests.cs @@ -1,116 +1,106 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using ICSharpCode.SharpDevelop; -//using ICSharpCode.SharpDevelop.Gui; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that the WixDialogDesignerDisplayBinding can attach to -// /// Wix documents. -// /// -// [TestFixture] -// public class CanAttachToFileNameTestFixture -// { -// WixDialogDesignerDisplayBinding binding; -// -// [SetUp] -// public void Init() -// { -// binding = new WixDialogDesignerDisplayBinding(); -// } -// -// [Test] -// public void WixFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetFileName("Setup.wxs"); -// Assert.IsTrue(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void WixIncludeFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetFileName("Setup.wxi"); -// Assert.IsTrue(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void WixFileNameUppercase() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetFileName("SETUP.WXS"); -// Assert.IsTrue(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void NonWixFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetFileName("Setup.txt"); -// Assert.IsFalse(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void NonTextEditorProviderView() -// { -// MockViewContent view = new MockViewContent(); -// view.SetFileName("Setup.wxs"); -// Assert.IsFalse(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void UntitledWixFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetUntitledFileName("Setup.wxs"); -// Assert.IsTrue(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void UntitledNonWixFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetUntitledFileName("Setup.txt"); -// Assert.IsFalse(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void NullUntitledFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetUntitledFileName(null); -// Assert.IsFalse(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void NullFileName() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// view.SetFileName(null); -// Assert.IsFalse(binding.CanAttachTo(view)); -// } -// -// [Test] -// public void ReattachIsFalse() -// { -// Assert.IsFalse(binding.ReattachWhenParserServiceIsReady); -// } -// -// [Test] -// public void CreatesWixDialogDesigner() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// IViewContent[] views = binding.CreateSecondaryViewContent(view); -// Assert.AreEqual(1, views.Length); -// Assert.IsTrue(views[0] is WixDialogDesigner); -// views[0].Dispose(); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that the WixDialogDesignerDisplayBinding can attach to + /// Wix documents. + /// + [TestFixture] + public class CanAttachToFileNameTestFixture + { + WixDialogDesignerDisplayBinding binding; + + [SetUp] + public void Init() + { + binding = new WixDialogDesignerDisplayBinding(); + } + + [Test] + public void WixFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetFileName("Setup.wxs"); + Assert.IsTrue(binding.CanAttachTo(view)); + } + + [Test] + public void WixIncludeFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetFileName("Setup.wxi"); + Assert.IsTrue(binding.CanAttachTo(view)); + } + + [Test] + public void WixFileNameUppercase() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetFileName("SETUP.WXS"); + Assert.IsTrue(binding.CanAttachTo(view)); + } + + [Test] + public void NonWixFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetFileName("Setup.txt"); + Assert.IsFalse(binding.CanAttachTo(view)); + } + + [Test] + public void NonTextEditorProviderView() + { + MockViewContent view = new MockViewContent(); + view.SetFileName("Setup.wxs"); + Assert.IsFalse(binding.CanAttachTo(view)); + } + + [Test] + public void UntitledWixFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetUntitledFileName("Setup.wxs"); + Assert.IsTrue(binding.CanAttachTo(view)); + } + + [Test] + public void UntitledNonWixFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetUntitledFileName("Setup.txt"); + Assert.IsFalse(binding.CanAttachTo(view)); + } + + [Test] + public void NullUntitledFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetUntitledFileName(null); + Assert.IsFalse(binding.CanAttachTo(view)); + } + + [Test] + public void NullFileName() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + view.SetFileName(null); + Assert.IsFalse(binding.CanAttachTo(view)); + } + + [Test] + public void ReattachIsFalse() + { + Assert.IsFalse(binding.ReattachWhenParserServiceIsReady); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DialogIdSpecifiedForDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DialogIdSpecifiedForDesignerLoaderTestFixture.cs index 25974d51fe..274dd5c45e 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/DialogIdSpecifiedForDesignerLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/DialogIdSpecifiedForDesignerLoaderTestFixture.cs @@ -1,112 +1,118 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.FormsDesigner.Services; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.ComponentModel.Design.Serialization; -//using System.Windows.Forms; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that a WixDialogDesignerLoader uses the dialog id to find the dialog -// /// XML element. -// /// -// [TestFixture] -// public class DialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner -// { -// Form formCreated; -// MockDesignerLoaderHost loaderHost; -// -// [TestFixtureSetUp] -// public void SetUpFixture() -// { -// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator()); -// loaderHost = new MockDesignerLoaderHost(); -// loader.BeginLoad(loaderHost); -// IComponent rootComponent = loaderHost.RootComponent; -// formCreated = (Form)rootComponent; -// } -// -// [TestFixtureTearDown] -// public void TearDownFixture() -// { -// if (formCreated != null) { -// formCreated.Dispose(); -// } -// } -// -// [Test] -// public void FormName() -// { -// Assert.AreEqual("WelcomeDialog", formCreated.Name); -// } -// -// [Test] -// public void OneComponentCreated() -// { -// Assert.AreEqual(1, loaderHost.CreatedComponents.Count); -// } -// -// [Test] -// public void NameCreationServiceCreated() -// { -// INameCreationService nameCreationService = (INameCreationService)loaderHost.GetService(typeof(INameCreationService)); -// Assert.IsTrue(nameCreationService is XmlDesignerNameCreationService); -// } -// -// [Test] -// public void ComponentSerializationServiceCreated() -// { -// ComponentSerializationService serializationService = (ComponentSerializationService)loaderHost.GetService(typeof(ComponentSerializationService)); -// Assert.IsTrue(serializationService is ComponentSerializationService); -// } -// -// [Test] -// public void DesignerSerializationServiceCreated() -// { -// IDesignerSerializationService designerSerializationServiceCreated = (IDesignerSerializationService)loaderHost.GetService(typeof(IDesignerSerializationService)); -// Assert.IsTrue(designerSerializationServiceCreated is DesignerSerializationService); -// } -// -// string IWixDialogDesigner.DialogId { -// get { -// return "WelcomeDialog"; -// } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return GetWixXml(); -// } -// -// public string DocumentFileName { -// get { -// return String.Empty; -// } -// } -// -// public WixProject Project { -// get { -// return WixBindingTestsHelper.CreateEmptyWixProject(); -// } -// } -// -// string GetWixXml() -// { -// return "\r\n" + -// "\t\r\n" + -// "\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\r\n" + -// "\t\r\n" + -// ""; -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.FormsDesigner; +using ICSharpCode.FormsDesigner.Services; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.Windows.Forms; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that a WixDialogDesignerLoader uses the dialog id to find the dialog + /// XML element. + /// + [TestFixture] + public class DialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner + { + Form formCreated; + MockDesignerLoaderHost loaderHost; + + [TestFixtureSetUp] + public void SetUpFixture() + { + WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); + loaderHost = new MockDesignerLoaderHost(); + loader.BeginLoad(loaderHost); + IComponent rootComponent = loaderHost.RootComponent; + formCreated = (Form)rootComponent; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + if (formCreated != null) { + formCreated.Dispose(); + } + } + + [Test] + public void FormName() + { + Assert.AreEqual("WelcomeDialog", formCreated.Name); + } + + [Test] + public void OneComponentCreated() + { + Assert.AreEqual(1, loaderHost.CreatedComponents.Count); + } + + [Test] + public void NameCreationServiceCreated() + { + INameCreationService nameCreationService = (INameCreationService)loaderHost.GetService(typeof(INameCreationService)); + Assert.IsTrue(nameCreationService is XmlDesignerNameCreationService); + } + + [Test] + public void ComponentSerializationServiceCreated() + { + ComponentSerializationService serializationService = (ComponentSerializationService)loaderHost.GetService(typeof(ComponentSerializationService)); + Assert.IsTrue(serializationService is ComponentSerializationService); + } + + [Test] + public void DesignerSerializationServiceCreated() + { + IDesignerSerializationService designerSerializationServiceCreated = (IDesignerSerializationService)loaderHost.GetService(typeof(IDesignerSerializationService)); + Assert.IsTrue(designerSerializationServiceCreated is DesignerSerializationService); + } + + string IWixDialogDesigner.DialogId { + get { + return "WelcomeDialog"; + } + } + + string IWixDialogDesigner.GetDocumentXml() + { + return GetWixXml(); + } + + public string DocumentFileName { + get { + return String.Empty; + } + } + + public WixProject Project { + get { + return WixBindingTestsHelper.CreateEmptyWixProject(); + } + } + + ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { + get { + throw new NotImplementedException(); + } + } + + string GetWixXml() + { + return "\r\n" + + "\t\r\n" + + "\t\t\r\n" + + "\t\t\t\r\n" + + "\t\t\r\n" + + "\t\r\n" + + ""; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/FlushLoaderTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/FlushLoaderTestFixture.cs index b80f19fa27..28a6068065 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/FlushLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/FlushLoaderTestFixture.cs @@ -1,105 +1,111 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.CodeDom; -//using System.CodeDom.Compiler; -//using System.Collections; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.Reflection; -//using System.Windows.Forms; -//using System.Xml; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that a WixDialogDesignerLoader calls the IDesignerGenerator.MergeFormChanges -// /// method after being flushed. -// /// -// [TestFixture] -// public class FlushLoaderTestFixture : IWixDialogDesignerGenerator, IWixDialogDesigner -// { -// class DerivedWixDialogDesignerLoader : WixDialogDesignerLoader -// { -// public DerivedWixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator) -// : base(designer, generator) -// { -// } -// -// public void CallPerformFlush() -// { -// base.PerformFlush(null); -// } -// } -// -// string newDialogTitle; -// string dialogId; -// -// [TestFixtureSetUp] -// public void SetUpFixture() -// { -// newDialogTitle = String.Empty; -// dialogId = String.Empty; -// -// DerivedWixDialogDesignerLoader loader = new DerivedWixDialogDesignerLoader(this, this); -// MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); -// loader.BeginLoad(loaderHost); -// using (Form form = (Form)loaderHost.RootComponent) { -// form.Text = "NewTitle"; -// loader.CallPerformFlush(); -// } -// } -// -// [Test] -// public void MergeFormChangesCalled() -// { -// Assert.AreEqual("NewTitle", newDialogTitle); -// } -// -// [Test] -// public void DialogId() -// { -// Assert.AreEqual("WelcomeDialog", dialogId); -// } -// -// string IWixDialogDesigner.DialogId { -// get { return "WelcomeDialog"; } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return GetWixXml(); -// } -// -// public string DocumentFileName { -// get { return String.Empty; } -// } -// -// public WixProject Project { -// get { return WixBindingTestsHelper.CreateEmptyWixProject(); } -// } -// -// string GetWixXml() -// { -// return -// "\r\n" + -// "\t\r\n" + -// "\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\r\n" + -// "\t\r\n" + -// ""; -// } -// -// public void MergeFormChanges(string dialogId, XmlElement dialogElement) -// { -// this.dialogId = dialogId; -// newDialogTitle = dialogElement.GetAttribute("Title"); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.FormsDesigner; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.CodeDom; +using System.CodeDom.Compiler; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using System.Windows.Forms; +using System.Xml; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that a WixDialogDesignerLoader calls the IDesignerGenerator.MergeFormChanges + /// method after being flushed. + /// + [TestFixture] + public class FlushLoaderTestFixture : IWixDialogDesignerGenerator, IWixDialogDesigner + { + class DerivedWixDialogDesignerLoader : WixDialogDesignerLoader + { + public DerivedWixDialogDesignerLoader(IWixDialogDesigner designer, IWixDialogDesignerGenerator generator) + : base(designer, generator) + { + } + + public void CallPerformFlush() + { + base.PerformFlush(null); + } + } + + string newDialogTitle; + string dialogId; + + [TestFixtureSetUp] + public void SetUpFixture() + { + newDialogTitle = String.Empty; + dialogId = String.Empty; + + DerivedWixDialogDesignerLoader loader = new DerivedWixDialogDesignerLoader(this, this); + MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); + loader.BeginLoad(loaderHost); + using (Form form = (Form)loaderHost.RootComponent) { + form.Text = "NewTitle"; + loader.CallPerformFlush(); + } + } + + [Test] + public void MergeFormChangesCalled() + { + Assert.AreEqual("NewTitle", newDialogTitle); + } + + [Test] + public void DialogId() + { + Assert.AreEqual("WelcomeDialog", dialogId); + } + + string IWixDialogDesigner.DialogId { + get { return "WelcomeDialog"; } + } + + string IWixDialogDesigner.GetDocumentXml() + { + return GetWixXml(); + } + + public string DocumentFileName { + get { return String.Empty; } + } + + public WixProject Project { + get { return WixBindingTestsHelper.CreateEmptyWixProject(); } + } + + ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { + get { + throw new NotImplementedException(); + } + } + + string GetWixXml() + { + return + "\r\n" + + "\t\r\n" + + "\t\t\r\n" + + "\t\t\t\r\n" + + "\t\t\r\n" + + "\t\r\n" + + ""; + } + + public void MergeFormChanges(string dialogId, XmlElement dialogElement) + { + this.dialogId = dialogId; + newDialogTitle = dialogElement.GetAttribute("Title"); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/GetWixDesignerFromViewTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/GetWixDesignerFromViewTests.cs index bb3d8b345b..587d344642 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/GetWixDesignerFromViewTests.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/GetWixDesignerFromViewTests.cs @@ -1,35 +1,58 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that the WixDialogDesigner.GetDesigner method returns the -// /// Wix dialog designer attached to the primary view. -// /// -// [TestFixture] -// public class GetWixDesignerFromViewTests -// { -// [Test] -// public void WixDesignerAttached() -// { -// MockTextEditorViewContent view = new MockTextEditorViewContent(); -// using (WixDialogDesigner designerAdded = new WixDialogDesigner(view)) { -// view.SecondaryViewContents.Add(designerAdded); -// Assert.IsNotNull(WixDialogDesigner.GetDesigner(view)); -// } -// } -// -// [Test] -// public void NoWixDesignerAttached() -// { -// MockViewContent view = new MockViewContent(); -// Assert.IsNull(WixDialogDesigner.GetDesigner(view)); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Widgets; +using ICSharpCode.SharpDevelop.WinForms; +using ICSharpCode.SharpDevelop.Workbench; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using Rhino.Mocks; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that the WixDialogDesigner.GetDesigner method returns the + /// Wix dialog designer attached to the primary view. + /// + [TestFixture] + public class GetWixDesignerFromViewTests + { + [TestFixtureSetUp] + public void FixtureSetUp() + { + SD.InitializeForUnitTests(); + SD.Services.AddService(typeof(IWinFormsService), MockRepository.GenerateStub()); + SD.WinForms.Stub(s => s.CreateWindowsFormsHost()).IgnoreArguments().Return(new CustomWindowsFormsHost()); + SD.Services.AddService(typeof(IWorkbench), new MockWorkbench()); + SD.Services.AddService(typeof(IFileService), MockRepository.GenerateStub()); + SD.Services.AddService(typeof(IProjectService), MockRepository.GenerateStub()); + } + + [TestFixtureTearDown] + public void FixtureTearDown() + { + SD.TearDownForUnitTests(); + } + + [Test] + public void WixDesignerAttached() + { + MockTextEditorViewContent view = new MockTextEditorViewContent(); + using (WixDialogDesigner designerAdded = new WixDialogDesigner(view)) { + view.SecondaryViewContents.Add(designerAdded); + Assert.IsNotNull(WixDialogDesigner.GetDesigner(view)); + } + } + + [Test] + public void NoWixDesignerAttached() + { + MockViewContent view = new MockViewContent(); + Assert.IsNull(WixDialogDesigner.GetDesigner(view)); + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/LoaderProviderTests.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/LoaderProviderTests.cs deleted file mode 100644 index 1bc237215a..0000000000 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/LoaderProviderTests.cs +++ /dev/null @@ -1,63 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.ComponentModel.Design.Serialization; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// [TestFixture] -// public class LoaderProviderTests : IWixDialogDesigner -// { -// [Test] -// public void NoDesignerSpecified() -// { -// WixDialogDesignerLoaderProvider provider = new WixDialogDesignerLoaderProvider(); -// WixDialogDesignerGenerator generator = new WixDialogDesignerGenerator(); -// try { -// DesignerLoader loader = provider.CreateLoader(generator); -// Assert.Fail("Expected an argument exception before this line."); -// } catch (ArgumentException ex) { -// Assert.AreEqual("designer", ex.ParamName); -// } -// } -// -// [Test] -// public void DialogIdAndTextEditorSpecified() -// { -// WixDialogDesignerLoaderProvider provider = new WixDialogDesignerLoaderProvider(); -// provider.Designer = this; -// WixDialogDesignerGenerator generator = new WixDialogDesignerGenerator(); -// WixDialogDesignerLoader loader = (WixDialogDesignerLoader)provider.CreateLoader(generator); -// Assert.IsTrue(loader is WixDialogDesignerLoader); -// Assert.AreSame(this, loader.Designer); -// Assert.AreSame(generator, loader.Generator); -// } -// -// string IWixDialogDesigner.DialogId { -// get { return "WelcomeDialog"; } -// } -// -// string IWixDialogDesigner.DocumentFileName { -// get { return String.Empty; } -// } -// -// WixProject IWixDialogDesigner.Project { -// get { return WixBindingTestsHelper.CreateEmptyWixProject(); } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return "\r\n" + -// "\t\r\n" + -// "\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\r\n" + -// "\t\r\n" + -// ""; -// } -// } -//} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/MissingDialogIdDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/MissingDialogIdDesignerLoaderTestFixture.cs index 9fa646db88..68c2692ced 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/MissingDialogIdDesignerLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/MissingDialogIdDesignerLoaderTestFixture.cs @@ -1,67 +1,75 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.Core; -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.Collections.Generic; -//using System.ComponentModel; -//using System.Resources; -//using System.Windows.Forms; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that a WixDialogDesignerLoader reports that the dialog id cannot be found -// /// in the Wix document. -// /// -// [TestFixture] -// public class MissingDialogIdDesignerLoaderTestFixture : IWixDialogDesigner -// { -// [TestFixtureSetUp] -// public void SetupFixture() -// { -// WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); -// } -// -// [Test] -// [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "Unable to find dialog with an id of 'MissingDialog'.")] -// public void LoadMissingDialog() -// { -// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator()); -// MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); -// loader.BeginLoad(loaderHost); -// } -// -// string IWixDialogDesigner.DialogId { -// get { return "MissingDialog"; } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return GetWixXml(); -// } -// -// public string DocumentFileName { -// get { return String.Empty; } -// } -// -// public WixProject Project { -// get { return WixBindingTestsHelper.CreateEmptyWixProject(); } -// } -// -// string GetWixXml() -// { -// return "\r\n" + -// "\t\r\n" + -// "\t\t\r\n" + -// "\t\t\t\r\n" + -// "\t\t\r\n" + -// "\t\r\n" + -// ""; -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.Core; +using ICSharpCode.FormsDesigner; +using ICSharpCode.SharpDevelop; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Resources; +using System.Windows.Forms; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that a WixDialogDesignerLoader reports that the dialog id cannot be found + /// in the Wix document. + /// + [TestFixture] + public class MissingDialogIdDesignerLoaderTestFixture : IWixDialogDesigner + { + [TestFixtureSetUp] + public void SetupFixture() + { + SD.InitializeForUnitTests(); + WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); + } + + [Test] + [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "Unable to find dialog with an id of 'MissingDialog'.")] + public void LoadMissingDialog() + { + WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); + MockDesignerLoaderHost loaderHost = new MockDesignerLoaderHost(); + loader.BeginLoad(loaderHost); + } + + string IWixDialogDesigner.DialogId { + get { return "MissingDialog"; } + } + + string IWixDialogDesigner.GetDocumentXml() + { + return GetWixXml(); + } + + public string DocumentFileName { + get { return String.Empty; } + } + + public WixProject Project { + get { return WixBindingTestsHelper.CreateEmptyWixProject(); } + } + + ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { + get { + throw new NotImplementedException(); + } + } + + string GetWixXml() + { + return "\r\n" + + "\t\r\n" + + "\t\t\r\n" + + "\t\t\t\r\n" + + "\t\t\r\n" + + "\t\r\n" + + ""; + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/NoDialogIdSpecifiedForDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/NoDialogIdSpecifiedForDesignerLoaderTestFixture.cs index 5e3dae5124..df8975fd71 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/NoDialogIdSpecifiedForDesignerLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/NoDialogIdSpecifiedForDesignerLoaderTestFixture.cs @@ -1,69 +1,66 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using ICSharpCode.Core; -//using ICSharpCode.FormsDesigner; -//using ICSharpCode.WixBinding; -//using NUnit.Framework; -//using System; -//using System.Resources; -//using WixBinding.Tests.Utils; -// -//namespace WixBinding.Tests.Gui -//{ -// /// -// /// Tests that a FormsDesignerLoadException is thrown when the WixDialogDesignerLoader -// /// is used when no dialog id is set. -// /// -// [TestFixture] -// public class NoDialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner -// { -// [TestFixtureSetUp] -// public void SetupFixture() -// { -// WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); -// } -// -// [Test] -// [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "No setup dialog selected in Wix document. Please move the cursor inside a dialog element or use the Setup Dialogs window to open a dialog.")] -// public void NoDialogIdSpecified() -// { -// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, new WixDialogDesignerGenerator()); -// loader.BeginLoad(new MockDesignerLoaderHost()); -// } -// -// [Test] -// public void NoGeneratorSpecified() -// { -// try { -// WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this, null); -// Assert.Fail("Expected an argument exception before this line."); -// } catch (ArgumentException ex) { -// Assert.AreEqual("generator", ex.ParamName); -// } -// } -// -// string IWixDialogDesigner.DialogId { -// get { -// return null; -// } -// } -// -// string IWixDialogDesigner.GetDocumentXml() -// { -// return String.Empty; -// } -// -// public string DocumentFileName { -// get { -// return String.Empty; -// } -// } -// -// public WixProject Project { -// get { -// return WixBindingTestsHelper.CreateEmptyWixProject(); -// } -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.Core; +using ICSharpCode.FormsDesigner; +using ICSharpCode.SharpDevelop; +using ICSharpCode.WixBinding; +using NUnit.Framework; +using System; +using System.Resources; +using WixBinding.Tests.Utils; + +namespace WixBinding.Tests.Gui +{ + /// + /// Tests that a FormsDesignerLoadException is thrown when the WixDialogDesignerLoader + /// is used when no dialog id is set. + /// + [TestFixture] + public class NoDialogIdSpecifiedForDesignerLoaderTestFixture : IWixDialogDesigner + { + [TestFixtureSetUp] + public void SetupFixture() + { + SD.InitializeForUnitTests(); + WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); + } + + [Test] + [ExpectedException(typeof(FormsDesignerLoadException), ExpectedMessage = "No setup dialog selected in Wix document. Please move the cursor inside a dialog element or use the Setup Dialogs window to open a dialog.")] + public void NoDialogIdSpecified() + { + WixDialogDesignerLoader loader = new WixDialogDesignerLoader(this); + loader.BeginLoad(new MockDesignerLoaderHost()); + } + + string IWixDialogDesigner.DialogId { + get { + return null; + } + } + + string IWixDialogDesigner.GetDocumentXml() + { + return String.Empty; + } + + ICSharpCode.SharpDevelop.Editor.ITextEditor IWixDialogDesigner.PrimaryViewContentTextEditor { + get { + throw new NotImplementedException(); + } + } + + public string DocumentFileName { + get { + return String.Empty; + } + } + + public WixProject Project { + get { + return WixBindingTestsHelper.CreateEmptyWixProject(); + } + } + } +} diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs index e0211107fb..63b36d786c 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs @@ -103,7 +103,7 @@ namespace WixBinding.Tests.Utils public PadDescriptor GetPad(Type type) { - throw new NotImplementedException(); + return null; } public void CloseAllViews() diff --git a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj index a1efe430e5..d2ecd43381 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj @@ -150,7 +150,6 @@ - @@ -323,6 +322,10 @@ {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} ICSharpCode.Core.WinForms + + {9E951B9F-6AC2-4537-9D0B-0AE7C026D5A1} + FormsDesigner + {DCA2703D-250A-463E-A68A-07ED105AE6BD} XmlEditor diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/IDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/IDesignerGenerator.cs index 269cb8f15f..781e48158d 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/IDesignerGenerator.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/IDesignerGenerator.cs @@ -14,6 +14,7 @@ using ICSharpCode.SharpDevelop.Workbench; namespace ICSharpCode.FormsDesigner { + /* public interface IDesignerGenerator { CodeDomProvider CodeDomProvider { @@ -35,4 +36,5 @@ namespace ICSharpCode.FormsDesigner ICollection GetCompatibleMethods(EventDescriptor edesc); void NotifyComponentRenamed(object component, string newName, string oldName); } + */ } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/AbstractCodeDomDesignerLoader.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/AbstractCodeDomDesignerLoader.cs index 0d64b93843..cd8d657318 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/AbstractCodeDomDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/AbstractCodeDomDesignerLoader.cs @@ -14,6 +14,7 @@ using ICSharpCode.FormsDesigner.Services; namespace ICSharpCode.FormsDesigner { + /* /// /// An abstract base class for CodeDOM designer loaders. /// @@ -172,4 +173,5 @@ namespace ICSharpCode.FormsDesigner MessageService.ShowError(sb.ToString()); } } + */ } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/DesignerLoaderProvider.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/DesignerLoaderProvider.cs index 7bb4599b93..153c8dcf2a 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/DesignerLoaderProvider.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/DesignerLoaderProvider.cs @@ -2,14 +2,22 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using System.ComponentModel.Design.Serialization; using ICSharpCode.NRefactory; +using ICSharpCode.SharpDevelop.Workbench; namespace ICSharpCode.FormsDesigner { public interface IDesignerLoaderProvider { - DesignerLoader CreateLoader(IDesignerGenerator generator); + DesignerLoader CreateLoader(FormsDesignerViewContent viewContent); + + /// + /// Gets the source files involved when designing. + /// The first file in the resulting list is the main code file. + /// + IReadOnlyList GetSourceFiles(FormsDesignerViewContent viewContent); } /* public class NRefactoryDesignerLoaderProvider : IDesignerLoaderProvider diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs index 2e98e28521..4b3959fbf4 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs @@ -39,7 +39,6 @@ namespace ICSharpCode.FormsDesigner readonly IViewContent primaryViewContent; readonly IDesignerLoaderProvider loaderProvider; DesignerLoader loader; - readonly IDesignerGenerator generator; readonly ResourceStore resourceStore; FormsDesignerUndoEngine undoEngine; TypeResolutionService typeResolutionService; @@ -132,17 +131,13 @@ namespace ICSharpCode.FormsDesigner ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting += this.DebugStarting; } - public FormsDesignerViewContent(IViewContent primaryViewContent, IDesignerLoaderProvider loaderProvider, IDesignerGenerator generator) + public FormsDesignerViewContent(IViewContent primaryViewContent, IDesignerLoaderProvider loaderProvider) : this(primaryViewContent) { if (loaderProvider == null) throw new ArgumentNullException("loaderProvider"); - if (generator == null) - throw new ArgumentNullException("generator"); this.loaderProvider = loaderProvider; - this.generator = generator; - this.generator.Attach(this); this.Files.Add(this.primaryViewContent.PrimaryFile); } @@ -194,9 +189,9 @@ namespace ICSharpCode.FormsDesigner this.sourceCodeStorage.LoadFile(file, stream); LoggingService.Debug("Forms designer: Determining designer source files for " + file.FileName); - OpenedFile newDesignerCodeFile; - IEnumerable sourceFiles = this.generator.GetSourceFiles(out newDesignerCodeFile); - if (sourceFiles == null || newDesignerCodeFile == null) { + IReadOnlyList sourceFiles = loaderProvider.GetSourceFiles(this); + OpenedFile newDesignerCodeFile = sourceFiles.FirstOrDefault(); + if (newDesignerCodeFile == null) { throw new FormsDesignerLoadException("The designer source files could not be determined."); } @@ -294,9 +289,9 @@ namespace ICSharpCode.FormsDesigner this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); - if (generator.CodeDomProvider != null) { - serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider); - } +// if (generator.CodeDomProvider != null) { +// serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider); +// } designSurface = CreateDesignSurface(serviceContainer); designSurface.Loading += this.DesignerLoading; @@ -305,10 +300,8 @@ namespace ICSharpCode.FormsDesigner designSurface.Unloading += this.DesignerUnloading; serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this, designSurface)); - ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface); - serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); - this.loader = loaderProvider.CreateLoader(generator); + this.loader = loaderProvider.CreateLoader(this); designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { @@ -378,16 +371,13 @@ namespace ICSharpCode.FormsDesigner bool loading = this.loader != null && this.loader.Loading; LoggingService.Debug("Forms designer: ComponentChanged: " + (e.Component == null ? "" : e.Component.ToString()) + ", Member=" + (e.Member == null ? "" : e.Member.Name) + ", OldValue=" + (e.OldValue == null ? "" : e.OldValue.ToString()) + ", NewValue=" + (e.NewValue == null ? "" : e.NewValue.ToString()) + "; Loading=" + loading + "; Unloading=" + this.unloading); if (!loading && !unloading) { - try { - this.MakeDirty(); - if (e.Component != null && e.Member != null && e.Member.Name == "Name" && - e.NewValue is string && !object.Equals(e.OldValue, e.NewValue)) { - // changing the name of the component - generator.NotifyComponentRenamed(e.Component, (string)e.NewValue, (string)e.OldValue); - } - } catch (Exception ex) { - MessageService.ShowException(ex); - } + this.MakeDirty(); + #warning Reimplement designer component rename +// if (e.Component != null && e.Member != null && e.Member.Name == "Name" && +// e.NewValue is string && !object.Equals(e.OldValue, e.NewValue)) { +// // changing the name of the component +// generator.NotifyComponentRenamed(e.Component, (string)e.NewValue, (string)e.OldValue); +// } } } @@ -657,6 +647,7 @@ namespace ICSharpCode.FormsDesigner } } + /* public void ShowSourceCode(IComponent component, EventDescriptor edesc, string eventMethodName) { int position; @@ -675,6 +666,7 @@ namespace ICSharpCode.FormsDesigner { return generator.GetCompatibleMethods(edesc); } + */ void IsActiveViewContentChangedHandler(object sender, EventArgs e) { @@ -726,10 +718,6 @@ namespace ICSharpCode.FormsDesigner this.IsActiveViewContentChanged -= this.IsActiveViewContentChangedHandler; - if (this.generator != null) { - this.generator.Detach(); - } - this.resourceStore.Dispose(); this.UserContent = null; diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs index 1073ac5e6e..8de55b2703 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/EventBindingService.cs @@ -9,6 +9,7 @@ using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.FormsDesigner.Services { + /* public class EventBindingService : System.ComponentModel.Design.EventBindingService { readonly FormsDesignerViewContent formDesigner; @@ -84,4 +85,5 @@ namespace ICSharpCode.FormsDesigner.Services } } + */ } diff --git a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs index 10e95a3f60..d40a5e2074 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyContainer.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.ComponentModel.Design; using System.Windows.Forms; +using ICSharpCode.SharpDevelop.Workbench; namespace ICSharpCode.SharpDevelop.Gui { @@ -40,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Gui internal PropertyContainer(bool createPadOnConstruction) { - if (createPadOnConstruction && SD.Workbench != null) { + if (createPadOnConstruction) { PadDescriptor desc = SD.Workbench.GetPad(typeof(PropertyPad)); if (desc != null) desc.CreatePad(); }