Ejemplo n.º 1
0
        protected override void Context()
        {
            base.Context();
            _convertedObject = A.Fake <IObjectBase>().WithName("BB");
            A.CallTo(() => _workspace.AddCommand(A <OSPSuiteInfoCommand> ._))
            .Invokes(x => _command = x.GetArgument <OSPSuiteInfoCommand>(0));

            A.CallTo(() => _executionContext.TypeFor(_convertedObject)).Returns("TYPE");
        }
Ejemplo n.º 2
0
        public void Handle(SimulationRunFinishedEvent eventToHandle)
        {
            var command = new OSPSuiteInfoCommand
            {
                Description       = PKSimConstants.Command.RunSimulationDescription(eventToHandle.Simulation.Name, eventToHandle.ExecutionTime.ToDisplay()),
                BuildingBlockName = eventToHandle.Simulation.Name,
                BuildingBlockType = PKSimConstants.ObjectTypes.Simulation,
                ObjectType        = PKSimConstants.ObjectTypes.Simulation
            };

            executeCommandAndAddToWorkspace(command);
        }
Ejemplo n.º 3
0
        private IInfoCommand getSimulationResultLabel(SimulationRunResults results)
        {
            var command = new OSPSuiteInfoCommand {
                Description = simulationLabelDescription(results)
            };

            if (results.Warnings.Any())
            {
                command.Comment = AppConstants.Commands.SimulationLabelComment(results.Warnings.Count());
            }

            return(command);
        }
        public void Handle(ObjectConvertedEvent eventToHandle)
        {
            var objectName  = _displayNameProvider.DisplayNameFor(eventToHandle.ConvertedObject);
            var objectType  = _context.TypeFor(eventToHandle.ConvertedObject);
            var fromVersion = eventToHandle.FromVersion;

            var command = new OSPSuiteInfoCommand
            {
                ObjectType  = _context.TypeFor(eventToHandle.ConvertedObject),
                Description = AppConstants.Commands.ObjectConvertedCommand(objectName, objectType, fromVersion.VersionDisplay, _applicationConfiguration.Version),
            };

            command.Run(_context);
            _context.AddToHistory(command);
        }
Ejemplo n.º 5
0
        public void Handle(ObjectBaseConvertedEvent eventToHandle)
        {
            var buildingBlock     = eventToHandle.ConvertedObject;
            var buildingBlockType = _executionContext.TypeFor(buildingBlock);
            var fromVersion       = eventToHandle.FromVersion;

            var command = new OSPSuiteInfoCommand
            {
                Description       = PKSimConstants.Command.ObjectConvertedDescription(buildingBlock.Name, buildingBlockType, fromVersion.VersionDisplay, _applicationConfiguration.Version),
                BuildingBlockName = buildingBlock.Name,
                BuildingBlockType = buildingBlockType,
                ObjectType        = buildingBlockType
            };

            executeCommandAndAddToWorkspace(command);
        }
        private bool saveCurrentProjectAs(string defaultName)
        {
            var defaultNameIsUndefined = string.Equals(CoreConstants.PROJECT_UNDEFINED, defaultName);
            var defaultFileName        = defaultNameIsUndefined ? string.Empty : defaultName;
            var fileName = _dialogCreator.AskForFileToSave(PKSimConstants.UI.SaveProjectTitle, CoreConstants.Filter.SAVE_PROJECT_FILTER, Constants.DirectoryKey.PROJECT, defaultFileName);

            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            var previousName = _workspace.Project.Name;
            var previousPath = _workspace.Project.FilePath;

            if (!saveProjectToFile(fileName))
            {
                return(false);
            }

            if (shouldShowWarningForSharedJournal(previousPath))
            {
                var journalName = FileHelper.FileNameFromFileFullPath(_journalRetriever.JournalFullPath);
                _dialogCreator.MessageBoxInfo(Captions.Journal.JournalWillBeSharedBetweenProjectInfo(journalName));
            }

            if (string.Equals(previousName, _workspace.Project.Name))
            {
                return(true);
            }

            //Project was renamed
            var command = new OSPSuiteInfoCommand
            {
                Description = PKSimConstants.Command.ProjectRenamedDescription(previousName, _workspace.Project.Name),
                ObjectType  = PKSimConstants.ObjectTypes.Project
            };

            _workspace.AddCommand(command);

            return(true);
        }
Ejemplo n.º 7
0
 private void executeCommandAndAddToWorkspace(OSPSuiteInfoCommand command)
 {
     command.Run(_executionContext);
     _workspace.AddCommand(command);
 }