Example #1
0
 protected override void Context()
 {
     _spSuiteExecutionContext = A.Fake <IOSPSuiteExecutionContext>();
     A.CallTo(() => _spSuiteExecutionContext.TypeFor(A <ParameterStartValuesBuildingBlock> ._)).Returns(ObjectTypes.ParameterStartValuesBuildingBlock);
     A.CallTo(() => _spSuiteExecutionContext.TypeFor(A <MoleculeStartValuesBuildingBlock> ._)).Returns(ObjectTypes.MoleculeStartValuesBuildingBlock);
     A.CallTo(() => _spSuiteExecutionContext.TypeFor(A <ObserverBuildingBlock> ._)).Returns(ObjectTypes.ObserverBuildingBlock);
     A.CallTo(() => _spSuiteExecutionContext.TypeFor(A <SpatialStructure> ._)).Returns(ObjectTypes.SpatialStructure);
     sut = new RelatedItemTypeRetriever(_spSuiteExecutionContext);
 }
        protected override void ExecuteWith(IOSPSuiteExecutionContext context)
        {
            var column = _observedData[_cellValueChanged.ColumnId];

            BuildingBlockName = _observedData.Name;
            BuildingBlockType = context.TypeFor(_observedData);

            if (!column.IsBaseGrid())
            {
                setValueInCell(column, context);
            }
            else
            {
                var baseGrid = column.DowncastTo <BaseGrid>();
                var newIndex = baseGrid.RightIndexOf(_cellValueChanged.NewValue);
                //same index, nothing to change
                if (newIndex == _cellValueChanged.RowIndex)
                {
                    setValueInCell(baseGrid, context);
                }
                else
                {
                    //new index. need to remove swap out the old one and for the new one
                    _observedData.SwapValues(_cellValueChanged.OldValue, _cellValueChanged.NewValue);
                    context.PublishEvent(new ObservedDataTableChangedEvent(_observedData));
                }
            }

            var baseGridNameValueUnits = GetDisplayFor(_observedData.BaseGrid.Id, _observedData.BaseGrid.Values[_cellValueChanged.RowIndex]);
            var oldNameValueUnits      = GetDisplayFor(column.Id, _cellValueChanged.OldValue);
            var newNameValueUnits      = GetDisplayFor(column.Id, _cellValueChanged.NewValue);

            Description = Command.SetObservedDataValueDescription(baseGridNameValueUnits, oldNameValueUnits, newNameValueUnits);
        }
Example #3
0
 protected override void Context()
 {
     _context         = A.Fake <IOSPSuiteExecutionContext>();
     _observedData    = new DataRepository("data");
     _baseGrid        = new BaseGrid("base", "Time", Constants.Dimension.NO_DIMENSION);
     _baseGrid.Values = new[] { 1f, 2f, 3f };
     _column          = new DataColumn("col", "Name", Constants.Dimension.NO_DIMENSION, _baseGrid);
     _column.Values   = new[] { 10f, 20f, 30f };
     _observedData.Add(_column);
     sut = new SetObservedDataValueCommand(_observedData, _cellValueChanged);
     A.CallTo(() => _context.TypeFor(_observedData)).Returns("TYPE");
 }
        public string TypeFor <T>(T relatedObject) where T : class
        {
            var type = _context.TypeFor(relatedObject);

            type = type.Replace(ObjectTypes.BuildingBlock, string.Empty).Trim();

            if (isStartValueBuildingBlock(relatedObject))
            {
                return(type.ToAcronym().Pluralize());
            }

            return(type.PluralizeIf(shouldPluralize(relatedObject)));
        }
        public bool Validate(IObjectBase objectToValidate)
        {
            var validationResult = _entityValidator.Validate(objectToValidate);

            if (validationResult.ValidationState == ValidationState.Valid)
            {
                return(true);
            }

            using (var validationMessagesPresenter = _applicationController.Start <IValidationMessagesPresenter>())
            {
                validationMessagesPresenter.Caption = Error.EntityIsInvalid(_executionContext.TypeFor(objectToValidate), objectToValidate.Name);
                return(validationMessagesPresenter.Display(validationResult));
            }
        }
Example #6
0
        public void CompareObjects(IObjectBase leftObject, IObjectBase rightObject, bool runComparison = true, string leftCaption = null, string rightCaption = null, string viewCaption = null)
        {
            _leftObject   = leftObject;
            _rightObject  = rightObject;
            _leftCaption  = leftCaption ?? Captions.Comparisons.Left;
            _rightCaption = rightCaption ?? Captions.Comparisons.Right;
            _view.Caption = viewCaption ?? Captions.Comparisons.ComparisonTitle(_executionContext.TypeFor(leftObject));
            updateButtons();

            _executionContext.Load(leftObject);
            _executionContext.Load(rightObject);

            if (runComparison)
            {
                RunComparison();
            }
        }
Example #7
0
        public static IMenuBarButton CompareObjectsMenu(IReadOnlyList <IObjectBase> objectsToCompare, IReadOnlyList <string> objectNames, IOSPSuiteExecutionContext context)
        {
            if (objectsToCompare.Count != 2)
            {
                return(null);
            }

            if (objectsToCompare.Count != objectNames.Count)
            {
                return(null);
            }

            var menu = CreateMenuButton.WithCaption(MenuNames.CompareObjects(context.TypeFor(objectsToCompare[0])))
                       .WithCommandFor <CompareObjectsUICommand, IReadOnlyList <IObjectBase> >(objectsToCompare)
                       .WithIcon(ApplicationIcons.Comparison);

            var compareObjectCommand = menu.Command.DowncastTo <CompareObjectsUICommand>();

            compareObjectCommand.ObjectNames = objectNames;
            return(menu);
        }
Example #8
0
 protected virtual string DefaultAnalysisNameFor(ISimulationAnalysis simulationAnalysis)
 {
     return(_executionContext.TypeFor(simulationAnalysis));
 }