Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #485 manual input event #538

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,6 @@ paket-files/
setup/deploy
setup/MoBi*
setup/*.zip
src/**/licenses.licx

*.ncrunchproject
23 changes: 12 additions & 11 deletions MoBi.sln
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
# Visual Studio Version 16
VisualStudioVersion = 16.0.31019.35
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi", "src\MoBi\MoBi.csproj", "{B831E5E2-431A-4627-B58C-3CE3F5002E42}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi", "src\MoBi\MoBi.csproj", "{B831E5E2-431A-4627-B58C-3CE3F5002E42}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.Core", "src\MoBi.Core\MoBi.Core.csproj", "{2DBF50BE-A749-421C-B526-8BDA31CFE7B3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.Core", "src\MoBi.Core\MoBi.Core.csproj", "{2DBF50BE-A749-421C-B526-8BDA31CFE7B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.Presentation", "src\MoBi.Presentation\MoBi.Presentation.csproj", "{B4C86DCA-8877-4400-8088-2401EE65B403}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.Presentation", "src\MoBi.Presentation\MoBi.Presentation.csproj", "{B4C86DCA-8877-4400-8088-2401EE65B403}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.Assets", "src\MoBi.Assets\MoBi.Assets.csproj", "{3C65FFC2-D9EC-4951-8C35-04854AD34E52}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.Assets", "src\MoBi.Assets\MoBi.Assets.csproj", "{3C65FFC2-D9EC-4951-8C35-04854AD34E52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.Tests", "Tests\MoBi.Tests\MoBi.Tests.csproj", "{9DFDB6C9-FB74-4578-AAAF-F89C07BD4414}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.Tests", "Tests\MoBi.Tests\MoBi.Tests.csproj", "{9DFDB6C9-FB74-4578-AAAF-F89C07BD4414}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.UI", "src\MoBi.UI\MoBi.UI.csproj", "{DE743812-F444-42E2-B72D-CF298933E2BA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.UI", "src\MoBi.UI\MoBi.UI.csproj", "{DE743812-F444-42E2-B72D-CF298933E2BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.BatchTool", "src\MoBi.BatchTool\MoBi.BatchTool.csproj", "{881D23DB-4A9F-45C8-BA67-58B790537634}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.BatchTool", "src\MoBi.BatchTool\MoBi.BatchTool.csproj", "{881D23DB-4A9F-45C8-BA67-58B790537634}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B29CBF46-FC2E-4201-BBEC-940B5601A773}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
appveyor-coverage.yml = appveyor-coverage.yml
appveyor-nightly.yml = appveyor-nightly.yml
appveyor.yml = appveyor.yml
Expand All @@ -29,9 +30,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
SolutionInfo.cs = SolutionInfo.cs
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.UI.Tests", "tests\MoBi.UI.Tests\MoBi.UI.Tests.csproj", "{2710573C-9216-4817-AD81-97099597A780}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.UI.Tests", "tests\MoBi.UI.Tests\MoBi.UI.Tests.csproj", "{2710573C-9216-4817-AD81-97099597A780}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoBi.Engine", "src\MoBi.Engine\MoBi.Engine.csproj", "{15ED932C-EDEC-407B-91D9-7BCB8E7F95F5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoBi.Engine", "src\MoBi.Engine\MoBi.Engine.csproj", "{15ED932C-EDEC-407B-91D9-7BCB8E7F95F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion src/MoBi.Presentation/DTO/EventAssignmentBuilderDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private IBusinessRule createTargetHasToBeSetRule()

public string ChangedEntityPath
{
get { return _changedEntityPath; }
get => _changedEntityPath;
set
{
_changedEntityPath = value;
Expand Down
72 changes: 42 additions & 30 deletions src/MoBi.Presentation/Presenter/EditEventBuilderPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@
using OSPSuite.Core.Services;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole code is a mess. REtrieving object from context etc...
I don't want to touch it too much because we'll probably revisit event stuff eventually...but wow

using OSPSuite.Presentation.Presenters;
using OSPSuite.Assets;
using OSPSuite.Core.Extensions;

namespace MoBi.Presentation.Presenter
{
public interface IEditEventBuilderPresenter : IEditPresenterWithParameters<IEventBuilder>, ICanEditPropertiesPresenter, IPresenterWithFormulaCache
, IListener<AddedEvent>, IListener<RemovedEvent>
{
void AddAssigment();
void AddAssignment();
void RemoveAssignment(EventAssignmentBuilderDTO dtoAssignmentBuilder);
void SetConditionFormula(string formulaName);
void SetTargetPathFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO);
void SetPropertyValueFor<T>(EventAssignmentBuilderDTO eventAssignmentBuilderDTO, string propertyName, T newValue, T oldValue);
IEnumerable<string> AllFormulaNames();
void AddConditionFormula();
void SetFormulaFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO, FormulaBuilderDTO formulaBuilderDTO);
void SetChangedEntityPath(string newPath, EventAssignmentBuilderDTO dto);
}

public class EditEventBuilderPresenter : AbstractCommandCollectorPresenter<IEditEventBuilderView, IEditEventBuilderPresenter>, IEditEventBuilderPresenter
Expand Down Expand Up @@ -113,10 +115,7 @@ public void Edit(IEventBuilder eventBuilder)
Edit(eventBuilder, eventBuilder.ParentContainer);
}

public object Subject
{
get { return _eventBuilder; }
}
public object Subject => _eventBuilder;

public void SetPropertyValueFromView<T>(string propertyName, T newValue, T oldValue)
{
Expand All @@ -135,7 +134,7 @@ public IEnumerable<FormulaBuilderDTO> GetFormulas()

public IBuildingBlock BuildingBlock
{
get { return _buildingBlock; }
get => _buildingBlock;
set
{
_buildingBlock = value;
Expand All @@ -144,59 +143,71 @@ public IBuildingBlock BuildingBlock
}
}

public IFormulaCache FormulaCache
{
get { return BuildingBlock.FormulaCache; }
}
public IFormulaCache FormulaCache => BuildingBlock.FormulaCache;

public void AddAssigment()
public void AddAssignment()
{
AddCommand(_interactionTasksForEventAssignmentBuilder.AddNew(_eventBuilder, BuildingBlock));
}

public void RemoveAssignment(EventAssignmentBuilderDTO dtoAssignmentBuilder)
{
var eventAssignment = _eventBuilder.Assignments.SingleOrDefault(assignment => assignment.Id.Equals(dtoAssignmentBuilder.Id));
var eventAssignment = eventAssignmentBuilderFor(dtoAssignmentBuilder);
AddCommand(_interactionTasksForEventAssignmentBuilder.Remove(eventAssignment, _eventBuilder, BuildingBlock));
}

public void SetConditionFormula(string formulaName)
{
var newFormula = FormulaCache.First(formula => formula.Name.Equals(formulaName));

if (!newFormula.Equals(_eventBuilder.Formula))
{
AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(_eventBuilder.PropertyName(x => x.Formula), newFormula, _eventBuilder.Formula, _eventBuilder, BuildingBlock).Run(_context));
_editFormulaPresenter.Edit(newFormula);
_view.SetFormulaView(_editFormulaPresenter.BaseView);
_view.SetSelectReferenceView(_selectReferencePresenter.View);
checkFormulaName(newFormula.Name);
}
if (newFormula == _eventBuilder.Formula)
return;

AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(_eventBuilder.PropertyName(x => x.Formula), newFormula, _eventBuilder.Formula, _eventBuilder, BuildingBlock).Run(_context));
_editFormulaPresenter.Edit(newFormula);
_view.SetFormulaView(_editFormulaPresenter.BaseView);
_view.SetSelectReferenceView(_selectReferencePresenter.View);
checkFormulaName(newFormula.Name);
}

public void SetTargetPathFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO)
{
var eventAssignmentBuilder = _eventBuilder.Assignments.Single(dto => dto.Id.Equals(eventAssignmentBuilderDTO.Id));
IObjectPath objectPath;
using (var selectEventAssingmentTargetPresenter = _applicationController.Start<ISelectEventAssingmentTargetPresenter>())
using (var selectEventAssignmentTargetPresenter = _applicationController.Start<ISelectEventAssingmentTargetPresenter>())
{
selectEventAssingmentTargetPresenter.Init(_context.CurrentProject, _eventBuilder.RootContainer);
objectPath = selectEventAssingmentTargetPresenter.Select();
selectEventAssignmentTargetPresenter.Init(_context.CurrentProject, _eventBuilder.RootContainer);
objectPath = selectEventAssignmentTargetPresenter.Select();
}

if (objectPath == null) return;
AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(eventAssignmentBuilder.PropertyName(x => x.ObjectPath), objectPath, eventAssignmentBuilder.ObjectPath, eventAssignmentBuilder, BuildingBlock)
.Run(_context));
if (objectPath == null)
return;

eventAssignmentBuilderDTO.ChangedEntityPath = objectPath.PathAsString;
setChantedEntityPath(objectPath, eventAssignmentBuilderDTO);
}

public void SetChangedEntityPath(string newPath, EventAssignmentBuilderDTO dto)
{
var objectPath = new ObjectPath(newPath.ToPathArray());
setChantedEntityPath(objectPath, dto);
}

private void setChantedEntityPath(IObjectPath objectPath, EventAssignmentBuilderDTO dto)
{
var eventAssignmentBuilder = eventAssignmentBuilderFor(dto);
SetPropertyValueFor(dto, eventAssignmentBuilder.PropertyName(x => x.ObjectPath), objectPath, eventAssignmentBuilder.ObjectPath);
dto.ChangedEntityPath = objectPath.PathAsString;
}

public void SetPropertyValueFor<T>(EventAssignmentBuilderDTO eventAssignmentBuilderDTO, string propertyName, T newValue, T oldValue)
{
var eventAssignmentBuilder = _context.Get<IEventAssignmentBuilder>(eventAssignmentBuilderDTO.Id);
var eventAssignmentBuilder = eventAssignmentBuilderFor(eventAssignmentBuilderDTO);
AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(propertyName, newValue, oldValue, eventAssignmentBuilder, BuildingBlock).Run(_context));
}

private IEventAssignmentBuilder eventAssignmentBuilderFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO)
{
return _eventBuilder.Assignments.Single(dto => dto.Id.Equals(eventAssignmentBuilderDTO.Id));
}

public IEnumerable<string> AllFormulaNames()
{
return FormulaCache.OrderBy(formula => formula.Name).Select(x => x.Name);
Expand Down Expand Up @@ -229,6 +240,7 @@ public void SetFormulaFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO, F
new EditObjectBasePropertyInBuildingBlockCommand(eventAssignmentBuilder.PropertyName(b => b.Formula), newFormula, eventAssignmentBuilder.Formula, eventAssignmentBuilder, BuildingBlock).Run(_context));
}


