From: <wp...@us...> - 2009-08-20 14:17:56
|
Revision: 857 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=857&view=rev Author: wp2udk Date: 2009-08-20 14:17:50 +0000 (Thu, 20 Aug 2009) Log Message: ----------- If you are abstracting properties (using the Template Design Pattern) to the base class the attribute editor cannot locate the visibility of the "missing" properties". In the code example below the Items part attribute is a member of the TBranch class, but the Items properties are introduced on the base class TLeaf. TLeaf = class(TInstantObject) {IOMETADATA stored; } protected function GetItemCount: Integer; virtual; function GetItems(Index: Integer): TLeaf; virtual; procedure SetItems(Index: Integer; Value: TLeaf); virtual; public property ItemCount: Integer read GetItemCount; virtual; property Items[Index: Integer]: TLeaf read GetItems write SetItems; end; TBranch = class(TLeaf) {IOMETADATA stored; Items: Parts(TLeaf) external 'Branch_Items'; } _Items: TInstantParts; protected function GetItemCount: Integer; override; function GetItems(Index: Integer): TLeaf; override; procedure SetItems(Index: Integer; Value: TLeaf); override; // These properties are removed from this class and they are introduced // manually on the base class. The Attribute Editor cannot find the // visibility of the "missing properties". // // property ItemCount: Integer read GetItemCount; // property Items[Index: Integer]: TLeaf read GetItems write SetItems; end; /Brian Modified Paths: -------------- trunk/Source/Design/InstantAttributeEditor.pas Modified: trunk/Source/Design/InstantAttributeEditor.pas =================================================================== --- trunk/Source/Design/InstantAttributeEditor.pas 2009-08-20 12:06:18 UTC (rev 856) +++ trunk/Source/Design/InstantAttributeEditor.pas 2009-08-20 14:17:50 UTC (rev 857) @@ -1,4 +1,4 @@ -(* + (* * InstantObjects * Attribute Editor *) @@ -376,6 +376,20 @@ end; procedure TInstantAttributeEditorForm.LoadVisibilities; + + function FindVisibility(ACodeClass: TInstantCodeClass; + AValuePropName: string): TInstantCodeProperty; + begin + if ACodeClass <> nil then + begin + Result := ACodeClass.FindProperty(AValuePropName); + + if Result = nil then + Result := FindVisibility(ACodeClass.BaseClass, AValuePropName); + end else + Result := nil; + end; + var I: Integer; S: String; @@ -397,7 +411,7 @@ if Limited then begin - CodeProperty := Subject.FindValueProp; + CodeProperty := FindVisibility(Subject.HostClass, Subject.ValuePropName); if CodeProperty <> nil then begin S := GetEnumName(TypeInfo(TInstantCodeVisibility), |