implemented registration functions for project, file and package types, added cgilazide package

git-svn-id: trunk@6282 -
This commit is contained in:
mattias 2004-11-22 21:39:40 +00:00
parent 259af31e44
commit a2102621c5
17 changed files with 568 additions and 412 deletions

5
.gitattributes vendored
View File

@ -3,6 +3,11 @@
components/README.txt svneol=native#text/plain components/README.txt svneol=native#text/plain
components/cgi/cgilaz.lpk svneol=native#text/pascal components/cgi/cgilaz.lpk svneol=native#text/pascal
components/cgi/cgimodules.pas svneol=native#text/pascal components/cgi/cgimodules.pas svneol=native#text/pascal
components/cgi/ide/README.txt svneol=native#text/plain
components/cgi/ide/cgilazide.lpk svneol=native#text/pascal
components/cgi/ide/cgilazideintf.pas svneol=native#text/pascal
components/cgi/ide/lib/README.txt svneol=native#text/plain
components/cgi/lib/README.txt svneol=native#text/plain
components/codetools/allcodetoolunits.pp svneol=native#text/pascal components/codetools/allcodetoolunits.pp svneol=native#text/pascal
components/codetools/basiccodetools.pas svneol=native#text/pascal components/codetools/basiccodetools.pas svneol=native#text/pascal
components/codetools/codeatom.pas svneol=native#text/pascal components/codetools/codeatom.pas svneol=native#text/pascal

View File

@ -1,6 +1,11 @@
cgi cgi
With the cgimodules.pas unit you can easily create cgi applications with With the cgimodules.pas unit you can easily create cgi applications with
datamodules and edit them in the IDE. datamodules.
In the IDE sub directory you can find a design time package, which will install
some helpful IDE features like 'CGI Application' and 'CGI Module'.

View File

@ -0,0 +1,16 @@
Package CGILazIDE
This package is a designtime package for the Lazarus IDE.
It adds a new project type and a new unit type to the IDE.
New Project Type:
CGI Application - A Free Pascal program for CGI
using TCgiApplication for the main source (normally hidden,
just like the .lpr file for a normal Application).
New Unit Type:
CGI Module - A unit with a TCGIDatamodule.

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="2">
<Name Value="CGILazIDE"/>
<CompilerOptions>
<Version Value="2"/>
<SearchPaths>
<UnitOutputDirectory Value="lib/"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="2">
<Item1>
<Filename Value="cgilazideintf.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="CGILazIDEIntf"/>
</Item1>
<Item2>
<Filename Value="README.txt"/>
<Type Value="Text"/>
</Item2>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="IDEIntf"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
<Item3>
<PackageName Value="cgiLaz"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,171 @@
{ Copyright (C) 2004 Mattias Gaertner
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Abstract:
This unit adds a new project type and a new unit type to the IDE.
New Project Type:
CGI Application - A Free Pascal program for CGI
using TCgiApplication for the main source (normally hidden,
just like the .lpr file for a normal Application).
New Unit Type:
CGI Module - A unit with a TCGIDatamodule.
See the README file for more information.
}
unit CGILazIDEIntf;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, cgiApp, cgiModules, LazIDEIntf, ProjectIntf, NewItemIntf;
type
{ TCGIApplicationDescriptor }
TCGIApplicationDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
procedure InitProject(AProject: TLazProject); override;
procedure CreateStartFiles(AProject: TLazProject); override;
end;
{ TFileDescPascalUnitWithCGIDataModule }
TFileDescPascalUnitWithCGIDataModule = class(TFileDescPascalUnitWithResource)
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
end;
var
ProjectDescriptorCGIApplication: TCGIApplicationDescriptor;
FileDescriptorCGIModule: TFileDescPascalUnitWithCGIDataModule;
procedure Register;
implementation
procedure Register;
begin
FileDescriptorCGIModule:=TFileDescPascalUnitWithCGIDataModule.Create;
RegisterProjectFileDescriptor(FileDescriptorCGIModule);
ProjectDescriptorCGIApplication:=TCGIApplicationDescriptor.Create;
RegisterProjectDescriptor(ProjectDescriptorCGIApplication);
end;
{ TCGIApplicationDescriptor }
constructor TCGIApplicationDescriptor.Create;
begin
inherited Create;
Name:='CGIApplication';
end;
function TCGIApplicationDescriptor.GetLocalizedName: string;
begin
Result:='CGi Application';
end;
function TCGIApplicationDescriptor.GetLocalizedDescription: string;
begin
Result:='CGi Application'#13#13'A CGI (Common Gateway Interface) program '
+'in Free Pascal. The program file is '
+'automatically maintained by Lazarus.';
end;
procedure TCGIApplicationDescriptor.InitProject(AProject: TLazProject);
var
le: string;
NewSource: String;
MainFile: TLazProjectFile;
begin
inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('cgiproject1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' cgiModules;'+le
+le
+'var'+le
+' Applicaton: TModuledCGIApplication;'+le
+'begin'+le
+' Application:=TModuledCGIApplication.Create(nil);'+le
+' Application.Initialize;'+le
+' Application.Run;'+le
+' Application.Free;'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
// add
AProject.AddPackageDependency('CGILaz');
// compiler options
AProject.LazCompilerOptions.Win32GraphicApp:=false;
end;
procedure TCGIApplicationDescriptor.CreateStartFiles(AProject: TLazProject);
begin
LazarusIDE.DoNewEditorFile(FileDescriptorCGIModule,'','',
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
end;
{ TFileDescPascalUnitWithCGIDataModule }
constructor TFileDescPascalUnitWithCGIDataModule.Create;
begin
inherited Create;
Name:='CGIModule';
ResourceClass:=TCGIDataModule;
UseCreateFormStatements:=true;
end;
function TFileDescPascalUnitWithCGIDataModule.GetInterfaceUsesSection: string;
begin
Result:=inherited GetInterfaceUsesSection;
Result:=Result+',cgiModules';
end;
function TFileDescPascalUnitWithCGIDataModule.GetLocalizedName: string;
begin
Result:='CGI Module';
end;
function TFileDescPascalUnitWithCGIDataModule.GetLocalizedDescription: string;
begin
Result:='CGi Module'#13
+'A datamodule for CGI applications.';
end;
end.

View File

@ -0,0 +1 @@
Output directory of package cgilazide

View File

@ -0,0 +1 @@
Output directory of package cgilaz

View File

@ -55,7 +55,7 @@ interface
// verbosity // verbosity
{ $DEFINE CTDEBUG} { $DEFINE CTDEBUG}
{ $DEFINE ShowTriedFiles} {$DEFINE ShowTriedFiles}
{ $DEFINE ShowTriedContexts} { $DEFINE ShowTriedContexts}
{ $DEFINE ShowTriedBaseContexts} { $DEFINE ShowTriedBaseContexts}
{ $DEFINE ShowTriedParentContexts} { $DEFINE ShowTriedParentContexts}

View File

@ -21,14 +21,15 @@
Author: Mattias Gaertner Author: Mattias Gaertner
Abstract: Abstract:
TJITForm - just-in-time form. JITForm - just-in-time form.
TJITDataModule = just-in-time datamodule Forms are the most common resources/design items in the IDE, hence the name.
Of course any TComponent descendant can be editid but naming it
This TForm descendent is used by the IDE as a template for creating forms 'JITComponent' would confuse new developers.
at run time (the designed forms).
Because the IDE does wild things with this form, like creating an own class Because the IDE does wild things with forms and datamodules, like creating
for each TJITForm and dynamically creating methods for it, you can't use an own class for each opened form/datamodule and dynamically creating
some special compiling modes like -pg (gprof) with it. methods for it, you can't use some special compiling modes like -pg (gprof)
with this unit.
Therefore this unit is kept in a directory of its own. Therefore this unit is kept in a directory of its own.
} }
unit JITForm; unit JITForm;
@ -41,26 +42,6 @@ uses
Classes, SysUtils, Forms, Controls; Classes, SysUtils, Forms, Controls;
type type
// TJITForm is a template TForm descendent class that can be altered at
// runtime
// OBSOLETE:
{TJITForm = class(TForm)
public
end;
TJITFormClass = class of TJITForm;
// TJITDataModule is a template TDataModule descendent class that can be
// altered at runtime
// OBSOLETE:
TJITDataModule = class(TDataModule)
public
end;
TJITDataModuleClass = class of TJITDataModule;}
// TPersistentWithTemplates // TPersistentWithTemplates
TPersistentWithTemplates = class(TPersistent) TPersistentWithTemplates = class(TPersistent)
published published

