code_junkie

Compartment items not displayed in DSL diagram

Nov 11th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. parentShape.FixupChildShapes(modelElement);
  2.  
  3. private Store LoadStore()
  4. {
  5. var store = new Store();
  6. store.LoadDomainModels(typeof(CoreDesignSurfaceDomainModel), typeof(ActiveWriterDomainModel));
  7. return store;
  8. }
  9.  
  10. private void LoadDiagram(Store store)
  11. {
  12. using (var tx = store.TransactionManager.BeginTransaction("tx", true))
  13. {
  14. var validator = new ValidationController();
  15. var deserializer = ActiveWriterSerializationHelper.Instance;
  16. deserializer.LoadModelAndDiagram(store,
  17. @"....ActiveWriter1.actiw", @"....ActiveWriter1.actiw.diagram", null, validator);
  18. tx.Commit();
  19. }
  20. }
  21.  
  22. private DiagramView CreateDiagramView()
  23. {
  24. var store = LoadStore();
  25. LoadDiagram(store);
  26.  
  27. using (var tx = store.TransactionManager.BeginTransaction("tx2", true))
  28. {
  29. var dir = store.DefaultPartition.ElementDirectory;
  30. var diag = dir.FindElements<ActiveRecordMapping>().SingleOrDefault();
  31. var view = new DiagramView(){Diagram = diag};
  32. diag.Associate(view);
  33. tx.Commit();
  34.  
  35. view.Dock = DockStyle.Fill;
  36. return view;
  37. }
  38. }
  39.  
  40. protected override void OnLoad(EventArgs e)
  41. {
  42. var view = CreateDiagramView();
  43. this.Controls.Add(view);
  44. }
  45.  
  46. private Store LoadStore()
  47. {
  48. var store = new Store();
  49. store.LoadDomainModels(typeof(CoreDesignSurfaceDomainModel), typeof(ActiveWriterDomainModel));
  50. ActiveWriterDomainModel.EnableDiagramRules(store);
  51. return store;
  52. }
  53.  
  54. /// <summary>
  55. /// Enables rules in this domain model related to diagram fixup for the given store.
  56. /// If diagram data will be loaded into the store, this method should be called first to ensure
  57. /// that the diagram behaves properly.
  58. /// </summary>
  59. public static void EnableDiagramRules(DslModeling::Store store)
  60. {
  61. if(store == null) throw new global::System.ArgumentNullException("store");
  62.  
  63. DslModeling::RuleManager ruleManager = store.RuleManager;
  64. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.FixUpDiagram));
  65. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.ConnectorRolePlayerChanged));
  66. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.CompartmentItemAddRule));
  67. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.CompartmentItemDeleteRule));
  68. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.CompartmentItemRolePlayerChangeRule));
  69. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.CompartmentItemRolePlayerPositionChangeRule));
  70. ruleManager.EnableRule(typeof(global::Altinoren.ActiveWriter.CompartmentItemChangeRule));
  71. }
Add Comment
Please, Sign In to add comment