Skip to content

Commit

Permalink
Removed old code from the old IDE Wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Apr 15, 2024
1 parent bbea870 commit 10d3156
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 670 deletions.
24 changes: 24 additions & 0 deletions ideexpert/DMVC.Expert.CodeGen.Commands.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
// ***************************************************************************
//
// Delphi MVC Framework
//
// Copyright (c) 2010-2024 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************

unit DMVC.Expert.CodeGen.Commands;

interface
Expand Down
24 changes: 24 additions & 0 deletions ideexpert/DMVC.Expert.CodeGen.Executor.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
// ***************************************************************************
//
// Delphi MVC Framework
//
// Copyright (c) 2010-2024 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************

unit DMVC.Expert.CodeGen.Executor;

interface
Expand Down
86 changes: 2 additions & 84 deletions ideexpert/DMVC.Expert.CodeGen.NewControllerUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,17 @@ interface
uses
ToolsApi,
System.IOUtils,
DMVC.Expert.CodeGen.NewUnit, JsonDataObjects;
DMVC.Expert.CodeGen.NewUnit,
JsonDataObjects;

type
TNewControllerUnitEx = class(TNewUnit)
protected
FCreateIndexMethod: Boolean;
FCreateCRUDMethods: Boolean;
FCreateActionFiltersMethods: Boolean;
FControllerClassName: string;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string)
: IOTAFile; override;
public
constructor Create(
const ConfigModelRef: TJSONObject;
const aCreateIndexMethod, aCreateCRUDMethods, aCreateActionFiltersMethods: Boolean;
const AControllerClassName: string;
const APersonality: string = ''); reintroduce;
end;

Expand All @@ -71,30 +66,16 @@ implementation

uses
System.SysUtils,
VCL.Dialogs,
DMVC.Expert.CodeGen.Templates,
DMVC.Expert.CodeGen.SourceFile,
DMVC.Expert.CodeGen.Executor,
DMVC.Expert.Commands.Templates,
DMVC.Expert.Commons;

constructor TNewControllerUnitEx.Create(
const ConfigModelRef: TJSONObject;
const aCreateIndexMethod, aCreateCRUDMethods,
aCreateActionFiltersMethods: Boolean;
const AControllerClassName: string;
const APersonality: string = '');
begin
inherited Create(ConfigModelRef);
Assert(Length(AControllerClassName) > 0);
FAncestorName := '';
FFormName := '';
FImplFileName := '';
FIntfFileName := '';
FControllerClassName := AControllerClassName;
FCreateIndexMethod := aCreateIndexMethod;
FCreateCRUDMethods := aCreateCRUDMethods;
FCreateActionFiltersMethods := aCreateActionFiltersMethods;
Personality := APersonality;
end;

