added custom property editors for filenames and paths

activated in
- custom tools editor: working dir + executable
- project conf: doc output, object dir, output filename, etc
This commit is contained in:
Basile Burg 2015-01-25 17:30:35 +01:00
parent 4241c7325a
commit 0395b36035
5 changed files with 113 additions and 32 deletions

View File

@ -140,7 +140,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item6> </Item6>
</RequiredPackages> </RequiredPackages>
<Units Count="35"> <Units Count="36">
<Unit0> <Unit0>
<Filename Value="coedit.lpr"/> <Filename Value="coedit.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -358,6 +358,11 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ce_dubwrap"/> <UnitName Value="ce_dubwrap"/>
</Unit34> </Unit34>
<Unit35>
<Filename Value="..\src\ce_inspectors.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ce_inspectors"/>
</Unit35>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -8,7 +8,7 @@ uses
{$ENDIF}{$ENDIF} {$ENDIF}{$ENDIF}
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_observer, ce_libman, Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_observer, ce_libman,
ce_tools, ce_dcd, ce_main, ce_writableComponent, ce_options, ce_symstring, ce_tools, ce_dcd, ce_main, ce_writableComponent, ce_options, ce_symstring,
ce_staticmacro, ce_icons, ce_dubwrap; ce_staticmacro, ce_icons, ce_dubwrap, ce_inspectors;
{$R *.res} {$R *.res}

View File

