mirror of https://gitlab.com/basile.b/dexed.git
refactored ce_customtools, global variable put off the less and less "main" form
This commit is contained in:
parent
9a939ac470
commit
fc98121147
|
@ -6,7 +6,7 @@ uses
|
|||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols,
|
||||
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_libman, ce_customtools,
|
||||
ce_dcd, ce_observer, ce_main, ce_writableComponent, ce_options, ce_symstring;
|
||||
|
||||
{$R *.res}
|
||||
|
|
|
@ -5,8 +5,8 @@ unit ce_customtools;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, process, asyncprocess, ce_common, ce_writableComponent,
|
||||
ce_interfaces, ce_observer;
|
||||
Classes, SysUtils, FileUtil, process, asyncprocess,
|
||||
ce_common, ce_writableComponent, ce_interfaces, ce_observer;
|
||||
|
||||
type
|
||||
|
||||
|
@ -53,6 +53,12 @@ type
|
|||
property tool[index: integer]: TCEToolItem read getTool;
|
||||
end;
|
||||
|
||||
const
|
||||
toolsFname = 'tools.txt';
|
||||
|
||||
Var
|
||||
CustomTools: TCETools;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
@ -114,13 +120,19 @@ begin
|
|||
end;
|
||||
|
||||
constructor TCETools.create(aOwner: TComponent);
|
||||
var
|
||||
fname: string;
|
||||
begin
|
||||
inherited;
|
||||
fTools := TCollection.Create(TCEToolItem);
|
||||
fname := getDocPath + toolsFname;
|
||||
if fileExists(fname) then loadFromFile(fname)
|
||||
end;
|
||||
|
||||
destructor TCETools.destroy;
|
||||
begin
|
||||
forceDirectory(getDocPath);
|
||||
saveToFile(getDocPath + toolsFname);
|
||||
fTools.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
@ -142,4 +154,7 @@ end;
|
|||
|
||||
initialization
|
||||
RegisterClasses([TCEToolItem, TCETools]);
|
||||
CustomTools := TCETools.create(nil);
|
||||
finalization
|
||||
CustomTools.Free;
|
||||
end.
|
||||
|
|
|
@ -5,7 +5,7 @@ unit ce_libman;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, ce_common, ce_writableComponent, ce_dcd;
|
||||
Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, ce_dcd;
|
||||
|
||||
type
|
||||
|
||||
|
@ -45,19 +45,30 @@ type
|
|||
procedure updateDCD;
|
||||
end;
|
||||
|
||||
const
|
||||
libFname = 'libraryManager.txt';
|
||||
|
||||
var
|
||||
LibMan: TLibraryManager;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TLibraryManager.create(aOwner: TComponent);
|
||||
var
|
||||
fName: string;
|
||||
begin
|
||||
inherited;
|
||||
fCol := TCollection.Create(TLibraryItem);
|
||||
fname := getDocPath + libFname;
|
||||
if fileExists(fname) then loadFromFile(fname);
|
||||
end;
|
||||
|
||||
destructor TLibraryManager.destroy;
|
||||
var
|
||||
fName: string;
|
||||
begin
|
||||
forceDirectory(getDocPath);
|
||||
LibMan.saveToFile(getDocPath + libFname);
|
||||
fCol.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
|
|
@ -10,7 +10,7 @@ uses
|
|||
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, dynlibs,
|
||||
ce_common, ce_dmdwrap, ce_project, ce_dcd, ce_plugin, ce_synmemo, ce_widget,
|
||||
ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf, ce_search,
|
||||
ce_staticexplorer, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_customtools,
|
||||
ce_staticexplorer, ce_miniexplorer, ce_libman, ce_libmaneditor,
|
||||
ce_observer, ce_writableComponent, ce_toolseditor, ce_procinput, ce_cdbcmd;
|
||||
|
||||
type
|
||||
|
@ -193,7 +193,6 @@ type
|
|||
{$IFDEF WIN32}
|
||||
fCdbWidg: TCECdbWidget;
|
||||
{$ENDIF}
|
||||
fTools: TCETools;
|
||||
|
||||
fRunProc: TCheckedAsyncProcess;
|
||||
|
||||
|
@ -221,8 +220,6 @@ type
|
|||
//Init - Fina
|
||||
procedure getCMdParams;
|
||||
procedure checkCompilo;
|
||||
procedure InitLibMan;
|
||||
procedure InitTools;
|
||||
procedure InitMRUs;
|
||||
procedure InitWidgets;
|
||||
procedure InitPlugins;
|
||||
|
@ -278,7 +275,6 @@ type
|
|||
procedure openFile(const aFilename: string);
|
||||
//
|
||||
property WidgetList: TCEWidgetList read fWidgList;
|
||||
property CustomTools: TCETools read fTools;
|
||||
end;
|
||||
|
||||
procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl;
|
||||
|
@ -301,9 +297,6 @@ begin
|
|||
EntitiesConnector.addObserver(self);
|
||||
//
|
||||
InitMRUs;
|
||||
InitLibMan;
|
||||
InitTools;
|
||||
//
|
||||
InitWidgets;
|
||||
InitDocking;
|
||||
InitSettings;
|
||||
|
@ -374,25 +367,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.InitLibMan;
|
||||
var
|
||||
fname: string;
|
||||
begin
|
||||
fname := getDocPath + 'libraryManager.txt';
|
||||
if fileExists(fname) then
|
||||
LibMan.loadFromFile(fname);
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.InitTools;
|
||||
var
|
||||
fname: string;
|
||||
begin
|
||||
fTools := TCETools.create(self);
|
||||
fname := getDocPath + 'tools.txt';
|
||||
if fileExists(fname) then
|
||||
fTools.loadFromFile(fname);
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.InitMRUs;
|
||||
begin
|
||||
fProjMru := TMruFileList.Create;
|
||||
|
@ -576,8 +550,6 @@ begin
|
|||
opts := TCEOptions.create(nil);
|
||||
try
|
||||
forceDirectory(getDocPath);
|
||||
LibMan.saveToFile(getDocPath + 'libraryManager.txt');
|
||||
fTools.saveToFile(getDocPath + 'tools.txt');
|
||||
opts.saveToFile(getDocPath + 'options2.txt');
|
||||
finally
|
||||
opts.Free;
|
||||
|
@ -1538,7 +1510,6 @@ procedure TCEMainForm.newProj;
|
|||
begin
|
||||
fProject := TCEProject.Create(nil);
|
||||
fProject.Name := 'CurrentProject';
|
||||
fProject.libraryManager := LibMan;
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.saveProj;
|
||||
|
|
|
@ -9,7 +9,7 @@ uses
|
|||
LclProc,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, process, asyncprocess, strUtils, ce_common, ce_writableComponent,
|
||||
ce_dmdwrap, ce_libman, ce_observer;
|
||||
ce_dmdwrap, ce_observer;
|
||||
|
||||
type
|
||||
|
||||
|
@ -31,7 +31,6 @@ type
|
|||
fOptsColl: TCollection;
|
||||
fSrcs, fSrcsCop: TStringList;
|
||||
fConfIx: Integer;
|
||||
fLibMan: TLibraryManager;
|
||||
fChangedCount: NativeInt;
|
||||
fProjectSubject: TCECustomSubject;
|
||||
fRunner: TCheckedAsyncProcess;
|
||||
|
@ -80,7 +79,6 @@ type
|
|||
function runProject(const runArgs: string = ''): Boolean;
|
||||
function compileProject: Boolean;
|
||||
//
|
||||
property libraryManager: TLibraryManager read fLibMan write fLibMan;
|
||||
property configuration[ix: integer]: TCompilerConfiguration read getConfig;
|
||||
property currentConfiguration: TCompilerConfiguration read getCurrConf;
|
||||
property onChange: TNotifyEvent read fOnChange write fOnChange;
|
||||
|
@ -92,7 +90,7 @@ type
|
|||
implementation
|
||||
|
||||
uses
|
||||
ce_interfaces, controls, dialogs, ce_symstring;
|
||||
ce_interfaces, controls, dialogs, ce_symstring, ce_libman;
|
||||
|
||||
constructor TCEProject.create(aOwner: TComponent);
|
||||
begin
|
||||
|
@ -321,11 +319,8 @@ begin
|
|||
aList.Add(abs); // process.inc ln 249. double quotes are added if there's a space.
|
||||
end;
|
||||
//
|
||||
if fLibMan <> nil then
|
||||
begin
|
||||
fLibMan.getLibFiles(fLibAliases, aList);
|
||||
fLibMan.getLibSources(fLibAliases, aList);
|
||||
end;
|
||||
LibMan.getLibFiles(fLibAliases, aList);
|
||||
LibMan.getLibSources(fLibAliases, aList);
|
||||
//
|
||||
TCompilerConfiguration(fOptsColl.Items[fConfIx]).getOpts(aList);
|
||||
end;
|
||||
|
|
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, RTTIGrids, Forms, Controls, Graphics, Dialogs,
|
||||
ExtCtrls, Menus, Buttons, StdCtrls, ce_widget;
|
||||
ExtCtrls, Menus, Buttons, StdCtrls, ce_widget, ce_customtools;
|
||||
|
||||
type
|
||||
|
||||
|
@ -34,9 +34,6 @@ type
|
|||
implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
ce_main;
|
||||
|
||||
constructor TCEToolsEditorWidget.create(aOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
@ -47,7 +44,7 @@ procedure TCEToolsEditorWidget.updateNames;
|
|||
var
|
||||
i: Integer;
|
||||
begin
|
||||
with CEMainForm do for i := 0 to CustomTools.tools.Count-1 do
|
||||
for i := 0 to CustomTools.tools.Count-1 do
|
||||
lstTools.Items.Strings[i] := CustomTools.tool[i].toolAlias;
|
||||
end;
|
||||
|
||||
|
@ -59,7 +56,7 @@ begin
|
|||
propsEd.ItemIndex := -1;
|
||||
lstTools.Clear;
|
||||
//
|
||||
with CEMainForm do for i := 0 to CustomTools.tools.Count-1 do
|
||||
for i := 0 to CustomTools.tools.Count-1 do
|
||||
lstTools.AddItem(CustomTools.tool[i].toolAlias, nil);
|
||||
if lstTools.Count > 0 then
|
||||
lstTools.ItemIndex := 0;
|
||||
|
@ -70,22 +67,20 @@ procedure TCEToolsEditorWidget.lstToolsSelectionChange(Sender: TObject;
|
|||
begin
|
||||
if lstTools.ItemIndex = -1 then
|
||||
exit;
|
||||
|
||||
propsEd.TIObject := CEMainForm.CustomTools.tool[lstTools.ItemIndex];
|
||||
propsEd.TIObject := CustomTools.tool[lstTools.ItemIndex];
|
||||
end;
|
||||
|
||||
procedure TCEToolsEditorWidget.propsEdModified(Sender: TObject);
|
||||
begin
|
||||
if propsEd.ItemIndex = -1 then
|
||||
exit;
|
||||
//
|
||||
if propsEd.Rows[propsEd.ItemIndex].Name = 'toolAlias' then
|
||||
updateNames;
|
||||
end;
|
||||
|
||||
procedure TCEToolsEditorWidget.BtnAddToolClick(Sender: TObject);
|
||||
begin
|
||||
CEMainForm.CustomTools.addTool;
|
||||
CustomTools.addTool;
|
||||
DataToGui;
|
||||
end;
|
||||
|
||||
|
@ -93,8 +88,7 @@ procedure TCEToolsEditorWidget.btnRemToolClick(Sender: TObject);
|
|||
begin
|
||||
if lstTools.ItemIndex = -1 then
|
||||
exit;
|
||||
//
|
||||
CEMainForm.CustomTools.tools.Delete(lstTools.ItemIndex);
|
||||
CustomTools.tools.Delete(lstTools.ItemIndex);
|
||||
DataToGui;
|
||||
end;
|
||||
|
||||
|
@ -102,8 +96,7 @@ procedure TCEToolsEditorWidget.btnRunClick(Sender: TObject);
|
|||
begin
|
||||
if lstTools.ItemIndex = -1 then
|
||||
exit;
|
||||
//
|
||||
CEMainForm.CustomTools.tool[lstTools.ItemIndex].execute;
|
||||
CustomTools.tool[lstTools.ItemIndex].execute;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue