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

Commit

Permalink
Fix UseTabs
Browse files Browse the repository at this point in the history
v2.0.5.7
  • Loading branch information
msawczyn committed Oct 15, 2020
1 parent 8a5acc3 commit d8b0c51
Show file tree
Hide file tree
Showing 32 changed files with 495 additions and 2,848 deletions.
6 changes: 2 additions & 4 deletions src/Dsl/CustomCode/Partials/ModelRoot.cs
Expand Up @@ -23,11 +23,9 @@ public partial class ModelRoot: IHasStore

public static Action ExecuteValidator { get; set; }

public static Func<Diagram> GetCurrentDiagram;
public static Func<Diagram> GetCurrentDiagram { get; set; }

public static Func<bool> WriteDiagramAsBinary = () => false;

public static Func<bool> UseTabs = () => false;
public static Func<bool> WriteDiagramAsBinary { get; set; } = () => false;

static ModelRoot()
{
Expand Down
8 changes: 8 additions & 0 deletions src/Dsl/DslDefinition.dsl
Expand Up @@ -305,6 +305,11 @@
<ExternalTypeMoniker Name="/System/Boolean" />
</Type>
</DomainProperty>
<DomainProperty Id="c37804d1-29d0-4390-a52d-9a9d3dd79436" Description="If true, will generate code with tabs instead of spaces for indentation" Name="UseTabs" DisplayName="Use Tabs" DefaultValue="false" Category="Code Generation">
<Type>
<ExternalTypeMoniker Name="/System/Boolean" />
</Type>
</DomainProperty>
</Properties>
<ElementMergeDirectives>
<ElementMergeDirective>
Expand Down Expand Up @@ -1993,6 +1998,9 @@
<XmlPropertyData XmlName="showForeignKeyPropertyNames">
<DomainPropertyMoniker Name="ModelRoot/ShowForeignKeyPropertyNames" />
</XmlPropertyData>
<XmlPropertyData XmlName="useTabs">
<DomainPropertyMoniker Name="ModelRoot/UseTabs" />
</XmlPropertyData>
</ElementData>
</XmlClassData>
<XmlClassData TypeName="ModelClass" MonikerAttributeName="" SerializeId="true" MonikerElementName="modelClassMoniker" ElementName="modelClass" MonikerTypeName="ModelClassMoniker">
Expand Down
94 changes: 47 additions & 47 deletions src/Dsl/DslDefinition.dsl.diagram

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions src/Dsl/GeneratedCode/DomainClasses.cs
Expand Up @@ -3711,6 +3711,94 @@ public override sealed void SetValue(ModelRoot element, global::System.Boolean n
}
}

#endregion
#region UseTabs domain property code

/// <summary>
/// UseTabs domain property Id.
/// </summary>
public static readonly global::System.Guid UseTabsDomainPropertyId = new global::System.Guid(0xc37804d1, 0x29d0, 0x4390, 0xa5, 0x2d, 0x9a, 0x9d, 0x3d, 0xd7, 0x94, 0x36);

/// <summary>
/// Storage for UseTabs
/// </summary>
private global::System.Boolean useTabsPropertyStorage;

