Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   Neues Live Template einbinden (https://www.delphipraxis.net/60743-neues-live-template-einbinden.html)

Jelly 11. Jan 2006 20:59


Neues Live Template einbinden
 
Nachdem die Templates ja so toll hier in den Videos gelobt wurden, wollt ich auch mal was ausprobieren, und hab Folgendes Template erstellt:

XML-Code:
<?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>
Eine Fehler drin seh ich auf Anhieb nicht. Aber ich kann das Template nicht nutzen. In der Template Liste in der IDE taucht mein Collection gar nicht auf.

Muss ich da noch was installieren ?

Jelly 11. Jan 2006 21:26

Re: Neues Live Template einbinden
 
Seltsam, irgendwie klappts beim zweiten Versuch. Am Code hab ich nichts verändert :gruebel:

Stinkt mir sehr nach Bug :coder:


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:53 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz