mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 08:19:26 +01:00
implemented registration functions for project, file and package types, added cgilazide package
git-svn-id: trunk@6282 -
This commit is contained in:
parent
259af31e44
commit
a2102621c5
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -3,6 +3,11 @@
|
||||
components/README.txt svneol=native#text/plain
|
||||
components/cgi/cgilaz.lpk 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/basiccodetools.pas svneol=native#text/pascal
|
||||
components/codetools/codeatom.pas svneol=native#text/pascal
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
cgi
|
||||
|
||||
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'.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
components/cgi/ide/README.txt
Normal file
16
components/cgi/ide/README.txt
Normal 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.
|
||||
|
||||
|
||||
|
||||
|
||||
49
components/cgi/ide/cgilazide.lpk
Normal file
49
components/cgi/ide/cgilazide.lpk
Normal 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>
|
||||
171
components/cgi/ide/cgilazideintf.pas
Normal file
171
components/cgi/ide/cgilazideintf.pas
Normal 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.
|
||||
|
||||
1
components/cgi/ide/lib/README.txt
Normal file
1
components/cgi/ide/lib/README.txt
Normal file
@ -0,0 +1 @@
|
||||
Output directory of package cgilazide
|
||||
1
components/cgi/lib/README.txt
Normal file
1
components/cgi/lib/README.txt
Normal file
@ -0,0 +1 @@
|
||||
Output directory of package cgilaz
|
||||
@ -55,7 +55,7 @@ interface
|
||||
|
||||
// verbosity
|
||||
{ $DEFINE CTDEBUG}
|
||||
{ $DEFINE ShowTriedFiles}
|
||||
{$DEFINE ShowTriedFiles}
|
||||
{ $DEFINE ShowTriedContexts}
|
||||
{ $DEFINE ShowTriedBaseContexts}
|
||||
{ $DEFINE ShowTriedParentContexts}
|
||||
|
||||
@ -21,14 +21,15 @@
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
TJITForm - just-in-time form.
|
||||
TJITDataModule = just-in-time datamodule
|
||||
|
||||
This TForm descendent is used by the IDE as a template for creating forms
|
||||
at run time (the designed forms).
|
||||
Because the IDE does wild things with this form, like creating an own class
|
||||
for each TJITForm and dynamically creating methods for it, you can't use
|
||||
some special compiling modes like -pg (gprof) with it.
|
||||
JITForm - just-in-time form.
|
||||
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
|
||||
'JITComponent' would confuse new developers.
|
||||
|
||||
Because the IDE does wild things with forms and datamodules, like creating
|
||||
an own class for each opened form/datamodule and dynamically creating
|
||||
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.
|
||||
}
|
||||
unit JITForm;
|
||||
@ -41,26 +42,6 @@ uses
|
||||
Classes, SysUtils, Forms, Controls;
|
||||
|
||||
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 = class(TPersistent)
|
||||
published
|
||||
|
||||
83
ide/main.pp
83
ide/main.pp
@ -70,14 +70,14 @@ uses
|
||||
DefineTemplates,
|
||||
// IDE interface
|
||||
AllIDEIntf, ObjectInspector, PropEdits, IDECommands, SrcEditorIntf,
|
||||
LazIDEIntf,
|
||||
NewItemIntf, PackageIntf, ProjectIntf, LazIDEIntf,
|
||||
// synedit
|
||||
SynEditKeyCmds,
|
||||
// compile
|
||||
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
|
||||
ImExportCompilerOpts,
|
||||
// projects
|
||||
ProjectIntf, Project, ProjectDefs, NewProjectDlg, ProjectOpts,
|
||||
Project, ProjectDefs, NewProjectDlg, ProjectOpts,
|
||||
PublishProjectDlg, ProjectInspector,
|
||||
// help manager
|
||||
HelpManager,
|
||||
@ -959,7 +959,7 @@ begin
|
||||
ConnectMainBarEvents;
|
||||
|
||||
// create main IDE register items
|
||||
NewIDEItems:=TNewIDEItemCategories.Create;
|
||||
NewIDEItems:=TNewLazIDEItemCategories.Create;
|
||||
SetupStandardProjectTypes;
|
||||
|
||||
// initialize the other IDE managers
|
||||
@ -1548,69 +1548,23 @@ begin
|
||||
end;
|
||||
|
||||
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
|
||||
// file descriptors ----------------------------------------------------------
|
||||
NewIDEItems.Add(TNewLazIDEItemCategoryFile.Create(FileDescGroupName));
|
||||
NewIDEItems.Add(TNewLazIDEItemCategoryProject.Create(ProjDescGroupName));
|
||||
|
||||
// file descriptors
|
||||
LazProjectFileDescriptors:=TLazProjectFileDescriptors.Create;
|
||||
// basic pascal unit
|
||||
FileDescPascalUnit:=TFileDescPascalUnit.Create;
|
||||
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescPascalUnit);
|
||||
// pascal unit with form
|
||||
FileDescPascalUnitWithForm:=TFileDescPascalUnitWithForm.Create;
|
||||
LazProjectFileDescriptors.RegisterFileDescriptor(FileDescPascalUnitWithForm);
|
||||
// pascal unit with datamodule
|
||||
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 -------------------------------------------------------
|
||||
RegisterProjectFileDescriptor(TFileDescPascalUnit.Create);
|
||||
RegisterProjectFileDescriptor(TFileDescPascalUnitWithForm.Create);
|
||||
RegisterProjectFileDescriptor(TFileDescPascalUnitWithDataModule.Create);
|
||||
RegisterProjectFileDescriptor(TFileDescSimplePascalProgram.Create);
|
||||
RegisterProjectFileDescriptor(TFileDescText.Create);
|
||||
|
||||
// project descriptors
|
||||
LazProjectDescriptors:=TLazProjectDescriptors.Create;
|
||||
// application
|
||||
ProjDescApplication:=TProjectApplicationDescriptor.Create;
|
||||
LazProjectDescriptors.RegisterDescriptor(ProjDescApplication);
|
||||
// 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;
|
||||
RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
|
||||
RegisterProjectDescriptor(TProjectManualProgramDescriptor.Create);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SetRecentFilesMenu;
|
||||
@ -11011,6 +10965,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$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
|
||||
implemented stopping project on close project
|
||||
|
||||
|
||||
@ -41,57 +41,28 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, StdCtrls, Buttons, ComCtrls,
|
||||
Dialogs, LResources, ProjectIntf, PackageIntf,
|
||||
Dialogs, LResources, ProjectIntf, PackageIntf, NewItemIntf,
|
||||
IDEOptionDefs, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
// Items that can be created in the IDE:
|
||||
{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;}
|
||||
{ TNewLazIDEItemCategory }
|
||||
|
||||
// Flags/Options for the items
|
||||
TNewIDEItemFlag = (
|
||||
niifCopy,
|
||||
niifInherited,
|
||||
niifUse
|
||||
);
|
||||
TNewIDEItemFlags = set of TNewIDEItemFlag;
|
||||
|
||||
TNewIDEItemTemplate = class;
|
||||
|
||||
|
||||
{ TNewIDEItemCategory }
|
||||
|
||||
TNewIDEItemCategory = class
|
||||
TNewLazIDEItemCategory = class(TNewIDEItemCategory)
|
||||
private
|
||||
FItems: TList;
|
||||
FName: string;
|
||||
function GetCount: integer;
|
||||
function GetItems(Index: integer): TNewIDEItemTemplate;
|
||||
protected
|
||||
function GetCount: integer; override;
|
||||
function GetItems(Index: integer): TNewIDEItemTemplate; override;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(const AName: string);
|
||||
constructor Create(const AName: string); override;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
procedure Add(ATemplate: TNewIDEItemTemplate);
|
||||
function LocalizedName: string; virtual;
|
||||
function Description: string; virtual;
|
||||
function IndexOfCategory(const CategoryName: string): integer;
|
||||
function FindCategoryByName(const CategoryName: string): TNewIDEItemCategory;
|
||||
procedure Clear; override;
|
||||
procedure Add(ATemplate: TNewIDEItemTemplate); override;
|
||||
function LocalizedName: string; override;
|
||||
function Description: string; 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;
|
||||
@ -99,123 +70,56 @@ type
|
||||
end;
|
||||
|
||||
|
||||
{ TNewIDEItemCategories }
|
||||
{ TNewLazIDEItemCategories }
|
||||
|
||||
TNewIDEItemCategories = class
|
||||
TNewLazIDEItemCategories = class(TNewIDEItemCategories)
|
||||
private
|
||||
FItems: TList;
|
||||
function GetItems(Index: integer): TNewIDEItemCategory;
|
||||
procedure SetItems(Index: integer; const AValue: TNewIDEItemCategory);
|
||||
protected
|
||||
function GetItems(Index: integer): TNewIDEItemCategory; override;
|
||||
procedure SetItems(Index: integer; const AValue: TNewIDEItemCategory); override;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
procedure Add(ACategory: TNewIDEItemCategory);
|
||||
function Count: integer;
|
||||
function IndexOf(const CategoryName: string): integer;
|
||||
function FindByName(const CategoryName: string): TNewIDEItemCategory;
|
||||
procedure RegisterItem(const Paths: string; NewItem: TNewIDEItemTemplate);
|
||||
procedure UnregisterItem(NewItem: TNewIDEItemTemplate);
|
||||
procedure Clear; override;
|
||||
procedure Add(ACategory: TNewIDEItemCategory); override;
|
||||
function Count: integer; override;
|
||||
function IndexOf(const CategoryName: string): integer; override;
|
||||
function FindByName(const CategoryName: string): TNewIDEItemCategory; override;
|
||||
procedure RegisterItem(const Paths: string; NewItem: TNewIDEItemTemplate); override;
|
||||
procedure UnregisterItem(NewItem: TNewIDEItemTemplate); override;
|
||||
function FindCategoryByPath(const Path: string;
|
||||
ErrorOnNotFound: boolean): TNewIDEItemCategory;
|
||||
public
|
||||
property Items[Index: integer]: TNewIDEItemCategory
|
||||
read GetItems write SetItems; default;
|
||||
ErrorOnNotFound: boolean): TNewIDEItemCategory; override;
|
||||
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
|
||||
|
||||
{ TNewIDEItemCategoryFile }
|
||||
{ TNewLazIDEItemCategoryFile }
|
||||
|
||||
TNewIDEItemCategoryFile = class(TNewIDEItemCategory)
|
||||
TNewLazIDEItemCategoryFile = class(TNewLazIDEItemCategory)
|
||||
public
|
||||
function LocalizedName: string; override;
|
||||
function Description: string; override;
|
||||
end;
|
||||
|
||||
{ TNewIDEItemCategoryProject }
|
||||
{ TNewLazIDEItemCategoryProject }
|
||||
|
||||
TNewIDEItemCategoryProject = class(TNewIDEItemCategory)
|
||||
TNewLazIDEItemCategoryProject = class(TNewLazIDEItemCategory)
|
||||
public
|
||||
function LocalizedName: string; override;
|
||||
function Description: string; override;
|
||||
end;
|
||||
|
||||
{ TNewIDEItemCategoryPackage }
|
||||
{ TNewLazIDEItemCategoryPackage }
|
||||
|
||||
TNewIDEItemCategoryPackage = class(TNewIDEItemCategory)
|
||||
TNewLazIDEItemCategoryPackage = class(TNewLazIDEItemCategory)
|
||||
public
|
||||
function LocalizedName: string; override;
|
||||
function Description: string; override;
|
||||
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;
|
||||
|
||||
var
|
||||
NewIDEItems: TNewIDEItemCategories;// will be set by the IDE
|
||||
|
||||
|
||||
procedure RegisterNewDialogItem(const Paths: string;
|
||||
NewItem: TNewIDEItemTemplate);
|
||||
procedure UnregisterNewDialogItem(NewItem: TNewIDEItemTemplate);
|
||||
|
||||
implementation
|
||||
|
||||
@ -268,21 +165,6 @@ begin
|
||||
NewOtherDialog.Free;
|
||||
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 }
|
||||
|
||||
procedure TNewOtherDialog.NewOtherDialogResize(Sender: TObject);
|
||||
@ -359,8 +241,8 @@ var
|
||||
begin
|
||||
ANode:=ItemsTreeView.Selected;
|
||||
if (ANode<>nil) and (ANode.Data<>nil) then begin
|
||||
if TObject(ANode.Data) is TNewIDEItemCategory then
|
||||
Desc:=TNewIDEItemCategory(ANode.Data).Description
|
||||
if TObject(ANode.Data) is TNewLazIDEItemCategory then
|
||||
Desc:=TNewLazIDEItemCategory(ANode.Data).Description
|
||||
else
|
||||
Desc:=TNewIDEItemTemplate(ANode.Data).Description;
|
||||
end else begin
|
||||
@ -452,38 +334,38 @@ begin
|
||||
Result:=TNewIDEItemTemplate(ANode.Data).CreateCopy;
|
||||
end;
|
||||
|
||||
{ TNewIDEItemCategory }
|
||||
{ TNewLazIDEItemCategory }
|
||||
|
||||
function TNewIDEItemCategory.GetCount: integer;
|
||||
function TNewLazIDEItemCategory.GetCount: integer;
|
||||
begin
|
||||
Result:=FItems.Count;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate;
|
||||
function TNewLazIDEItemCategory.GetItems(Index: integer): TNewIDEItemTemplate;
|
||||
begin
|
||||
Result:=TNewIDEItemTemplate(FItems[Index]);
|
||||
end;
|
||||
|
||||
constructor TNewIDEItemCategory.Create;
|
||||
constructor TNewLazIDEItemCategory.Create;
|
||||
begin
|
||||
raise Exception.Create('TNewIDEItemCategory.Create: call Create(Name) instead');
|
||||
raise Exception.Create('TNewLazIDEItemCategory.Create: call Create(Name) instead');
|
||||
end;
|
||||
|
||||
constructor TNewIDEItemCategory.Create(const AName: string);
|
||||
constructor TNewLazIDEItemCategory.Create(const AName: string);
|
||||
begin
|
||||
FItems:=TList.Create;
|
||||
FName:=AName;
|
||||
//debugln('TNewIDEItemCategory.Create ',Name);
|
||||
//debugln('TNewLazIDEItemCategory.Create ',Name);
|
||||
end;
|
||||
|
||||
destructor TNewIDEItemCategory.Destroy;
|
||||
destructor TNewLazIDEItemCategory.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FItems.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategory.Clear;
|
||||
procedure TNewLazIDEItemCategory.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
@ -491,20 +373,20 @@ begin
|
||||
FItems.Clear;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate);
|
||||
procedure TNewLazIDEItemCategory.Add(ATemplate: TNewIDEItemTemplate);
|
||||
begin
|
||||
//debugln('TNewIDEItemCategory.Add ',Name);
|
||||
//debugln('TNewLazIDEItemCategory.Add ',Name);
|
||||
FItems.Add(ATemplate);
|
||||
ATemplate.fCategory:=Self;
|
||||
ATemplate.Category:=Self;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.LocalizedName: string;
|
||||
function TNewLazIDEItemCategory.LocalizedName: string;
|
||||
begin
|
||||
// ToDo:
|
||||
Result:=Name;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.Description: string;
|
||||
function TNewLazIDEItemCategory.Description: string;
|
||||
begin
|
||||
if Name='File' then begin
|
||||
Result:=Format(lisNewDlgCreateANewEditorFileChooseAType, [#13]);
|
||||
@ -514,14 +396,14 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.IndexOfCategory(const CategoryName: string
|
||||
function TNewLazIDEItemCategory.IndexOfCategory(const CategoryName: string
|
||||
): integer;
|
||||
begin
|
||||
// TODO
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategory.FindCategoryByName(const CategoryName: string
|
||||
function TNewLazIDEItemCategory.FindCategoryByName(const CategoryName: string
|
||||
): TNewIDEItemCategory;
|
||||
var
|
||||
i: LongInt;
|
||||
@ -533,73 +415,32 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ TNewIDEItemTemplate }
|
||||
{ TNewLazIDEItemCategories }
|
||||
|
||||
constructor TNewIDEItemTemplate.Create(const AName: string;
|
||||
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;
|
||||
function TNewLazIDEItemCategories.GetItems(Index: integer): TNewIDEItemCategory;
|
||||
begin
|
||||
Result:=TNewIDEItemCategory(FItems[Index]);
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategories.SetItems(Index: integer;
|
||||
procedure TNewLazIDEItemCategories.SetItems(Index: integer;
|
||||
const AValue: TNewIDEItemCategory);
|
||||
begin
|
||||
FItems[Index]:=AValue;
|
||||
end;
|
||||
|
||||
constructor TNewIDEItemCategories.Create;
|
||||
constructor TNewLazIDEItemCategories.Create;
|
||||
begin
|
||||
FItems:=TList.Create;
|
||||
end;
|
||||
|
||||
destructor TNewIDEItemCategories.Destroy;
|
||||
destructor TNewLazIDEItemCategories.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FItems.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategories.Clear;
|
||||
procedure TNewLazIDEItemCategories.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
@ -607,24 +448,24 @@ begin
|
||||
FItems.Clear;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategories.Add(ACategory: TNewIDEItemCategory);
|
||||
procedure TNewLazIDEItemCategories.Add(ACategory: TNewIDEItemCategory);
|
||||
begin
|
||||
FItems.Add(ACategory);
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategories.Count: integer;
|
||||
function TNewLazIDEItemCategories.Count: integer;
|
||||
begin
|
||||
Result:=FItems.Count;
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategories.IndexOf(const CategoryName: string): integer;
|
||||
function TNewLazIDEItemCategories.IndexOf(const CategoryName: string): integer;
|
||||
begin
|
||||
Result:=Count-1;
|
||||
while (Result>=0) and (AnsiCompareText(CategoryName,Items[Result].Name)<>0) do
|
||||
dec(Result);
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategories.FindByName(const CategoryName: string
|
||||
function TNewLazIDEItemCategories.FindByName(const CategoryName: string
|
||||
): TNewIDEItemCategory;
|
||||
var
|
||||
i: LongInt;
|
||||
@ -636,7 +477,7 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategories.RegisterItem(const Paths: string;
|
||||
procedure TNewLazIDEItemCategories.RegisterItem(const Paths: string;
|
||||
NewItem: TNewIDEItemTemplate);
|
||||
|
||||
procedure AddToPath(const Path: string);
|
||||
@ -668,12 +509,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TNewIDEItemCategories.UnregisterItem(NewItem: TNewIDEItemTemplate);
|
||||
procedure TNewLazIDEItemCategories.UnregisterItem(NewItem: TNewIDEItemTemplate);
|
||||
begin
|
||||
raise Exception.Create('TODO TNewIDEItemCategories.UnregisterItem');
|
||||
raise Exception.Create('TODO TNewLazIDEItemCategories.UnregisterItem');
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategories.FindCategoryByPath(const Path: string;
|
||||
function TNewLazIDEItemCategories.FindCategoryByPath(const Path: string;
|
||||
ErrorOnNotFound: boolean): TNewIDEItemCategory;
|
||||
var
|
||||
StartPos: Integer;
|
||||
@ -706,95 +547,38 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TNewItemProjectFile }
|
||||
{ TNewLazIDEItemCategoryFile }
|
||||
|
||||
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;
|
||||
|
||||
{ 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;
|
||||
function TNewLazIDEItemCategoryFile.LocalizedName: string;
|
||||
begin
|
||||
Result:='File';
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategoryFile.Description: string;
|
||||
function TNewLazIDEItemCategoryFile.Description: string;
|
||||
begin
|
||||
Result:='Choose one of these items to create a new File';
|
||||
end;
|
||||
|
||||
{ TNewIDEItemCategoryProject }
|
||||
{ TNewLazIDEItemCategoryProject }
|
||||
|
||||
function TNewIDEItemCategoryProject.LocalizedName: string;
|
||||
function TNewLazIDEItemCategoryProject.LocalizedName: string;
|
||||
begin
|
||||
Result:='Project';
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategoryProject.Description: string;
|
||||
function TNewLazIDEItemCategoryProject.Description: string;
|
||||
begin
|
||||
Result:='Choose one of these items to create a new Project';
|
||||
end;
|
||||
|
||||
{ TNewIDEItemCategoryPackage }
|
||||
{ TNewLazIDEItemCategoryPackage }
|
||||
|
||||
function TNewIDEItemCategoryPackage.LocalizedName: string;
|
||||
function TNewLazIDEItemCategoryPackage.LocalizedName: string;
|
||||
begin
|
||||
Result:='Package';
|
||||
end;
|
||||
|
||||
function TNewIDEItemCategoryPackage.Description: string;
|
||||
function TNewLazIDEItemCategoryPackage.Description: string;
|
||||
begin
|
||||
Result:='Choose one of these items to create a new Package';
|
||||
end;
|
||||
|
||||
@ -38,7 +38,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Laz_XMLCfg, Forms, SynRegExpr, FileUtil, LCLProc,
|
||||
ProjectIntf,
|
||||
NewItemIntf, ProjectIntf,
|
||||
LazarusIDEStrConsts, PublishModule;
|
||||
|
||||
type
|
||||
@ -79,6 +79,7 @@ type
|
||||
function Count: integer; override;
|
||||
function GetUniqueName(const Name: string): string; override;
|
||||
function IndexOf(const Name: string): integer; override;
|
||||
function IndexOf(FileDescriptor: TProjectFileDescriptor): integer; override;
|
||||
function FindByName(const Name: string): TProjectFileDescriptor; override;
|
||||
procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override;
|
||||
procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); override;
|
||||
@ -87,6 +88,7 @@ type
|
||||
property DefaultPascalFileExt: string read FDefaultPascalFileExt write SetDefaultPascalFileExt;
|
||||
end;
|
||||
|
||||
|
||||
{ TLazProjectDescriptors }
|
||||
|
||||
TLazProjectDescriptors = class(TProjectDescriptors)
|
||||
@ -101,6 +103,7 @@ type
|
||||
function Count: integer; override;
|
||||
function GetUniqueName(const Name: string): string; override;
|
||||
function IndexOf(const Name: string): integer; override;
|
||||
function IndexOf(Descriptor: TProjectDescriptor): integer; override;
|
||||
function FindByName(const Name: string): TProjectDescriptor; override;
|
||||
procedure RegisterDescriptor(Descriptor: TProjectDescriptor); override;
|
||||
procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); override;
|
||||
@ -999,6 +1002,14 @@ begin
|
||||
dec(Result);
|
||||
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
|
||||
): TProjectFileDescriptor;
|
||||
var
|
||||
@ -1020,11 +1031,19 @@ begin
|
||||
raise Exception.Create('TLazProjectFileDescriptors.RegisterFileDescriptor FileDescriptor.Name empty');
|
||||
if FileDescriptor.DefaultFilename='' then
|
||||
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);
|
||||
DefPasExt:=DefaultPascalFileExt;
|
||||
if DefPasExt<>'' then
|
||||
FileDescriptor.UpdateDefaultPascalFileExtension(DefPasExt);
|
||||
FItems.Add(FileDescriptor);
|
||||
|
||||
// register ResourceClass, so that the IDE knows, what means
|
||||
// '= class(<ResourceClass.ClassName>)'
|
||||
if FileDescriptor.ResourceClass<>nil then
|
||||
RegisterClass(FileDescriptor.ResourceClass);
|
||||
end;
|
||||
|
||||
procedure TLazProjectFileDescriptors.UnregisterFileDescriptor(
|
||||
@ -1100,6 +1119,14 @@ begin
|
||||
dec(Result);
|
||||
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
|
||||
): TProjectDescriptor;
|
||||
var
|
||||
@ -1117,8 +1144,12 @@ procedure TLazProjectDescriptors.RegisterDescriptor(
|
||||
begin
|
||||
if Descriptor.Name='' then
|
||||
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);
|
||||
FItems.Add(Descriptor);
|
||||
if Descriptor.VisibleInNewDialog then
|
||||
;
|
||||
end;
|
||||
|
||||
procedure TLazProjectDescriptors.UnregisterDescriptor(
|
||||
|
||||
@ -23,7 +23,7 @@ uses
|
||||
ComponentEditors, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
||||
ComponentTreeView, ActionsEditor, HelpIntf, TextTools, FormEditingIntf,
|
||||
SrcEditorIntf, ComponentReg, PackageIntf, HelpHTML, ConfigStorage,
|
||||
HelpFPDoc, ProjectIntf, LazIDEIntf;
|
||||
HelpFPDoc, ProjectIntf, LazIDEIntf, NewItemIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -38,9 +38,10 @@ unit PackageIntf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms;
|
||||
Classes, SysUtils, Forms, NewItemIntf;
|
||||
|
||||
const
|
||||
PkgDescGroupName = 'Package';
|
||||
PkgDescNameStandard = 'Standard Package';
|
||||
|
||||
type
|
||||
@ -81,6 +82,22 @@ type
|
||||
property Name: string read FName write SetName;
|
||||
property VisibleInNewDialog: boolean read FVisibleInNewDialog write FVisibleInNewDialog;
|
||||
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 }
|
||||
|
||||
@ -101,10 +118,26 @@ type
|
||||
var
|
||||
PackageDescriptors: TPackageDescriptors; // will be set by the IDE
|
||||
|
||||
|
||||
procedure RegisterPackageDescriptor(PkgDesc: TPackageDescriptor);
|
||||
function PackageDescriptorStd: TPackageDescriptor;
|
||||
|
||||
|
||||
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;
|
||||
begin
|
||||
Result:=PackageDescriptors.FindByName(PkgDescNameStandard);
|
||||
@ -148,6 +181,25 @@ begin
|
||||
inc(FReferenceCount);
|
||||
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
|
||||
PackageEditingInterface:=nil;
|
||||
|
||||
|
||||
@ -22,17 +22,19 @@ unit ProjectIntf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileUtil;
|
||||
Classes, SysUtils, LCLProc, FileUtil, NewItemIntf;
|
||||
|
||||
const
|
||||
FileDescNamePascalUnit = 'unit';
|
||||
FileDescNameLCLForm = 'form';
|
||||
FileDescNameDatamodule = 'datamodule';
|
||||
FileDescNameText = 'text';
|
||||
FileDescGroupName = 'File';
|
||||
FileDescNamePascalUnit = 'Unit';
|
||||
FileDescNameLCLForm = 'Form';
|
||||
FileDescNameDatamodule = 'Datamodule';
|
||||
FileDescNameText = 'Text';
|
||||
|
||||
ProjDescNameApplication = 'application';
|
||||
ProjDescNameProgram = 'program';
|
||||
ProjDescNameCustomProgram = 'custom program';
|
||||
ProjDescGroupName = 'Project';
|
||||
ProjDescNameApplication = 'Application';
|
||||
ProjDescNameProgram = 'Program';
|
||||
ProjDescNameCustomProgram = 'Custom Program';
|
||||
|
||||
type
|
||||
{ TLazCompilerOptions }
|
||||
@ -262,9 +264,19 @@ type
|
||||
write SetIsPartOfProject;
|
||||
property Filename: string read GetFilename;
|
||||
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)
|
||||
private
|
||||
@ -314,8 +326,23 @@ type
|
||||
property IsPascalUnit: boolean read FIsPascalUnit write FIsPascalUnit;
|
||||
property AddToProject: boolean read FAddToProject write FAddToProject;
|
||||
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 = class(TProjectFileDescriptor)
|
||||
@ -353,12 +380,14 @@ type
|
||||
function Count: integer; virtual; abstract;
|
||||
function GetUniqueName(const Name: string): string; 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;
|
||||
procedure RegisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract;
|
||||
procedure UnregisterFileDescriptor(FileDescriptor: TProjectFileDescriptor); virtual; abstract;
|
||||
public
|
||||
property Items[Index: integer]: TProjectFileDescriptor read GetItems; default;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
ProjectFileDescriptors: TProjectFileDescriptors; // will be set by the IDE
|
||||
@ -409,6 +438,21 @@ type
|
||||
property Flags: TProjectFlags read FFlags write SetFlags;
|
||||
property DefaultExt: string read FDefaultExt write FDefaultExt;
|
||||
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 }
|
||||
@ -447,6 +491,7 @@ type
|
||||
property LazCompilerOptions: TLazCompilerOptions read FLazCompilerOptions
|
||||
write SetLazCompilerOptions;
|
||||
end;
|
||||
TLazProjectClass = class of TLazProject;
|
||||
|
||||
|
||||
{ TProjectDescriptors }
|
||||
@ -458,12 +503,14 @@ type
|
||||
function Count: integer; virtual; abstract;
|
||||
function GetUniqueName(const Name: string): string; 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;
|
||||
procedure RegisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract;
|
||||
procedure UnregisterDescriptor(Descriptor: TProjectDescriptor); virtual; abstract;
|
||||
public
|
||||
property Items[Index: integer]: TProjectDescriptor read GetItems; default;
|
||||
end;
|
||||
TProjectDescriptorsClass = class of TProjectDescriptors;
|
||||
|
||||
var
|
||||
ProjectDescriptors: TProjectDescriptors; // will be set by the IDE
|
||||
@ -492,9 +539,37 @@ const
|
||||
function ProjectFlagsToStr(Flags: TProjectFlags): string;
|
||||
|
||||
|
||||
procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor);
|
||||
procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor);
|
||||
|
||||
|
||||
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;
|
||||
begin
|
||||
Result:=ProjectFileDescriptors.FindByName(FileDescNamePascalUnit);
|
||||
@ -838,6 +913,44 @@ begin
|
||||
FOwner := TheOwner;
|
||||
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
|
||||
ProjectFileDescriptors:=nil;
|
||||
|
||||
|
||||
@ -1045,6 +1045,7 @@ begin
|
||||
AddFile('objectinspector.pp','ObjectInspector',pftUnit,[],cpBase);
|
||||
AddFile('objinspstrconsts.pas','ObjInspStrConsts',pftUnit,[],cpBase);
|
||||
AddFile('packageintf.pas','PackageIntf',pftUnit,[],cpBase);
|
||||
AddFile('projectintf.pas','ProjectIntf',pftUnit,[],cpBase);
|
||||
AddFile('propedits.pp','PropEdits',pftUnit,[],cpBase);
|
||||
AddFile('srceditorintf.pas','SrcEditorIntf',pftUnit,[],cpBase);
|
||||
AddFile('texttools.pas','TextTools',pftUnit,[],cpBase);
|
||||
|
||||
@ -49,7 +49,7 @@ uses
|
||||
// codetools
|
||||
CodeToolManager, CodeCache, BasicCodeTools, Laz_XMLCfg, OldAvLTree,
|
||||
// IDE Interface
|
||||
ProjectIntf, PackageIntf, LazIDEIntf,
|
||||
NewItemIntf, ProjectIntf, PackageIntf, LazIDEIntf,
|
||||
// IDE
|
||||
LazConf, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, KeyMapping,
|
||||
EnvironmentOpts, MiscOptions, InputHistory, ProjectDefs, Project,
|
||||
@ -1434,6 +1434,8 @@ begin
|
||||
MiscellaneousOptions.BuildLazOpts.WithStaticPackages:=true;
|
||||
end;
|
||||
|
||||
// TODO: sort FirstAutoInstallDependency topological
|
||||
|
||||
sl:=TStringList.Create;
|
||||
Dependency:=FirstAutoInstallDependency;
|
||||
while Dependency<>nil do begin
|
||||
@ -1467,6 +1469,7 @@ begin
|
||||
PackageGraph.OpenDependency(Dependency);
|
||||
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
|
||||
end;
|
||||
// TODO: sort FirstAutoInstallDependency topological
|
||||
|
||||
// register them
|
||||
PackageGraph.RegisterStaticBasePackages;
|
||||
@ -3084,6 +3087,7 @@ begin
|
||||
NeedSaving:=true;
|
||||
end;
|
||||
end;
|
||||
// TODO: sort FirstAutoInstallDependency topological
|
||||
if NeedSaving then
|
||||
SaveAutoInstallDependencies(true);
|
||||
|
||||
@ -3496,24 +3500,9 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLazPackageDescriptors.AddDefaultPackageDescriptors;
|
||||
var
|
||||
i: Integer;
|
||||
NewItem: TNewItemPackage;
|
||||
PkgItem: TPackageDescriptor;
|
||||
begin
|
||||
// standard package
|
||||
RegisterDescriptor(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;
|
||||
NewIDEItems.Add(TNewLazIDEItemCategoryPackage.Create(PkgDescGroupName));
|
||||
RegisterPackageDescriptor(TPackageDescriptorStd.Create);
|
||||
end;
|
||||
|
||||
{ TPackageDescriptorStd }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user