View File

@ -70,14 +70,14 @@ uses
DefineTemplates, DefineTemplates,
// IDE interface // IDE interface
AllIDEIntf, ObjectInspector, PropEdits, IDECommands, SrcEditorIntf, AllIDEIntf, ObjectInspector, PropEdits, IDECommands, SrcEditorIntf,
LazIDEIntf, NewItemIntf, PackageIntf, ProjectIntf, LazIDEIntf,
// synedit // synedit
SynEditKeyCmds, SynEditKeyCmds,
// compile // compile
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts, Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
ImExportCompilerOpts, ImExportCompilerOpts,
// projects // projects
ProjectIntf, Project, ProjectDefs, NewProjectDlg, ProjectOpts, Project, ProjectDefs, NewProjectDlg, ProjectOpts,
PublishProjectDlg, ProjectInspector, PublishProjectDlg, ProjectInspector,
// help manager // help manager
HelpManager, HelpManager,
@ -959,7 +959,7 @@ begin
ConnectMainBarEvents; ConnectMainBarEvents;
// create main IDE register items // create main IDE register items
NewIDEItems:=TNewIDEItemCategories.Create; NewIDEItems:=TNewLazIDEItemCategories.Create;
SetupStandardProjectTypes; SetupStandardProjectTypes;
// initialize the other IDE managers // initialize the other IDE managers
@ -1548,69 +1548,23 @@ begin
end; end;
procedure TMainIDE.SetupStandardProjectTypes; procedure TMainIDE.SetupStandardProjectTypes;
var
FileDescPascalUnit: TFileDescPascalUnit;
FileDescPascalUnitWithForm: TFileDescPascalUnitWithForm;
FileDescPascalUnitWithDataModule: TFileDescPascalUnitWithDataModule;
FileDescText: TFileDescText;
FileDescSimplePascalProgram: TFileDescSimplePascalProgram;
ProjDescApplication: TProjectApplicationDescriptor;
ProjDescProgram: TProjectProgramDescriptor;
ProjDescCustomProgram: TProjectManualProgramDescriptor;
i: Integer;
NewItemFile: TNewItemProjectFile;
NewItemProject: TNewItemProject;
FileItem: TProjectFileDescriptor;
ProjectItem: TProjectDescriptor;
begin begin
// file descriptors ---------------------------------------------------------- NewIDEItems.Add(TNewLazIDEItemCategoryFile.Create(FileDescGroupName));
NewIDEItems.Add(TNewLazIDEItemCategoryProject.Create(ProjDescGroupName));
// file descriptors
LazProjectFileDescriptors:=TLazProjectFileDescriptors.Create; LazProjectFileDescriptors:=TLazProjectFileDescriptors.Create;
// basic pascal unit RegisterProjectFileDescriptor(TFileDescPascalUnit.Create);
FileDescPascalUnit:=TFileDescPascalUnit.Create; RegisterProjectFileDescriptor(TFileDescPascalUnitWithForm.Create);
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescPascalUnit); RegisterProjectFileDescriptor(TFileDescPascalUnitWithDataModule.Create);
// pascal unit with form RegisterProjectFileDescriptor(TFileDescSimplePascalProgram.Create);
FileDescPascalUnitWithForm:=TFileDescPascalUnitWithForm.Create; RegisterProjectFileDescriptor(TFileDescText.Create);
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescPascalUnitWithForm);
// pascal unit with datamodule // project descriptors
FileDescPascalUnitWithDataModule:=TFileDescPascalUnitWithDataModule.Create;
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescPascalUnitWithDataModule);
// simple pascal program
FileDescSimplePascalProgram:=TFileDescSimplePascalProgram.Create;
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescSimplePascalProgram);
// empty text file
FileDescText:=TFileDescText.Create;
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescText);
// project descriptors -------------------------------------------------------
LazProjectDescriptors:=TLazProjectDescriptors.Create; LazProjectDescriptors:=TLazProjectDescriptors.Create;
// application RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
ProjDescApplication:=TProjectApplicationDescriptor.Create; RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
LazProjectDescriptors.RegisterDescriptor(ProjDescApplication); RegisterProjectDescriptor(TProjectManualProgramDescriptor.Create);
// program
ProjDescProgram:=TProjectProgramDescriptor.Create;
LazProjectDescriptors.RegisterDescriptor(ProjDescProgram);
// custom program
ProjDescCustomProgram:=TProjectManualProgramDescriptor.Create;
LazProjectDescriptors.RegisterDescriptor(ProjDescCustomProgram);
NewIDEItems.Add(TNewIDEItemCategoryFile.Create('File'));
NewIDEItems.Add(TNewIDEItemCategoryProject.Create('Project'));
// TODO: move this mechanism to LazProjectFileDescriptors.RegisterFileDescriptor
for i:=0 to LazProjectFileDescriptors.Count-1 do begin
FileItem:=LazProjectFileDescriptors[i];
if not FileItem.VisibleInNewDialog then continue;
NewItemFile:=TNewItemProjectFile.Create(FileItem.Name,niifCopy,[niifCopy]);
NewItemFile.Descriptor:=FileItem;
RegisterNewDialogItem('File',NewItemFile);
end;
for i:=0 to LazProjectDescriptors.Count-1 do begin
ProjectItem:=LazProjectDescriptors[i];
if not ProjectItem.VisibleInNewDialog then continue;
NewItemProject:=TNewItemProject.Create(ProjectItem.Name,niifCopy,[niifCopy]);
NewItemProject.Descriptor:=ProjectItem;
RegisterNewDialogItem('Project',NewItemProject);
end;
end; end;
procedure TMainIDE.SetRecentFilesMenu; procedure TMainIDE.SetRecentFilesMenu;
@ -11011,6 +10965,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.796 2004/11/22 21:39:39 mattias
implemented registration functions for project, file and package types, added cgilazide package
Revision 1.795 2004/11/20 11:49:15 mattias Revision 1.795 2004/11/20 11:49:15 mattias
implemented stopping project on close project implemented stopping project on close project