@ -5,7 +5,7 @@ unit ce_dmdwrap;
interface interface
uses uses
classes, sysutils, process, asyncprocess, ce_common; classes, sysutils, process, asyncprocess, ce_common, ce_inspectors;
(* (*
@ -39,18 +39,18 @@ type
TDocOpts = class(TOptsGroup) TDocOpts = class(TOptsGroup)
private private
fGenDoc: boolean; fGenDoc: boolean;
fDocDir: string; fDocDir: TCEPathname;
fGenJson: boolean; fGenJson: boolean;
fJsonFname: string; fJsonFname: TCEFilename;
procedure setGenDoc(const aValue: boolean); procedure setGenDoc(const aValue: boolean);
procedure setGenJSON(const aValue: boolean); procedure setGenJSON(const aValue: boolean);
procedure setDocDir(const aValue: string); procedure setDocDir(const aValue: TCEPathname);
procedure setJSONFile(const aValue: string); procedure setJSONFile(const aValue: TCEFilename);
published published
property generateDocumentation: boolean read fGenDoc write setGenDoc default false; property generateDocumentation: boolean read fGenDoc write setGenDoc default false;
property generateJSON: boolean read fGenJson write setGenJSON default false; property generateJSON: boolean read fGenJson write setGenJSON default false;
property DocumentationDirectory: string read fDocDir write setDocDir; property DocumentationDirectory: TCEPathname read fDocDir write setDocDir;
property JSONFilename: string read fJsonFname write setJSONFile; property JSONFilename: TCEFilename read fJsonFname write setJSONFile;
public public
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(const aList: TStrings); override; procedure getOpts(const aList: TStrings); override;
@ -208,18 +208,18 @@ type
fIncl: TStringList; fIncl: TStringList;
fImpt: TStringList; fImpt: TStringList;
fExcl: TStringList; fExcl: TStringList;
fFname: string; fFname: TCEFilename;
fObjDir: string; fObjDir: TCEPathname;
procedure setFname(const aValue: string); procedure setFname(const aValue: TCEFilename);
procedure setObjDir(const aValue: string); procedure setObjDir(const aValue: TCEPathname);
procedure setSrcs(aValue: TStringList); procedure setSrcs(aValue: TStringList);
procedure setIncl(aValue: TStringList); procedure setIncl(aValue: TStringList);
procedure setImpt(aValue: TStringList); procedure setImpt(aValue: TStringList);
procedure setExcl(aValue: TStringList); procedure setExcl(aValue: TStringList);
procedure strLstChange(sender: TObject); procedure strLstChange(sender: TObject);
published published
property outputFilename: string read fFname write setFname; property outputFilename: TCEFilename read fFname write setFname;
property objectDirectory: string read fObjDir write setObjDir; property objectDirectory: TCEPathname read fObjDir write setObjDir;
property Sources: TStringList read fExtraSrcs write setSrcs stored false; deprecated; property Sources: TStringList read fExtraSrcs write setSrcs stored false; deprecated;
property exclusions: TStringList read fExcl write setExcl; property exclusions: TStringList read fExcl write setExcl;
property extraSources: TStringList read fExtraSrcs write setSrcs; property extraSources: TStringList read fExtraSrcs write setSrcs;
@ -254,19 +254,19 @@ type
*) *)
TCustomProcOptions = class(TOptsGroup) TCustomProcOptions = class(TOptsGroup)
private private
fExecutable: string; fExecutable: TCEFilename;
fWorkDir: string; fWorkDir: TCEPathname;
fOptions: TProcessOptions; fOptions: TProcessOptions;
fParameters: TStringList; fParameters: TStringList;
fShowWin: TShowWindowOptions; fShowWin: TShowWindowOptions;
procedure setExecutable(const aValue: string); procedure setExecutable(const aValue: TCEFilename);
procedure setWorkDir(const aValue: string); procedure setWorkDir(const aValue: TCEPathname);
procedure setOptions(const aValue: TProcessOptions); procedure setOptions(const aValue: TProcessOptions);
procedure setParameters(aValue: TStringList); procedure setParameters(aValue: TStringList);
procedure setShowWin(const aValue: TShowWindowOptions); procedure setShowWin(const aValue: TShowWindowOptions);
protected protected
property executable: string read fExecutable write setExecutable; property executable: TCEFilename read fExecutable write setExecutable;
property workingDirectory: string read fWorkDir write setWorkDir; property workingDirectory: TCEPathname read fWorkDir write setWorkDir;
property options: TProcessOptions read fOptions write setOptions; property options: TProcessOptions read fOptions write setOptions;
property parameters: TStringList read fParameters write setParameters; property parameters: TStringList read fParameters write setParameters;
property showWindow: TShowWindowOptions read fShowWin write setShowWin; property showWindow: TShowWindowOptions read fShowWin write setShowWin;
@ -422,7 +422,7 @@ begin
doChanged; doChanged;
end; end;
procedure TDocOpts.setDocDir(const aValue: string); procedure TDocOpts.setDocDir(const aValue: TCEPathname);
begin begin
if fDocDir = aValue then if fDocDir = aValue then
exit; exit;
@ -432,7 +432,7 @@ begin
doChanged; doChanged;
end; end;
procedure TDocOpts.setJSONFile(const aValue: string); procedure TDocOpts.setJSONFile(const aValue: TCEFilename);
begin begin
if fJsonFname = aValue then if fJsonFname = aValue then
exit; exit;
@ -887,7 +887,7 @@ begin
inherited; inherited;
end; end;
procedure TPathsOpts.setFname(const aValue: string); procedure TPathsOpts.setFname(const aValue: TCEFilename);
begin begin
if fFname = aValue then exit; if fFname = aValue then exit;
fFname := patchPlateformPath(aValue); fFname := patchPlateformPath(aValue);
@ -895,7 +895,7 @@ begin
doChanged; doChanged;
end; end;
procedure TPathsOpts.setObjDir(const aValue: string); procedure TPathsOpts.setObjDir(const aValue: TCEPathname);
begin begin
if fObjDir = aValue then exit; if fObjDir = aValue then exit;
fObjDir := patchPlateformPath(aValue); fObjDir := patchPlateformPath(aValue);
@ -1045,14 +1045,14 @@ begin
aProcess.StartupOptions := aProcess.StartupOptions + [suoUseShowWindow]; aProcess.StartupOptions := aProcess.StartupOptions + [suoUseShowWindow];
end; end;
procedure TCustomProcOptions.setExecutable(const aValue: string); procedure TCustomProcOptions.setExecutable(const aValue: TCEFilename);
begin begin
if fExecutable = aValue then exit; if fExecutable = aValue then exit;
fExecutable := aValue; fExecutable := aValue;
doChanged; doChanged;
end; end;
procedure TCustomProcOptions.setWorkDir(const aValue: string); procedure TCustomProcOptions.setWorkDir(const aValue: TCEPathname);
begin begin
if fWorkDir = aValue then exit; if fWorkDir = aValue then exit;
fWorkDir := aValue; fWorkDir := aValue;

