|
From: <dav...@us...> - 2012-01-28 20:08:39
|
Revision: 956
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=956&view=rev
Author: davidvtaylor
Date: 2012-01-28 20:08:32 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
+ Allow the "index" keyword to optionally followed by an index name (e.g. SomeField: String(50) index 'MyCustomIndexName')
* Modify the attribute designer to allow editing of the index name
Modified Paths:
--------------
trunk/Source/Core/InstantCode.pas
trunk/Source/Core/InstantMetadata.pas
trunk/Source/Design/InstantAttributeEditor.dfm
trunk/Source/Design/InstantAttributeEditor.pas
trunk/Source/ObjectFoundry/OFClasses.pas
Modified: trunk/Source/Core/InstantCode.pas
===================================================================
--- trunk/Source/Core/InstantCode.pas 2012-01-28 16:57:31 UTC (rev 955)
+++ trunk/Source/Core/InstantCode.pas 2012-01-28 20:08:32 UTC (rev 956)
@@ -605,6 +605,7 @@
function GetIsIndexed: Boolean;
function GetIsRequired: Boolean;
function GetIsUnique: Boolean;
+ function GetIndexName: string;
function GetMetadata: TInstantAttributeMetadata;
function GetMethodTypes: TInstantCodeContainerMethodTypes;
function GetObjectClass: TInstantCodeClass;
@@ -628,6 +629,7 @@
procedure SetIsIndexed(const Value: Boolean);
procedure SetIsRequired(const Value: Boolean);
procedure SetIsUnique(const Value: Boolean);
+ procedure SetIndexName(const Value: string);
procedure SetMethodTypes(const Value: TInstantCodeContainerMethodTypes);
procedure SetObjectClassName(const Value: string);
procedure SetPropTypeName(const Value: string);
@@ -716,6 +718,7 @@
property IsIndexed: Boolean read GetIsIndexed write SetIsIndexed;
property IsRequired: Boolean read GetIsRequired write SetIsRequired;
property IsUnique: Boolean read GetIsUnique write SetIsUnique;
+ property IndexName: string read GetIndexName write SetIndexName;
property Metadata: TInstantAttributeMetadata read GetMetadata;
property MethodTypes: TInstantCodeContainerMethodTypes read GetMethodTypes
write SetMethodTypes;
@@ -3952,6 +3955,11 @@
Result := Metadata.IsUnique;
end;
+function TInstantCodeAttribute.GetIndexName: string;
+begin
+ Result := Metadata.IndexName;
+end;
+
function TInstantCodeAttribute.GetMetadata: TInstantAttributeMetadata;
begin
if not Assigned(FMetadata) then
@@ -4135,7 +4143,10 @@
else if Token = MetaKeyUseNull then
Metadata.UseNull := True
else if Token = MetaKeyIndex then
- IsIndexed := True
+ begin
+ MetaData.IndexName := trim(Reader.ReadStringValue);
+ IsIndexed := True;
+ end
else if Token = MetaKeyRequired then
IsRequired := True
else if Token = MetaKeyUnique then
@@ -4190,7 +4201,11 @@
if Metadata.HasDisplayLabel then
WriteStr(MetaKeyLabel, Metadata.DisplayLabel);
if IsIndexed then
+ begin
Writer.Write(' ' + MetaKeyIndex);
+ if Metadata.HasIndexName then
+ Writer.Write(' ''' + Metadata.IndexName + '''');
+ end;
if IsUnique then
Writer.Write(' ' + MetaKeyUnique);
if IsRequired then
@@ -4306,6 +4321,11 @@
Metadata.IsUnique := Value;
end;
+procedure TInstantCodeAttribute.SetIndexName(const Value: string);
+begin
+ Metadata.IndexName := Value;
+end;
+
procedure TInstantCodeAttribute.SetMethodTypes(
const Value: TInstantCodeContainerMethodTypes);
begin
Modified: trunk/Source/Core/InstantMetadata.pas
===================================================================
--- trunk/Source/Core/InstantMetadata.pas 2012-01-28 16:57:31 UTC (rev 955)
+++ trunk/Source/Core/InstantMetadata.pas 2012-01-28 20:08:32 UTC (rev 956)
@@ -470,6 +470,7 @@
FIsIndexed: Boolean;
FIsRequired: Boolean;
FIsUnique: Boolean;
+ FIndexName: string;
FObjectClassName: string;
FSize: Integer;
FStorageName: string;
@@ -488,6 +489,7 @@
function GetFieldName: string;
function GetHasValidChars: Boolean;
function GetHasDisplayLabel: Boolean;
+ function GetHasIndexName: Boolean;
function GetIsDefault: Boolean;
function GetObjectClass: TInstantAbstractObjectClass;
function GetObjectClassMetadata: TInstantClassMetadata;
@@ -530,6 +532,7 @@
property FieldName: string read GetFieldName write SetFieldName;
property HasValidChars: Boolean read GetHasValidChars;
property HasDisplayLabel: Boolean read GetHasDisplayLabel;
+ property HasIndexName: Boolean read GetHasIndexName;
property TableName: string read GetTableName;
procedure ValidateAttribute(const AAttribute: TInstantAbstractAttribute;
const AValue: string);
@@ -552,6 +555,7 @@
property IsIndexed: Boolean read FIsIndexed write FIsIndexed;
property IsRequired: Boolean read FIsRequired write FIsRequired;
property IsUnique: Boolean read FIsUnique write FIsUnique;
+ property IndexName: string read FIndexName write FIndexName;
property ObjectClassName: string read FObjectClassName
write FObjectClassName;
property Size: Integer read FSize write FSize default 0;
@@ -1232,6 +1236,7 @@
TInstantTableMetadatas);
var
Maps: TInstantAttributeMaps;
+ IndexName: string;
I: Integer;
procedure AddMap(Map: TInstantAttributeMap);
@@ -1334,15 +1339,19 @@
begin
if AttributeMetadata.IsIndexed then
begin
+ if AttributeMetadata.HasIndexName then
+ IndexName := AttributeMetadata.IndexName else
+ IndexName := Map.Name + AttributeMetadata.FieldName;
+
if AttributeMetadata.IsUnique then
begin
- IndexMetadatas.AddIndexMetadata(Map.Name +
- AttributeMetadata.FieldName, AttributeMetadata.FieldName, [ixUnique]);
+ IndexMetadatas.AddIndexMetadata(IndexName,
+ AttributeMetadata.FieldName, [ixUnique]);
Options := Options + [foIndexed, foUnique];
end else
begin
- IndexMetadatas.AddIndexMetadata(Map.Name +
- AttributeMetadata.FieldName, AttributeMetadata.FieldName, []);
+ IndexMetadatas.AddIndexMetadata(IndexName,
+ AttributeMetadata.FieldName, []);
Options := Options + [foIndexed];
end;
end
@@ -1745,6 +1754,7 @@
FIsRequired := LSource.IsRequired;
FIsUnique := LSource.IsUnique;
FUseNull := LSource.UseNull;
+ FIndexName := LSource.IndexName;
FObjectClassName := LSource.ObjectClassName;
FSize := LSource.Size;
FStorageName := LSource.StorageName;
@@ -1881,6 +1891,11 @@
Result := FDisplayLabel <> '';
end;
+function TInstantAttributeMetadata.GetHasIndexName: Boolean;
+begin
+ Result := FIndexName <> '';
+end;
+
function TInstantAttributeMetadata.GetIsDefault: Boolean;
begin
Result := Assigned(ClassMetadata) and
Modified: trunk/Source/Design/InstantAttributeEditor.dfm
===================================================================
--- trunk/Source/Design/InstantAttributeEditor.dfm 2012-01-28 16:57:31 UTC (rev 955)
+++ trunk/Source/Design/InstantAttributeEditor.dfm 2012-01-28 20:08:32 UTC (rev 956)
@@ -207,6 +207,14 @@
Caption = '&Singular Name'
FocusControl = SingularNameEdit
end
+ object IndexNameLabel: TLabel
+ Left = 8
+ Top = 181
+ Width = 58
+ Height = 13
+ Caption = 'Index Name'
+ FocusControl = IndexNameEdit
+ end
object VisibilityEdit: TDBComboBox
Left = 8
Top = 24
@@ -313,6 +321,7 @@
Height = 17
Caption = 'Inde&xed'
TabOrder = 0
+ OnClick = OptionIndexedCheckBoxClick
end
object OptionRequiredCheckBox: TCheckBox
Left = 8
@@ -339,6 +348,15 @@
TabOrder = 4
end
end
+ object IndexNameEdit: TDBEdit
+ Left = 7
+ Top = 197
+ Width = 210
+ Height = 21
+ DataField = 'IndexName'
+ DataSource = SubjectSource
+ TabOrder = 4
+ end
end
object PresentationSheet: TTabSheet
Caption = 'Presentation'
Modified: trunk/Source/Design/InstantAttributeEditor.pas
===================================================================
--- trunk/Source/Design/InstantAttributeEditor.pas 2012-01-28 16:57:31 UTC (rev 955)
+++ trunk/Source/Design/InstantAttributeEditor.pas 2012-01-28 20:08:32 UTC (rev 956)
@@ -122,6 +122,8 @@
OptionUseNullCheckBox: TCheckBox;
EnumeratedTypeLabel: TLabel;
EnumeratedTypeEdit: TDBComboBox;
+ IndexNameLabel: TLabel;
+ IndexNameEdit: TDBEdit;
procedure NameEditKeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure NameEditChange(Sender: TObject);
@@ -140,6 +142,7 @@
procedure StorageNameEditChange(Sender: TObject);
procedure EnumeratedTypeEditChange(Sender: TObject);
procedure EnumeratedTypeEditEnter(Sender: TObject);
+ procedure OptionIndexedCheckBoxClick(Sender: TObject);
private
FBaseClassStorageName: string;
FLimited: Boolean;
@@ -758,6 +761,8 @@
EnableCtrl(OptionRequiredCheckBox, True);
EnableCtrl(OptionUniqueCheckBox, True);
EnableCtrl(OptionUseNullCheckBox, not IsContainer);
+ EnableCtrl(IndexNameLabel, OptionIndexedCheckBox.Checked);
+ EnableCtrl(IndexNameEdit, OptionIndexedCheckBox.Checked);
EnableCtrl(OkButton, IsValid);
PresentationSheet.TabVisible := IsMaskable;
end;
@@ -844,6 +849,11 @@
end;
end;
+procedure TInstantAttributeEditorForm.OptionIndexedCheckBoxClick(Sender: TObject);
+begin
+ UpdateControls;
+end;
+
procedure TInstantAttributeEditorForm.StorageNameEditChange(Sender: TObject);
begin
inherited;
Modified: trunk/Source/ObjectFoundry/OFClasses.pas
===================================================================
--- trunk/Source/ObjectFoundry/OFClasses.pas 2012-01-28 16:57:31 UTC (rev 955)
+++ trunk/Source/ObjectFoundry/OFClasses.pas 2012-01-28 20:08:32 UTC (rev 956)
@@ -342,6 +342,7 @@
TaggedBooleans['IsIndexed'] := IsIndexed;
TaggedBooleans['IsRequired'] := IsRequired;
TaggedBooleans['IsUnique'] := IsUnique;
+ TaggedStrings['IndexName'] := IndexName;
TaggedStrings['SingularName'] := SingularName;
TaggedStrings['EditMask'] := Metadata.EditMask;
TaggedStrings['ValidChars'] := Metadata.ValidCharsString;
@@ -547,6 +548,7 @@
IsIndexed := TaggedBooleans['IsIndexed'];
IsRequired := TaggedBooleans['IsRequired'];
IsUnique := TaggedBooleans['IsUnique'];
+ IndexName := TaggedStrings['IndexName'];
SingularName := TaggedStrings['SingularName'];
Metadata.Size := TaggedIntegers['Size'];
Metadata.EditMask := TaggedStrings['EditMask'];
|