Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2386 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
13 changed files with 251 additions and 300 deletions
@ -0,0 +1,155 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Russell Wilkins" email=""/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
#region Using
|
||||||
|
using System; |
||||||
|
using System.ComponentModel.Design; |
||||||
|
using System.ComponentModel.Design.Serialization; |
||||||
|
using System.Drawing.Design; |
||||||
|
using System.Globalization; |
||||||
|
using System.IO; |
||||||
|
using System.Text; |
||||||
|
using System.Workflow.ComponentModel.Design; |
||||||
|
using System.Workflow.ComponentModel.Compiler; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace WorkflowDesigner.Loaders |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of BasicWorkflowDesignerLoader.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class BasicWorkflowDesignerLoader : WorkflowDesignerLoader |
||||||
|
{ |
||||||
|
private IViewContent viewContent; |
||||||
|
private string ruleFileName = string.Empty; |
||||||
|
private StringBuilder rules; |
||||||
|
|
||||||
|
public BasicWorkflowDesignerLoader(IViewContent viewContent) |
||||||
|
{ |
||||||
|
this.viewContent = viewContent; |
||||||
|
ruleFileName = Path.Combine(Path.GetDirectoryName(FileName), |
||||||
|
Path.GetFileNameWithoutExtension(FileName) + ".rules"); |
||||||
|
} |
||||||
|
|
||||||
|
#region Property Accessors
|
||||||
|
public IViewContent ViewContent { |
||||||
|
get { return viewContent; } |
||||||
|
} |
||||||
|
|
||||||
|
public override string FileName { |
||||||
|
get { |
||||||
|
return viewContent.PrimaryFileName; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public IProject Project { |
||||||
|
get { |
||||||
|
return ProjectService.OpenSolution.FindProjectContainingFile(FileName); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
public override TextReader GetFileReader(string filePath) |
||||||
|
{ |
||||||
|
return new StringReader(rules.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
public override TextWriter GetFileWriter(string filePath) |
||||||
|
{ |
||||||
|
if (rules == null) { |
||||||
|
rules = new StringBuilder(); |
||||||
|
CreateRulesProjectItem(); |
||||||
|
} |
||||||
|
|
||||||
|
return new StringWriter(rules, CultureInfo.CurrentCulture); |
||||||
|
} |
||||||
|
|
||||||
|
private void LoadRules() |
||||||
|
{ |
||||||
|
// Load the rules
|
||||||
|
if (File.Exists(ruleFileName)) { |
||||||
|
rules = new StringBuilder(File.ReadAllText(ruleFileName)); |
||||||
|
CreateRulesProjectItem(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void UpdateRules() |
||||||
|
{ |
||||||
|
if ((rules != null) && (rules.Length > 0)) |
||||||
|
File.WriteAllText(ruleFileName, rules.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
private void CreateRulesProjectItem() |
||||||
|
{ |
||||||
|
if (Project != null){ |
||||||
|
if (!Project.IsFileInProject(ruleFileName)) { |
||||||
|
FileProjectItem fpi = Project.FindFile(FileName); |
||||||
|
FileProjectItem rfpi = new FileProjectItem(Project,ItemType.EmbeddedResource); |
||||||
|
rfpi.FileName = Path.Combine(Path.GetDirectoryName(FileName), Path.GetFileName(ruleFileName)); |
||||||
|
rfpi.DependentUpon = Path.GetFileName(FileName); |
||||||
|
ProjectService.AddProjectItem(Project, rfpi); |
||||||
|
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView(); |
||||||
|
Project.Save(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Initialize() |
||||||
|
{ |
||||||
|
base.Initialize(); |
||||||
|
|
||||||
|
// Add the basic service required by all designers
|
||||||
|
LoaderHost.AddService(typeof(IToolboxService), new WorkflowToolboxService(LoaderHost)); |
||||||
|
LoaderHost.AddService(typeof(ITypeProvider), TypeProviderService.GetTypeProvider(Project)); |
||||||
|
LoaderHost.AddService(typeof(IMenuCommandService), new WorkflowMenuCommandService(LoaderHost)); |
||||||
|
LoaderHost.AddService(typeof(ITypeResolutionService), new TypeResolutionService(Project,LoaderHost)); |
||||||
|
LoaderHost.AddService(typeof(IPropertyValueUIService), new PropertyValueUIService()); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public override void Dispose() |
||||||
|
{ |
||||||
|
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(IMenuCommandService)); |
||||||
|
LoaderHost.RemoveService(typeof(IPropertyValueUIService)); |
||||||
|
|
||||||
|
LoaderHost.RemoveService(typeof(ITypeResolutionService)); |
||||||
|
LoaderHost.RemoveService(typeof(IMemberCreationService)); |
||||||
|
} |
||||||
|
} finally { |
||||||
|
base.Dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override void PerformLoad(IDesignerSerializationManager serializationManager) |
||||||
|
{ |
||||||
|
base.PerformLoad(serializationManager); |
||||||
|
DoPerformLoad(serializationManager); |
||||||
|
LoadRules(); |
||||||
|
LoaderHost.Activate(); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void DoPerformLoad(IDesignerSerializationManager serializationManager); |
||||||
|
|
||||||
|
protected override void PerformFlush(IDesignerSerializationManager serializationManager) |
||||||
|
{ |
||||||
|
DoPerformFlush(serializationManager); |
||||||
|
UpdateRules(); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void DoPerformFlush(IDesignerSerializationManager serializationManager); |
||||||
|
} |
||||||
|
} |
@ -1,63 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Russell Wilkins" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
#region Using
|
|
||||||
using System; |
|
||||||
using System.Workflow.ComponentModel.Design; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Workflow.Activities; |
|
||||||
using System.Workflow.ComponentModel; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Text; |
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace WorkflowDesigner |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of IdentifierCreationService.
|
|
||||||
/// </summary>
|
|
||||||
public class IdentifierCreationService : IIdentifierCreationService |
|
||||||
{ |
|
||||||
public IdentifierCreationService() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public void EnsureUniqueIdentifiers(CompositeActivity parentActivity, System.Collections.ICollection childActivities) |
|
||||||
{ |
|
||||||
if (parentActivity == null) |
|
||||||
throw new ArgumentNullException("parentActivity"); |
|
||||||
|
|
||||||
if (childActivities == null) |
|
||||||
throw new ArgumentNullException("childActivities"); |
|
||||||
|
|
||||||
LoggingService.DebugFormatted("EnsureUniqueIdentifiers(parentActivity={0}, childActivities={1})", parentActivity, childActivities); |
|
||||||
|
|
||||||
foreach (Activity activity in childActivities) |
|
||||||
{ |
|
||||||
LoggingService.DebugFormatted("{0}", activity.Name); |
|
||||||
// TODO: Something here?
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void ValidateIdentifier(Activity activity, string identifier) |
|
||||||
{ |
|
||||||
if (activity == null) |
|
||||||
throw new ArgumentNullException("activity"); |
|
||||||
|
|
||||||
if (identifier == null) |
|
||||||
throw new ArgumentNullException("identifier"); |
|
||||||
|
|
||||||
LoggingService.DebugFormatted("ValidateIdentifier(ValidateIdentifier={0}, identifier={1})", activity, identifier); |
|
||||||
|
|
||||||
//TODO: Something here?
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue