private void SynchronizeDiagram(UIWorkflowLayer model) { bool isDirty = false; using (Transaction transaction = model.Store.TransactionManager.BeginTransaction("Synchro diagram")) { foreach (Scenario scenario in model.Scenarios) { ScenarioShape scenarioShape = null; foreach (ShapeElement shape in base.Diagram.NestedChildShapes) { if (shape.ModelElement.Id == scenario.Id) { scenarioShape = (ScenarioShape)shape; break; } } if (scenarioShape == null) { scenarioShape = new ScenarioShape(model.Store); scenarioShape.Associate(scenario); base.Diagram.NestedChildShapes.Add(scenarioShape); isDirty = true; } foreach (UIView clazz in scenario.Views) { UiViewShape classShape = null; foreach (ShapeElement shape in scenarioShape.NestedChildShapes) { if (shape.ModelElement.Id == clazz.Id) { classShape = (UiViewShape)shape; break; } } if (classShape == null) { classShape = new UiViewShape(model.Store); classShape.Associate(clazz); scenarioShape.NestedChildShapes.Add(classShape); isDirty = true; } } } //ArrangeShapesCommand command2 = new ArrangeShapesCommand( base.Diagram ); //command2.Exec(); if (isDirty) { transaction.Commit(); } } }
/// <summary> /// Called to initialize the view after the corresponding document has been loaded. /// </summary> protected override bool LoadView() { base.LoadView(); ReadOnlyCollection <UIWorkflowLayer> models = this.DocData.Store.ElementDirectory.FindElements <global::DSLFactory.Candle.SystemModel.UIWorkflowLayer>(); if (models.Count == 0) { return(false); } UIWorkflowLayer model = models[0]; global::System.Diagnostics.Debug.Assert(this.DocData.RootElement != null); if (this.DocData.RootElement == null) { return(false); } // Penser à rajouter le diagramme dans GetCustomDomainModelTypes de SystemModel global::System.Collections.ObjectModel.ReadOnlyCollection <global::DSLFactory.Candle.SystemModel.UIWorkflowLayerDiagram> diagrams = this.DocData.Store.ElementDirectory.FindElements <global::DSLFactory.Candle.SystemModel.UIWorkflowLayerDiagram>(); if (diagrams.Count > 0) { this.Diagram = (DslDiagrams::Diagram)diagrams[0]; } else { // Sinon on le crée UIWorkflowLayerDiagram diagram; using (Transaction transaction = this.DocData.Store.TransactionManager.BeginTransaction("Load ui view")) { diagram = new UIWorkflowLayerDiagram(DocData.Store); diagram.Associate(model); transaction.Commit(); } if (diagram != null) { base.Diagram = diagram; } } SynchronizeDiagram(model); return(base.Diagram != null); }
/// <summary> /// Création d'un scenario /// </summary> /// <param name="elem">The elem.</param> /// <param name="layer">The layer.</param> /// <returns></returns> private static Scenario CreateScenario(CandleElement elem, UIWorkflowLayer layer) { string name = StrategyManager.GetInstance(elem.Store).NamingStrategy.CreateElementName(layer, elem.RootName); // On regarde d'abord si il n'existe pas une classe du même nom foreach (Scenario cl in layer.Scenarios) { if (cl.Name == name) { return(cl); } } // Sinon création d'une nouvelle Scenario scenario = new Scenario(layer.Store); scenario.RootName = elem.RootName; scenario.Name = name; scenario.Comment = elem.Comment; layer.Scenarios.Add(scenario); UnplacedModelHelper.RegisterNewModel(layer.Store, scenario); return(scenario); }
/// <summary> /// Gets the parent for UI workflow layer. /// </summary> /// <param name="uIWorkflowLayer">The u I workflow layer.</param> /// <returns></returns> private Microsoft.VisualStudio.Modeling.ModelElement GetParentForUIWorkflowLayer(UIWorkflowLayer uIWorkflowLayer) { return(uIWorkflowLayer.Component); }