public void AddNewAttribute(string attributeName, string newSimpleDataType, uint?lower, UnlimitedNatural?upper, string @default) { MacroCommand <ModelController> command = MacroCommandFactory <ModelController> .Factory().Create(DiagramController.ModelController); AddSimpleTypeCommand simpleTypeCommand = (AddSimpleTypeCommand)AddSimpleTypeCommandFactory.Factory().Create(DiagramController.ModelController); ElementHolder <DataType> type = new ElementHolder <DataType>(); simpleTypeCommand.CreatedSimpleType = type; command.Commands.Add(simpleTypeCommand); NewAttributeCommand attributeCommand = (NewAttributeCommand)NewAttributeCommandFactory.Factory().Create(DiagramController.ModelController); if (!String.IsNullOrEmpty(attributeName)) { attributeCommand.Name = attributeName; } else { attributeCommand.Name = NameSuggestor <Property> .SuggestUniqueName(Class.Attributes, "Attribute", property => property.Name); } attributeCommand.Type = type; attributeCommand.Lower = lower; attributeCommand.Upper = upper; attributeCommand.Default = @default; attributeCommand.Owner = Class; command.Commands.Add(attributeCommand); command.Execute(); }
public void Set(PSMAttribute attribute) { //Only PIMLess attributes if (attribute.RepresentedAttribute != null) { return; } ElementHolder <Property> AttributeHolder = new ElementHolder <Property>(); NewAttributeCommand c1 = NewAttributeCommandFactory.Factory().Create(Controller) as NewAttributeCommand; c1.createdAttributeHolder = AttributeHolder; c1.Owner = attribute.Class.RepresentedClass; c1.Lower = attribute.Lower; c1.Upper = attribute.Upper; c1.Default = attribute.Default; c1.Name = NameSuggestor <Property> .SuggestUniqueName(attribute.Class.RepresentedClass.Attributes, attribute.Name ?? attribute.Alias, property => property.Name); c1.Type = new ElementHolder <DataType>(attribute.Type); Commands.Add(c1); RenameElementCommand <Property> c2 = RenameElementCommandFactory <Property> .Factory().Create(Controller) as RenameElementCommand <Property>; c2.ContainingCollection = attribute.Class.Attributes; c2.RenamedElement = attribute; c2.NewName = c1.Name; Commands.Add(c2); PropagatePIMLessCommand c3 = PropagatePIMLessCommandFactory.Factory().Create(Controller) as PropagatePIMLessCommand; c3.Set(new ElementHolder <PSMAttribute>(attribute), AttributeHolder); Commands.Add(c3); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="association">The PSM association</param> /// <param name="parentPath">List of NestingJoinSteps describing the ParentPath</param> public void Set(PSMAssociation association, List <NestingJoinStep> parentPath) { Association = new ElementHolder <PSMAssociation>() { Element = association }; ParentPath = parentPath; }
/// <summary> /// Prepares this command for execution. /// </summary> /// <param name="representedClass">Class to be represented</param> /// <param name="representative">PSMClass to become PSMStructuralRepresentative</param> public void Set(PSMClass representedClass, PSMClass representative) { RepresentedClass = representedClass; Representative = new ElementHolder <PSMClass>() { Element = representative }; }
public void ChangeAttributeType(PSMAttribute attribute, ElementHolder <DataType> newType) { ChangeAttributeTypeCommand c = (ChangeAttributeTypeCommand)ChangeAttributeTypeCommandFactory.Factory().Create(DiagramController.ModelController); c.AssociatedElements.Add(Class); c.Attribute = attribute; c.NewType = newType; c.Execute(); }
internal override void CommandOperation() { Generalization generalization = Controller.Model.Schema.SetGeneralization(GeneralPSMClass.Element, SpecificPSMClass.Element); if (CreatedGeneralization == null) { CreatedGeneralization = new ElementHolder <Generalization>(); } CreatedGeneralization.Element = generalization; }
internal override void CommandOperation() { if (CreatedGeneralization == null) { CreatedGeneralization = new ElementHolder <Generalization>(); } CreatedGeneralization.Element = Model.Schema.SetGeneralization(General, Specific); Debug.Assert(CreatedGeneralization.HasValue); AssociatedElements.Add(CreatedGeneralization.Element); }
internal override void CommandOperation() { if (CreatedSimpleType == null) { CreatedSimpleType = new ElementHolder <DataType>(); } SimpleDataType type = Package.AddSimpleDataType(Parent); type.Name = TypeName; type.DefaultXSDImplementation = XSDefinition; CreatedSimpleType.Element = type; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Add Element //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public int AddElement(T a_ClassInstance) { if (a_ClassInstance != null) { ElementHolder <T> Holder = new ElementHolder <T>(); Holder.Instance = a_ClassInstance; Holder.ID = this.ClassList.Count; this.ClassList.Add(Holder); return(Holder.ID); } return(-1); }
internal override void CommandOperation() { if (CreatedComment == null) { CreatedComment = new ElementHolder <Comment>(); } CreatedComment.Element = AnnotatedElement.AddComment(NameSuggestor <Comment> .SuggestUniqueName(AnnotatedElement.Comments, "Comment", comment => comment.Body));; CreatedComment.Element.Body = Text; Debug.Assert(CreatedComment.HasValue); AssociatedElements.Add(CreatedComment.Element); }
internal override void CommandOperation() { if (CreatedClass == null) { CreatedClass = new ElementHolder <PIMClass>(); } CreatedClass.Element = Package.AddClass(); if (!String.IsNullOrEmpty(ClassName)) { CreatedClass.Element.Name = ClassName; } Debug.Assert(CreatedClass.HasValue); AssociatedElements.Add(CreatedClass.Element); }
internal override void CommandOperation() { if (CreatedAssociation == null) { CreatedAssociation = new ElementHolder <Association>(); } CreatedAssociation.Element = Controller.Model.Schema.AssociateClasses(AssociatedClasses); if (!String.IsNullOrEmpty(Name)) { CreatedAssociation.Element.Name = Name; } Debug.Assert(CreatedAssociation.HasValue); AssociatedElements.Add(CreatedAssociation.Element); }
internal override void CommandOperation() { if (CreatedClass == null) { CreatedClass = new ElementHolder <PSMClass>(); } PSMClass psmClass = RepresentedClass.DerivePSMClass(); CreatedClass.Element = psmClass; Debug.Assert(CreatedClass.HasValue); AssociatedElements.Add(CreatedClass.Element); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="parentHolder">Holder containing the parent element of the association</param> /// <param name="childHolder">Holder containing the child element of the association</param> /// <param name="createdAssociation">Holder that will contain the newly created association - can be null</param> /// <param name="index">Index at which to insert the association into parents components (null = default)</param> public void Set(ElementHolder <PSMSuperordinateComponent> parentHolder, ElementHolder <PSMAssociationChild> childHolder, ElementHolder <PSMAssociation> createdAssociation, int?index) { ParentHolder = parentHolder; ChildHolder = childHolder; Index = index; if (createdAssociation == null) { CreatedAssociation = new ElementHolder <PSMAssociation>(); } else { CreatedAssociation = createdAssociation; } }
public void Set(PSMClassUnion classUnion, IEnumerable <PSMAssociation> associations) { AddedAssociations.AddRange(associations); ClassUnion = classUnion; ElementHolder <PSMAssociation> leadingAssociationHolder = new ElementHolder <PSMAssociation>(ClassUnion.ParentAssociation); ElementHolder <PSMClassUnion> unionHolder = new ElementHolder <PSMClassUnion>(ClassUnion); CopyNestingJoinsCommand c3 = CopyNestingJoinsCommandFactory.Factory().Create(Controller.ModelController) as CopyNestingJoinsCommand; c3.Set(leadingAssociationHolder, AddedAssociations); this.Commands.Add(c3); /*GetClassUnionContentCommand c4 = GetClassUnionContentCommandFactory.Factory().Create(Controller.ModelController) as GetClassUnionContentCommand; * c4.Set(joinedAssociations, CreatedUnion); * Commands.Add(c4);*/ DeleteFromPSMDiagramCommand delCommand = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand; delCommand.DeletedElements = new List <Element>(AddedAssociations.Cast <Element>()); delCommand.CheckOrdering = false; Commands.Add(delCommand); PutClassesToUnionCommand c4 = PutClassesToUnionCommandFactory.Factory().Create(Controller.ModelController) as PutClassesToUnionCommand; c4.Set(AddedAssociations, unionHolder); Commands.Add(c4); foreach (PSMAssociation assoc in AddedAssociations) { PSMClassUnion union = assoc.Child as PSMClassUnion; if (union != null) { MoveClassUnionContentCommand moveCommand = MoveClassUnionContentCommandFactory.Factory().Create(Controller) as MoveClassUnionContentCommand; moveCommand.Set(union, unionHolder); Commands.Add(moveCommand); DeleteFromPSMDiagramCommand delUnion = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand; delUnion.DeletedElements = new List <Element>(); delUnion.DeletedElements.Add(union); Commands.Add(delUnion); } } }
/// <summary> /// Perpares this command for execution. /// </summary> /// <param name="modelController">The ModelController, which will store this command in its undo/redo stacks</param> /// <param name="package">The Model Package, in which the class will be created</param> public override void Set(ModelController modelController, Package package) { if (CreatedClass == null) { CreatedClass = new ElementHolder <PIMClass>(); } c = (NewModelClassCommand)NewModelClassCommandFactory.Factory().Create(modelController); c.ClassName = ClassName; c.Package = package; c.CreatedClass = CreatedClass; d = (ElementToDiagramCommand <PIMClass, ClassViewHelper>) ElementToDiagramCommandFactory <PIMClass, ClassViewHelper> .Factory().Create(Controller); d.IncludedElement = CreatedClass; d.ViewHelper.X = X; d.ViewHelper.Y = Y; Commands.Add(c); Commands.Add(d); }
public GameControl() { InitializeComponent(); UpdateTask = new TaskEntry(this); if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject())) { UpdateManager = App.Kernel.Get <UpdateManager>(); UpdateManager.FileSystemOpenError += UpdateManager_FileSystemOpenError; UpdateManager.StatusChanged += OnUpdateStatusChanged; ElementHolder.RemoveChild(StartButton); ElementHolder.RemoveChild(UpdateBlock); WrapElement.Content = StartButton; Application.Current.MainWindow.TaskbarItemInfo = TaskBar; LanguageManager.LanguageChanged += OnLanguageChanged; App.Kernel.Get <LoginManager>().LoginCompleted += OnGameStartCompleted; ProfileManager.ProfileChanged += OnProfileChanged; CheckWorker.DoWork += CheckWorker_DoWork; OnProfileChanged(this, BaseEventArgs.Empty); } }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="Parent">Parent element of the association</param> /// <param name="Child">Child element of the association</param> /// <param name="createdAssociation">Holder that will contain the newly created association - can be null</param> /// <param name="index">Index at which to insert the association into parents components (null = default)</param> public void Set(PSMSuperordinateComponent Parent, PSMAssociationChild Child, ElementHolder <PSMAssociation> createdAssociation, int?index) { ParentHolder = new ElementHolder <PSMSuperordinateComponent>() { Element = Parent }; ChildHolder = new ElementHolder <PSMAssociationChild>() { Element = Child }; Index = index; if (createdAssociation == null) { CreatedAssociation = new ElementHolder <PSMAssociation>(); } else { CreatedAssociation = createdAssociation; } }
public void Set(PIMClass RepresentedClass) { PSMClassHolder = new ElementHolder <PSMClass>(); NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller.ModelController) as NewPSMClassCommand; c1.RepresentedClass = RepresentedClass; c1.CreatedClass = PSMClassHolder; Commands.Add(c1); ElementToDiagramCommand <PSMClass, PSMElementViewHelper> c2 = ElementToDiagramCommandFactory <PSMClass, PSMElementViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <PSMClass, PSMElementViewHelper>; c2.IncludedElement = PSMClassHolder; Commands.Add(c2); AddPSMClassToRootsCommand c3 = AddPSMClassToRootsCommandFactory.Factory().Create(Controller) as AddPSMClassToRootsCommand; c3.Set(PSMClassHolder); Commands.Add(c3); }
internal override void CommandOperation() { if (CreatedDiagramReference == null) { CreatedDiagramReference = new ElementHolder <PSMDiagramReference>(); } PSMDiagramReference reference = new PSMDiagramReference() { ReferencedDiagram = ReferencedDiagram, ReferencingDiagram = (PSMDiagram)this.Diagram, Name = ReferencedDiagram.Caption, Local = true, SchemaLocation = ReferencedDiagram.Caption + ".xsd" }; CreatedDiagramReference.Element = reference; Debug.Assert(CreatedDiagramReference.HasValue); Diagram.AddModelElement(reference, ViewHelper); AssociatedElements.Add(reference); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="c">PIMClass to be derived from</param> /// <param name="d">Diagram to which to add the PSM Class as one of roots</param> /// <param name="h">Optional Element holder where the final PSMClass will be placed</param> public void Set(PIMClass c, PSMDiagram d, ElementHolder <PSMClass> h) { Class = c; HolderBase <PSMDiagram> DiagramHolder = new HolderBase <PSMDiagram>() { Element = d }; if (h != null) { pSMClassHolder = h; } else { pSMClassHolder = new ElementHolder <PSMClass>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller) as NewPSMClassCommand; c1.RepresentedClass = Class; c1.CreatedClass = pSMClassHolder; Commands.Add(c1); PSMClassToDiagram_ModelCommand c3 = PSMClassToDiagram_ModelCommandFactory.Factory().Create(Controller) as PSMClassToDiagram_ModelCommand; c3.Set(pSMClassHolder, DiagramHolder); Commands.Add(c3); AddPSMClassToRoots_ModelCommand c4 = AddPSMClassToRoots_ModelCommandFactory.Factory().Create(Controller) as AddPSMClassToRoots_ModelCommand; c4.Set(pSMClassHolder, DiagramHolder); Commands.Add(c4); ActivateDiagramCommand c5 = ActivateDiagramCommandFactory.Factory().Create(Controller) as ActivateDiagramCommand; c5.Set(d); Commands.Add(c5); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="c">PIMClass to be derived from</param> /// <param name="h">Optional Element holder where the final PSMClass will be placed</param> public void Set(PIMClass c, ElementHolder <PSMClass> h) { Class = c; if (h != null) { pSMClassHolder = h; } else { pSMClassHolder = new ElementHolder <PSMClass>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller) as NewPSMClassCommand; c1.RepresentedClass = Class; c1.CreatedClass = pSMClassHolder; Commands.Add(c1); AddPSMDiagramCommand c2 = AddPSMDiagramCommandFactory.Factory().Create(Controller) as AddPSMDiagramCommand; if (DiagramHolder == null) { DiagramHolder = new HolderBase <PSMDiagram>(); } c2.Set(Controller.Project, DiagramHolder); Commands.Add(c2); PSMClassToDiagram_ModelCommand c3 = PSMClassToDiagram_ModelCommandFactory.Factory().Create(Controller) as PSMClassToDiagram_ModelCommand; c3.Set(pSMClassHolder, DiagramHolder); Commands.Add(c3); AddPSMClassToRoots_ModelCommand c4 = AddPSMClassToRoots_ModelCommandFactory.Factory().Create(Controller) as AddPSMClassToRoots_ModelCommand; c4.Set(pSMClassHolder, DiagramHolder); Commands.Add(c4); }
public void Set(PSMClass generalPSMClass, PIMClass specificPIMClass) { if (CreatedSpecificPSMClass == null) { CreatedSpecificPSMClass = new ElementHolder <PSMClass>(); } if (CreatedGeneralization == null) { CreatedGeneralization = new ElementHolder <Generalization>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller.ModelController) as NewPSMClassCommand; c1.RepresentedClass = specificPIMClass; c1.CreatedClass = CreatedSpecificPSMClass; Commands.Add(c1); NewPSMSpecializationCommand c2 = NewPSMSpecializationCommandFactory.Factory().Create(Controller.ModelController) as NewPSMSpecializationCommand; c2.GeneralPSMClass = new ElementHolder <PSMClass>() { Element = generalPSMClass }; c2.SpecificPSMClass = CreatedSpecificPSMClass; c2.CreatedGeneralization = CreatedGeneralization; Commands.Add(c2); ElementToDiagramCommand <PSMClass, PSMElementViewHelper> c3 = ElementToDiagramCommandFactory <PSMClass, PSMElementViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <PSMClass, PSMElementViewHelper>; c3.IncludedElement = CreatedSpecificPSMClass; Commands.Add(c3); ElementToDiagramCommand <Generalization, GeneralizationViewHelper> c4 = ElementToDiagramCommandFactory <Generalization, GeneralizationViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <Generalization, GeneralizationViewHelper>; c4.IncludedElement = CreatedGeneralization; Commands.Add(c4); }
private Element(ElementHolder holder) { _holder = holder; }
public void Set(ElementHolder <PSMClass> c, HolderBase <PSMDiagram> d) { pSMClassHolder = c; DiagramHolder = d; }
private void bOk_Click(object sender, RoutedEventArgs e) { #region parse multiplicity uint? lower; UnlimitedNatural upper; try { lower = MultiplicityElementController.ParseNullabelUint(tbLower.Text); upper = MultiplicityElementController.ParseUnlimitedNatural(tbUpper.Text); } catch (FormatException) { CommandCantExecuteDialog dialog = new CommandCantExecuteDialog(); dialog.tbCommand.Content = "Wrong multiplicity format"; dialog.tbExMsg.Content = String.Format("{0}..{1} is not a correct format for multiplicity.", tbLower.Text, tbUpper.Text); dialog.ShowDialog(); return; } #endregion modelController.BeginMacro(); modelController.CreatedMacro.Description = CommandDescription.UPDATE_PROPERTY_MACRO; if (pimClassController != null) { if (tbName.ValueChanged) { NamedElementController.RenameElement(attribute, tbName.Text, modelController, attribute.Class.Attributes); } if (tbOnto.ValueChanged) { NamedElementController.ChangeOntologyEquivalent(attribute, tbOnto.Text, modelController); } if (tbDefaultValue.ValueChanged) { pimClassController.ChangeAttributeDefaultValue(attribute, tbDefaultValue.Text); } if (tbLower.ValueChanged || tbUpper.ValueChanged) { MultiplicityElementController.ChangeMultiplicityOfElement(attribute, attribute.Class, lower, upper, modelController); } #region change attribute type (create new simple type if required) if (cbDataType.SelectedItem != null && cbDataType.SelectedItem is DataType) { SimpleDataType t = cbDataType.SelectedItem as SimpleDataType; if (t != null && editedSimpleType) { modelController.AlterSimpleType(t, PrimitiveTypeName, PrimitiveTypeXSD); } if (!(cbDataType.SelectedItem.Equals(oldType))) { pimClassController.ChangeAttributeType(attribute, new ElementHolder <DataType>((DataType)cbDataType.SelectedItem)); } } else { if (newSimpleType) { ElementHolder <DataType> type = new ElementHolder <DataType>(); modelController.CreateSimpleType(PrimitiveTypeName, PrimitiveTypePackage, PrimitiveTypeParent, PrimitiveTypeXSD, type); pimClassController.ChangeAttributeType(attribute, type); } else if (oldType != null) { pimClassController.ChangeAttributeType(attribute, new ElementHolder <DataType>()); } } #endregion } if (psmClassController != null) { PSMAttribute psmAttribute = (PSMAttribute)attribute; if (tbName.ValueChanged) { NamedElementController.RenameElement(psmAttribute, tbName.Text, modelController, attribute.Class.Attributes); } #region change attribute type (create new simple type if required) if (cbDataType.SelectedItem != null && cbDataType.SelectedItem is DataType) { SimpleDataType t = cbDataType.SelectedItem as SimpleDataType; if (t != null && editedSimpleType) { modelController.AlterSimpleType(t, PrimitiveTypeName, PrimitiveTypeXSD); } if (!(cbDataType.SelectedItem.Equals(oldType))) { psmClassController.ChangeAttributeType(psmAttribute, new ElementHolder <DataType>((DataType)cbDataType.SelectedItem)); } } else { if (newSimpleType) { ElementHolder <DataType> type = new ElementHolder <DataType>(); modelController.CreateSimpleType(PrimitiveTypeName, PrimitiveTypePackage, PrimitiveTypeParent, PrimitiveTypeXSD, type); psmClassController.ChangeAttributeType(psmAttribute, type); } else if (oldType != null) { psmClassController.ChangeAttributeType(psmAttribute, new ElementHolder <DataType>()); } } #endregion if (tbDefaultValue.ValueChanged) { psmClassController.ChangeAttributeDefaultValue(psmAttribute, tbDefaultValue.Text); } if (tbLower.ValueChanged || tbUpper.ValueChanged) { MultiplicityElementController.ChangeMultiplicityOfElement(psmAttribute, attribute.Class, lower, upper, modelController); } if (tbAlias.ValueChanged) { psmClassController.ChangeAttributeAlias(psmAttribute, tbAlias.Text); } } modelController.CommitMacro(); DialogResult = true; Close(); }
public override void CommandsExecuted() { base.CommandsExecuted(); this.ViewHelper = d.ViewHelper; this.CreatedClass = c.CreatedClass; }
public void ChangeAttributeType(PSMAttribute attribute, ElementHolder <DataType> newType) { controlsPSMAttributes.ChangeAttributeType(attribute, newType); }
public void Set(ElementHolder <PSMClass> ch) { pSMClassHolder = ch; }
public void CreateSimpleType(string name, Package package, SimpleDataType parent, string xsdImplementation, ElementHolder <DataType> holder) { AddSimpleTypeCommand simpleTypeCommand = (AddSimpleTypeCommand)AddSimpleTypeCommandFactory.Factory().Create(this); simpleTypeCommand.XSDefinition = xsdImplementation; simpleTypeCommand.CreatedSimpleType = holder; simpleTypeCommand.TypeName = name; simpleTypeCommand.Parent = parent; simpleTypeCommand.Package = package; simpleTypeCommand.Execute(); }