From: <dav...@us...> - 2012-01-14 02:59:19
|
Revision: 953 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=953&view=rev Author: davidvtaylor Date: 2012-01-14 02:59:12 +0000 (Sat, 14 Jan 2012) Log Message: ----------- + Implement support for setting the Display Label for model attributes Modified Paths: -------------- trunk/Source/Core/InstantCode.pas trunk/Source/Core/InstantMetadata.pas trunk/Source/Core/InstantPresentation.pas trunk/Source/Design/InstantAttributeEditor.dfm trunk/Source/Design/InstantAttributeEditor.pas trunk/Source/ObjectFoundry/OFClasses.pas trunk/Tests/TestInstantAttributeMetadata.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/Core/InstantCode.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -1594,6 +1594,7 @@ MetaKeyEmbedded = 'embedded'; MetaKeyValid = 'valid'; MetaKeyWidth = 'width'; + MetaKeyLabel = 'label'; ModuleTypeNames: array[TInstantCodeModuleType] of string = ('program', 'unit', 'library'); @@ -4133,6 +4134,8 @@ Metadata.ValidCharsString := Reader.ReadStringValue else if Token = MetaKeyWidth then Metadata.DisplayWidth := Reader.ReadInteger + else if Token = MetaKeyLabel then + Metadata.Displaylabel := Reader.ReadStringValue else Reader.ErrorMessage('Unknown parameter: ' + Token); end; @@ -4172,6 +4175,8 @@ if Metadata.HasValidChars then WriteStr(MetaKeyValid, Metadata.ValidCharsString); WriteInt(MetaKeyWidth, Metadata.DisplayWidth); + if Metadata.HasDisplayLabel then + WriteStr(MetaKeyLabel, Metadata.DisplayLabel); if IsIndexed then Writer.Write(' ' + MetaKeyIndex); if IsRequired then Modified: trunk/Source/Core/InstantMetadata.pas =================================================================== --- trunk/Source/Core/InstantMetadata.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/Core/InstantMetadata.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -465,6 +465,7 @@ FDefaultValue: string; FUseNull: Boolean; FDisplayWidth: Integer; + FDisplayLabel: string; FEditMask: string; FIsIndexed: Boolean; FIsRequired: Boolean; @@ -485,6 +486,7 @@ function GetCollection: TInstantAttributeMetadatas; function GetFieldName: string; function GetHasValidChars: Boolean; + function GetHasDisplayLabel: Boolean; function GetIsDefault: Boolean; function GetObjectClass: TInstantAbstractObjectClass; function GetObjectClassMetadata: TInstantClassMetadata; @@ -526,6 +528,7 @@ read GetObjectClassMetadata; property FieldName: string read GetFieldName write SetFieldName; property HasValidChars: Boolean read GetHasValidChars; + property HasDisplayLabel: Boolean read GetHasDisplayLabel; property TableName: string read GetTableName; procedure ValidateAttribute(const AAttribute: TInstantAbstractAttribute; const AValue: string); @@ -539,6 +542,7 @@ property UseNull: Boolean read FUseNull write FUseNull default False; property DisplayWidth: Integer read FDisplayWidth write FDisplayWidth default 0; + property DisplayLabel: string read FDisplayLabel write FDisplayLabel; property EditMask: string read FEditMask write FEditMask; property ExternalStorageName: string read FExternalStorageName write FExternalStorageName; @@ -1725,6 +1729,7 @@ FAttributeType := LSource.AttributeType; FDefaultValue := LSource.DefaultValue; FDisplayWidth := LSource.DisplayWidth; + FDisplayLabel := LSource.DisplayLabel; FEditMask := LSource.EditMask; FIsIndexed := LSource.IsIndexed; FIsRequired := LSource.IsRequired; @@ -1860,6 +1865,11 @@ Result := FValidCharsString <> ''; end; +function TInstantAttributeMetadata.GetHasDisplayLabel: Boolean; +begin + Result := FDisplayLabel <> ''; +end; + function TInstantAttributeMetadata.GetIsDefault: Boolean; begin Result := Assigned(ClassMetadata) and Modified: trunk/Source/Core/InstantPresentation.pas =================================================================== --- trunk/Source/Core/InstantPresentation.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/Core/InstantPresentation.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -24,7 +24,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Joao Morais, + * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Joao Morais, * Steven Mitchell, Brian Andersen, David Taylor * * ***** END LICENSE BLOCK ***** *) @@ -3192,6 +3192,8 @@ begin (Field as TBCDField).Currency := True; end; + if Assigned(Metadata) and (Metadata.HasDisplayLabel) then + Field.DisplayLabel := Metadata.DisplayLabel; if Assigned(FOnInitField) then FOnInitField(Self, Field); end; Modified: trunk/Source/Design/InstantAttributeEditor.dfm =================================================================== --- trunk/Source/Design/InstantAttributeEditor.dfm 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/Design/InstantAttributeEditor.dfm 2012-01-14 02:59:12 UTC (rev 953) @@ -351,6 +351,14 @@ Caption = 'Display &Width' FocusControl = DisplayWidthEdit end + object DisplayLabelLabel: TLabel + Left = 8 + Top = 128 + Width = 64 + Height = 13 + Caption = 'Display &Label' + FocusControl = DisplayLabelEdit + end object ValidCharsLabel: TLabel Left = 8 Top = 48 @@ -361,7 +369,7 @@ end object DefaultValueLabel: TLabel Left = 8 - Top = 128 + Top = 168 Width = 64 Height = 13 Caption = '&Default Value' @@ -385,6 +393,15 @@ DataSource = SubjectSource TabOrder = 2 end + object DisplayLabelEdit: TDBEdit + Left = 8 + Top = 144 + Width = 209 + Height = 21 + DataField = 'Metadata.DisplayLabel' + DataSource = SubjectSource + TabOrder = 3 + end object ValidCharsEdit: TDBEdit Left = 8 Top = 64 @@ -396,12 +413,12 @@ end object DefaultValueEdit: TDBEdit Left = 8 - Top = 144 + Top = 184 Width = 209 Height = 21 DataField = 'Metadata.DefaultValue' DataSource = SubjectSource - TabOrder = 3 + TabOrder = 4 end end end Modified: trunk/Source/Design/InstantAttributeEditor.pas =================================================================== --- trunk/Source/Design/InstantAttributeEditor.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/Design/InstantAttributeEditor.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -77,6 +77,8 @@ DefinitionSheet: TTabSheet; DisplayWidthEdit: TDBEdit; DisplayWidthLabel: TLabel; + DisplayLabelEdit: TDBEdit; + DisplayLabelLabel: TLabel; EditMaskEdit: TDBEdit; EdtMaskLabel: TLabel; MethodAddCheckBox: TCheckBox; Modified: trunk/Source/ObjectFoundry/OFClasses.pas =================================================================== --- trunk/Source/ObjectFoundry/OFClasses.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Source/ObjectFoundry/OFClasses.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -345,6 +345,7 @@ TaggedStrings['EditMask'] := Metadata.EditMask; TaggedStrings['ValidChars'] := Metadata.ValidCharsString; TaggedIntegers['DisplayWidth'] := Metadata.DisplayWidth; + TaggedString['DisplayLabel'] := Metadata.DisplayLabel; TaggedStrings['DefaultValue'] := Metadata.DefaultValue; WasReadOnly := Prop.WriteAccess = rwNone; if ReadOnly <> WasReadOnly then @@ -549,6 +550,7 @@ Metadata.EditMask := TaggedStrings['EditMask']; Metadata.ValidCharsString := TaggedStrings['ValidChars']; Metadata.DisplayWidth := TaggedIntegers['DisplayWidth']; + Metadata.DisplayLabel := TaggedStrings['DisplayLabel']; Metadata.DefaultValue := TaggedStrings['DefaultValue']; DetectContainerMethods; FOldName := Name; Modified: trunk/Tests/TestInstantAttributeMetadata.pas =================================================================== --- trunk/Tests/TestInstantAttributeMetadata.pas 2012-01-09 23:06:34 UTC (rev 952) +++ trunk/Tests/TestInstantAttributeMetadata.pas 2012-01-14 02:59:12 UTC (rev 953) @@ -231,6 +231,7 @@ FInstantAttributeMetadata.AttributeType := atString; FInstantAttributeMetadata.DefaultValue := 'Default'; FInstantAttributeMetadata.DisplayWidth := 10; + FInstantAttributeMetadata.DisplayLabel := ''; FInstantAttributeMetadata.EditMask := ''; FInstantAttributeMetadata.IsIndexed := False; FInstantAttributeMetadata.IsRequired := True; @@ -262,6 +263,7 @@ vSource.AttributeType := atString; vSource.DefaultValue := 'Default'; vSource.DisplayWidth := 10; + vSource.DisplayLabel := 'FieldLabel'; vSource.EditMask := ''; vSource.IsIndexed := False; vSource.IsRequired := True; @@ -278,6 +280,7 @@ AssertEquals('AttributeType incorrect', 'atString', vStr); AssertEquals('DefaultValue incorrect', 'Default', vDest.DefaultValue); AssertEquals('DisplayWidth incorrect', 10, vDest.DisplayWidth); + AssertEquals('DisplayLabel incorrect', 'FieldLabel', vDest.DisplayLabel); AssertEquals('EditMask incorrect', '', vDest.EditMask); AssertEquals('IsIndexed incorrect', False, vDest.IsIndexed); AssertEquals('IsRequired incorrect', True, vDest.IsRequired); |