Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Fixes for enum deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
msawczyn committed Mar 15, 2020
1 parent 21a024c commit 90a074e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
Binary file modified dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix
Binary file not shown.
23 changes: 20 additions & 3 deletions src/Dsl/CustomCode/Partials/EFModelDiagram.cs
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;

Expand Down Expand Up @@ -40,7 +41,14 @@ private bool IsAcceptableDropItem(DiagramDragEventArgs diagramDragEventArgs)

public override void OnDragDrop(DiagramDragEventArgs diagramDragEventArgs)
{
base.OnDragDrop(diagramDragEventArgs);
try
{
base.OnDragDrop(diagramDragEventArgs);
}
catch (ArgumentException e)
{
// ignore. byproduct of multiple diagrams
}

if (IsDropping)
{
Expand All @@ -60,7 +68,16 @@ public override void OnDragDrop(DiagramDragEventArgs diagramDragEventArgs)
missingFiles = filenames.Except(existingFiles).ToArray();
}
else
base.OnDragDrop(diagramDragEventArgs);
{
try
{
base.OnDragDrop(diagramDragEventArgs);
}
catch (ArgumentException e)
{
// ignore. byproduct of multiple diagrams
}
}

if (missingFiles != null && missingFiles.Any())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Dsl/CustomCode/Rules/ModelEnumDeleteRules.cs
Expand Up @@ -27,7 +27,7 @@ public override void ElementDeleting(ElementDeletingEventArgs e)
if (current.IsSerializing || ModelRoot.BatchUpdating)
return;

string fullName = element.FullName;
string fullName = element.FullName.Split('.').Last();

using (Transaction t1 = store.TransactionManager.BeginTransaction("Remove enum properties"))
{
Expand Down
11 changes: 7 additions & 4 deletions src/DslPackage/CustomCode/CommandSet.cs
Expand Up @@ -154,10 +154,13 @@ protected override void ProcessOnMenuDeleteCommand()
{
foreach (EnumShape enumShape in CurrentSelection.OfType<EnumShape>())
{
if (enumShape.ModelElement is ModelEnum modelEnum
&& ModelEnum.IsUsed(modelEnum)
&& BooleanQuestionDisplay.Show($"{modelEnum.FullName} is used as an entity property. Deleting the enumeration will remove those properties. Are you sure?") != true)
return;
if (enumShape.ModelElement is ModelEnum modelEnum && ModelEnum.IsUsed(modelEnum))
{
string fullName = modelEnum.FullName.Split('.').Last();

if (BooleanQuestionDisplay.Show($"{fullName} is used as an entity property. Deleting the enumeration will remove those properties. Are you sure?") != true)
return;
}
}

base.ProcessOnMenuDeleteCommand();
Expand Down

0 comments on commit 90a074e

Please sign in to comment.