Expand All @@ -104,52 +85,7 @@ function TNewControllerUnitEx.NewImplSource(const ModuleIdent, FormIdent,
lUnitIdent: string;
lFormName: string;
lFileName: string;
// lIndexMethodIntf: string;
// lIndexMethodImpl: string;
// lControllerUnit: string;
// lActionFiltersMethodsIntf: string;
// lActionFiltersMethodsImpl: string;
// lCRUDMethodsIntf: string;
// lCRUDMethodsImpl: string;
// lBOClassesIntf: string;
// lBOClassesImpl: string;
begin
{
lControllerUnit := sControllerUnit;
lIndexMethodIntf := sIndexMethodIntf;
lIndexMethodImpl := Format(sIndexMethodImpl, [FControllerClassName]);
lCRUDMethodsIntf := sCRUDMethodsIntf;
lCRUDMethodsImpl := Format(sCRUDMethodsImpl, [FControllerClassName]);
lBOClassesIntf := sBOClassesIntf;
lBOClassesImpl := Format(sBOClassesImpl, ['TPerson']);
if not FCreateIndexMethod then
begin
lIndexMethodIntf := '';
lIndexMethodImpl := '';
end;
if not FCreateCRUDMethods then
begin
lCRUDMethodsIntf := '';
lCRUDMethodsImpl := '';
lBOClassesIntf := '';
lBOClassesImpl := '';
end;
lActionFiltersMethodsIntf := sActionFiltersIntf;
lActionFiltersMethodsImpl := Format(sActionFiltersImpl,
[FControllerClassName]);
if not FCreateActionFiltersMethods then
begin
lActionFiltersMethodsIntf := '';
lActionFiltersMethodsImpl := '';
end;
}
// http://stackoverflow.com/questions/4196412/how-do-you-retrieve-a-new-unit-name-from-delphis-open-tools-api
// So using method mentioned by Marco Cantu.
(BorlandIDEServices as IOTAModuleServices).GetNewModuleAndClassName('',
Expand All @@ -164,19 +100,6 @@ function TNewControllerUnitEx.NewImplSource(const ModuleIdent, FormIdent,
FillControllerTemplates(Gen);
end,
fConfigModelRef);
// Result := TSourceFile.Create(sControllerUnit,
// [
// lUnitIdent,
// FControllerClassName,
// lIndexMethodIntf,
// lIndexMethodImpl,
// lActionFiltersMethodsIntf,
// lActionFiltersMethodsImpl,
// lCRUDMethodsIntf,
// lCRUDMethodsImpl,
// lBOClassesIntf,
// lBOClassesImpl
// ]);
end;

{ TNewJSONRPCUnitEx }
Expand All @@ -201,11 +124,6 @@ function TNewJSONRPCUnitEx.NewImplSource(const ModuleIdent, FormIdent,
lFileName := '';
(BorlandIDEServices as IOTAModuleServices).GetNewModuleAndClassName('',
lUnitIdent, lDummy, lFileName);
// Result := TSourceFile.Create(sJSONRPCUnit,
// [
// lUnitIdent,
// fJSONRPCClassName
// ]);
fConfigModelRef.S[TConfigKey.jsonrpc_unit_name] := lUnitIdent;
Result := TSourceFile.Create(
procedure (Gen: TMVCCodeGenerator)
Expand Down
30 changes: 0 additions & 30 deletions ideexpert/DMVC.Expert.CodeGen.NewDMVCProject.pas
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,19 @@ interface
type
TDMVCProjectFile = class(TNewProjectEx)
private
FDefaultPort: Integer;
FUseMSHeapOnWindows: Boolean;
fConfigModelRef: TJsonObject;
procedure SetDefaultPort(const Value: Integer);
procedure SetUseMSHeapOnWindows(const Value: Boolean);
protected
function NewProjectSource(const ProjectName: string): IOTAFile; override;
function GetFrameworkType: string; override;
public
constructor Create; overload;
constructor Create(const APersonality: string; const ConfigModelRef: TJSONObject); overload;
property DefaultPort: Integer read FDefaultPort write SetDefaultPort;
property UseMSHeapOnWindows: Boolean read FUseMSHeapOnWindows write SetUseMSHeapOnWindows;
end;

implementation

uses
DMVC.Expert.CodeGen.SourceFile,
DMVC.Expert.CodeGen.Templates,
System.SysUtils,
DMVC.Expert.CodeGen.Executor,
DMVC.Expert.Commands.Templates,
Expand All @@ -72,8 +65,6 @@ constructor TDMVCProjectFile.Create;
// Return Blank and the project will be 'ProjectX.dpr' where X is the next available number
inherited;
FFileName := '';
FDefaultPort := 0;
FUseMSHeapOnWindows := False;
end;

constructor TDMVCProjectFile.Create(const APersonality: string; const ConfigModelRef: TJSONObject);
Expand All @@ -89,19 +80,8 @@ function TDMVCProjectFile.GetFrameworkType: string;
end;

function TDMVCProjectFile.NewProjectSource(const ProjectName: string): IOTAFile;
var
lCodeForUseMSHeapOnWindows: String;
begin
lCodeForUseMSHeapOnWindows := '';
if FUseMSHeapOnWindows then
begin
lCodeForUseMSHeapOnWindows := '{$IF Defined(MSWINDOWS)}' + sLineBreak + ' MSHeap,' + sLineBreak + '{$ENDIF}';
end;
//Result := TSourceFile.Create(sDMVCDPR, [ProjectName, FDefaultPort, lCodeForUseMSHeapOnWindows]);

fConfigModelRef.S[TConfigKey.program_name] := ProjectName;

fConfigModelRef.SaveToFile('C:\todelete\configmodelref.json', False);
Result := TSourceFile.Create(
procedure (Gen: TMVCCodeGenerator)
begin
Expand All @@ -110,14 +90,4 @@ function TDMVCProjectFile.NewProjectSource(const ProjectName: string): IOTAFile;
fConfigModelRef);
end;

procedure TDMVCProjectFile.SetDefaultPort(const Value: Integer);
begin
FDefaultPort := Value;
end;

procedure TDMVCProjectFile.SetUseMSHeapOnWindows(const Value: Boolean);
begin
FUseMSHeapOnWindows := Value;
end;

end.
67 changes: 0 additions & 67 deletions ideexpert/DMVC.Expert.CodeGen.NewWebModuleUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,13 @@ interface
TNewWebModuleUnitEx = class(TNewUnit)
private
FUnitIdent, FFormName, FFileName : String;
FMiddlewares: TArray<String>;
protected
FWebModuleClassName : string;
FControllerClassName: string;
FControllerUnit: string;
FJSONRPCClassName: string;
FJSONRPCClassUnit: string;
function GetCreatorType: string; override;
function NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile; override;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile; override;
public
constructor Create(
const ConfigModelRef: TJSONObject;
const aWebModuleClassName: string;
const aControllerClassName: string;
const aControllerUnit: string;
const aMiddlewares: TArray<String>;
const aJSONRPCClassName: String;
const aJSONRPCClassUnit: String;
const aPersonality : String);reintroduce;
end;

Expand All @@ -70,34 +58,16 @@ implementation
Winapi.Windows,
System.SysUtils,
VCL.Dialogs,
DMVC.Expert.CodeGen.Templates,
DMVC.Expert.CodeGen.SourceFile,
DMVC.Expert.CodeGen.Executor,
DMVC.Expert.Commands.Templates,
DMVC.Expert.Commons;

constructor TNewWebModuleUnitEx.Create(
const ConfigModelRef: TJSONObject;
const aWebModuleClassName: string;
const aControllerClassName: string;
const aControllerUnit: string;
const aMiddlewares: TArray<String>;
const aJSONRPCClassName: String;
const aJSONRPCClassUnit: String;
const aPersonality : String);
begin
inherited Create(ConfigModelRef);
Assert(Length(aWebModuleClassName) > 0);
FAncestorName := '';
FFormName := '';
FImplFileName := '';
FIntfFileName := '';
FJSONRPCClassName := aJSONRPCClassName;
FJSONRPCClassUnit := aJSONRPCClassUnit;
FWebModuleClassName := aWebModuleClassName;
FControllerClassName := aControllerClassName;
FControllerUnit := aControllerUnit;
FMiddlewares := AMiddlewares;
Personality := APersonality;
(BorlandIDEServices as IOTAModuleServices).GetNewModuleAndClassName(
'', FUnitIdent, FFormName, FFileName);
Expand All @@ -110,7 +80,6 @@ function TNewWebModuleUnitEx.GetCreatorType: string;

function TNewWebModuleUnitEx.NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;
begin
//Result := TSourceFile.Create(sWebModuleDFM, [FormIdent, FWebModuleClassName]);
Result := TSourceFile.Create(
procedure (Gen: TMVCCodeGenerator)
begin
Expand All @@ -120,47 +89,11 @@ function TNewWebModuleUnitEx.NewFormFile(const FormIdent, AncestorIdent: string)
end;

function TNewWebModuleUnitEx.NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
var
lJSONRPCCode: string;
lMiddlewaresCode: String;
I: Integer;
begin
lMiddlewaresCode := sLineBreak;
for I := Low(FMiddlewares) to High(FMiddlewares) do
begin
lMiddlewaresCode := lMiddlewaresCode + ' ' + FMiddlewares[I] + sLineBreak;
end;

lJSONRPCCode := '';
if not FJSONRPCClassName.IsEmpty then
begin
lJSONRPCCode := 'FMVC.PublishObject( ' + sLineBreak +
' function : TObject ' + sLineBreak +
' begin ' + sLineBreak +
' Result := ' + FJSONRPCClassName + '.Create; ' + sLineBreak +
' end, ''/jsonrpc'');' + sLineBreak + sLineBreak;
end;

//ModuleIdent is blank for some reason.
// http://stackoverflow.com/questions/4196412/how-do-you-retrieve-a-new-unit-name-from-delphis-open-tools-api
// So using method mentioned by Marco Cantu.
if not lJSONRPCCode.IsEmpty then
begin
if not FJSONRPCClassUnit.IsEmpty then
begin
FJSONRPCClassUnit := FJSONRPCClassUnit + ',';
end;
end;

fConfigModelRef.S[TConfigKey.webmodule_unit_name] := FUnitIdent;
// Result := TSourceFile.Create(sWebModuleUnit, [
// FUnitIdent,
// FWebModuleClassName,
// FControllerUnit,
// FControllerClassName,
// lMiddlewaresCode,
// lJSONRPCCode,
// FJSONRPCClassUnit]);
Result := TSourceFile.Create(
procedure (Gen: TMVCCodeGenerator)
begin
Expand Down
1 change: 0 additions & 1 deletion ideexpert/DMVC.Expert.CodeGen.SourceFile.pas
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function TSourceFile.GetAge: TDateTime;

function TSourceFile.GetSource: string;
begin
//Result := FSource;
Result := TMVCCodeGenerator.GenerateSource(fJSON,
procedure (Gen: TMVCCodeGenerator)
begin
Expand Down
Loading

0 comments on commit 10d3156

Please sign in to comment.