public void Handle(AddedEvent eventToHandle)
{
if (shouldShow(eventToHandle.AddedObject))
Expand Down
4 changes: 2 additions & 2 deletions src/MoBi.UI/Views/EditApplicationBuilderView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/MoBi.UI/Views/EditApplicationBuilderView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
using MoBi.Presentation.DTO;
using MoBi.Presentation.Presenter;
using MoBi.Presentation.Views;
using OSPSuite.Assets;
using OSPSuite.UI.Views;
using OSPSuite.Presentation;
using OSPSuite.Presentation.Extensions;
using OSPSuite.Presentation.Views;
using OSPSuite.UI.Controls;
using OSPSuite.UI.Services;
using ToolTips = MoBi.Assets.ToolTips;

namespace MoBi.UI.Views
{
Expand Down Expand Up @@ -85,6 +86,10 @@ public override void InitializeResources()
layoutGroupContainer.Text = AppConstants.Captions.InContainerWith;
layoutGroupApplicationBuilder.Text = AppConstants.Captions.ApplicationMoleculeBuilder;
layoutItemMolecule.Text = AppConstants.Captions.AdministeredMolecule.FormatForLabel();
tabMolecules.Text = AppConstants.Captions.AdministeredMolecule;
tabMolecules.Image = ApplicationIcons.Molecule;
tabParameter.Text = AppConstants.Captions.Parameters;
tabParameter.Image = ApplicationIcons.Parameters;
}

public void Activate()
Expand Down
Loading