/// <summary>
/// Gets or sets the value of UseTabs domain property.
/// If true, will generate code with tabs instead of spaces for indentation
/// </summary>
[DslDesign::DisplayNameResource("Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.DisplayName", typeof(global::Sawczyn.EFDesigner.EFModel.EFModelDomainModel), "Sawczyn.EFDesigner.EFModel.GeneratedCode.DomainModelResx")]
[DslDesign::CategoryResource("Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.Category", typeof(global::Sawczyn.EFDesigner.EFModel.EFModelDomainModel), "Sawczyn.EFDesigner.EFModel.GeneratedCode.DomainModelResx")]
[DslDesign::DescriptionResource("Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.Description", typeof(global::Sawczyn.EFDesigner.EFModel.EFModelDomainModel), "Sawczyn.EFDesigner.EFModel.GeneratedCode.DomainModelResx")]
[DslModeling::DomainObjectId("c37804d1-29d0-4390-a52d-9a9d3dd79436")]
public global::System.Boolean UseTabs
{
[global::System.Diagnostics.DebuggerStepThrough]
get
{
return useTabsPropertyStorage;
}
[global::System.Diagnostics.DebuggerStepThrough]
set
{
UseTabsPropertyHandler.Instance.SetValue(this, value);
}
}
/// <summary>
/// Value handler for the ModelRoot.UseTabs domain property.
/// </summary>
internal sealed partial class UseTabsPropertyHandler : DslModeling::DomainPropertyValueHandler<ModelRoot, global::System.Boolean>
{
private UseTabsPropertyHandler() { }

/// <summary>
/// Gets the singleton instance of the ModelRoot.UseTabs domain property value handler.
/// </summary>
public static readonly UseTabsPropertyHandler Instance = new UseTabsPropertyHandler();

/// <summary>
/// Gets the Id of the ModelRoot.UseTabs domain property.
/// </summary>
public sealed override global::System.Guid DomainPropertyId
{
[global::System.Diagnostics.DebuggerStepThrough]
get
{
return UseTabsDomainPropertyId;
}
}

/// <summary>
/// Gets a strongly-typed value of the property on specified element.
/// </summary>
/// <param name="element">Element which owns the property.</param>
/// <returns>Property value.</returns>
public override sealed global::System.Boolean GetValue(ModelRoot element)
{
if (element == null) throw new global::System.ArgumentNullException("element");
return element.useTabsPropertyStorage;
}

/// <summary>
/// Sets property value on an element.
/// </summary>
/// <param name="element">Element which owns the property.</param>
/// <param name="newValue">New property value.</param>
public override sealed void SetValue(ModelRoot element, global::System.Boolean newValue)
{
if (element == null) throw new global::System.ArgumentNullException("element");

global::System.Boolean oldValue = GetValue(element);
if (newValue != oldValue)
{
ValueChanging(element, oldValue, newValue);
element.useTabsPropertyStorage = newValue;
ValueChanged(element, oldValue, newValue);
}
}
}

#endregion
#region Comments opposite domain role accessor

