public bool CorrectName <T>(IEnumerable <string> alreadyUsedNames, T objectForRename) where T : IObjectBase { var usedNames = alreadyUsedNames.ToList(); var oldName = objectForRename.Name; var newName = oldName; var typeName = _objectTypeResolver.TypeFor <T>(); usedNames.AddRange(AppConstants.UnallowedNames); if (usedNames.Contains(oldName)) { newName = _dialogCreator.AskForInput( AppConstants.Dialog.AskForChangedName(oldName, typeName), Captions.Rename, getNextSuggestedName(usedNames, oldName), usedNames, iconName: ApplicationIcons.Rename.IconName); } //Rename was canceled if (newName.IsNullOrEmpty()) { return(false); } objectForRename.Name = newName; return(true); }
public IMoBiCommand Rename(IObjectBase objectBase, IEnumerable <string> allreadyNames, IBuildingBlock buildingBlock) { var unallowedNames = new List <string>(allreadyNames); unallowedNames.AddRange(AppConstants.UnallowedNames); var objectName = _objectTypeResolver.TypeFor(objectBase); string newName = _dialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(objectBase.Name), AppConstants.Captions.NewName, objectBase.Name, unallowedNames); if (string.IsNullOrEmpty(newName)) { return(new MoBiEmptyCommand()); } var commandCollector = new MoBiMacroCommand { CommandType = AppConstants.Commands.RenameCommand, ObjectType = objectName, Description = AppConstants.Commands.RenameDescription(objectBase, newName) }; if (CheckUsagesFor(newName, objectBase.Name, objectBase, commandCollector)) { commandCollector.AddCommand(new RenameObjectBaseCommand(objectBase, newName, buildingBlock) { ObjectType = objectName }); } commandCollector.Run(_context); return(commandCollector); }
public void ChangeTranportName(TransporterMoleculeContainer transporterMoleculeContainer, IBuildingBlock buildingBlock) { var unallowedNames = new List <string>(AppConstants.UnallowedNames); unallowedNames.AddRange(GetForbiddenNamesWithoutSelf(transporterMoleculeContainer, transporterMoleculeContainer.ParentContainer)); var oldTransportName = transporterMoleculeContainer.TransportName; var newName = _dialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(oldTransportName), AppConstants.Captions.NewName, oldTransportName, unallowedNames); if (string.IsNullOrEmpty(newName)) { return; } var commandCollector = new MoBiMacroCommand { CommandType = AppConstants.Commands.RenameCommand, ObjectType = ObjectName, Description = AppConstants.Commands.RenameDescription(transporterMoleculeContainer, newName) }; if (_objectBaseTask.CheckUsagesFor(newName, transporterMoleculeContainer.TransportName, transporterMoleculeContainer, commandCollector)) { commandCollector.AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(transporterMoleculeContainer.PropertyName(x => x.TransportName), newName, oldTransportName, transporterMoleculeContainer, buildingBlock) { ObjectType = ObjectName }); } commandCollector.Run(_context); _context.AddToHistory(commandCollector); }
public void Rename(FormulaBuilderDTO formulaDTO) { var formula = getFormulaForDTO(formulaDTO); if (formula == null) { return; } var newName = _dialogCreator.AskForInput(AppConstants.Captions.NewName, AppConstants.Captions.EnterNewFormulaName, formula.Name, _buildingBlock.FormulaCache.Select(x => x.Name)); if (string.IsNullOrEmpty(newName)) { return; } AddCommand(new RenameObjectBaseCommand(formula, newName, _buildingBlock).Run(_context)); Edit(_buildingBlock); }
public IMoBiCommand AddNewTagTo(IEntity entity, IBuildingBlock buildingBlock) { var tag = _dialogCreator.AskForInput("New Tag for Container", "New Tag", string.Empty, entity.Tags.Select(x => x.Value), getUsedTags()); if (string.IsNullOrEmpty(tag)) { return(new MoBiEmptyCommand()); } return(new AddTagCommand(tag, entity, buildingBlock).Run(_context)); }
public void RenameResults(IMoBiSimulation simulation, DataRepository dataRepository) { string newName = _dialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(dataRepository.Name), AppConstants.Captions.NewName, dataRepository.Name, allUsedResultsNameIn(simulation)); if (string.IsNullOrEmpty(newName)) { return; } AddCommand(new RenameSimulationResultsCommand(dataRepository, simulation, newName).Run(_context)); }
public IMoBiCommand AddNewTagTo(IEntity entity, ITaggedEntityDTO dto, IBuildingBlock buildingBlock) { var tag = _dialogCreator.AskForInput("New Tag for Container", "New Tag", string.Empty, Enumerable.Empty <string>(), getUsedTags()); if (string.IsNullOrEmpty(tag)) { return(new MoBiEmptyCommand()); } dto.Tags.Add(new TagDTO(tag)); return(new AddTagCommand(tag, entity, buildingBlock).Run(_context)); }
public override void Rename(DataRepository dataRepository) { var newName = _mobiDialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(dataRepository.Name), AppConstants.Captions.NewName, dataRepository.Name, _context.CurrentProject.AllObservedData.Select(x => x.Name)); if (string.IsNullOrEmpty(newName)) { return; } _context.AddToHistory(new RenameObservedDataCommand(dataRepository, newName).Run(_context)); }
public (IMoBiCommand command, IFormula formula) CreateNewFormulaInBuildingBlock(Type formulaType, IDimension formulaDimension, IEnumerable <string> existingFormulaNames, IBuildingBlock buildingBlock) { var newName = _dialogCreator.AskForInput(AppConstants.Captions.NewName, AppConstants.Captions.EnterNewFormulaName, string.Empty, existingFormulaNames); if (string.IsNullOrEmpty(newName)) { return(new MoBiEmptyCommand(), null); } var formula = CreateNewFormula(formulaType, formulaDimension).WithName(newName); return(new AddFormulaToFormulaCacheCommand(buildingBlock, formula).Run(_context), formula); }
private bool addNeighborhood(INeighborhoodBuilder neighborhoodBuilder, MoBiMacroCommand command, IMoBiSpatialStructure spatialStructure) { var forbiddenNames = spatialStructure.NeighborhoodsContainer.Children.Select(x => x.Name).Union(AppConstants.UnallowedNames).ToList(); if (forbiddenNames.Contains(neighborhoodBuilder.Name)) { string newName = _dialogCreator.AskForInput(AppConstants.Dialog.AskForChangedName(neighborhoodBuilder.Name, ObjectTypes.NeighborhoodBuilder), AppConstants.Captions.NewName, neighborhoodBuilder.Name, forbiddenNames); if (string.IsNullOrEmpty(newName)) { return(false); } neighborhoodBuilder.Name = newName; } command.AddCommand(new AddContainerToSpatialStructureCommand(spatialStructure.NeighborhoodsContainer, neighborhoodBuilder, spatialStructure).Run(Context)); return(true); }
private string getNewTagName(TagType tagType) { if (tagType == TagType.MatchAll) { return(AppConstants.MatchAll); } IEnumerable <string> forbidenTags; string caption; if (tagType == TagType.Match) { caption = AppConstants.Dialog.NewMatchTag; forbidenTags = _descriptorCriteria.OfType <MatchTagCondition>().Select(x => x.Tag); } else { caption = AppConstants.Dialog.NewNotMatchTag; forbidenTags = _descriptorCriteria.OfType <NotMatchTagCondition>().Select(x => x.Tag); } return(_dialogCreator.AskForInput(caption, AppConstants.Captions.Tag, String.Empty, forbidenTags, getUsedTags())); }
public void AddConditionFormula() { string newName = _dialogCreator.AskForInput(AppConstants.Captions.NewName, AppConstants.Captions.EnterNewFormulaName, string.Empty, AllFormulaNames()); checkFormulaName(newName); if (string.IsNullOrEmpty(newName)) { return; } var newFormula = _context.Create <ExplicitFormula>().WithName(newName); var newFormulaCommand = new MoBiMacroCommand { Description = AppConstants.Commands.EditDescription(ObjectTypes.EventBuilder, _formulaPropertyName, string.Empty, newName, _eventBuilder.Name), CommandType = AppConstants.Commands.EditCommand, ObjectType = ObjectTypes.EventBuilder }; newFormulaCommand.AddCommand(new AddFormulaToFormulaCacheCommand(BuildingBlock, newFormula).Run(_context)); newFormulaCommand.AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(_formulaPropertyName, newFormula, _eventBuilder.Formula, _eventBuilder, BuildingBlock).Run(_context)); AddCommand(newFormulaCommand); Edit(_eventBuilder); }
private string getNewTagName <TTagCondition>(string caption) where TTagCondition : ITagCondition { var forbiddenTags = _descriptorCriteria.OfType <TTagCondition>().Select(x => x.Tag); return(_dialogCreator.AskForInput(caption, AppConstants.Captions.Tag, String.Empty, forbiddenTags, getUsedTags())); }
private string newMoleculeName() { return(_dialogCreator.AskForInput(AppConstants.Dialog.GetReactionMoleculeName, AppConstants.Captions.AddReactionMolecule, string.Empty, Enumerable.Empty <string>(), getMoleculeNames())); }
protected string AskForInput(string caption, string text, string defaultName, List <string> usedNames) { return(_dialogCreator.AskForInput(caption, text, defaultName, usedNames)); }
protected override string AskForInput(string caption, string s, string defaultName, List <string> usedNames) { return(_dialogCreator.AskForInput(caption, s, defaultName, usedNames)); }