|
From: <dav...@us...> - 2010-01-29 18:28:11
|
Revision: 895
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=895&view=rev
Author: davidvtaylor
Date: 2010-01-29 18:28:03 +0000 (Fri, 29 Jan 2010)
Log Message:
-----------
* Fix ModelExplorer breakage caused by an enumeration-related change to TInstantCustomExposer. Not all exposed objects are InstantObjects!!
Modified Paths:
--------------
trunk/Source/Core/InstantPresentation.pas
Modified: trunk/Source/Core/InstantPresentation.pas
===================================================================
--- trunk/Source/Core/InstantPresentation.pas 2010-01-29 04:36:35 UTC (rev 894)
+++ trunk/Source/Core/InstantPresentation.pas 2010-01-29 18:28:03 UTC (rev 895)
@@ -2211,6 +2211,12 @@
Result := ftString;
end;
+ // TODO The attribute mapping process needs to be re-evaluated.
+ // The metadata-based approach fails in some cases since the Exposer
+ // subject is not always a TInstanObject instance (e.g. Delphi a TList).
+ // The code now falls back to RTTI based mapping as it did originally.
+ // Restoring the previous behavior fixes a breakage in Model Exporer
+ // DVT
function EnumerationToFieldType(const FieldName: string): TFieldType;
var
AttributeMetadata: TInstantAttributeMetadata;
@@ -2218,12 +2224,21 @@
Result := ftString;
AttributeMetadata := FindAttributeMetadata(FieldName);
if Assigned(AttributeMetadata) then
+ begin
case AttributeMetadata.AttributeType of
atEnum:
Result := ftInteger;
atBoolean:
Result := ftBoolean;
end;
+ end else
+ begin
+ // Default to original logic when metadata is not found!
+ if PropInfo^.PropType^^.Name = 'Boolean' then
+ Result := ftBoolean
+ else
+ Result := ftString;
+ end;
end;
var
@@ -2246,10 +2261,6 @@
case TypeKind of
tkEnumeration:
FieldType := EnumerationToFieldType(FieldName);
-{ if PropInfo^.PropType^^.Name = 'Boolean' then
- FieldType := ftBoolean
- else
- FieldType := ftString;}
tkString, tkLString{$IFDEF D12+}, tkUString{$ENDIF}:
FieldType := StringFieldType(FieldName);
tkInteger:
|