Expand Down
1 change: 1 addition & 0 deletions src/Dsl/GeneratedCode/DomainModel.cs
Expand Up @@ -157,6 +157,7 @@ protected sealed override DomainMemberInfo[] GetGeneratedDomainProperties()
new DomainMemberInfo(typeof(ModelRoot), "SnapToGrid", ModelRoot.SnapToGridDomainPropertyId, typeof(ModelRoot.SnapToGridPropertyHandler)),
new DomainMemberInfo(typeof(ModelRoot), "GridColor", ModelRoot.GridColorDomainPropertyId, typeof(ModelRoot.GridColorPropertyHandler)),
new DomainMemberInfo(typeof(ModelRoot), "ShowForeignKeyPropertyNames", ModelRoot.ShowForeignKeyPropertyNamesDomainPropertyId, typeof(ModelRoot.ShowForeignKeyPropertyNamesPropertyHandler)),
new DomainMemberInfo(typeof(ModelRoot), "UseTabs", ModelRoot.UseTabsDomainPropertyId, typeof(ModelRoot.UseTabsPropertyHandler)),
new DomainMemberInfo(typeof(ModelClass), "IsAbstract", ModelClass.IsAbstractDomainPropertyId, typeof(ModelClass.IsAbstractPropertyHandler)),
new DomainMemberInfo(typeof(ModelClass), "TableName", ModelClass.TableNameDomainPropertyId, typeof(ModelClass.TableNamePropertyHandler)),
new DomainMemberInfo(typeof(ModelClass), "DatabaseSchema", ModelClass.DatabaseSchemaDomainPropertyId, typeof(ModelClass.DatabaseSchemaPropertyHandler)),
Expand Down
12 changes: 12 additions & 0 deletions src/Dsl/GeneratedCode/DomainModelResx.resx
Expand Up @@ -621,6 +621,18 @@
<value>Designer</value>
<comment>Category for DomainProperty &apos;ShowForeignKeyPropertyNames&apos; on DomainClass &apos;ModelRoot&apos;</comment>
</data>
<data name="Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.Description" xml:space="preserve">
<value>If true, will generate code with tabs instead of spaces for indentation</value>
<comment>Description for DomainProperty &apos;UseTabs&apos; on DomainClass &apos;ModelRoot&apos;</comment>
</data>
<data name="Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.DisplayName" xml:space="preserve">
<value>Use Tabs</value>
<comment>DisplayName for DomainProperty &apos;UseTabs&apos; on DomainClass &apos;ModelRoot&apos;</comment>
</data>
<data name="Sawczyn.EFDesigner.EFModel.ModelRoot/UseTabs.Category" xml:space="preserve">
<value>Code Generation</value>
<comment>Category for DomainProperty &apos;UseTabs&apos; on DomainClass &apos;ModelRoot&apos;</comment>
</data>
<data name="Sawczyn.EFDesigner.EFModel.ModelClass.Description" xml:space="preserve">
<value></value>
<comment>Description for DomainClass &apos;ModelClass&apos;</comment>
Expand Down
6 changes: 6 additions & 0 deletions src/Dsl/GeneratedCode/EFModelSchema.xsd
Expand Up @@ -321,6 +321,12 @@
<xsd:documentation>If true, will show declared foreign key property names (if any) on the association ends</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!-- Property: UseTabs -->
<xsd:attribute name="useTabs" type="xsd:boolean" >
<xsd:annotation>
<xsd:documentation>If true, will generate code with tabs instead of spaces for indentation</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
6 changes: 6 additions & 0 deletions src/Dsl/GeneratedCode/LanguageNameSchema.xsd
Expand Up @@ -321,6 +321,12 @@
<xsd:documentation>If true, will show declared foreign key property names (if any) on the association ends</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!-- Property: UseTabs -->
<xsd:attribute name="useTabs" type="xsd:boolean" >
<xsd:annotation>
<xsd:documentation>If true, will generate code with tabs instead of spaces for indentation</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
30 changes: 30 additions & 0 deletions src/Dsl/GeneratedCode/Serializer.cs
Expand Up @@ -817,6 +817,23 @@ protected override void ReadPropertiesFromAttributes(DslModeling::SerializationC
}
}
}
// UseTabs
if (!serializationContext.Result.Failed)
{
string attribUseTabs = EFModelSerializationHelper.Instance.ReadAttribute(serializationContext, element, reader, "useTabs");
if (attribUseTabs != null)
{
global::System.Boolean valueOfUseTabs;
if (DslModeling::SerializationUtilities.TryGetValue<global::System.Boolean>(serializationContext, attribUseTabs, out valueOfUseTabs))
{
instanceOfModelRoot.UseTabs = valueOfUseTabs;
}
else
{ // Invalid property value, ignored.
EFModelSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "useTabs", typeof(global::System.Boolean), attribUseTabs);
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -1973,6 +1990,19 @@ protected override void WritePropertiesAsAttributes(DslModeling::SerializationCo
}
}
}
// UseTabs
if (!serializationContext.Result.Failed)
{
global::System.Boolean propValue = instanceOfModelRoot.UseTabs;
string serializedPropValue = DslModeling::SerializationUtilities.GetString<global::System.Boolean>(serializationContext, propValue);
if (!serializationContext.Result.Failed)
{
if (serializationContext.WriteOptionalPropertiesWithDefaultValue || string.CompareOrdinal(serializedPropValue, "false") != 0)
{ // No need to write the value out if it's the same as default value.
EFModelSerializationHelper.Instance.WriteAttributeString(serializationContext, element, writer, "useTabs", serializedPropValue);
}
}
}
}