76
src/ce_inspectors.pas Normal file
View File

@ -0,0 +1,76 @@
unit ce_inspectors;
{$I ce_defines.inc}
interface
uses
Classes, SysUtils, Dialogs, PropEdits;
type
TCEPathname = type string;
TCEFilename = type string;
TCustomPathType = (ptFile, ptFolder);
TCECustomPathEditor = class(TStringPropertyEditor)
private
fType: TCustomPathType;
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
TCEPathnameEditor = class(TCECustomPathEditor)
constructor Create(Hook: TPropertyEditorHook; APropCount: Integer); override;
end;
TCEFilenameEditor = class(TCECustomPathEditor)
constructor Create(Hook: TPropertyEditorHook; APropCount: Integer); override;
end;
implementation
function TCECustomPathEditor.GetAttributes: TPropertyAttributes;
begin
exit( inherited GetAttributes() + [paDialog]);
end;
procedure TCECustomPathEditor.Edit;
var
newValue: string;
begin
case fType of
ptFile:
with TOpenDialog.create(nil) do try
InitialDir := ExtractFileName(GetValue);
FileName := GetValue;
if Execute then SetValue(FileName);
finally
free;
end;
ptFolder:
if SelectDirectory(GetPropInfo^.Name, GetValue, newValue) then
SetValue(newValue);
end;
end;
constructor TCEPathnameEditor.Create(Hook: TPropertyEditorHook; APropCount: Integer);
begin
inherited;
fType := ptFolder;
end;
constructor TCEFilenameEditor.Create(Hook: TPropertyEditorHook; APropCount: Integer);
begin
inherited;
fType := ptFile;
end;
initialization
RegisterPropertyEditor(TypeInfo(TCEPathname), nil, '', TCEPathnameEditor);
RegisterPropertyEditor(TypeInfo(TCEFilename), nil, '', TCEfilenameEditor);
end.

View File

@ -6,15 +6,15 @@ interface
uses uses
Classes, SysUtils, FileUtil, process, menus, Classes, SysUtils, FileUtil, process, menus,
ce_common, ce_writableComponent, ce_interfaces, ce_observer; ce_common, ce_writableComponent, ce_interfaces, ce_observer, ce_inspectors;
type type
TCEToolItem = class(TCollectionItem) TCEToolItem = class(TCollectionItem)
private private
fProcess: TCheckedAsyncProcess; fProcess: TCheckedAsyncProcess;
fExecutable: string; fExecutable: TCEFilename;
fWorkingDir: string; fWorkingDir: TCEPathname;
fShowWin: TShowWindowOptions; fShowWin: TShowWindowOptions;
fOpts: TProcessOptions; fOpts: TProcessOptions;
fParameters: TStringList; fParameters: TStringList;
@ -32,8 +32,8 @@ type
published published
property toolAlias: string read fToolAlias write fToolAlias; property toolAlias: string read fToolAlias write fToolAlias;
property options: TProcessOptions read fOpts write fOpts; property options: TProcessOptions read fOpts write fOpts;
property executable: string read fExecutable write fExecutable; property executable: TCEFilename read fExecutable write fExecutable;
property workingDirectory: string read fWorkingDir write fWorkingDir; property workingDirectory: TCEPathname read fWorkingDir write fWorkingDir;
property parameters: TStringList read fParameters write setParameters; property parameters: TStringList read fParameters write setParameters;
property showWindows: TShowWindowOptions read fShowWin write fShowWin; property showWindows: TShowWindowOptions read fShowWin write fShowWin;
property queryParameters: boolean read fQueryParams write fQueryParams; property queryParameters: boolean read fQueryParams write fQueryParams;