mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 08:59:35 +01:00
IDEIntf: TNewIDEItemCategory is no longer abstract. RegisterNewItemCategory now expects a real category class, needed for localization
git-svn-id: trunk@21069 -
This commit is contained in:
parent
69a4d44595
commit
475edb145e
@ -8,8 +8,7 @@ uses
|
||||
Classes, SysUtils, Forms;
|
||||
|
||||
Type
|
||||
TFormClass = Class of TForm;
|
||||
|
||||
|
||||
{ TCustomFormDescr }
|
||||
|
||||
TCustomFormDescr = Class
|
||||
@ -161,7 +160,9 @@ begin
|
||||
For I:=0 to CustomFormList.Count-1 do
|
||||
L.Add(TCustomFormDescr(CustomFormList[i]).Category);
|
||||
For I:=0 to L.Count-1 do
|
||||
RegisterNewItemCategory(L[i]);
|
||||
begin
|
||||
RegisterNewItemCategory(TNewIDEItemCategory.Create(L[i]));
|
||||
end;
|
||||
Finally
|
||||
L.Free;
|
||||
end;
|
||||
|
||||
@ -79,13 +79,13 @@ Resourcestring
|
||||
Procedure Register;
|
||||
|
||||
begin
|
||||
RegisterNewItemCategory(SDaemonApps);
|
||||
RegisterNewItemCategory(TNewIDEItemCategory.Create(SDaemonApps));
|
||||
RegisterProjectDescriptor(TDaemonProjectDescriptor.Create,SDaemonApps);
|
||||
RegisterProjectFileDescriptor(TDaemonFileDescriptor.Create,SDaemonApps);
|
||||
RegisterProjectFileDescriptor(TDaemonMapperDescriptor.Create,SDaemonApps);
|
||||
FormEditingHook.RegisterDesignerBaseClass(TDaemonMapper);
|
||||
FormEditingHook.RegisterDesignerBaseClass(TDaemon);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TDaemonFileDescriptor }
|
||||
|
||||
@ -50,26 +50,8 @@ type
|
||||
{ TNewLazIDEItemCategory }
|
||||
|
||||
TNewLazIDEItemCategory = class(TNewIDEItemCategory)
|
||||
private
|
||||
FItems: TList;
|
||||
protected
|
||||
function GetCount: integer; override;
|
||||
function GetItems(Index: integer): TNewIDEItemTemplate; override;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(const AName: string); override;
|
||||
destructor Destroy; override;
|
||||
procedure Clear; override;
|
||||
procedure Add(ATemplate: TNewIDEItemTemplate); override;
|
||||
function LocalizedName: string; override;
|
||||
function Description: string; override;
|
||||
function IndexOfTemplate(const TemplateName: string): integer; override;
|
||||
function FindTemplateByName(const TemplateName: string): TNewIDEItemTemplate; override;
|
||||
function IndexOfCategory(const CategoryName: string): integer; override;
|
||||
function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory; override;
|
||||
public
|
||||
property Count: integer Read GetCount;
|
||||
property Items[Index: integer]: TNewIDEItemTemplate Read GetItems; default;
|
||||
end;
|
||||
|
||||
|
||||
@ -86,7 +68,6 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Clear; override;
|
||||
procedure Add(ACategory: TNewIDEItemCategory); override;
|
||||
procedure Add(ACategoryName: string); override;
|
||||
function Count: integer; override;
|
||||
function IndexOf(const CategoryName: string): integer; override;
|
||||
function FindByName(const CategoryName: string): TNewIDEItemCategory; override;
|
||||
@ -401,58 +382,6 @@ end;
|
||||
|
||||
{ TNewLazIDEItemCategory }
|
||||
|
||||
function TNewLazIDEItemCategory.GetCount: integer;
|
||||
begin
|
||||
Result := FItems.Count;
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate;
|
||||
begin
|
||||
Result := TNewIDEItemTemplate(FItems[Index]);
|
||||
end;
|
||||
|
||||
constructor TNewLazIDEItemCategory.Create;
|
||||
begin
|
||||
raise Exception.Create('TNewLazIDEItemCategory.Create: call Create(Name) instead');
|
||||
end;
|
||||
|
||||
constructor TNewLazIDEItemCategory.Create(const AName: string);
|
||||
begin
|
||||
inherited Create(AName);
|
||||
FItems := TList.Create;
|
||||
FName := AName;
|
||||
//debugln('TNewLazIDEItemCategory.Create ',Name);
|
||||
end;
|
||||
|
||||
destructor TNewLazIDEItemCategory.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FItems.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TNewLazIDEItemCategory.Clear;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to FItems.Count - 1 do
|
||||
Items[i].Free;
|
||||
FItems.Clear;
|
||||
end;
|
||||
|
||||
procedure TNewLazIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate);
|
||||
begin
|
||||
//debugln('TNewLazIDEItemCategory.Add ',Name);
|
||||
FItems.Add(ATemplate);
|
||||
ATemplate.Category := Self;
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.LocalizedName: string;
|
||||
begin
|
||||
// ToDo:
|
||||
Result := Name;
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.Description: string;
|
||||
begin
|
||||
if Name = 'File' then
|
||||
@ -463,43 +392,6 @@ begin
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.IndexOfTemplate(const TemplateName: string): integer;
|
||||
begin
|
||||
Result:=FItems.Count-1;
|
||||
while (Result>=0) and (SysUtils.CompareText(Items[Result].Name,TemplateName)<>0) do
|
||||
dec(Result);
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.FindTemplateByName(
|
||||
const TemplateName: string): TNewIDEItemTemplate;
|
||||
var
|
||||
i: longint;
|
||||
begin
|
||||
i := IndexOfTemplate(TemplateName);
|
||||
if i >= 0 then
|
||||
Result := Items[i]
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.IndexOfCategory(const CategoryName: string
|
||||
): integer;
|
||||
begin
|
||||
Result:=-1; // Todo
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategory.FindCategoryByName(const CategoryName: string
|
||||
): TNewIDEItemCategory;
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i := IndexOfCategory(CategoryName);
|
||||
if i >= 0 then
|
||||
Result := nil // ToDo
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{ TNewLazIDEItemCategories }
|
||||
|
||||
function TNewLazIDEItemCategories.GetItems(Index: integer): TNewIDEItemCategory;
|
||||
@ -539,19 +431,6 @@ begin
|
||||
FItems.Add(ACategory);
|
||||
end;
|
||||
|
||||
procedure TNewLazIDEItemCategories.Add(ACategoryName: string);
|
||||
var
|
||||
I: integer;
|
||||
begin
|
||||
I := IndexOf(ACategoryName);
|
||||
if I <> -1 then
|
||||
begin
|
||||
Items[I].Free;
|
||||
FItems.Delete(I);
|
||||
end;
|
||||
Add(TNewLazIDEItemCategoryFile.Create(ACategoryName));
|
||||
end;
|
||||
|
||||
function TNewLazIDEItemCategories.Count: integer;
|
||||
begin
|
||||
Result := FItems.Count;
|
||||
|
||||
@ -22,7 +22,7 @@ unit NewItemIntf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
Classes, SysUtils, ObjInspStrConsts;
|
||||
|
||||
type
|
||||
// Flags/Options for the items
|
||||
@ -43,18 +43,20 @@ type
|
||||
FVisibleInNewDialog: boolean;
|
||||
protected
|
||||
FName: string;
|
||||
function GetCount: integer; virtual; abstract;
|
||||
function GetItems(Index: integer): TNewIDEItemTemplate; virtual; abstract;
|
||||
FItems: TFPList;
|
||||
function GetCount: integer; virtual;
|
||||
function GetItems(Index: integer): TNewIDEItemTemplate; virtual;
|
||||
public
|
||||
constructor Create(const AName: string); virtual;
|
||||
procedure Clear; virtual; abstract;
|
||||
procedure Add(ATemplate: TNewIDEItemTemplate); virtual; abstract;
|
||||
function LocalizedName: string; virtual; abstract;
|
||||
function Description: string; virtual; abstract;
|
||||
function IndexOfTemplate(const TemplateName: string): integer; virtual; abstract;
|
||||
function FindTemplateByName(const TemplateName: string): TNewIDEItemTemplate; virtual; abstract;
|
||||
function IndexOfCategory(const CategoryName: string): integer; virtual; abstract;
|
||||
function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory; virtual; abstract;
|
||||
destructor Destroy; override;
|
||||
procedure Clear; virtual;
|
||||
procedure Add(ATemplate: TNewIDEItemTemplate); virtual;
|
||||
function LocalizedName: string; virtual;
|
||||
function Description: string; virtual;
|
||||
function IndexOfTemplate(const TemplateName: string): integer; virtual;
|
||||
function FindTemplateByName(const TemplateName: string): TNewIDEItemTemplate; virtual;
|
||||
function IndexOfCategory(const CategoryName: string): integer; virtual;
|
||||
function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory; virtual;
|
||||
public
|
||||
property Count: integer read GetCount;
|
||||
property Items[Index: integer]: TNewIDEItemTemplate read GetItems; default;
|
||||
@ -72,7 +74,6 @@ type
|
||||
public
|
||||
procedure Clear; virtual; abstract;
|
||||
procedure Add(ACategory: TNewIDEItemCategory); virtual; abstract;
|
||||
Procedure Add(ACategoryName : String); virtual; abstract;
|
||||
function Count: integer; virtual; abstract;
|
||||
function IndexOf(const CategoryName: string): integer; virtual; abstract;
|
||||
function FindByName(const CategoryName: string): TNewIDEItemCategory; virtual; abstract;
|
||||
@ -123,13 +124,13 @@ procedure RegisterNewDialogItem(const Paths: string;
|
||||
NewItem: TNewIDEItemTemplate);
|
||||
procedure UnregisterNewDialogItem(NewItem: TNewIDEItemTemplate);
|
||||
|
||||
procedure RegisterNewItemCategory(const ACategory: String);
|
||||
procedure RegisterNewItemCategory(ACategory: TNewIDEItemCategory);
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
procedure RegisterNewItemCategory(const ACategory: String);
|
||||
procedure RegisterNewItemCategory(ACategory: TNewIDEItemCategory);
|
||||
begin
|
||||
NewIdeItems.Add(ACategory);
|
||||
end;
|
||||
@ -151,9 +152,91 @@ end;
|
||||
|
||||
{ TNewIDEItemCategory }
|
||||
|
||||
function TNewIDEItemCategory.GetCount: integer;
|
||||
begin
|
||||
Result:=FItems.Count;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate;
|
||||
begin
|
||||
Result:=TNewIDEItemTemplate(FItems[Index]);
|
||||
end;
|
||||
|
||||
constructor TNewIDEItemCategory.Create(const AName: string);
|
||||
begin
|
||||
FVisibleInNewDialog:=true;
|
||||
FItems := TFPList.Create;
|
||||
FName := AName;
|
||||
end;
|
||||
|
||||
destructor TNewIDEItemCategory.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FreeAndNil(FItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategory.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to FItems.Count - 1 do
|
||||
Items[i].Free;
|
||||
FItems.Clear;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate);
|
||||
begin
|
||||
FItems.Add(ATemplate);
|
||||
ATemplate.Category := Self;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.LocalizedName: string;
|
||||
begin
|
||||
Result:=Name;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.Description: string;
|
||||
begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.IndexOfTemplate(const TemplateName: string
|
||||
): integer;
|
||||
begin
|
||||
Result:=FItems.Count-1;
|
||||
while (Result>=0) and (SysUtils.CompareText(Items[Result].Name,TemplateName)<>0) do
|
||||
dec(Result);
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.FindTemplateByName(const TemplateName: string
|
||||
): TNewIDEItemTemplate;
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i := IndexOfTemplate(TemplateName);
|
||||
if i >= 0 then
|
||||
Result := Items[i]
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.IndexOfCategory(const CategoryName: string
|
||||
): integer;
|
||||
begin
|
||||
Result:=-1; // ToDo
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.FindCategoryByName(const CategoryName: string
|
||||
): TNewIDEItemCategory;
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i := IndexOfCategory(CategoryName);
|
||||
if i >= 0 then
|
||||
Result := nil // ToDo
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{ TNewIDEItemTemplate }
|
||||
|
||||
@ -451,6 +451,8 @@ resourcestring
|
||||
pirsDebugSearchPath = 'Debug search path';
|
||||
pirsLinkerOptions = 'Linker options';
|
||||
pirsCustomOptions = 'Custom options';
|
||||
oisIndexOutOfBounds = 'Index out of bounds';
|
||||
oisNotSupported = 'not supported';
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user