/// <summary>
Expand Down
61 changes: 53 additions & 8 deletions src/DslPackage/CustomCode/OptionsPage.cs
@@ -1,27 +1,72 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;

using Microsoft.VisualStudio.Shell;

namespace Sawczyn.EFDesigner.EFModel.DslPackage
{
public class OptionsEventArgs : EventArgs
{
public string Option { get; }
public object OldValue { get; }
public object NewValue { get; }

public OptionsEventArgs(string option, object oldValue, object newValue)
{
Option = option;
OldValue = oldValue;
NewValue = newValue;
}
}

public class OptionsPage : DialogPage
{
public event EventHandler<OptionsEventArgs> OptionChanged ;

protected virtual void OnOptionsChanged(OptionsEventArgs args)
{
OptionChanged?.Invoke(this, args);
}

private string dotExePath;

[Category("Display")]
[DisplayName("GraphViz dot.exe path")]
[Description("Path to the GraphViz dot.exe file, if present")]
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string DotExePath { get; set; }
public string DotExePath
{
get
{
return dotExePath;
}
set
{
OptionsEventArgs args = new OptionsEventArgs("DotExePath", dotExePath, value);
dotExePath = value;
OnOptionsChanged(args);
}
}

private bool saveDiagramsCompressed;

[Category("File")]
[DisplayName("Save diagram using legacy binary format")]
[Description("If true, .diagramx files will be saved in compressed format. If false, they will not.")]
public bool SaveDiagramsCompressed { get; set; }

[Category("Code Generation")]
[DisplayName("Indent with tabs instead of spaces")]
[Description("If true, code will be generated using tabs and obey the editor's tab width")]
public bool UseTabs { get; set; }
public bool SaveDiagramsCompressed
{
get
{
return saveDiagramsCompressed;
}
set
{
OptionsEventArgs args = new OptionsEventArgs("SaveDiagramsCompressed", saveDiagramsCompressed, value);
saveDiagramsCompressed = value;
OnOptionsChanged(args);
}
}
}
}
1 change: 0 additions & 1 deletion src/DslPackage/CustomCode/Partials/EFModelDocData.cs
Expand Up @@ -215,7 +215,6 @@ protected override void OnDocumentLoaded()
ModelRoot.ExecuteValidator = ValidateAll;
ModelRoot.GetCurrentDiagram = GetCurrentDiagram;
ModelRoot.WriteDiagramAsBinary = () => EFModelPackage.Options.SaveDiagramsCompressed;
ModelRoot.UseTabs = () => EFModelPackage.Options.UseTabs;
ModelDiagramData.OpenDiagram = DisplayDiagram;
ModelDiagramData.CloseDiagram = CloseDiagram;
ModelDiagramData.RenameWindow = RenameWindow;
Expand Down
Binary file modified src/DslPackage/Parsers/EF6Parser.exe
Binary file not shown.
Binary file modified src/DslPackage/Parsers/EFCore2Parser.exe
Binary file not shown.
Binary file modified src/DslPackage/Parsers/EFCore3Parser.exe
Binary file not shown.
6 changes: 6 additions & 0 deletions src/DslPackage/ProjectItemTemplates/EFModel.xsd
Expand Up @@ -321,6 +321,12 @@
<xsd:documentation>If true, will show declared foreign key property names (if any) on the association ends</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!-- Property: UseTabs -->
<xsd:attribute name="useTabs" type="xsd:boolean" >
<xsd:annotation>
<xsd:documentation>If true, will generate code with tabs instead of spaces for indentation</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
2 changes: 1 addition & 1 deletion src/DslPackage/TextTemplates/EFDesigner.ttinclude
Expand Up @@ -281,7 +281,7 @@
WriteLine(text);

if (text.EndsWith("{"))
PushIndent(ModelRoot.UseTabs() ? "\t" : " ");
PushIndent(ModelRoot.UseTabs ? "\t" : " ");
}

void Output(string template, params object[] items)
Expand Down

0 comments on commit d8b0c51

Please sign in to comment.