diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs index 58cbcd0f21..3d9668c6e3 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Gui/ViewContentControl.cs @@ -87,7 +87,6 @@ namespace WorkflowDesigner designer.Dock = DockStyle.Fill; Controls.Add(designer); DesignerHost.Activate(); - Selected(); // HACK: Selected event not working so calling directly at present } } catch (Exception e) { TextBox errorText = new TextBox(); @@ -144,7 +143,7 @@ namespace WorkflowDesigner // Monitor for updates and make the view dirty. IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService)); - //componentChangeService.ComponentAdding += new ComponentEventHandler(ComponentAddingHandler); + componentChangeService.ComponentAdding += new ComponentEventHandler(ComponentAddingHandler); componentChangeService.ComponentAdded += new ComponentEventHandler(ComponentAddedHandler); componentChangeService.ComponentChanged += new ComponentChangedEventHandler(ComponentChangedHandler); @@ -153,15 +152,15 @@ namespace WorkflowDesigner selectionService.SelectionChanged += new EventHandler(SelectionChangedHandler); } - void UpdateCCU() + void UpdateCodeCompileUniteCompileUnit() { IWorkflowDesignerEventBindingService srv = this.DesignerHost.GetService(typeof(IEventBindingService)) as IWorkflowDesignerEventBindingService; - srv.UpdateCCU(); + srv.UpdateCodeCompileUnit(); } void ComponentAddedHandler(object sender, ComponentEventArgs args) { - UpdateCCU(); + UpdateCodeCompileUniteCompileUnit(); LoggingService.Debug("ComponentAddedHandler"); } @@ -172,7 +171,7 @@ namespace WorkflowDesigner void ComponentChangedHandler(object sender, ComponentChangedEventArgs args) { - UpdateCCU(); + UpdateCodeCompileUniteCompileUnit(); viewContent.PrimaryFile.MakeDirty(); ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService)); UpdatePropertyPadSelection(selectionService); @@ -194,10 +193,6 @@ namespace WorkflowDesigner PropertyPad.Grid.CommandsVisibleIfAvailable = false; } - internal void Selected() - { - } - internal void Deselected() { propertyContainer.SelectableObjects = null; diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs index 6c8c32e86c..5b42d940c6 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlCodeSeparationDesignerLoader.cs @@ -46,7 +46,7 @@ namespace WorkflowDesigner protected override void Load(IDesignerSerializationManager serializationManager) { IWorkflowDesignerEventBindingService srv = LoaderHost.GetService(typeof(IEventBindingService)) as IWorkflowDesignerEventBindingService; - srv.UpdateCCU(); + srv.UpdateCodeCompileUnit(); LoadFromXoml(serializationManager); diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs index 2c59dd5386..b9d2b54aa6 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs @@ -161,8 +161,9 @@ namespace WorkflowDesigner } LoaderHost.Container.Add(rootActivity, rootActivity.QualifiedName); - if (rootActivity is CompositeActivity) - AddChildren(rootActivity as CompositeActivity); + CompositeActivity compositeActivity = rootActivity as CompositeActivity; + if (compositeActivity != null) + AddChildren(compositeActivity); SetBaseComponentClassName(rootActivity.GetType().FullName); @@ -179,25 +180,31 @@ namespace WorkflowDesigner foreach (Activity activity in compositeActivity.Activities) { LoaderHost.Container.Add(activity, activity.QualifiedName); - if (activity is CompositeActivity) - AddChildren(activity as CompositeActivity); + + CompositeActivity compositeActivity2 = activity as CompositeActivity; + if (compositeActivity2 != null) + AddChildren(compositeActivity2); } } public override void Dispose() { - // Remove all the services from the from the host designer. - if (LoaderHost != null) - { - LoaderHost.RemoveService(typeof(IToolboxService)); - LoaderHost.RemoveService(typeof(ITypeProvider)); - LoaderHost.RemoveService(typeof(IEventBindingService)); - LoaderHost.RemoveService(typeof(IMemberCreationService)); - LoaderHost.RemoveService(typeof(IMenuCommandService)); + try { + // Remove all the services from the from the host designer. + if (LoaderHost != null) + { + LoaderHost.RemoveService(typeof(IToolboxService)); + LoaderHost.RemoveService(typeof(ITypeProvider)); + LoaderHost.RemoveService(typeof(IEventBindingService)); + LoaderHost.RemoveService(typeof(IMemberCreationService)); + LoaderHost.RemoveService(typeof(IMenuCommandService)); + } + + } finally { + base.Dispose(); + } - - base.Dispose(); } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs index a4f0820e20..56bc847eb7 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/SecondaryView/SecondaryViewContent.cs @@ -56,7 +56,6 @@ namespace WorkflowDesigner protected override void LoadFromPrimary() { control.LoadWorkflow(new NRefactoryDesignerLoader(((ITextEditorControlProvider)viewContent).TextEditorControl, viewContent)); - control.Selected(); } protected override void SaveToPrimary() diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs index b9e7b3b47f..2e1265423d 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/CSharpWorkflowDesignerEventBindingService.cs @@ -35,7 +35,6 @@ namespace WorkflowDesigner { DomRegion r = method.BodyRegion; int offset = document.PositionToOffset(new Point(r.BeginColumn - 1, r.BeginLine - 1)); - string tmp = document.GetText(offset, 10); while (offset < document.TextLength) { char c = document.GetCharAt(offset++); if (c == '{') { @@ -50,7 +49,7 @@ namespace WorkflowDesigner protected override string CreateEventHandler(IClass completeClass, EventDescriptor edesc, string eventMethodName, string body, string indentation) { - string param = GenerateParams(completeClass, edesc, true); + string param = GenerateParameters(completeClass, edesc, true); StringBuilder b = new StringBuilder(); b.AppendLine(indentation); @@ -66,10 +65,10 @@ namespace WorkflowDesigner return b.ToString(); } - protected string GenerateParams(IClass completeClass, EventDescriptor edesc, bool paramNames) + protected string GenerateParameters(IClass completeClass, EventDescriptor eventDescriptor, bool paramNames) { CSharpOutputVisitor v = new CSharpOutputVisitor(); - MethodDeclaration md = ConvertDescriptorToNRefactory(completeClass, edesc, "name"); + MethodDeclaration md = ConvertDescriptorToNRefactory(completeClass, eventDescriptor, "name"); if (md != null) { v.AppendCommaSeparatedList(md.Parameters); } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs index 1146c2bbfa..1b6d2b2c15 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/IWorkflowDesignerEventBindingService.cs @@ -20,6 +20,6 @@ namespace WorkflowDesigner public interface IWorkflowDesignerEventBindingService : IEventBindingService { string CodeFileName { get;} - void UpdateCCU(); + void UpdateCodeCompileUnit(); } } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs index 45c788867e..2e5d34a7b6 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/WorkflowDesignerEventBindingService.cs @@ -50,7 +50,7 @@ namespace WorkflowDesigner #region IWorkflowDesignerEventBinginService implementation - public void UpdateCCU() + public void UpdateCodeCompileUnit() { LoggingService.Debug("UpdateCCU"); @@ -108,6 +108,12 @@ namespace WorkflowDesigner #region IEventBindingService implemention public string CreateUniqueMethodName(IComponent component, EventDescriptor e) { + if (component == null) + throw new ArgumentNullException("component"); + + if (e == null) + throw new ArgumentNullException("eventDescriptor"); + LoggingService.Debug("CreateUniqueMethodName(" + component + ", " + e + ")"); return String.Format("{0}{1}", Char.ToUpper(component.Site.Name[0]) + component.Site.Name.Substring(1), e.DisplayName); } @@ -123,7 +129,10 @@ namespace WorkflowDesigner public PropertyDescriptorCollection GetEventProperties(EventDescriptorCollection events) { - ArrayList props = new ArrayList (); + if (events == null) + throw new ArgumentNullException("events"); + + ArrayList props = new ArrayList(); foreach (EventDescriptor e in events) props.Add (GetEventProperty (e)); @@ -201,7 +210,12 @@ namespace WorkflowDesigner public bool ShowCode(IComponent component, EventDescriptor e) { + if (component == null) + throw new ArgumentNullException("component"); + if (e == null) + throw new ArgumentNullException("eventDescriptor"); + Activity activity = component as Activity; if (component == null) throw new ArgumentException("component must be derived from Activity"); @@ -227,7 +241,7 @@ namespace WorkflowDesigner return method.BodyRegion.BeginLine + 1; } - protected abstract string CreateEventHandler(IClass completeClass, EventDescriptor edesc, string eventMethodName, string body, string indentation); + protected abstract string CreateEventHandler(IClass completeClass, EventDescriptor eventDescriptor, string eventMethodName, string body, string indentation); public bool ShowCode(IComponent component, EventDescriptor e, string methodName) @@ -280,10 +294,10 @@ namespace WorkflowDesigner /// Gets a method implementing the signature specified by the event descriptor /// protected static ICSharpCode.NRefactory.Ast.MethodDeclaration - ConvertDescriptorToNRefactory(IClass completeClass, EventDescriptor edesc, string methodName) + ConvertDescriptorToNRefactory(IClass completeClass, EventDescriptor eventDescriptor, string methodName) { return ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertMember( - ConvertDescriptorToDom(completeClass, edesc, methodName), + ConvertDescriptorToDom(completeClass, eventDescriptor, methodName), new ClassFinder(completeClass, completeClass.BodyRegion.BeginLine + 1, 1) ) as ICSharpCode.NRefactory.Ast.MethodDeclaration; } @@ -293,7 +307,7 @@ namespace WorkflowDesigner return c.Region.EndLine; } - public bool UseMethod(IComponent component, EventDescriptor edesc, string methodName) + public bool UseMethod(IComponent component, EventDescriptor eventDescriptor, string methodName) { LoggingService.DebugFormatted("UseMethod {0}", methodName); IClass completeClass; @@ -308,7 +322,7 @@ namespace WorkflowDesigner ParseInformation info = ParserService.ParseFile(this.codeFileName); ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit; - MethodInfo methodInfo = edesc.EventType.GetMethod("Invoke"); + MethodInfo methodInfo = eventDescriptor.EventType.GetMethod("Invoke"); foreach (IClass c in cu.Classes) { if (c.Name == rootDesigner.Component.Site.Name){ @@ -344,9 +358,9 @@ namespace WorkflowDesigner LoggingService.DebugFormatted("Creating new method..."); int line = GetEventHandlerInsertionLine(c); int offset = t.TextEditorControl.Document.GetLineSegment(line - 1).Offset; - t.TextEditorControl.Document.Insert(offset, CreateEventHandler(completeClass, edesc, methodName, "", "\t\t")); - UpdateCCU(); - return ShowCode(component, edesc, methodName); + t.TextEditorControl.Document.Insert(offset, CreateEventHandler(completeClass, eventDescriptor, methodName, "", "\t\t")); + UpdateCodeCompileUnit(); + return ShowCode(component, eventDescriptor, methodName); } } } diff --git a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs index 6b287c9373..e01676a8f9 100644 --- a/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs +++ b/src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/WorkflowSideTabService.cs @@ -101,6 +101,9 @@ namespace WorkflowDesigner public static void AddViewContent(IViewContent viewContent) { + if (viewContent == null) + throw new ArgumentNullException("viewContent"); + if (!initialised) Initialise();