mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 12:00:18 +02:00
* Register Project Options frame for pas2js
git-svn-id: trunk@56991 -
This commit is contained in:
parent
907b1725a5
commit
cd78a8452c
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -3795,7 +3795,6 @@ components/pas2js/frmpas2jsnodejsprojectoptions.lfm svneol=native#text/plain
|
|||||||
components/pas2js/frmpas2jsnodejsprojectoptions.pp svneol=native#text/plain
|
components/pas2js/frmpas2jsnodejsprojectoptions.pp svneol=native#text/plain
|
||||||
components/pas2js/frmpas2jswebservers.lfm svneol=native#text/plain
|
components/pas2js/frmpas2jswebservers.lfm svneol=native#text/plain
|
||||||
components/pas2js/frmpas2jswebservers.pp svneol=native#text/plain
|
components/pas2js/frmpas2jswebservers.pp svneol=native#text/plain
|
||||||
components/pas2js/languages/strpas2jsdesign.po svneol=native#text/plain
|
|
||||||
components/pas2js/languages/strpas2jsdesign.pt_BR.po svneol=native#text/plain
|
components/pas2js/languages/strpas2jsdesign.pt_BR.po svneol=native#text/plain
|
||||||
components/pas2js/languages/strpas2jsdesign.ru.po svneol=native#text/plain
|
components/pas2js/languages/strpas2jsdesign.ru.po svneol=native#text/plain
|
||||||
components/pas2js/languages/strpas2jsdesign.uk.po svneol=native#text/plain
|
components/pas2js/languages/strpas2jsdesign.uk.po svneol=native#text/plain
|
||||||
@ -3806,6 +3805,8 @@ components/pas2js/pjsdsgnoptions.pas svneol=native#text/plain
|
|||||||
components/pas2js/pjsdsgnoptsframe.lfm svneol=native#text/plain
|
components/pas2js/pjsdsgnoptsframe.lfm svneol=native#text/plain
|
||||||
components/pas2js/pjsdsgnoptsframe.pas svneol=native#text/plain
|
components/pas2js/pjsdsgnoptsframe.pas svneol=native#text/plain
|
||||||
components/pas2js/pjsdsgnregister.pas svneol=native#text/plain
|
components/pas2js/pjsdsgnregister.pas svneol=native#text/plain
|
||||||
|
components/pas2js/pjsprojectoptions.lfm svneol=native#text/plain
|
||||||
|
components/pas2js/pjsprojectoptions.pp svneol=native#text/plain
|
||||||
components/pas2js/strpas2jsdesign.pp svneol=native#text/plain
|
components/pas2js/strpas2jsdesign.pp svneol=native#text/plain
|
||||||
components/plotfunction/demo/event/frmmain.lfm svneol=native#text/plain
|
components/plotfunction/demo/event/frmmain.lfm svneol=native#text/plain
|
||||||
components/plotfunction/demo/event/frmmain.pp svneol=native#text/plain
|
components/plotfunction/demo/event/frmmain.pp svneol=native#text/plain
|
||||||
|
@ -80,10 +80,7 @@ procedure TWebBrowserProjectOptionsForm.CBUseHTTPServerChange(Sender: TObject);
|
|||||||
C.Enabled:=CBUseHTTPServer.Checked;
|
C.Enabled:=CBUseHTTPServer.Checked;
|
||||||
if C is TRadioButton then
|
if C is TRadioButton then
|
||||||
if not C.Enabled then
|
if not C.Enabled then
|
||||||
begin
|
|
||||||
Writeln('Unchecking ',C.Name);
|
|
||||||
TRadioButton(C).Checked:=False;
|
TRadioButton(C).Checked:=False;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
|
||||||
|
|
||||||
#: strpas2jsdesign.pjsdnodejsappdescription
|
|
||||||
msgid "A pas2js program running in node.js"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.pjsdnodejsapplication
|
|
||||||
msgid "Node.js Application"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.pjsdwebappdescription
|
|
||||||
msgid "A pas2js program running in the browser"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.pjsdwebapplication
|
|
||||||
msgid "Web Browser Application"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.spasjswebserverscaption
|
|
||||||
msgid "Pas2JS WebServers"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.sstatuserror
|
|
||||||
msgid "Error starting"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.sstatusrunning
|
|
||||||
msgid "Running"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.sstatusstopped
|
|
||||||
msgid "Stopped"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserversbasedir
|
|
||||||
msgid "Root directory"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserverscaption
|
|
||||||
msgid "Web server processes"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserverscount
|
|
||||||
msgid "Number of webserver processes:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserversextra
|
|
||||||
msgid "Additional info"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserversport
|
|
||||||
msgid "Port"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserversproject
|
|
||||||
msgid "Project"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: strpas2jsdesign.swebserversstatus
|
|
||||||
msgid "Status"
|
|
||||||
msgstr ""
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
<Description Value="Adds a Lazarus project for pas2js browser applications."/>
|
<Description Value="Adds a Lazarus project for pas2js browser applications."/>
|
||||||
<License Value="GPL-2"/>
|
<License Value="GPL-2"/>
|
||||||
<Version Major="1" Release="1"/>
|
<Version Major="1" Release="1"/>
|
||||||
<Files Count="8">
|
<Files Count="10">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="pjsdsgnregister.pas"/>
|
<Filename Value="pjsdsgnregister.pas"/>
|
||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
@ -52,6 +52,14 @@
|
|||||||
<Filename Value="strpas2jsdesign.pp"/>
|
<Filename Value="strpas2jsdesign.pp"/>
|
||||||
<UnitName Value="strpas2jsdesign"/>
|
<UnitName Value="strpas2jsdesign"/>
|
||||||
</Item8>
|
</Item8>
|
||||||
|
<Item9>
|
||||||
|
<Filename Value="pjsprojectoptions.pp"/>
|
||||||
|
<UnitName Value="pjsprojectoptions"/>
|
||||||
|
</Item9>
|
||||||
|
<Item10>
|
||||||
|
<Filename Value="pjsprojectoptions.pp"/>
|
||||||
|
<UnitName Value="pjsprojectoptions"/>
|
||||||
|
</Item10>
|
||||||
</Files>
|
</Files>
|
||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N Value="True"/>
|
<EnableI18N Value="True"/>
|
||||||
|
@ -10,7 +10,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
PJSDsgnRegister, PJSDsgnOptsFrame, frmpas2jsbrowserprojectoptions,
|
PJSDsgnRegister, PJSDsgnOptsFrame, frmpas2jsbrowserprojectoptions,
|
||||||
PJSDsgnOptions, frmpas2jsnodejsprojectoptions, pjscontroller,
|
PJSDsgnOptions, frmpas2jsnodejsprojectoptions, pjscontroller,
|
||||||
frmpas2jswebservers, strpas2jsdesign, LazarusPackageIntf;
|
frmpas2jswebservers, strpas2jsdesign, pjsprojectoptions, LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -70,9 +70,13 @@ Type
|
|||||||
Const
|
Const
|
||||||
// Custom settings in .lpi
|
// Custom settings in .lpi
|
||||||
PJSProjectWebBrowser = 'PasJSWebBrowserProject';
|
PJSProjectWebBrowser = 'PasJSWebBrowserProject';
|
||||||
PJSProjectURL = 'PasJSURL';
|
|
||||||
PJSProjectHTMLFile = 'PasJSHTMLFile';
|
PJSProjectHTMLFile = 'PasJSHTMLFile';
|
||||||
|
PJSIsProjectHTMLFile = 'PasJSIsProjectHTMLFile';
|
||||||
|
PJSProjectMaintainHTML = 'MaintainHTML';
|
||||||
|
PJSProjectUseBrowserConsole = 'BrowserConsole';
|
||||||
|
PJSProjectRunAtReady = 'RunAtReady';
|
||||||
PJSProjectPort = 'PasJSPort';
|
PJSProjectPort = 'PasJSPort';
|
||||||
|
PJSProjectURL = 'PasJSURL';
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -39,7 +39,6 @@ type
|
|||||||
function ShowOptionsDialog: TModalResult; virtual;
|
function ShowOptionsDialog: TModalResult; virtual;
|
||||||
public
|
public
|
||||||
constructor Create; override;
|
constructor Create; override;
|
||||||
function GetBrowserCommand(AFileName: string): String;
|
|
||||||
Function DoInitDescriptor : TModalResult; override;
|
Function DoInitDescriptor : TModalResult; override;
|
||||||
function GetLocalizedName: string; override;
|
function GetLocalizedName: string; override;
|
||||||
function GetLocalizedDescription: string; override;
|
function GetLocalizedDescription: string; override;
|
||||||
@ -73,6 +72,10 @@ type
|
|||||||
var
|
var
|
||||||
PJSOptionsFrameID: integer = 1000;
|
PJSOptionsFrameID: integer = 1000;
|
||||||
|
|
||||||
|
Const
|
||||||
|
// Position in project options dialog.
|
||||||
|
Pas2JSOptionsIndex = ProjectOptionsMisc + 100;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -81,6 +84,7 @@ uses
|
|||||||
frmpas2jswebservers,
|
frmpas2jswebservers,
|
||||||
frmpas2jsnodejsprojectoptions,
|
frmpas2jsnodejsprojectoptions,
|
||||||
frmpas2jsbrowserprojectoptions,
|
frmpas2jsbrowserprojectoptions,
|
||||||
|
pjsprojectoptions,
|
||||||
pjscontroller, strpas2jsdesign, MenuIntf;
|
pjscontroller, strpas2jsdesign, MenuIntf;
|
||||||
|
|
||||||
procedure ShowServerDialog(Sender: TObject);
|
procedure ShowServerDialog(Sender: TObject);
|
||||||
@ -98,10 +102,13 @@ begin
|
|||||||
// register new-project items
|
// register new-project items
|
||||||
RegisterProjectDescriptor(TProjectPas2JSWebApp.Create);
|
RegisterProjectDescriptor(TProjectPas2JSWebApp.Create);
|
||||||
RegisterProjectDescriptor(TProjectPas2JSNodeJSApp.Create);
|
RegisterProjectDescriptor(TProjectPas2JSNodeJSApp.Create);
|
||||||
// add options frame
|
// add IDE options frame
|
||||||
PJSOptionsFrameID:=RegisterIDEOptionsEditor(GroupEnvironment,TPas2jsOptionsFrame,
|
PJSOptionsFrameID:=RegisterIDEOptionsEditor(GroupEnvironment,TPas2jsOptionsFrame,
|
||||||
PJSOptionsFrameID)^.Index;
|
PJSOptionsFrameID)^.Index;
|
||||||
RegisterIdeMenuCommand(itmViewDebugWindows,'Pas2JSWebservers',SPasJSWebserversCaption,nil,@ShowServerDialog);
|
RegisterIdeMenuCommand(itmViewDebugWindows,'Pas2JSWebservers',SPasJSWebserversCaption,nil,@ShowServerDialog);
|
||||||
|
// Add project options frame
|
||||||
|
RegisterIDEOptionsEditor(GroupProject,TPas2JSProjectOptionsFrame, Pas2JSOptionsIndex);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TProjectPas2JSNodeJSApp }
|
{ TProjectPas2JSNodeJSApp }
|
||||||
@ -243,23 +250,10 @@ begin
|
|||||||
MainFile.IsPartOfProject:=true;
|
MainFile.IsPartOfProject:=true;
|
||||||
AProject.AddFile(MainFile,false);
|
AProject.AddFile(MainFile,false);
|
||||||
AProject.MainFileID:=0;
|
AProject.MainFileID:=0;
|
||||||
|
|
||||||
CompOpts:=AProject.LazCompilerOptions;
|
|
||||||
CompOpts.TargetFilename:='program1';
|
|
||||||
CompOpts.Win32GraphicApp:=false;
|
|
||||||
CompOpts.UnitOutputDirectory:='js';
|
|
||||||
CompOpts.TargetFilename:='project1';
|
CompOpts.TargetFilename:='project1';
|
||||||
if Length(PJSOptions.CompilerFilename)=0 then
|
SetDefaultNodeJSCompileOptions(AProject.LazCompilerOptions);
|
||||||
Compiler:='$MakeExe(pas2js)'
|
|
||||||
else
|
|
||||||
Compiler:=AnsiQuotedStr(PJSOptions.CompilerFilename, '"');
|
|
||||||
CompOpts.SetAlternativeCompile(Compiler+' -Jc -Jminclude -Tnodejs "-Fu$(ProjUnitPath)" $Name($(ProjFile))',true);
|
|
||||||
|
|
||||||
RunParams:=AProject.RunParameters.Find('Default');
|
SetDefaultNodeRunParams(AProject.RunParameters.GetOrCreate('Default'));
|
||||||
if (RunParams=Nil) then
|
|
||||||
RunParams:=AProject.RunParameters.Add('Default');
|
|
||||||
RunParams.UseLaunchingApplication:=True;
|
|
||||||
RunParams.LaunchingApplicationPathPlusParams:='$(Pas2JSNodeJS) "$MakeDir($(ProjPath))$NameOnly($(ProjFile)).js"';
|
|
||||||
|
|
||||||
// create program source
|
// create program source
|
||||||
AProject.MainFile.SetSourceText(CreateProjectSource,true);
|
AProject.MainFile.SetSourceText(CreateProjectSource,true);
|
||||||
@ -285,11 +279,11 @@ begin
|
|||||||
Flags:=DefaultProjectNoApplicationFlags-[pfRunnable];
|
Flags:=DefaultProjectNoApplicationFlags-[pfRunnable];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProjectPas2JSWebApp.GetBrowserCommand(AFileName : string): String;
|
(*function TProjectPas2JSWebApp.GetBrowserCommand(AFileName : string): String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:='$(Pas2JSBrowser) $(Pas2JSProjectURL)';
|
Result:='$(Pas2JSBrowser) $(Pas2JSProjectURL)'
|
||||||
end;
|
end; *)
|
||||||
|
|
||||||
function TProjectPas2JSWebApp.GetNextPort : Word;
|
function TProjectPas2JSWebApp.GetNextPort : Word;
|
||||||
|
|
||||||
@ -497,45 +491,28 @@ end;
|
|||||||
function TProjectPas2JSWebApp.InitProject(AProject: TLazProject): TModalResult;
|
function TProjectPas2JSWebApp.InitProject(AProject: TLazProject): TModalResult;
|
||||||
|
|
||||||
var
|
var
|
||||||
MainFile : TLazProjectFile;
|
MainFile,
|
||||||
CompOpts: TLazCompilerOptions;
|
HTMLFile : TLazProjectFile;
|
||||||
RunParams : TAbstractRunParamsOptionsMode;
|
|
||||||
Compiler : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=inherited InitProject(AProject);
|
Result:=inherited InitProject(AProject);
|
||||||
|
|
||||||
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
MainFile:=AProject.CreateProjectFile('project1.lpr');
|
||||||
MainFile.IsPartOfProject:=true;
|
MainFile.IsPartOfProject:=true;
|
||||||
AProject.AddFile(MainFile,false);
|
AProject.AddFile(MainFile,false);
|
||||||
AProject.MainFileID:=0;
|
AProject.MainFileID:=0;
|
||||||
|
SetDefaultWebCompileOptions(AProject.LazCompilerOptions);
|
||||||
CompOpts:=AProject.LazCompilerOptions;
|
SetDefaultWebRunParams(AProject.RunParameters.GetOrCreate('Default'));
|
||||||
CompOpts.TargetFilename:='program1';
|
|
||||||
CompOpts.Win32GraphicApp:=false;
|
|
||||||
CompOpts.UnitOutputDirectory:='js';
|
|
||||||
CompOpts.TargetFilename:='project1';
|
|
||||||
if Length(PJSOptions.CompilerFilename)=0 then
|
|
||||||
Compiler:='$MakeExe(pas2js)'
|
|
||||||
else
|
|
||||||
Compiler:=AnsiQuotedStr(PJSOptions.CompilerFilename, '"');
|
|
||||||
CompOpts.SetAlternativeCompile(Compiler+' -Jirtl.js -Jc -Jminclude -Tbrowser "-Fu$(ProjUnitPath)" $Name($(ProjFile))',true);
|
|
||||||
RunParams:=AProject.RunParameters.Find('Default');
|
|
||||||
if (RunParams=Nil) then
|
|
||||||
RunParams:=AProject.RunParameters.Add('Default');
|
|
||||||
RunParams.UseLaunchingApplication:=True;
|
|
||||||
RunParams.LaunchingApplicationPathPlusParams:=GetBrowserCommand(CompOpts.TargetFileName);
|
|
||||||
AProject.MainFile.SetSourceText(CreateProjectSource,true);
|
AProject.MainFile.SetSourceText(CreateProjectSource,true);
|
||||||
AProject.CustomData.Values[PJSProjectWebBrowser]:='1';
|
AProject.CustomData.Values[PJSProjectWebBrowser]:='1';
|
||||||
if baoUseURL in Options then
|
if baoUseURL in Options then
|
||||||
begin
|
begin
|
||||||
AProject.CustomData.Values[PJSProjectPort]:='';
|
AProject.CustomData.Remove(PJSProjectPort);
|
||||||
AProject.CustomData.Values[PJSProjectURL]:=ProjectURL;
|
AProject.CustomData.Values[PJSProjectURL]:=ProjectURL;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
AProject.CustomData.Values[PJSProjectPort]:=IntToStr(ProjectPort);
|
AProject.CustomData.Values[PJSProjectPort]:=IntToStr(ProjectPort);
|
||||||
AProject.CustomData.Values[PJSProjectURL]:='';
|
AProject.CustomData.Remove(PJSProjectURL);
|
||||||
end;
|
end;
|
||||||
With AProject.CustomData do
|
With AProject.CustomData do
|
||||||
begin
|
begin
|
||||||
@ -545,8 +522,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
// create html source
|
// create html source
|
||||||
if baoCreateHtml in Options then
|
if baoCreateHtml in Options then
|
||||||
CreateHTMLFile(aProject,'project1.js');
|
begin
|
||||||
|
HTMLFile:=CreateHTMLFile(aProject,'project1.js');
|
||||||
|
HTMLFIle.CustomData[PJSIsProjectHTMLFile]:='1';
|
||||||
|
if baoMaintainHTML in Options then
|
||||||
|
AProject.CustomData.Values[PJSProjectMaintainHTML]:='1';
|
||||||
|
if baoUseBrowserConsole in Options then
|
||||||
|
AProject.CustomData[PJSProjectWebBrowser]:='1';
|
||||||
|
if baoRunOnReady in options then
|
||||||
|
AProject.CustomData[PJSProjectRunAtReady]:='1';
|
||||||
|
end;
|
||||||
AProject.AddPackageDependency('pas2js_rtl');
|
AProject.AddPackageDependency('pas2js_rtl');
|
||||||
if baoUseBrowserApp in Options then
|
if baoUseBrowserApp in Options then
|
||||||
AProject.AddPackageDependency('fcl_base_pas2js');
|
AProject.AddPackageDependency('fcl_base_pas2js');
|
||||||
|
176
components/pas2js/pjsprojectoptions.lfm
Normal file
176
components/pas2js/pjsprojectoptions.lfm
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
object Pas2JSProjectOptionsFrame: TPas2JSProjectOptionsFrame
|
||||||
|
Left = 0
|
||||||
|
Height = 372
|
||||||
|
Top = 0
|
||||||
|
Width = 495
|
||||||
|
ClientHeight = 372
|
||||||
|
ClientWidth = 495
|
||||||
|
TabOrder = 0
|
||||||
|
DesignLeft = 473
|
||||||
|
DesignTop = 400
|
||||||
|
object CBWebProject: TCheckBox
|
||||||
|
Left = 12
|
||||||
|
Height = 22
|
||||||
|
Top = 8
|
||||||
|
Width = 252
|
||||||
|
Caption = 'Project is a Web Browser (pas2js) project'
|
||||||
|
OnChange = CBWebProjectChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object LCBProjectHTMLFile: TLabel
|
||||||
|
AnchorSideTop.Control = CBWebProject
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 18
|
||||||
|
Height = 17
|
||||||
|
Top = 36
|
||||||
|
Width = 98
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Project HTML file:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object CBHTMLFile: TComboBox
|
||||||
|
AnchorSideTop.Control = LCBProjectHTMLFile
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = Owner
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 16
|
||||||
|
Height = 31
|
||||||
|
Top = 59
|
||||||
|
Width = 463
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
BorderSpacing.Right = 16
|
||||||
|
ItemHeight = 0
|
||||||
|
Style = csDropDownList
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object CBMaintainHTMLFile: TCheckBox
|
||||||
|
AnchorSideTop.Control = CBHTMLFile
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 12
|
||||||
|
Height = 22
|
||||||
|
Top = 90
|
||||||
|
Width = 131
|
||||||
|
Caption = 'Maintain HTML File'
|
||||||
|
OnChange = CBMaintainHTMLFileChange
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object CBRunOnReady: TCheckBox
|
||||||
|
AnchorSideLeft.Control = CBUseBrowserConsole
|
||||||
|
AnchorSideTop.Control = CBUseBrowserConsole
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 36
|
||||||
|
Height = 22
|
||||||
|
Top = 146
|
||||||
|
Width = 288
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Run rtl when all page resources are fully loaded'
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object SEPort: TSpinEdit
|
||||||
|
AnchorSideLeft.Control = RBStartServerAt
|
||||||
|
AnchorSideTop.Control = RBStartServerAt
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 76
|
||||||
|
Height = 27
|
||||||
|
Top = 226
|
||||||
|
Width = 82
|
||||||
|
BorderSpacing.Left = 32
|
||||||
|
BorderSpacing.Top = 2
|
||||||
|
MaxValue = 65354
|
||||||
|
MinValue = 1024
|
||||||
|
TabOrder = 4
|
||||||
|
Value = 3000
|
||||||
|
end
|
||||||
|
object RBStartServerAt: TRadioButton
|
||||||
|
AnchorSideLeft.Control = CBUseHTTPServer
|
||||||
|
AnchorSideTop.Control = CBUseHTTPServer
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 44
|
||||||
|
Height = 22
|
||||||
|
Top = 202
|
||||||
|
Width = 167
|
||||||
|
BorderSpacing.Left = 32
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Start HTTP Server on port'
|
||||||
|
Checked = True
|
||||||
|
OnChange = RBStartServerAtChange
|
||||||
|
TabOrder = 5
|
||||||
|
TabStop = True
|
||||||
|
end
|
||||||
|
object CBServerURL: TComboBox
|
||||||
|
AnchorSideLeft.Control = SEPort
|
||||||
|
AnchorSideTop.Control = RBUseURL
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = Owner
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 76
|
||||||
|
Height = 29
|
||||||
|
Top = 283
|
||||||
|
Width = 403
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
BorderSpacing.Right = 16
|
||||||
|
ItemHeight = 0
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
|
object RBUseURL: TRadioButton
|
||||||
|
AnchorSideLeft.Control = RBStartServerAt
|
||||||
|
AnchorSideTop.Control = SEPort
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 44
|
||||||
|
Height = 22
|
||||||
|
Top = 255
|
||||||
|
Width = 161
|
||||||
|
BorderSpacing.Top = 2
|
||||||
|
Caption = 'Use this URL to start app'
|
||||||
|
OnChange = RBUseURLChange
|
||||||
|
TabOrder = 7
|
||||||
|
end
|
||||||
|
object CBUseHTTPServer: TCheckBox
|
||||||
|
AnchorSideLeft.Control = CBMaintainHTMLFile
|
||||||
|
AnchorSideTop.Control = CBRunOnReady
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 12
|
||||||
|
Height = 22
|
||||||
|
Top = 174
|
||||||
|
Width = 183
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Project needs a HTTP Server'
|
||||||
|
OnChange = CBUseHTTPServerChange
|
||||||
|
TabOrder = 8
|
||||||
|
end
|
||||||
|
object CBUseBrowserConsole: TCheckBox
|
||||||
|
AnchorSideLeft.Control = CBMaintainHTMLFile
|
||||||
|
AnchorSideTop.Control = CBMaintainHTMLFile
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 36
|
||||||
|
Height = 22
|
||||||
|
Top = 118
|
||||||
|
Width = 312
|
||||||
|
BorderSpacing.Left = 24
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'Use Browser Console unit to display writeln() output'
|
||||||
|
TabOrder = 9
|
||||||
|
end
|
||||||
|
object BResetRunCommand: TButton
|
||||||
|
Left = 18
|
||||||
|
Height = 25
|
||||||
|
Top = 339
|
||||||
|
Width = 172
|
||||||
|
Anchors = [akLeft, akBottom]
|
||||||
|
Caption = 'Reset Run Command'
|
||||||
|
OnClick = BResetRunCommandClick
|
||||||
|
TabOrder = 10
|
||||||
|
end
|
||||||
|
object BResetCompileCommand: TButton
|
||||||
|
Left = 204
|
||||||
|
Height = 25
|
||||||
|
Top = 339
|
||||||
|
Width = 172
|
||||||
|
Anchors = [akLeft, akBottom]
|
||||||
|
Caption = 'Reset compile Command'
|
||||||
|
OnClick = BResetCompileCommandClick
|
||||||
|
TabOrder = 11
|
||||||
|
end
|
||||||
|
end
|
318
components/pas2js/pjsprojectoptions.pp
Normal file
318
components/pas2js/pjsprojectoptions.pp
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
unit pjsprojectoptions;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, Spin, projectintf, CompOptsIntf, IDEOptionsIntf;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TPas2JSProjectOptionsFrame }
|
||||||
|
|
||||||
|
TPas2JSProjectOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||||
|
BResetRunCommand: TButton;
|
||||||
|
BResetCompileCommand: TButton;
|
||||||
|
CBRunOnReady: TCheckBox;
|
||||||
|
CBServerURL: TComboBox;
|
||||||
|
CBUseBrowserConsole: TCheckBox;
|
||||||
|
CBUseHTTPServer: TCheckBox;
|
||||||
|
CBWebProject: TCheckBox;
|
||||||
|
CBHTMLFile: TComboBox;
|
||||||
|
CBMaintainHTMLFile: TCheckBox;
|
||||||
|
LCBProjectHTMLFile: TLabel;
|
||||||
|
RBStartServerAt: TRadioButton;
|
||||||
|
RBUseURL: TRadioButton;
|
||||||
|
SEPort: TSpinEdit;
|
||||||
|
procedure BResetCompileCommandClick(Sender: TObject);
|
||||||
|
procedure BResetRunCommandClick(Sender: TObject);
|
||||||
|
procedure CBMaintainHTMLFileChange(Sender: TObject);
|
||||||
|
procedure CBUseHTTPServerChange(Sender: TObject);
|
||||||
|
procedure CBWebProjectChange(Sender: TObject);
|
||||||
|
procedure RBStartServerAtChange(Sender: TObject);
|
||||||
|
procedure RBUseURLChange(Sender: TObject);
|
||||||
|
private
|
||||||
|
procedure CheckAllControls(aEnabled: Boolean);
|
||||||
|
procedure CheckHTMLOptions(aEnabled: Boolean);
|
||||||
|
procedure CheckServerOptions(aEnabled: Boolean);
|
||||||
|
function FillFilesCombo(PRJ: TLazProject): Integer;
|
||||||
|
procedure ToggleCB(CB: TCheckBox; aEnabled: Boolean);
|
||||||
|
|
||||||
|
public
|
||||||
|
function GetTitle: string; override;
|
||||||
|
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
|
||||||
|
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
|
||||||
|
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
|
||||||
|
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetDefaultWebRunParams(RunParams : TAbstractRunParamsOptionsMode);
|
||||||
|
Procedure SetDefaultNodeRunParams(RunParams : TAbstractRunParamsOptionsMode);
|
||||||
|
Procedure SetDefaultWebCompileOptions(CompOpts: TLazCompilerOptions);
|
||||||
|
Procedure SetDefaultNodeJSCompileOptions(CompOpts: TLazCompilerOptions);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses ideintf, lazideintf, pjsdsgnoptions, pjscontroller;
|
||||||
|
|
||||||
|
Procedure ResetRunParams(RunParams : TAbstractRunParamsOptionsMode);
|
||||||
|
|
||||||
|
begin
|
||||||
|
RunParams.HostApplicationFilename:='';
|
||||||
|
RunParams.CmdLineParams:='';
|
||||||
|
RunParams.UseLaunchingApplication:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetDefaultWebRunParams(RunParams : TAbstractRunParamsOptionsMode);
|
||||||
|
|
||||||
|
begin
|
||||||
|
ResetRunParams(RunParams);
|
||||||
|
RunParams.LaunchingApplicationPathPlusParams:='$(Pas2JSBrowser) $(Pas2JSProjectURL)';
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetDefaultNodeRunParams(RunParams : TAbstractRunParamsOptionsMode);
|
||||||
|
|
||||||
|
begin
|
||||||
|
ResetRunParams(RunParams);
|
||||||
|
RunParams.LaunchingApplicationPathPlusParams:='$(Pas2JSNodeJS) "$MakeDir($(ProjPath))$NameOnly($(ProjFile)).js"';
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetPasJSCompileOptions(CompOpts: TLazCompilerOptions; Opts : String);
|
||||||
|
|
||||||
|
Var
|
||||||
|
Compiler : String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
CompOpts.Win32GraphicApp:=false;
|
||||||
|
CompOpts.UnitOutputDirectory:='js';
|
||||||
|
if Length(PJSOptions.CompilerFilename)=0 then
|
||||||
|
Compiler:='$MakeExe(pas2js)'
|
||||||
|
else
|
||||||
|
Compiler:=AnsiQuotedStr(PJSOptions.CompilerFilename, '"');
|
||||||
|
CompOpts.SetAlternativeCompile(Compiler+' '+Opts,true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetDefaultWebCompileOptions(CompOpts: TLazCompilerOptions);
|
||||||
|
|
||||||
|
begin
|
||||||
|
SetPasJSCompileOptions(CompOpts,'-Jirtl.js -Jc -Jminclude -Tbrowser "-Fu$(ProjUnitPath)" $Name($(ProjFile))');
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetDefaultNodeJSCompileOptions(CompOpts: TLazCompilerOptions);
|
||||||
|
|
||||||
|
begin
|
||||||
|
SetPasJSCompileOptions(CompOpts,'-Jc -Jminclude -Tnodejs "-Fu$(ProjUnitPath)" $Name($(ProjFile))');
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
{ TPas2JSProjectOptionsFrame }
|
||||||
|
|
||||||
|
function TPas2JSProjectOptionsFrame.GetTitle: string;
|
||||||
|
begin
|
||||||
|
Result:='Web Project (pas2js)'
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
|
||||||
|
begin
|
||||||
|
// Do nothing
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CBWebProjectChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CheckAllControls(CBWebProject.Checked);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.RBStartServerAtChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SEPort.Enabled:=RBStartServerAt.Enabled and RBStartServerAt.Checked;;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.RBUseURLChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CBServerURL.Enabled:=RBUseURL.Enabled and RBUseURL.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CBMaintainHTMLFileChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CheckHTMLOptions(CBMaintainHTMLFile.Checked);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.BResetRunCommandClick(Sender: TObject);
|
||||||
|
|
||||||
|
Var
|
||||||
|
Prj : TLazProject;
|
||||||
|
RP : TAbstractRunParamsOptionsMode;
|
||||||
|
|
||||||
|
begin
|
||||||
|
PRJ:=LazarusIDE.ActiveProject;
|
||||||
|
SetDefaultWebRunParams(Prj.RunParameters.GetOrCreate('Default'));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.BResetCompileCommandClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CBUseHTTPServerChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CheckServerOptions(CBUseHTTPServer.Checked);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.ToggleCB(CB : TCheckBox; aEnabled: Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
With CB do
|
||||||
|
begin
|
||||||
|
Enabled:=aEnabled;
|
||||||
|
if not AEnabled then
|
||||||
|
Checked:=False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CheckHTMLOptions(aEnabled : Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
ToggleCB(CBUseBrowserConsole,aEnabled);
|
||||||
|
ToggleCB(CBRunOnReady,aEnabled);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CheckServerOptions(aEnabled : Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
RBStartServerAt.Enabled:=aEnabled;
|
||||||
|
RBUseURL.Enabled:=aEnabled;
|
||||||
|
SEPort.Enabled:=aEnabled and RBStartServerAt.Checked;
|
||||||
|
CBServerURL.Enabled:=aEnabled and RBUseURL.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.CheckAllControls(aEnabled : Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
BResetRunCommand.enabled:=aEnabled;
|
||||||
|
BResetCompileCommand.Enabled:=aEnabled;
|
||||||
|
CBHTMLFile.Enabled:=aEnabled;
|
||||||
|
ToggleCB(CBMaintainHTMLFile,aEnabled);
|
||||||
|
CheckHTMLOptions(CBMaintainHTMLFile.Checked);
|
||||||
|
ToggleCB(CBUseHTTPServer,aEnabled);
|
||||||
|
CheckServerOptions(CBUseHTTPServer.Checked)
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
// Fill combo with HTM(L) files.
|
||||||
|
// Return index of file that has IsProjectHTMLFile set.
|
||||||
|
Function TPas2JSProjectOptionsFrame.FillFilesCombo(PRJ : TLazProject) : Integer;
|
||||||
|
|
||||||
|
Var
|
||||||
|
I,H : integer;
|
||||||
|
HPF,PF : TLazProjectFile;
|
||||||
|
Ext : String;
|
||||||
|
L : TStringList;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=-1;
|
||||||
|
HPF:=Nil;
|
||||||
|
L:=TstringList.Create;
|
||||||
|
try
|
||||||
|
For I:=0 to PRJ.FileCount-1 do
|
||||||
|
begin
|
||||||
|
PF:=PRJ.Files[i];
|
||||||
|
Ext:=LowerCase(ExtractFileExt(PF.Filename));
|
||||||
|
if Pos(Ext,'.html')>0 then
|
||||||
|
begin
|
||||||
|
L.AddObject(PF.FileName,PF);
|
||||||
|
If PF.CustomData[PJSIsProjectHTMLFile]='1' then
|
||||||
|
HPF:=PF;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
L.Sort;
|
||||||
|
CBHTMLFile.Items:=L;;
|
||||||
|
finally
|
||||||
|
L.Free;
|
||||||
|
end;
|
||||||
|
if (HPF<>Nil) then
|
||||||
|
Result:=CBHTMLFile.Items.IndexOfObject(HPF);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||||
|
|
||||||
|
Var
|
||||||
|
Prj : TLazProject;
|
||||||
|
HFN : String;
|
||||||
|
HTMLIdx : Integer;
|
||||||
|
Port : Word;
|
||||||
|
URL : String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
PRJ:=LazarusIDE.ActiveProject;
|
||||||
|
HTMLIdx:=FillFilesCombo(PRJ);
|
||||||
|
CBWebProject.Checked:=PRJ.CustomData[PJSProjectWebBrowser]='1';
|
||||||
|
if HTMLIdx=-1 then
|
||||||
|
begin
|
||||||
|
HFN:=PRJ.CustomData[PJSProjectHTMLFile];
|
||||||
|
HTMLIdx:=CBHTMLFile.Items.IndexOf(HFN);
|
||||||
|
end;
|
||||||
|
CBHTMLFile.ItemIndex:=HTMLIdx;
|
||||||
|
CBMaintainHTMLFile.Checked:=PRJ.CustomData[PJSProjectMaintainHTML]='1';
|
||||||
|
CBUseBrowserConsole.Checked:=PRJ.CustomData[PJSProjectWebBrowser]='1';
|
||||||
|
CBRunOnReady.Checked:=PRJ.CustomData[PJSProjectRunAtReady]='1';
|
||||||
|
Port:=StrToIntDef(PRJ.CustomData[PJSProjectPort],0);
|
||||||
|
URL:=PRJ.CustomData[PJSProjectURL];
|
||||||
|
CBUseHTTPServer.Checked:=(Port>0) or (URL<>'');
|
||||||
|
SEPort.Value:=Port;
|
||||||
|
CBServerURL.AddHistoryItem(URL,10,True,False);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSProjectOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
|
||||||
|
|
||||||
|
Var
|
||||||
|
Prj : TLazProject;
|
||||||
|
|
||||||
|
Procedure DoBool(N : String; AValue : Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
if AValue then
|
||||||
|
PRJ.CustomData[N]:='1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
PRJ:=LazarusIDE.ActiveProject;
|
||||||
|
// Clear everything
|
||||||
|
With PRJ.CustomData do
|
||||||
|
begin
|
||||||
|
Remove(PJSProjectWebBrowser);
|
||||||
|
Remove(PJSProjectHTMLFile);
|
||||||
|
Remove(PJSProjectMaintainHTML);
|
||||||
|
Remove(PJSProjectWebBrowser);
|
||||||
|
Remove(PJSProjectRunAtReady);
|
||||||
|
Remove(PJSProjectPort);
|
||||||
|
Remove(PJSProjectURL);
|
||||||
|
end;
|
||||||
|
// Set what is needed
|
||||||
|
if CBWebProject.Checked then
|
||||||
|
begin
|
||||||
|
PRJ.CustomData[PJSProjectWebBrowser]:='1';
|
||||||
|
With CBHTMLFile do
|
||||||
|
if ItemIndex<>-1 then
|
||||||
|
(Items.Objects[ItemIndex] as TLazProjectFile).CustomData[PJSIsProjectHTMLFile]:='1';
|
||||||
|
DoBool(PJSProjectMaintainHTML,CBMaintainHTMLFile.Checked);
|
||||||
|
DoBool(PJSProjectWebBrowser,CBUseBrowserConsole.Checked);
|
||||||
|
DoBool(PJSProjectRunAtReady,CBRunOnReady.Checked);
|
||||||
|
if CBUseHTTPServer.Checked then
|
||||||
|
begin
|
||||||
|
if RBStartServerAt.Checked and (SEPort.Value>0) then
|
||||||
|
PRJ.CustomData[PJSProjectPort]:=IntToStr(SEPort.Value);
|
||||||
|
if RBUseURL.Checked and (CBServerURL.Text<>'') then
|
||||||
|
PRJ.CustomData[PJSProjectURL]:=CBServerURL.Text;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TPas2JSProjectOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
||||||
|
begin
|
||||||
|
Result:=TAbstractIDEProjectOptions;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user