public override bool CanExecute() { if (PSMAttribute.RepresentedAttribute != null) { if (Name != PSMAttribute.RepresentedAttribute.Name || Type != PSMAttribute.RepresentedAttribute.Type) { ErrorDescription = CommandError.CMDERR_REPRESENTING_ATTRIBUTES_CAN_NOT_BE_UPDATED; } } string name = DecideName(); if (name == null) { ErrorDescription = CommandError.CMDERR_PIMLESS_NAME; } if (!NameSuggestor <PSMAttribute> .IsNameUnique(PSMAttribute.Class.PSMAttributes, name, attribute => attribute.AliasOrName, PSMAttribute)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, name); return(false); } if (customMultiplicity && !MultiplicityElementController.IsMultiplicityValid(Lower, Upper)) { ErrorDescription = string.Format(CommandError.CMDERR_MULTIPLICITY_BAD_BOUNDS, name); return(false); } return(true); }
public override bool CanExecute() { if (!NameSuggestor <Operation> .IsNameUnique(Owner.Operations, Name, operation => operation.Name)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, Name); return(false); } return(true); }
public override bool CanExecute() { if (!NameSuggestor <Diagram> .IsNameUnique(Project.Diagrams, NewCaption, diagram => diagram.Caption)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, NewCaption); return(false); } return(RenamedDiagram != null && NewCaption != null); }
public override bool CanExecute() { if (Name != SimpleDataType.Name) { return(NameSuggestor <DataType> .IsNameUnique(SimpleDataType.Package.OwnedTypes, Name, item => item.Name)); } else { return(true); } }
public override bool CanExecute() { if (CreatedPackage != null && CreatedPackage.Element != null) { if (!NameSuggestor <Package> .IsNameUnique(Package.NestedPackages, CreatedPackage.Element.Name, package => package.Name)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, CreatedPackage.Element.Name); return(false); } } return(true); }
public override bool CanExecute() { if (ContainingCollection != null) { if (NewName != RenamedElement.Name && NewName != "" && !NameSuggestor <ElementType> .IsNameUnique(ContainingCollection, NewName, element => element.Name)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, NewName); return(false); } } return(true); }
public override bool CanExecute() { if (OldPackage == NewPackage) { ErrorDescription = String.Format(CommandError.CMDERR_ADDING_PRESENT, MovedClass); return(false); } if (!NameSuggestor <PIMClass> .IsNameUnique(NewPackage.Classes, MovedClass.Name, modelClass => modelClass.Name)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, MovedClass.Name); return(false); } return(true); }
protected string GetTemplateName(string name) { string returns; if (NameSuggestor <string> .IsNameUnique(templateNames, name, S => S)) { returns = name; } else { returns = NameSuggestor <string> .SuggestUniqueName(templateNames, name, S => S); } templateNames.Add(returns); return(returns); }
public override bool CanExecute() { // Error messages missing if (Package == null) { return(false); } if (CreatedClass != null && CreatedClass.Element != null) { return(NameSuggestor <PIMClass> .IsNameUnique(Package.Classes, CreatedClass.Element.Name, modelClass => modelClass.Name)); } else { return(true); } }
public override bool CanExecute() { if (RepresentedAttribute != null) { if (!PSMClass.RepresentedClass.MeAndAncestors.Contains(RepresentedAttribute.Class)) { ErrorDescription = CommandError.CMDERR_INCLUDED_ATTRIBUTES_INCONSISTENCE; return(false); } if (Name != RepresentedAttribute.Name || Type != null) { ErrorDescription = CommandError.CMDERR_REPRESENTING_ATTRIBUTES_CAN_NOT_BE_UPDATED; } } string name = DecideName(); if (name == null) { ErrorDescription = CommandError.CMDERR_PIMLESS_NAME; } IEnumerable <string> nameCollection; if (UsedAliasesOrNames != null) { nameCollection = UsedAliasesOrNames; } else { nameCollection = from PSMAttribute att in PSMClass.PSMAttributes select att.AliasOrName; } if (!NameSuggestor <string> .IsNameUnique(nameCollection, name, n => n)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, name); return(false); } if (!MultiplicityElementController.IsMultiplicityValid(Lower, Upper)) { ErrorDescription = string.Format(CommandError.CMDERR_MULTIPLICITY_BAD_BOUNDS, name); return(false); } return(true); }
public override bool CanExecute() { if (Lower != null && Upper != null) { if (Lower > Upper) { ErrorDescription = CommandError.CMDERR_MULTIPLICITY_BAD_BOUNDS; return(false); } } if (!NameSuggestor <Property> .IsNameUnique(Owner.Attributes, Name, attribute => attribute.Name)) { ErrorDescription = String.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, Name); return(false); } return(true); }
protected string GetTemplateName(string prefix) { string returns; XNamespace ns = GetNamespace(prefix); string id = CutID(prefix); if (NameSuggestor <string> .IsNameUnique(templateNames, Namespaces[ns] + ":" + id, S => S)) { returns = Namespaces[ns] + ":" + id; } else { returns = NameSuggestor <string> .SuggestUniqueName(templateNames, Namespaces[ns] + ":" + id, S => S); } templateNames.Add(returns); return(returns); }
public override bool CanExecute() { if (Attribute.AttributeContainer != null) { if (NewAlias != Attribute.Alias && !NameSuggestor <PSMAttribute> .IsNameUnique(Attribute.AttributeContainer.PSMAttributes, NewAlias, attr => attr.AliasOrName, Attribute)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, NewAlias); return(false); } } else { if (NewAlias != Attribute.Alias && !NameSuggestor <PSMAttribute> .IsNameUnique(Attribute.Class.PSMAttributes, NewAlias, attr => attr.AliasOrName, Attribute)) { ErrorDescription = string.Format(CommandError.CMDERR_NAME_NOT_UNIQUE, NewAlias); return(false); } } return(true); }
internal override OperationResult UndoOperation() { if (Attribute.Alias != oldAlias) { if (Attribute.AttributeContainer != null) { if (!NameSuggestor <PSMAttribute> .IsNameUnique(Attribute.AttributeContainer.PSMAttributes, oldAlias, attr => attr.Alias)) { ErrorDescription = string.Format(CommandError.CMDERR_DUPLICATE_ATTRIBUTE, oldAlias, Attribute.AttributeContainer); return(OperationResult.Failed); } } else { if (!NameSuggestor <PSMAttribute> .IsNameUnique(Attribute.Class.PSMAttributes, oldAlias, attr => attr.Alias)) { ErrorDescription = string.Format(CommandError.CMDERR_DUPLICATE_ATTRIBUTE, oldAlias, Attribute.Class); return(OperationResult.Failed); } } Attribute.Alias = oldAlias; } return(OperationResult.OK); }