protected override void ModifyModelActionOnExecute(object sender, SingleChoiceActionExecuteEventArgs e) { var choiceActionItem = e.SelectedChoiceActionItem; if (choiceActionItem.Id == ModifyModelActionChoiceItemsUpdater.ResetViewModel) { var modelApplicationBase = (ModelApplicationBase)Application.Model; var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); modelApplication.Id = modelApplicationBase.LastLayer.Id; new ModelXmlReader().ReadFromModel(modelApplication, modelApplicationBase.LastLayer); var modelViews = ((IModelApplication)modelApplication).Views; if (modelViews != null) { var modelView = modelViews[View.Id]; if (modelView != null) { if (!modelView.IsNewNode()) { modelView.Remove(); ModelApplicationHelper.RemoveLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); } else { throw new UserFriendlyException("Cannot reset new views"); } } } Frame.GetController <ModelController>().SetView(e.ShowViewParameters); } }
public void ResetViewModel(ActionBaseEventArgs e) { var modelApplicationBase = (ModelApplicationBase)Application.Model; var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); modelApplication.Id = modelApplicationBase.LastLayer.Id; new ModelXmlReader().ReadFromModel(modelApplication, modelApplicationBase.LastLayer); var modelViews = ((IModelApplication)modelApplication).Views; var modelView = modelViews?[View.Id]; if (modelView != null) { if (!modelView.IsNewNode()) { modelView.Remove(); ModelApplicationHelper.RemoveLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); } else { throw new UserFriendlyException("Cannot reset new views"); } } var showViewParameters = e.ShowViewParameters; Frame.GetController <ModelController>(controller => controller.SetView(showViewParameters)); }
void LoadApplicationModels(ModelApplicationBase model) { var userDiffLayers = new List <ModelApplicationBase>(); while (model.LastLayer != null && model.LastLayer.Id != "After Setup") { userDiffLayers.Add(model.LastLayer); ModelApplicationHelper.RemoveLayer(model); } if (model.LastLayer == null) { throw new ArgumentException("Model.LastLayer null"); } var customModelDifferenceStoreEventArgs = new CreateCustomModelDifferenceStoreEventArgs(); OnCreateCustomModelDifferenceStore(customModelDifferenceStoreEventArgs); if (!customModelDifferenceStoreEventArgs.Handled) { new XpoModelDictionaryDifferenceStore(Application, customModelDifferenceStoreEventArgs.ExtraDiffStores).Load(model); } userDiffLayers.Reverse(); foreach (var layer in userDiffLayers) { ModelApplicationHelper.AddLayer((ModelApplicationBase)Application.Model, layer); } }
private static void RefreshLayers(ModelApplicationBase application, Func <ModelApplicationBase, ModelApplicationBase> func) { var modelApplicationBases = new List <ModelApplicationBase>(); var lastLayer = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); var afterSetup = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); while (application.LastLayer.Id != "Unchanged Master Part") { ModelApplicationBase modelApplicationBase = application.LastLayer; modelApplicationBase = func.Invoke(modelApplicationBase); if (modelApplicationBase != null) { modelApplicationBases.Add(modelApplicationBase); } ModelApplicationHelper.RemoveLayer(application); } modelApplicationBases.Reverse(); foreach (var modelApplicationBase in modelApplicationBases) { ModelApplicationHelper.AddLayer(application, modelApplicationBase); } ModelApplicationHelper.AddLayer(application, afterSetup); ModelApplicationHelper.AddLayer(application, lastLayer); }
public static void AddLayerBeforeLast(this ModelApplicationBase application, ModelApplicationBase layer) { ModelApplicationBase lastLayer = application.LastLayer; ModelApplicationHelper.RemoveLayer(application); ModelApplicationHelper.AddLayer(application, layer); ModelApplicationHelper.AddLayer(application, lastLayer); }
void GetModelUnSafe(ModelApplicationBase modelApplicationBase, ModelDifferenceObject modelDifferenceObject) { var afterSetupLayer = GetAfterSetupLayer(modelApplicationBase); ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); modelDifferenceObject.GetModel(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); }
public static void AddLayerBeforeLast(this ModelApplicationBase application, ModelApplicationBase layer) { ModelApplicationBase lastLayer = application.LastLayer; if (lastLayer.Id != "After Setup" && lastLayer.Id != "UserDiff") { throw new ArgumentException("LastLayer.Id", lastLayer.Id); } ModelApplicationHelper.RemoveLayer(application); ModelApplicationHelper.AddLayer(application, layer); ModelApplicationHelper.AddLayer(application, lastLayer); }
protected virtual void Populate(Func <IModelMember, string> collect) { var name = PropertyName; if (name != null) { var model = ((ModelApplicationBase)Application.Model); var lastLayer = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); PopulateCore(collect, name); ModelApplicationHelper.AddLayer(model, lastLayer); } }
protected virtual void ReplaceLayer(ModelApplicationBase model, ModelApplicationBase layer, bool isCurrentUserModel, ShowViewParameters showViewParameters) { if (isCurrentUserModel) { ModelApplicationHelper.RemoveLayer(model); layer.Id = "UserDiff"; ModelApplicationHelper.AddLayer(model, layer); } else { model.ReplaceLayer(layer); } }
public void Load() { var model = (ModelApplicationBase)Application.Model; var userDiff = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); foreach (var roleModel in GetActiveRoleDifferenceObjects()) { roleModel.GetModel(model); } ModelApplicationHelper.AddLayer(model, userDiff); LoadCore(userDiff); }
public void CreateAspects(ModelApplicationBase model, ModelApplicationBase master) { var applicationBase = GetModel(master); new ModelXmlReader().ReadFromModel(applicationBase, model); CreateAspectsCore(model); if (applicationBase != null) { var lastLayer = master.LastLayer; ModelApplicationHelper.RemoveLayer(master); ModelApplicationHelper.RemoveLayer(master); ModelApplicationHelper.AddLayer(master, lastLayer); } }
IEnumerable <ModelApplicationBase> RemoveLayers(ModelApplicationBase modelApplicationBase, IEnumerable <string> strings) { var modelApplicationBases = new List <ModelApplicationBase>(); while (modelApplicationBase.LastLayer.Id != "Unchanged Master Part") { if (!(strings.Contains(modelApplicationBase.LastLayer.Id))) { modelApplicationBases.Add(modelApplicationBase.LastLayer); } ModelApplicationHelper.RemoveLayer(modelApplicationBase); } return(modelApplicationBases); }
public void Chained_Cloned_listview_merging(bool deepMerge) { string GetModel() { string xml; using (var xafApplication = Platform.Win.NewApplication <ModelViewInheritanceModule>()){ var inheritanceModule = DefaultModelViewInheritancerModule(xafApplication, true, typeof(CloneModelViewModule)); var model = inheritanceModule.Application.Model; var modelApplication = ((ModelApplicationBase)model).CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(((ModelApplicationBase)model), modelApplication); var elementListView = model.BOModel.GetClass(typeof(Element)).DefaultListView; elementListView.Columns[nameof(Element.Street)].Index = -1; var lvBase = ((IModelListView)model.Views[Element.ListViewBase]); var mergedDifferences = ((IModelObjectViewMergedDifferences)lvBase).MergedDifferences; var mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = elementListView; mergedDifferences = ((IModelObjectViewMergedDifferences)model.Views[Element.ListViewBaseNested]).MergedDifferences; mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = elementListView; mergedDifference.DeepMerge = deepMerge; if (!deepMerge) { mergedDifference = mergedDifferences.AddNode <IModelMergedDifference>(); mergedDifference.View = lvBase; } xml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)xafApplication.Model); } return(xml); } var modelXml = GetModel(); using (var newApplication = Platform.Win.NewApplication <ModelViewInheritanceModule>()){ var module = DefaultModelViewInheritancerModule(newApplication, false, typeof(CloneModelViewModule)); var testModule1 = new TestModule1 { DiffsStore = new StringModelStore(modelXml) }; testModule1.AdditionalExportedTypes.Add(typeof(Element)); newApplication.SetupDefaults(module, testModule1, new CloneModelViewModule()); var listViewBase = ((IModelListView)newApplication.Model.Views[Element.ListViewBase]); listViewBase.Columns[nameof(Element.Street)].Index.ShouldBe(-1); ((IModelListView)newApplication.Model.Views[Element.ListViewBaseNested]).Columns[nameof(Element.Street)].Index.ShouldBe(-1); } }
public static void ReInitLayers(this ModelApplicationBase modelApplicationBase) { if (modelApplicationBase.Id == "Application") { var lastLayer = modelApplicationBase.LastLayer; while (lastLayer.Id != "Unchanged Master Part") { ModelApplicationHelper.RemoveLayer(lastLayer); lastLayer = modelApplicationBase.LastLayer; } var afterSetupLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); afterSetupLayer.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); } }
void Application_LoggedOff(object sender, EventArgs e) { var modelApplicationBase = ((ModelApplicationBase)((XafApplication)sender).Model); var lastLayer = modelApplicationBase.LastLayer; while (lastLayer.Id != "Unchanged Master Part") { ModelApplicationHelper.RemoveLayer(modelApplicationBase); lastLayer = modelApplicationBase.LastLayer; } var afterSetupLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); afterSetupLayer.Id = "After Setup"; ModelApplicationHelper.AddLayer(modelApplicationBase, afterSetupLayer); }
void LoadApplicationModels(bool loadResources, ModelApplicationBase model) { var userDiffLayer = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); var customModelDifferenceStoreEventArgs = new CreateCustomModelDifferenceStoreEventArgs(); OnCreateCustomModelDifferenceStore(customModelDifferenceStoreEventArgs); if (!customModelDifferenceStoreEventArgs.Handled) { new XpoModelDictionaryDifferenceStore(Application, GetPath(), customModelDifferenceStoreEventArgs.ExtraDiffStores, loadResources).Load(model); } ModelApplicationHelper.AddLayer((ModelApplicationBase)Application.Model, userDiffLayer); RuntimeMemberBuilder.CreateRuntimeMembers(Application.Model); }
void CreateResourceRoleModels(ResourcesLayerBuilder resourcesLayerBuilder, Dictionary <string, ModelDifferenceObjectInfo> loadedModelDifferenceObjectInfos, ModelApplicationBase model) { var roleMarker = CreateModelApplication(model, DifferenceType.Role, DeviceCategory.All); roleMarker.Id = "RoleMarker"; model.AddLayerBeforeLast(roleMarker); resourcesLayerBuilder.AddLayers(RoleApplicationPrefix, loadedModelDifferenceObjectInfos, model); var lastLayer = model.LastLayer; while (model.LastLayer.Id != "RoleMarker") { ModelApplicationHelper.RemoveLayer(model); } ModelApplicationHelper.RemoveLayer(model); ModelApplicationHelper.AddLayer(model, lastLayer); }
public static void SetSettings(this ISupportStoreSettings supportStoreSettings, Action baseCall) { var list = new List <ModelApplicationBase>(); var applicationBase = (ModelApplicationBase)CaptionHelper.ApplicationModel; while (applicationBase.LastLayer.Id != "UserDiff" && applicationBase.LastLayer.Id != "After Setup") { var modelApplicationBase = applicationBase.LastLayer; list.Add(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); } baseCall(); foreach (var modelApplicationBase in list) { ModelApplicationHelper.AddLayer(applicationBase, modelApplicationBase); } }
public override void SetSettings(IModelTemplate modelTemplate) { var list = new List <ModelApplicationBase>(); var applicationBase = ((ModelApplicationBase)Application().Model); while (applicationBase.LastLayer.Id != "UserDiff" && applicationBase.LastLayer.Id != "After Setup") { var modelApplicationBase = applicationBase.LastLayer; list.Add(modelApplicationBase); ModelApplicationHelper.RemoveLayer(modelApplicationBase); } base.SetSettings(modelTemplate); foreach (var modelApplicationBase in list) { ModelApplicationHelper.AddLayer(applicationBase, modelApplicationBase); } }
private void ObjectSpaceOnObjectSaved(object sender, ObjectManipulatingEventArgs args) { var userModelDifferenceObject = args.Object as UserModelDifferenceObject; if (userModelDifferenceObject != null && ReferenceEquals(GetDifference(Application.GetType().FullName, userModelDifferenceObject.Name, userModelDifferenceObject.DeviceCategory), userModelDifferenceObject)) { var applicationModel = (ModelApplicationBase)Application.Model; var model = applicationModel.CreatorInstance.CreateModelApplication(); model.Id = applicationModel.LastLayer.Id; foreach (var aspectObject in userModelDifferenceObject.AspectObjects.Where(o => !string.IsNullOrWhiteSpace(o.Xml))) { new ModelXmlReader().ReadFromString(model, userModelDifferenceObject.GetAspectName(aspectObject), aspectObject.Xml); } ModelApplicationHelper.RemoveLayer(applicationModel); ModelApplicationHelper.AddLayer(applicationModel, model); } }
public void Load() { var model = (ModelApplicationBase)Application.Model; var userDiff = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); var modelDifferenceObjects = GetActiveRoleDifferenceObjects(DeviceCategory.All); if (DeviceModelsEnabled) { modelDifferenceObjects = modelDifferenceObjects.Concat(GetActiveRoleDifferenceObjects(Application.GetDeviceCategory())); } foreach (var roleModel in modelDifferenceObjects) { roleModel.GetModel(model); } ModelApplicationHelper.AddLayer(model, userDiff); LoadCore(userDiff); }
public override IModelTemplate GetTemplateCustomizationModel(IFrameTemplate template) { var applicationBase = ((ModelApplicationBase)Model); if (applicationBase.Id == "Application") { var list = new List <ModelApplicationBase>(); while (applicationBase.LastLayer.Id != "UserDiff" && applicationBase.LastLayer.Id != AfterSetupLayerId && applicationBase.LastLayer.Id != "Unchanged Master Part") { list.Add(applicationBase.LastLayer); ModelApplicationHelper.RemoveLayer(applicationBase); } var modelTemplate = base.GetTemplateCustomizationModel(template); foreach (var modelApplicationBase in list) { ModelApplicationHelper.AddLayer((ModelApplicationBase)Model, modelApplicationBase); } return(modelTemplate); } return(base.GetTemplateCustomizationModel(template)); }
public void Load() { var model = (ModelApplicationBase)Application.Model; var userDiff = model.LastLayer; ModelApplicationHelper.RemoveLayer(model); foreach (var roleModel in GetActiveRoleDifferenceObjects()) { roleModel.GetModel(model); } ModelApplicationHelper.AddLayer(model, userDiff); var modelDifferenceObjects = GetActiveDifferenceObjects().ToList(); if (!modelDifferenceObjects.Any()) { SaveDifference(model); return; } CombineWithActiveDifferenceObjects(model.LastLayer, modelDifferenceObjects); RuntimeMemberBuilder.AddFields((IModelApplication)model, XpandModuleBase.Dictiorary); }
public IEnumerable <string> GetModels() { var modelApplicationBase = ((ModelApplicationBase)_application.Model); var objectViewBase = modelApplicationBase.Application.Views[$"{nameof(ABaseMvi)}_{_viewType}"].AsObjectView; yield return(Layer1ObjectViewA()); yield return(Layer2ObjectViewA()); yield return(RegisterRules()); string Layer2ObjectViewA() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); ModifyAttributes(objectViewBase); if (_viewType == ViewType.ListView) { ModifyColumns((IModelListView)objectViewBase); var modelListViewFilter = (IModelViewHiddenActions)objectViewBase; var hiddenAction = modelListViewFilter.HiddenActions.AddNode <IModelActionLink>(); hiddenAction.Action = _application.Model.ActionDesign.Actions["Save"]; } else { ModifyLayout((IModelDetailView)objectViewBase); } ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(modelApplication.Xml); } string Layer1ObjectViewA() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); objectViewBase.AllowDelete = false; var applicationXml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(applicationXml); } void ModifyAttributes(IModelObjectView modelObjectView) { modelObjectView.Caption = "Changed"; } void ModifyLayout(IModelDetailView modelDetailView) { var node = modelDetailView.Layout.GetNodeByPath($"Main/SimpleEditors/{nameof(ABaseMvi)}/{nameof(ABaseMvi.Name)}"); ((IModelNode)node).Remove(); var oidItem = modelDetailView.Layout.GetNode("Main").AddNode <IModelLayoutViewItem>("Oid"); oidItem.ViewItem = oidItem.ViewItems.First(item => item.Id == "Oid"); oidItem.Index = 1; modelDetailView.Layout.GetNodeByPath("Main/Tags_Group").Index = 2; } void ModifyColumns(IModelListView modelListView) { modelListView.Columns[nameof(ABaseMvi.Description)].Caption = "New"; modelListView.Columns[nameof(ABaseMvi.Name)].Remove(); modelListView.Columns["Oid"].Index = 100; } string RegisterRules() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); var objectViewA = modelApplication.Application.Views[$"{nameof(AMvi)}_{_viewType}"].AsObjectView; var differences = ((IModelObjectViewMergedDifferences)objectViewA).MergedDifferences; var difference = _attribute ? differences.First() : differences.AddNode <IModelMergedDifference>(); difference.View = objectViewBase; var xml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(xml); } }
public IEnumerator <string> GetEnumerator() { var modelApplicationBase = ((ModelApplicationBase)_application.Model); var objectViewA = modelApplicationBase.Application.Views[$"{nameof(ModelViewInheritanceClassA)}_{_viewType}"].AsObjectView; yield return(Layer1ObjectViewA()); yield return(Layer2ObjectViewA()); yield return(RegisterRules()); string Layer2ObjectViewA() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); ModifyAttributes(objectViewA); if (_viewType == ViewType.ListView) { ModifyColumns((IModelListView)objectViewA); var modelListViewFilter = (IModelViewHiddenActions)objectViewA; var hiddenAction = modelListViewFilter.HiddenActions.AddNode <IModelActionLink>(); hiddenAction.Action = _application.Model.ActionDesign.Actions["Save"]; } else { ModifyLayout((IModelDetailView)objectViewA); } ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(modelApplication.Xml); } string Layer1ObjectViewA() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); objectViewA.AllowDelete = false; var applicationXml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(applicationXml); } void ModifyAttributes(IModelObjectView modelObjectView) { modelObjectView.Caption = "Changed"; } void ModifyLayout(IModelDetailView modelDetailView) { var node = modelDetailView.Layout.GetNodeByPath($"Main/SimpleEditors/{nameof(ModelViewInheritanceClassA)}/{nameof(ModelViewInheritanceClassA.Test2)}"); ((IModelNode)node).Remove(); } void ModifyColumns(IModelListView modelListView) { modelListView.Columns[nameof(ModelViewInheritanceClassA.Test1)].Caption = "New"; modelListView.Columns[nameof(ModelViewInheritanceClassA.Test2)].Remove(); } string RegisterRules() { var modelApplication = modelApplicationBase.CreatorInstance.CreateModelApplication(); ModelApplicationHelper.AddLayer(modelApplicationBase, modelApplication); var objectViewB = modelApplication.Application.Views[$"{nameof(ModelViewInheritanceClassB)}_{_viewType}"].AsObjectView; var differences = ((IModelObjectViewMergedDifferences)objectViewB).MergedDifferences; var difference = _attribute ? differences.First() : differences.AddNode <IModelMergedDifference>(); difference.View = objectViewA; var xml = modelApplication.Xml; ModelApplicationHelper.RemoveLayer((ModelApplicationBase)_application.Model); return(xml); } }
public static void RemoveLayer(this ModelApplicationBase application) { ModelApplicationHelper.RemoveLayer(application); }