View File

@ -41,57 +41,28 @@ interface
uses uses
Classes, SysUtils, LCLProc, Forms, Controls, StdCtrls, Buttons, ComCtrls, Classes, SysUtils, LCLProc, Forms, Controls, StdCtrls, Buttons, ComCtrls,
Dialogs, LResources, ProjectIntf, PackageIntf, Dialogs, LResources, ProjectIntf, PackageIntf, NewItemIntf,
IDEOptionDefs, LazarusIDEStrConsts; IDEOptionDefs, LazarusIDEStrConsts;
type type
// Items that can be created in the IDE: { TNewLazIDEItemCategory }
{TNewIDEItemType = (
niiNone,
niiCustom, // for experts (IDE plugins)
niiUnit, // pascal unit
niiForm, // pascal unit with lcl form
niiDataModule, // pascal nuit with datamodule
niiText, // text file
niiApplication,// Project: Application
niiFPCProject, // Project: with hidden main file
niiCustomProject,// Project: pascal program without any specials
niiPackage // standard package
);
TNewIDEItemTypes = set of TNewIDEItemType;}
// Flags/Options for the items TNewLazIDEItemCategory = class(TNewIDEItemCategory)
TNewIDEItemFlag = (
niifCopy,
niifInherited,
niifUse
);
TNewIDEItemFlags = set of TNewIDEItemFlag;
TNewIDEItemTemplate = class;
{ TNewIDEItemCategory }
TNewIDEItemCategory = class
private private
FItems: TList; FItems: TList;
FName: string; protected
function GetCount: integer; function GetCount: integer; override;
function GetItems(Index: integer): TNewIDEItemTemplate; function GetItems(Index: integer): TNewIDEItemTemplate; override;
public public
constructor Create; constructor Create;
constructor Create(const AName: string); constructor Create(const AName: string); override;
destructor Destroy; override; destructor Destroy; override;
procedure Clear; procedure Clear; override;
procedure Add(ATemplate: TNewIDEItemTemplate); procedure Add(ATemplate: TNewIDEItemTemplate); override;
function LocalizedName: string; virtual; function LocalizedName: string; override;
function Description: string; virtual; function Description: string; override;
function IndexOfCategory(const CategoryName: string): integer; function IndexOfCategory(const CategoryName: string): integer; override;
function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory; function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory; override;
public public
property Count: integer read GetCount; property Count: integer read GetCount;
property Items[Index: integer]: TNewIDEItemTemplate read GetItems; default; property Items[Index: integer]: TNewIDEItemTemplate read GetItems; default;
@ -99,123 +70,56 @@ type
end; end;
{ TNewIDEItemCategories } { TNewLazIDEItemCategories }
TNewIDEItemCategories = class TNewLazIDEItemCategories = class(TNewIDEItemCategories)
private private
FItems: TList; FItems: TList;
function GetItems(Index: integer): TNewIDEItemCategory; protected
procedure SetItems(Index: integer; const AValue: TNewIDEItemCategory); function GetItems(Index: integer): TNewIDEItemCategory; override;
procedure SetItems(Index: integer; const AValue: TNewIDEItemCategory); override;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Clear; procedure Clear; override;
procedure Add(ACategory: TNewIDEItemCategory); procedure Add(ACategory: TNewIDEItemCategory); override;
function Count: integer; function Count: integer; override;
function IndexOf(const CategoryName: string): integer; function IndexOf(const CategoryName: string): integer; override;
function FindByName(const CategoryName: string): TNewIDEItemCategory; function FindByName(const CategoryName: string): TNewIDEItemCategory; override;
procedure RegisterItem(const Paths: string; NewItem: TNewIDEItemTemplate); procedure RegisterItem(const Paths: string; NewItem: TNewIDEItemTemplate); override;
procedure UnregisterItem(NewItem: TNewIDEItemTemplate); procedure UnregisterItem(NewItem: TNewIDEItemTemplate); override;
function FindCategoryByPath(const Path: string; function FindCategoryByPath(const Path: string;
ErrorOnNotFound: boolean): TNewIDEItemCategory; ErrorOnNotFound: boolean): TNewIDEItemCategory; override;
public
property Items[Index: integer]: TNewIDEItemCategory
read GetItems write SetItems; default;
end; end;
{ TNewIDEItemTemplate }
TNewIDEItemTemplate = class(TPersistent)
private
FAllowedFlags: TNewIDEItemFlags;
FDefaultFlag: TNewIDEItemFlag;
FName: string;
fCategory: TNewIDEItemCategory;
public
constructor Create(const AName: string; ADefaultFlag: TNewIDEItemFlag;
TheAllowedFlags: TNewIDEItemFlags);
function LocalizedName: string; virtual;
function Description: string; virtual;
function CreateCopy: TNewIDEItemTemplate; virtual;
procedure Assign(Source: TPersistent); override;
public
property DefaultFlag: TNewIDEItemFlag read FDefaultFlag;
property AllowedFlags: TNewIDEItemFlags read FAllowedFlags;
property Name: string read FName;
property Category: TNewIDEItemCategory read fCategory; // main category
end;
TNewIDEItemTemplateClass = class of TNewIDEItemTemplate;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// standard categories for new dialog // standard categories for new dialog
{ TNewIDEItemCategoryFile } { TNewLazIDEItemCategoryFile }
TNewIDEItemCategoryFile = class(TNewIDEItemCategory) TNewLazIDEItemCategoryFile = class(TNewLazIDEItemCategory)
public public
function LocalizedName: string; override; function LocalizedName: string; override;
function Description: string; override; function Description: string; override;
end; end;
{ TNewIDEItemCategoryProject } { TNewLazIDEItemCategoryProject }
TNewIDEItemCategoryProject = class(TNewIDEItemCategory) TNewLazIDEItemCategoryProject = class(TNewLazIDEItemCategory)
public public
function LocalizedName: string; override; function LocalizedName: string; override;
function Description: string; override; function Description: string; override;
end; end;
{ TNewIDEItemCategoryPackage } { TNewLazIDEItemCategoryPackage }
TNewIDEItemCategoryPackage = class(TNewIDEItemCategory) TNewLazIDEItemCategoryPackage = class(TNewLazIDEItemCategory)
public public
function LocalizedName: string; override; function LocalizedName: string; override;
function Description: string; override; function Description: string; override;
end; end;
//----------------------------------------------------------------------------
// standard items for new dialog
{ TNewItemProjectFile - a new item for project file descriptors }
TNewItemProjectFile = class(TNewIDEItemTemplate)
private
FDescriptor: TProjectFileDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TProjectFileDescriptor read FDescriptor write FDescriptor;
end;
{ TNewItemProject - a new item for project descriptors }
TNewItemProject = class(TNewIDEItemTemplate)
private
FDescriptor: TProjectDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TProjectDescriptor read FDescriptor write FDescriptor;
end;
{ TNewItemPackage - a new item for package descriptors }
TNewItemPackage = class(TNewIDEItemTemplate)
private
FDescriptor: TPackageDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TPackageDescriptor read FDescriptor write FDescriptor;
end;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -243,13 +147,6 @@ type
function ShowNewIDEItemDialog(var NewItem: TNewIDEItemTemplate): TModalResult; function ShowNewIDEItemDialog(var NewItem: TNewIDEItemTemplate): TModalResult;
var
NewIDEItems: TNewIDEItemCategories;// will be set by the IDE
procedure RegisterNewDialogItem(const Paths: string;
NewItem: TNewIDEItemTemplate);
procedure UnregisterNewDialogItem(NewItem: TNewIDEItemTemplate);
implementation implementation
@ -268,21 +165,6 @@ begin
NewOtherDialog.Free; NewOtherDialog.Free;
end; end;
procedure RegisterNewDialogItem(const Paths: string;
NewItem: TNewIDEItemTemplate);
begin
if NewIDEItems=nil then
raise Exception.Create('RegisterNewDialogItem NewIDEItems=nil');
NewIDEItems.RegisterItem(Paths,NewItem);
end;
procedure UnregisterNewDialogItem(NewItem: TNewIDEItemTemplate);
begin
if NewIDEItems=nil then
raise Exception.Create('RegisterNewDialogItem NewIDEItems=nil');
NewIDEItems.UnregisterItem(NewItem);
end;
{ TNewOtherDialog } { TNewOtherDialog }
procedure TNewOtherDialog.NewOtherDialogResize(Sender: TObject); procedure TNewOtherDialog.NewOtherDialogResize(Sender: TObject);
@ -359,8 +241,8 @@ var
begin begin
ANode:=ItemsTreeView.Selected; ANode:=ItemsTreeView.Selected;
if (ANode<>nil) and (ANode.Data<>nil) then begin if (ANode<>nil) and (ANode.Data<>nil) then begin
if TObject(ANode.Data) is TNewIDEItemCategory then if TObject(ANode.Data) is TNewLazIDEItemCategory then
Desc:=TNewIDEItemCategory(ANode.Data).Description Desc:=TNewLazIDEItemCategory(ANode.Data).Description
else else
Desc:=TNewIDEItemTemplate(ANode.Data).Description; Desc:=TNewIDEItemTemplate(ANode.Data).Description;
end else begin end else begin
@ -452,38 +334,38 @@ begin
Result:=TNewIDEItemTemplate(ANode.Data).CreateCopy; Result:=TNewIDEItemTemplate(ANode.Data).CreateCopy;
end; end;
{ TNewIDEItemCategory } { TNewLazIDEItemCategory }
function TNewIDEItemCategory.GetCount: integer; function TNewLazIDEItemCategory.GetCount: integer;
begin begin
Result:=FItems.Count; Result:=FItems.Count;
end; end;
function TNewIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate; function TNewLazIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate;
begin begin
Result:=TNewIDEItemTemplate(FItems[Index]); Result:=TNewIDEItemTemplate(FItems[Index]);
end; end;
constructor TNewIDEItemCategory.Create; constructor TNewLazIDEItemCategory.Create;
begin begin
raise Exception.Create('TNewIDEItemCategory.Create: call Create(Name) instead'); raise Exception.Create('TNewLazIDEItemCategory.Create: call Create(Name) instead');
end; end;
constructor TNewIDEItemCategory.Create(const AName: string); constructor TNewLazIDEItemCategory.Create(const AName: string);
begin begin
FItems:=TList.Create; FItems:=TList.Create;
FName:=AName; FName:=AName;
//debugln('TNewIDEItemCategory.Create ',Name); //debugln('TNewLazIDEItemCategory.Create ',Name);
end; end;
destructor TNewIDEItemCategory.Destroy; destructor TNewLazIDEItemCategory.Destroy;
begin begin
Clear; Clear;
FItems.Free; FItems.Free;
inherited Destroy; inherited Destroy;
end; end;
procedure TNewIDEItemCategory.Clear; procedure TNewLazIDEItemCategory.Clear;
var var
i: Integer; i: Integer;
begin begin
@ -491,20 +373,20 @@ begin
FItems.Clear; FItems.Clear;
end; end;
procedure TNewIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate); procedure TNewLazIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate);
begin begin
//debugln('TNewIDEItemCategory.Add ',Name); //debugln('TNewLazIDEItemCategory.Add ',Name);
FItems.Add(ATemplate); FItems.Add(ATemplate);
ATemplate.fCategory:=Self; ATemplate.Category:=Self;
end; end;
function TNewIDEItemCategory.LocalizedName: string; function TNewLazIDEItemCategory.LocalizedName: string;
begin begin
// ToDo: // ToDo:
Result:=Name; Result:=Name;
end; end;
function TNewIDEItemCategory.Description: string; function TNewLazIDEItemCategory.Description: string;
begin begin
if Name='File' then begin if Name='File' then begin
Result:=Format(lisNewDlgCreateANewEditorFileChooseAType, [#13]); Result:=Format(lisNewDlgCreateANewEditorFileChooseAType, [#13]);
@ -514,14 +396,14 @@ begin
Result:=''; Result:='';
end; end;
function TNewIDEItemCategory.IndexOfCategory(const CategoryName: string function TNewLazIDEItemCategory.IndexOfCategory(const CategoryName: string
): integer; ): integer;
begin begin
// TODO // TODO
Result:=-1; Result:=-1;
end; end;
function TNewIDEItemCategory.FindCategoryByName(const CategoryName: string function TNewLazIDEItemCategory.FindCategoryByName(const CategoryName: string
): TNewIDEItemCategory; ): TNewIDEItemCategory;
var var
i: LongInt; i: LongInt;
@ -533,73 +415,32 @@ begin
Result:=nil; Result:=nil;
end; end;
{ TNewIDEItemTemplate } { TNewLazIDEItemCategories }
constructor TNewIDEItemTemplate.Create(const AName: string; function TNewLazIDEItemCategories.GetItems(Index: integer): TNewIDEItemCategory;
ADefaultFlag: TNewIDEItemFlag; TheAllowedFlags: TNewIDEItemFlags);
begin
FName:=AName;
FDefaultFlag:=ADefaultFlag;
FAllowedFlags:=TheAllowedFlags;
Include(FAllowedFlags,FDefaultFlag);
end;
function TNewIDEItemTemplate.LocalizedName: string;
begin
Result:=Name;
end;
function TNewIDEItemTemplate.Description: string;
begin
Result:='<Description not set>';
end;
function TNewIDEItemTemplate.CreateCopy: TNewIDEItemTemplate;
begin
Result:=TNewIDEItemTemplateClass(ClassType).Create(
Name,DefaultFlag,AllowedFlags);
Result.Assign(Self);
end;
procedure TNewIDEItemTemplate.Assign(Source: TPersistent);
var
Src: TNewIDEItemTemplate;
begin
if Source is TNewIDEItemTemplate then begin
Src:=TNewIDEItemTemplate(Source);
FName:=Src.Name;
FDefaultFlag:=Src.DefaultFlag;
FAllowedFlags:=Src.AllowedFlags;
end else
inherited Assign(Source);
end;
{ TNewIDEItemCategories }
function TNewIDEItemCategories.GetItems(Index: integer): TNewIDEItemCategory;
begin begin
Result:=TNewIDEItemCategory(FItems[Index]); Result:=TNewIDEItemCategory(FItems[Index]);
end; end;
procedure TNewIDEItemCategories.SetItems(Index: integer; procedure TNewLazIDEItemCategories.SetItems(Index: integer;
const AValue: TNewIDEItemCategory); const AValue: TNewIDEItemCategory);
begin begin
FItems[Index]:=AValue; FItems[Index]:=AValue;
end; end;
constructor TNewIDEItemCategories.Create; constructor TNewLazIDEItemCategories.Create;
begin begin
FItems:=TList.Create; FItems:=TList.Create;
end; end;
destructor TNewIDEItemCategories.Destroy; destructor TNewLazIDEItemCategories.Destroy;
begin begin
Clear; Clear;
FItems.Free; FItems.Free;
inherited Destroy; inherited Destroy;
end; end;
procedure TNewIDEItemCategories.Clear; procedure TNewLazIDEItemCategories.Clear;
var var
i: Integer; i: Integer;
begin begin
@ -607,24 +448,24 @@ begin
FItems.Clear; FItems.Clear;
end; end;
procedure TNewIDEItemCategories.Add(ACategory: TNewIDEItemCategory); procedure TNewLazIDEItemCategories.Add(ACategory: TNewIDEItemCategory);
begin begin
FItems.Add(ACategory); FItems.Add(ACategory);
end; end;
function TNewIDEItemCategories.Count: integer; function TNewLazIDEItemCategories.Count: integer;
begin begin
Result:=FItems.Count; Result:=FItems.Count;
end; end;
function TNewIDEItemCategories.IndexOf(const CategoryName: string): integer; function TNewLazIDEItemCategories.IndexOf(const CategoryName: string): integer;
begin begin
Result:=Count-1; Result:=Count-1;
while (Result>=0) and (AnsiCompareText(CategoryName,Items[Result].Name)<>0) do while (Result>=0) and (AnsiCompareText(CategoryName,Items[Result].Name)<>0) do
dec(Result); dec(Result);
end; end;
function TNewIDEItemCategories.FindByName(const CategoryName: string function TNewLazIDEItemCategories.FindByName(const CategoryName: string
): TNewIDEItemCategory; ): TNewIDEItemCategory;
var var
i: LongInt; i: LongInt;
@ -636,7 +477,7 @@ begin
Result:=nil; Result:=nil;
end; end;
procedure TNewIDEItemCategories.RegisterItem(const Paths: string; procedure TNewLazIDEItemCategories.RegisterItem(const Paths: string;
NewItem: TNewIDEItemTemplate); NewItem: TNewIDEItemTemplate);
procedure AddToPath(const Path: string); procedure AddToPath(const Path: string);
@ -668,12 +509,12 @@ begin
end; end;
end; end;
procedure TNewIDEItemCategories.UnregisterItem(NewItem: TNewIDEItemTemplate); procedure TNewLazIDEItemCategories.UnregisterItem(NewItem: TNewIDEItemTemplate);
begin begin
raise Exception.Create('TODO TNewIDEItemCategories.UnregisterItem'); raise Exception.Create('TODO TNewLazIDEItemCategories.UnregisterItem');
end; end;
function TNewIDEItemCategories.FindCategoryByPath(const Path: string; function TNewLazIDEItemCategories.FindCategoryByPath(const Path: string;
ErrorOnNotFound: boolean): TNewIDEItemCategory; ErrorOnNotFound: boolean): TNewIDEItemCategory;
var var
StartPos: Integer; StartPos: Integer;
@ -706,95 +547,38 @@ begin
end; end;
end; end;
{ TNewItemProjectFile } { TNewLazIDEItemCategoryFile }
function TNewItemProjectFile.LocalizedName: string; function TNewLazIDEItemCategoryFile.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemProjectFile.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemProjectFile.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemProjectFile then
FDescriptor:=TNewItemProjectFile(Source).Descriptor;
end;
{ TNewItemProject }
function TNewItemProject.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemProject.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemProject.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemProject then
FDescriptor:=TNewItemProject(Source).Descriptor;
end;
{ TNewItemPackage }
function TNewItemPackage.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemPackage.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemPackage.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemPackage then
FDescriptor:=TNewItemPackage(Source).Descriptor;
end;
{ TNewIDEItemCategoryFile }
function TNewIDEItemCategoryFile.LocalizedName: string;
begin begin
Result:='File'; Result:='File';
end; end;
function TNewIDEItemCategoryFile.Description: string; function TNewLazIDEItemCategoryFile.Description: string;
begin begin
Result:='Choose one of these items to create a new File'; Result:='Choose one of these items to create a new File';
end; end;
{ TNewIDEItemCategoryProject } { TNewLazIDEItemCategoryProject }
function TNewIDEItemCategoryProject.LocalizedName: string; function TNewLazIDEItemCategoryProject.LocalizedName: string;
begin begin
Result:='Project'; Result:='Project';
end; end;
function TNewIDEItemCategoryProject.Description: string; function TNewLazIDEItemCategoryProject.Description: string;
begin begin
Result:='Choose one of these items to create a new Project'; Result:='Choose one of these items to create a new Project';
end; end;
{ TNewIDEItemCategoryPackage } { TNewLazIDEItemCategoryPackage }
function TNewIDEItemCategoryPackage.LocalizedName: string; function TNewLazIDEItemCategoryPackage.LocalizedName: string;
begin begin
Result:='Package'; Result:='Package';
end; end;
function TNewIDEItemCategoryPackage.Description: string; function TNewLazIDEItemCategoryPackage.Description: string;
begin begin
Result:='Choose one of these items to create a new Package'; Result:='Choose one of these items to create a new Package';
end; end;

View File

@ -38,7 +38,7 @@ interface
uses uses
Classes, SysUtils, Laz_XMLCfg, Forms, SynRegExpr, FileUtil, LCLProc, Classes, SysUtils, Laz_XMLCfg, Forms, SynRegExpr, FileUtil, LCLProc,
ProjectIntf, NewItemIntf, ProjectIntf,
LazarusIDEStrConsts, PublishModule; LazarusIDEStrConsts, PublishModule;
type type
@ -79,6 +79,7 @@ type
function Count: integer; override; function Count: integer; override;
function GetUniqueName(const Name: string): string; override; function GetUniqueName(const Name: string): string; override;
function IndexOf(const Name: string): integer; override; function IndexOf(const Name: string): integer; override;
function IndexOf(FileDescriptor: TProjectFileDescriptor): integer; override;
function FindByName(const Name: string): TProjectFileDescriptor; override; function FindByName(const Name: string): TProjectFileDescriptor; override;
procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override; procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override;
procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override; procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override;
@ -87,6 +88,7 @@ type
property DefaultPascalFileExt: string read FDefaultPascalFileExt write SetDefaultPascalFileExt; property DefaultPascalFileExt: string read FDefaultPascalFileExt write SetDefaultPascalFileExt;
end; end;
{ TLazProjectDescriptors } { TLazProjectDescriptors }
TLazProjectDescriptors = class(TProjectDescriptors) TLazProjectDescriptors = class(TProjectDescriptors)
@ -101,6 +103,7 @@ type
function Count: integer; override; function Count: integer; override;
function GetUniqueName(const Name: string): string; override; function GetUniqueName(const Name: string): string; override;
function IndexOf(const Name: string): integer; override; function IndexOf(const Name: string): integer; override;
function IndexOf(Descriptor: TProjectDescriptor): integer; override;
function FindByName(const Name: string): TProjectDescriptor; override; function FindByName(const Name: string): TProjectDescriptor; override;
procedure RegisterDescriptor(Descriptor: TProjectDescriptor); override; procedure RegisterDescriptor(Descriptor: TProjectDescriptor); override;
procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); override; procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); override;
@ -999,6 +1002,14 @@ begin
dec(Result); dec(Result);
end; end;
function TLazProjectFileDescriptors.IndexOf(
FileDescriptor: TProjectFileDescriptor): integer;
begin
Result:=Count-1;
while (Result>=0) and (Items[Result]<>FileDescriptor) do
dec(Result);
end;
function TLazProjectFileDescriptors.FindByName(const Name: string function TLazProjectFileDescriptors.FindByName(const Name: string
): TProjectFileDescriptor; ): TProjectFileDescriptor;
var var
@ -1020,11 +1031,19 @@ begin
raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor.Name empty'); raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor.Name empty');
if FileDescriptor.DefaultFilename='' then if FileDescriptor.DefaultFilename='' then
raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor.DefaultFilename empty'); raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor.DefaultFilename empty');
if IndexOf(FileDescriptor)>=0 then
raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor already registered');
// make name unique
FileDescriptor.Name:=GetUniqueName(FileDescriptor.Name); FileDescriptor.Name:=GetUniqueName(FileDescriptor.Name);
DefPasExt:=DefaultPascalFileExt; DefPasExt:=DefaultPascalFileExt;
if DefPasExt<>'' then if DefPasExt<>'' then
FileDescriptor.UpdateDefaultPascalFileExtension(DefPasExt); FileDescriptor.UpdateDefaultPascalFileExtension(DefPasExt);
FItems.Add(FileDescriptor); FItems.Add(FileDescriptor);
// register ResourceClass, so that the IDE knows, what means
// '= class(<ResourceClass.ClassName>)'
if FileDescriptor.ResourceClass<>nil then
RegisterClass(FileDescriptor.ResourceClass);
end; end;
procedure TLazProjectFileDescriptors.UnregisterFileDescriptor( procedure TLazProjectFileDescriptors.UnregisterFileDescriptor(
@ -1100,6 +1119,14 @@ begin
dec(Result); dec(Result);
end; end;
function TLazProjectDescriptors.IndexOf(Descriptor: TProjectDescriptor
): integer;
begin
Result:=Count-1;
while (Result>=0) and (Items[Result]<>Descriptor) do
dec(Result);
end;
function TLazProjectDescriptors.FindByName(const Name: string function TLazProjectDescriptors.FindByName(const Name: string
): TProjectDescriptor; ): TProjectDescriptor;
var var
@ -1117,8 +1144,12 @@ procedure TLazProjectDescriptors.RegisterDescriptor(
begin begin
if Descriptor.Name='' then if Descriptor.Name='' then
raise Exception.Create('TLazProjectDescriptors.RegisterDescriptor Descriptor.Name empty'); raise Exception.Create('TLazProjectDescriptors.RegisterDescriptor Descriptor.Name empty');
if IndexOf(Descriptor)>=0 then
raise Exception.Create('TLazProjectDescriptors.RegisterDescriptor Descriptor already registered');
Descriptor.Name:=GetUniqueName(Descriptor.Name); Descriptor.Name:=GetUniqueName(Descriptor.Name);
FItems.Add(Descriptor); FItems.Add(Descriptor);
if Descriptor.VisibleInNewDialog then
;
end; end;
procedure TLazProjectDescriptors.UnregisterDescriptor( procedure TLazProjectDescriptors.UnregisterDescriptor(

View File

@ -23,7 +23,7 @@ uses
ComponentEditors, GraphPropEdits, ListViewPropEdit, ImageListEditor, ComponentEditors, GraphPropEdits, ListViewPropEdit, ImageListEditor,
ComponentTreeView, ActionsEditor, HelpIntf, TextTools, FormEditingIntf, ComponentTreeView, ActionsEditor, HelpIntf, TextTools, FormEditingIntf,
SrcEditorIntf, ComponentReg, PackageIntf, HelpHTML, ConfigStorage, SrcEditorIntf, ComponentReg, PackageIntf, HelpHTML, ConfigStorage,
HelpFPDoc, ProjectIntf, LazIDEIntf; HelpFPDoc, ProjectIntf, LazIDEIntf, NewItemIntf;
implementation implementation

View File

@ -38,9 +38,10 @@ unit PackageIntf;
interface interface
uses uses
Classes, SysUtils, Forms; Classes, SysUtils, Forms, NewItemIntf;
const const
PkgDescGroupName = 'Package';
PkgDescNameStandard = 'Standard Package'; PkgDescNameStandard = 'Standard Package';
type type
@ -81,6 +82,22 @@ type
property Name: string read FName write SetName; property Name: string read FName write SetName;
property VisibleInNewDialog: boolean read FVisibleInNewDialog write FVisibleInNewDialog; property VisibleInNewDialog: boolean read FVisibleInNewDialog write FVisibleInNewDialog;
end; end;
TPackageDescriptorClass = class of TPackageDescriptor;
{ TNewItemPackage - a new item for package descriptors }
TNewItemPackage = class(TNewIDEItemTemplate)
private
FDescriptor: TPackageDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TPackageDescriptor read FDescriptor write FDescriptor;
end;
{ TPackageDescriptors } { TPackageDescriptors }
@ -101,10 +118,26 @@ type
var var
PackageDescriptors: TPackageDescriptors; // will be set by the IDE PackageDescriptors: TPackageDescriptors; // will be set by the IDE
procedure RegisterPackageDescriptor(PkgDesc: TPackageDescriptor);
function PackageDescriptorStd: TPackageDescriptor; function PackageDescriptorStd: TPackageDescriptor;
implementation implementation
procedure RegisterPackageDescriptor(PkgDesc: TPackageDescriptor);
var
NewItemPkg: TNewItemPackage;
begin
PackageDescriptors.RegisterDescriptor(PkgDesc);
if PkgDesc.VisibleInNewDialog then begin
NewItemPkg:=TNewItemPackage.Create(PkgDesc.Name,niifCopy,[niifCopy]);
NewItemPkg.Descriptor:=PkgDesc;
RegisterNewDialogItem(PkgDescGroupName,NewItemPkg);
end;
end;
function PackageDescriptorStd: TPackageDescriptor; function PackageDescriptorStd: TPackageDescriptor;
begin begin
Result:=PackageDescriptors.FindByName(PkgDescNameStandard); Result:=PackageDescriptors.FindByName(PkgDescNameStandard);
@ -148,6 +181,25 @@ begin
inc(FReferenceCount); inc(FReferenceCount);
end; end;
{ TNewItemPackage }
function TNewItemPackage.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemPackage.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemPackage.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemPackage then
FDescriptor:=TNewItemPackage(Source).Descriptor;
end;
initialization initialization
PackageEditingInterface:=nil; PackageEditingInterface:=nil;

View File

@ -22,17 +22,19 @@ unit ProjectIntf;
interface interface
uses uses
Classes, SysUtils, LCLProc, FileUtil; Classes, SysUtils, LCLProc, FileUtil, NewItemIntf;
const const
FileDescNamePascalUnit = 'unit'; FileDescGroupName = 'File';
FileDescNameLCLForm = 'form'; FileDescNamePascalUnit = 'Unit';
FileDescNameDatamodule = 'datamodule'; FileDescNameLCLForm = 'Form';
FileDescNameText = 'text'; FileDescNameDatamodule = 'Datamodule';
FileDescNameText = 'Text';
ProjDescNameApplication = 'application'; ProjDescGroupName = 'Project';
ProjDescNameProgram = 'program'; ProjDescNameApplication = 'Application';
ProjDescNameCustomProgram = 'custom program'; ProjDescNameProgram = 'Program';
ProjDescNameCustomProgram = 'Custom Program';
type type
{ TLazCompilerOptions } { TLazCompilerOptions }
@ -262,9 +264,19 @@ type
write SetIsPartOfProject; write SetIsPartOfProject;
property Filename: string read GetFilename; property Filename: string read GetFilename;
end; end;
TLazProjectFileClass = class of TLazProjectFile;
{ TProjectFileDescriptor } { TProjectFileDescriptor
ResourceClass: When the IDE creates a new unit of this type the IDE will
create a direct descendant from this class.
You should also register this class, so that, when the IDE
opens a unit with such a type
(i.e. 'TMyResouceClass1 = class(TMyResouceClass)')
it creates the correct class type. Just call somewhere once
RegisterClass(ResourceClass);
}
TProjectFileDescriptor = class(TPersistent) TProjectFileDescriptor = class(TPersistent)
private private
@ -314,8 +326,23 @@ type
property IsPascalUnit: boolean read FIsPascalUnit write FIsPascalUnit; property IsPascalUnit: boolean read FIsPascalUnit write FIsPascalUnit;
property AddToProject: boolean read FAddToProject write FAddToProject; property AddToProject: boolean read FAddToProject write FAddToProject;
end; end;
TProjectFileDescriptorClass = class of TProjectFileDescriptor;
{ TNewItemProjectFile - a new item for project file descriptors }
TNewItemProjectFile = class(TNewIDEItemTemplate)
private
FDescriptor: TProjectFileDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TProjectFileDescriptor read FDescriptor write FDescriptor;
end;
{ TFileDescPascalUnit } { TFileDescPascalUnit }
TFileDescPascalUnit = class(TProjectFileDescriptor) TFileDescPascalUnit = class(TProjectFileDescriptor)
@ -353,12 +380,14 @@ type
function Count: integer; virtual; abstract; function Count: integer; virtual; abstract;
function GetUniqueName(const Name: string): string; virtual; abstract; function GetUniqueName(const Name: string): string; virtual; abstract;
function IndexOf(const Name: string): integer; virtual; abstract; function IndexOf(const Name: string): integer; virtual; abstract;
function IndexOf(FileDescriptor: TProjectFileDescriptor): integer; virtual; abstract;
function FindByName(const Name: string): TProjectFileDescriptor; virtual; abstract; function FindByName(const Name: string): TProjectFileDescriptor; virtual; abstract;
procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract; procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract;
procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract; procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract;
public public
property Items[Index: integer]: TProjectFileDescriptor read GetItems; default; property Items[Index: integer]: TProjectFileDescriptor read GetItems; default;
end; end;
var var
ProjectFileDescriptors: TProjectFileDescriptors; // will be set by the IDE ProjectFileDescriptors: TProjectFileDescriptors; // will be set by the IDE
@ -409,6 +438,21 @@ type
property Flags: TProjectFlags read FFlags write SetFlags; property Flags: TProjectFlags read FFlags write SetFlags;
property DefaultExt: string read FDefaultExt write FDefaultExt; property DefaultExt: string read FDefaultExt write FDefaultExt;
end; end;
TProjectDescriptorClass = class of TProjectDescriptor;
{ TNewItemProject - a new item for project descriptors }
TNewItemProject = class(TNewIDEItemTemplate)
private
FDescriptor: TProjectDescriptor;
public
function LocalizedName: string; override;
function Description: string; override;
procedure Assign(Source: TPersistent); override;
public
property Descriptor: TProjectDescriptor read FDescriptor write FDescriptor;
end;
{ TLazProject - interface class to a Lazarus project } { TLazProject - interface class to a Lazarus project }
@ -447,6 +491,7 @@ type
property LazCompilerOptions: TLazCompilerOptions read FLazCompilerOptions property LazCompilerOptions: TLazCompilerOptions read FLazCompilerOptions
write SetLazCompilerOptions; write SetLazCompilerOptions;
end; end;
TLazProjectClass = class of TLazProject;
{ TProjectDescriptors } { TProjectDescriptors }
@ -458,12 +503,14 @@ type
function Count: integer; virtual; abstract; function Count: integer; virtual; abstract;
function GetUniqueName(const Name: string): string; virtual; abstract; function GetUniqueName(const Name: string): string; virtual; abstract;
function IndexOf(const Name: string): integer; virtual; abstract; function IndexOf(const Name: string): integer; virtual; abstract;
function IndexOf(Descriptor: TProjectDescriptor): integer; virtual; abstract;
function FindByName(const Name: string): TProjectDescriptor; virtual; abstract; function FindByName(const Name: string): TProjectDescriptor; virtual; abstract;
procedure RegisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract; procedure RegisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract;
procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract; procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract;
public public
property Items[Index: integer]: TProjectDescriptor read GetItems; default; property Items[Index: integer]: TProjectDescriptor read GetItems; default;
end; end;
TProjectDescriptorsClass = class of TProjectDescriptors;
var var
ProjectDescriptors: TProjectDescriptors; // will be set by the IDE ProjectDescriptors: TProjectDescriptors; // will be set by the IDE
@ -492,9 +539,37 @@ const
function ProjectFlagsToStr(Flags: TProjectFlags): string; function ProjectFlagsToStr(Flags: TProjectFlags): string;
procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor);
procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor);
implementation implementation
procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor);
var
NewItemFile: TNewItemProjectFile;
begin
ProjectFileDescriptors.RegisterFileDescriptor(FileDesc);
if FileDesc.VisibleInNewDialog then begin
NewItemFile:=TNewItemProjectFile.Create(FileDesc.Name,niifCopy,[niifCopy]);
NewItemFile.Descriptor:=FileDesc;
RegisterNewDialogItem(FileDescGroupName,NewItemFile);
end;
end;
procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor);
var
NewItemProject: TNewItemProject;
begin
ProjectDescriptors.RegisterDescriptor(ProjDesc);
if ProjDesc.VisibleInNewDialog then begin
NewItemProject:=TNewItemProject.Create(ProjDesc.Name,niifCopy,[niifCopy]);
NewItemProject.Descriptor:=ProjDesc;
RegisterNewDialogItem(ProjDescGroupName,NewItemProject);
end;
end;
function FileDescriptorUnit: TProjectFileDescriptor; function FileDescriptorUnit: TProjectFileDescriptor;
begin begin
Result:=ProjectFileDescriptors.FindByName(FileDescNamePascalUnit); Result:=ProjectFileDescriptors.FindByName(FileDescNamePascalUnit);
@ -838,6 +913,44 @@ begin
FOwner := TheOwner; FOwner := TheOwner;
end; end;
{ TNewItemProjectFile }
function TNewItemProjectFile.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemProjectFile.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemProjectFile.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemProjectFile then
FDescriptor:=TNewItemProjectFile(Source).Descriptor;
end;
{ TNewItemProject }
function TNewItemProject.LocalizedName: string;
begin
Result:=Descriptor.GetLocalizedName;
end;
function TNewItemProject.Description: string;
begin
Result:=Descriptor.GetLocalizedDescription;
end;
procedure TNewItemProject.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TNewItemProject then
FDescriptor:=TNewItemProject(Source).Descriptor;
end;
initialization initialization
ProjectFileDescriptors:=nil; ProjectFileDescriptors:=nil;

View File

@ -1045,6 +1045,7 @@ begin
AddFile('objectinspector.pp','ObjectInspector',pftUnit,[],cpBase); AddFile('objectinspector.pp','ObjectInspector',pftUnit,[],cpBase);
AddFile('objinspstrconsts.pas','ObjInspStrConsts',pftUnit,[],cpBase); AddFile('objinspstrconsts.pas','ObjInspStrConsts',pftUnit,[],cpBase);
AddFile('packageintf.pas','PackageIntf',pftUnit,[],cpBase); AddFile('packageintf.pas','PackageIntf',pftUnit,[],cpBase);
AddFile('projectintf.pas','ProjectIntf',pftUnit,[],cpBase);
AddFile('propedits.pp','PropEdits',pftUnit,[],cpBase); AddFile('propedits.pp','PropEdits',pftUnit,[],cpBase);
AddFile('srceditorintf.pas','SrcEditorIntf',pftUnit,[],cpBase); AddFile('srceditorintf.pas','SrcEditorIntf',pftUnit,[],cpBase);
AddFile('texttools.pas','TextTools',pftUnit,[],cpBase); AddFile('texttools.pas','TextTools',pftUnit,[],cpBase);

View File

@ -49,7 +49,7 @@ uses
// codetools // codetools
CodeToolManager, CodeCache, BasicCodeTools, Laz_XMLCfg, OldAvLTree, CodeToolManager, CodeCache, BasicCodeTools, Laz_XMLCfg, OldAvLTree,
// IDE Interface // IDE Interface
ProjectIntf, PackageIntf, LazIDEIntf, NewItemIntf, ProjectIntf, PackageIntf, LazIDEIntf,
// IDE // IDE
LazConf, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, KeyMapping, LazConf, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, KeyMapping,
EnvironmentOpts, MiscOptions, InputHistory, ProjectDefs, Project, EnvironmentOpts, MiscOptions, InputHistory, ProjectDefs, Project,
@ -1434,6 +1434,8 @@ begin
MiscellaneousOptions.BuildLazOpts.WithStaticPackages:=true; MiscellaneousOptions.BuildLazOpts.WithStaticPackages:=true;
end; end;
// TODO: sort FirstAutoInstallDependency topological
sl:=TStringList.Create; sl:=TStringList.Create;
Dependency:=FirstAutoInstallDependency; Dependency:=FirstAutoInstallDependency;
while Dependency<>nil do begin while Dependency<>nil do begin
@ -1467,6 +1469,7 @@ begin
PackageGraph.OpenDependency(Dependency); PackageGraph.OpenDependency(Dependency);
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires); Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
end; end;
// TODO: sort FirstAutoInstallDependency topological
// register them // register them
PackageGraph.RegisterStaticBasePackages; PackageGraph.RegisterStaticBasePackages;
@ -3084,6 +3087,7 @@ begin
NeedSaving:=true; NeedSaving:=true;
end; end;
end; end;
// TODO: sort FirstAutoInstallDependency topological
if NeedSaving then if NeedSaving then
SaveAutoInstallDependencies(true); SaveAutoInstallDependencies(true);
@ -3496,24 +3500,9 @@ begin
end; end;
procedure TLazPackageDescriptors.AddDefaultPackageDescriptors; procedure TLazPackageDescriptors.AddDefaultPackageDescriptors;
var
i: Integer;
NewItem: TNewItemPackage;
PkgItem: TPackageDescriptor;
begin begin
// standard package NewIDEItems.Add(TNewLazIDEItemCategoryPackage.Create(PkgDescGroupName));
RegisterDescriptor(TPackageDescriptorStd.Create); RegisterPackageDescriptor(TPackageDescriptorStd.Create);
// register in new dialog: package category
NewIDEItems.Add(TNewIDEItemCategoryPackage.Create('Package'));
// register in new dialog: all package templates
for i:=0 to Count-1 do begin
PkgItem:=Items[i];
if not PkgItem.VisibleInNewDialog then continue;
NewItem:=TNewItemPackage.Create(PkgItem.Name,niifCopy,[niifCopy]);
NewItem.Descriptor:=PkgItem;
RegisterNewDialogItem('Package',NewItem);
end;
end; end;
{ TPackageDescriptorStd } { TPackageDescriptorStd }