<?
xml version="1.0" encoding="utf-8" ?>
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="collection" invoke="manual">
<description>
Collection Klasse mit dazugehöriger Item Klasse
</description>
<author>
Tom Peiffer, 2006
</author>
<point name="ContainerClass">
<text>
TContainerClass
</text>
<hint>
Klassentyp, in dem die Collection aufgenommen wird
</hint>
</point>
<point name="CollectionItemClass">
<text>
TMyCollectionItem
</text>
<hint>
Item Klasse eines Eintrags in der Collection
</hint>
</point>
<point name="CollectionClass">
<text>
TMyCollection
</text>
<hint>
Collection Klasse
</hint>
</point>
<code language="Delphi" context="decl" delimiter="|"><![CDATA[
|ContainerClass| = class ;
{ Den Typen |ContainerClass| muss als }
{ forward deklariert sein da er selbst }
{ in der Collection benutzt wird }
|CollectionItemClass| = class (TCollectionItem)
private
protected
procedure DefineProperties (Filer : TFiler) ; override ;
function GetDisplayName : string ; override ;
public
constructor Create (Collection : TCollection) ; override ;
destructor Destroy ; override ;
procedure Assign (Source : TPersistent) ; override ;
published
{ Hier werden die eigenen Item Properties definiert }
|*|
end ;
|CollectionClass| = class (TCollection)
private
FOwner : |ContainerClass| ; { Benutze hier den Typ deiner Komponente }
function GetItem(Index: integer): |CollectionItemClass|;
procedure SetItem(Index: integer; const Value: |CollectionItemClass|);
protected
function GetOwner : TPersistent ; override ;
procedure Update (Item : TCollectionItem) ; override ;
public
constructor Create (AOwner : |ContainerClass|) ;
function Add : |CollectionItemClass| ;
property YourComponent : |ContainerClass| read FOwner ;
property Items[Index : integer]: |CollectionItemClass| read GetItem write SetItem ; default ;
end ;
|ContainerClass| = class (TComponent)
private
FItems: |CollectionClass|;
procedure SetItems(const Value: |CollectionClass|);
public
constructor Create (AOwner : TComponent) ; override ;
published
property Items : |CollectionClass| read FItems write SetItems;
end ;
{ |CollectionItemClass| }
procedure |CollectionItemClass|.Assign(Source: TPersistent);
begin
inherited Assign (Source) ;
end;
constructor |CollectionItemClass|.Create(Collection: TCollection);
begin
inherited Create (Collection) ;
end;
procedure |CollectionItemClass|.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties (Filer) ;
end;
destructor |CollectionItemClass|.Destroy;
begin
inherited Destroy ;
end;
function |CollectionItemClass|.GetDisplayName: string;
begin
if (FProp = '')
then GetDisplayName := inherited GetDisplayName
else GetDisplayName := FProp ;
end;
{ |CollectionClass| }
function |CollectionClass|.Add: |CollectionItemClass|;
begin
Result := |CollectionItemClass|(inherited Add) ;
end;
constructor |CollectionClass|.Create(AOwner: |ContainerClass|);
begin
inherited Create (|CollectionItemClass|) ;
FOwner := AOwner ;
end;
function |CollectionClass|.GetItem(Index: integer): |CollectionItemClass|;
begin
Result := |CollectionItemClass|(inherited GetItem(index)) ;
end;
function |CollectionClass|.GetOwner: TPersistent;
begin
Result := FOwner ;
end;
procedure |CollectionClass|.SetItem(Index: integer;
const Value: |CollectionItemClass|);
begin
inherited SetItem (Index,Value) ;
end;
procedure |CollectionClass|.Update(Item: TCollectionItem);
begin
//
end;
{ |ContainerClass| }
constructor |ContainerClass|.Create(AOwner: TComponent);
begin
inherited Create (AOwner) ;
FItems := |CollectionClass|.create (Self) ;
end;
procedure |ContainerClass|.SetItems(const Value: |CollectionClass|);
begin
FItems := Value;
end;
]]>
</code>
</template>
</codetemplate>