added tools editor widget

This commit is contained in:
Basile Burg 2014-10-31 06:06:28 +01:00
parent 9e6639a9c5
commit 02337b060b
6 changed files with 346 additions and 10 deletions

View File

@ -135,7 +135,7 @@
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="26">
<Units Count="27">
<Unit0>
<Filename Value="coedit.lpr"/>
<IsPartOfProject Value="True"/>
@ -296,6 +296,14 @@
<IsPartOfProject Value="True"/>
<UnitName Value="ce_options"/>
</Unit25>
<Unit26>
<Filename Value="..\src\ce_toolseditor.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="CEToolsEditorWidget"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="ce_toolseditor"/>
</Unit26>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -16,15 +16,17 @@ type
fShowWin: TShowWindowOptions;
fOpts: TProcessOptions;
fParameters: TStringList;
fName: string;
fToolAlias: string;
fShortcut: string;
procedure setParameters(const aValue: TStringList);
published
property name: string read fName write fName;
property toolAlias: string read fToolAlias write fToolAlias;
property options: TProcessOptions read fOpts write fOpts;
property executable: string read fExecutable write fExecutable;
property workingDirectory: string read fWorkingDir write fWorkingDir;
property parameters: TStringList read fParameters write setParameters;
property showWindows: TShowWindowOptions read fShowWin write fShowWin;
//property shortcut: string read fShortcut write fShortcut;
public
constructor create(ACollection: TCollection); override;
destructor destroy; override;
@ -55,7 +57,7 @@ uses
constructor TCEToolItem.create(ACollection: TCollection);
begin
inherited;
fName := format('<tool %d>', [ID]);
fToolAlias := format('<tool %d>', [ID]);
fParameters := TStringList.create;
end;
@ -78,12 +80,15 @@ begin
proc := TProcess.Create(nil);
try
proc.Options := fOpts;
proc.Executable := CEMainForm.expandSymbolicString(fExecutable);
if fExecutable <> '' then
proc.Executable := CEMainForm.expandSymbolicString(fExecutable);
proc.ShowWindow := fShowWin;
proc.CurrentDirectory := CEMainForm.expandSymbolicString(fWorkingDir);
if fWorkingDir <> '' then
proc.CurrentDirectory := CEMainForm.expandSymbolicString(fWorkingDir);
proc.Parameters.Clear;
for i:= 0 to fParameters.Count-1 do
proc.Parameters.Add(CEMainForm.expandSymbolicString(fParameters.Strings[i]));
if fParameters.Strings[i] <> '' then
proc.Parameters.Add(CEMainForm.expandSymbolicString(fParameters.Strings[i]));
proc.Options := proc.Options - [poUsePipes, poWaitOnExit];
proc.Execute;
finally

View File

@ -10,7 +10,7 @@ object CEMainForm: TCEMainForm
OnCloseQuery = FormCloseQuery
OnDropFiles = FormDropFiles
ShowHint = True
LCLVersion = '1.2.4.0'
LCLVersion = '1.2.6.0'
object mainMenu: TMainMenu
Images = imgList
top = 1

View File

@ -11,13 +11,12 @@ uses
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_observer, ce_writableComponent;
ce_observer, ce_writableComponent, ce_toolseditor;
type
// TODO-cfeature: options
// TODO-cwidget: options editor
// TODO-cwidget: custom tools editor
// TODO-cfeature: tools menu
{ TCEMainForm }
@ -183,6 +182,7 @@ type
fFindWidg: TCESearchWidget;
fExplWidg: TCEMiniExplorerWidget;
fLibMWidg: TCELibManEditorWidget;
fTlsEdWidg: TCEToolsEditorWidget;
fProjMru: TMruFileList;
fFileMru: TMruFileList;
fLibMan: TLibraryManager;
@ -264,6 +264,7 @@ type
property WidgetList: TCEWidgetList read fWidgList;
property MessageWidget: TCEMessagesWidget read fMesgWidg;
property LibraryManager: TLibraryManager read fLibMan;
property CustomTools: TCETools read fTools;
end;
procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl;
@ -286,6 +287,7 @@ begin
InitMRUs;
InitLibMan;
InitTools;
//
InitWidgets;
InitDocking;
InitSettings;
@ -444,6 +446,7 @@ begin
fFindWidg := TCESearchWidget.create(self);
fExplWidg := TCEMiniExplorerWidget.create(self);
fLibMWidg := TCELibManEditorWidget.create(self);
fTlsEdWidg:= TCEToolsEditorWidget.create(self);
fWidgList.addWidget(@fMesgWidg);
fWidgList.addWidget(@fEditWidg);
@ -453,6 +456,7 @@ begin
fWidgList.addWidget(@fFindWidg);
fWidgList.addWidget(@fExplWidg);
fWidgList.addWidget(@fLibMWidg);
fWidgList.addWidget(@fTlsEdWidg);
for widg in fWidgList do
begin
@ -504,6 +508,7 @@ begin
DockMaster.GetAnchorSite(fExplWidg).Close;
DockMaster.GetAnchorSite(fLibMWidg).Close;
DockMaster.GetAnchorSite(fTlsEdWidg).Close;
LoadDocking;
end;

208
src/ce_toolseditor.lfm Normal file
View File

@ -0,0 +1,208 @@
inherited CEToolsEditorWidget: TCEToolsEditorWidget
Left = 1461
Height = 398
Top = 34
Width = 415
Caption = 'Tools editor'
ClientHeight = 398
ClientWidth = 415
inherited Back: TPanel
Height = 398
Width = 415
ClientHeight = 398
ClientWidth = 415
inherited Content: TPanel
Height = 398
Width = 415
ClientHeight = 398
ClientWidth = 415
object Panel1: TPanel[0]
Left = 4
Height = 28
Top = 4
Width = 407
Align = alTop
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 28
ClientWidth = 407
TabOrder = 0
object BtnAddTool: TBitBtn
Left = 0
Height = 28
Hint = 'add a tool'
Top = 0
Width = 28
Align = alLeft
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000001E0000003300000033000000330000001E00000000BB871F00BB87
1F00BB871F00BB871F00BB871F00BB871F00BB871F00BE871E00CD8419000000
0021008D57AC009E5EFF009D5DFF009E5EFF008C55AC0000001E000000240000
003300000033000000330000003300000033000000330000003300000033038F
55B700A66BFF00BA86FF77DFC4FF00BA86FF00A66AFF008C55ACA8740DC1B67E
0EFFB47B09FFB47A07FFB47A07FFB47A07FFB47A07FFB77A07FFC97A06FF009D
5FFF00C08CFF00BB82FFFFFFFFFF00BB82FF00C08CFF009E5EFFB67E0EFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0096
51FF73E4CAFFFFFFFFFFFFFFFFFFFFFFFFFF77E5CCFF009C5CFFB47B09FFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0091
4AFF00C993FF00C78EFFFFFFFFFF00C88FFF00CC98FF009D5DFFB47A07FFFFFF
FFFFFBFCFDFFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFFFDFBFCFFFFFFFFFF65C3
9EFF00A766FF00D199FF73ECD2FF00D39DFF00AF74FF009F6294B47A07FFFFFF
FFFFF2F3F3FFF2F2F1FFF2F2F1FFF2F2F1FFF2F2F1FFF3F2F1FFF8F4F4FFFFF9
FDFF61C099FF00934BFF00934DFF009755FF55903AFF00A36900B47B08FFFFFF
FFFFEAEAEBFFEBEAE9FFEBEAE9FFEBEAE9FFEBEAE9FFEBEAE9FFEDEAEAFFF1EC
ECFFFAEFF1FFFFF0F5FFFFF1F7FFFFFFFFFFC67C08FFCC831600B47B08FFFFFF
FFFFE1E0E1FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE3E2
E1FFE5E2E1FFE5E2E2FFE5E2E3FFFFFFFFFFB77B08FFBD851A00B47B08FFFFFF
FFFFD5D6D6FFD6D6D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7
D5FFD7D7D5FFD6D6D5FFD5D6D6FFFFFFFFFFB47B08FFBA851B00B57C0AFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB57C0AFFBA851C00B57E0FFFF7E0
BFFFE0A649FFE0A74CFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE0A8
4DFFE0A84DFFE0A74CFFE0A649FFF7E0BFFFB57E0FFFBA851C00B68013FFF2D8
AEFFD49222FFD49426FFD49427FFD49427FFD49427FFD49427FFD49427FFD494
27FFD49427FFD49426FFD49222FFF2D8AEFFB68013FFBA861D00B88217FFEED0
9BFFECCE98FFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE
9AFFECCE9AFFECCE9AFFECCE98FFEED09BFFB88217FFBB861E00BA851CC5B882
17FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB781
16FFB78116FFB78116FFB78116FFB88217FFBA851CA7BB871F00
}
OnClick = BtnAddToolClick
TabOrder = 0
end
object btnRemTool: TBitBtn
Left = 28
Height = 28
Hint = 'remove selected tool'
Top = 0
Width = 28
Align = alLeft
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000001E0000003300000033000000330000001E00000000BB871F00BB87
1F00BB871F00BB871F00BB871F00BB871F00BB871F00BD881C00C88C0E000000
00212E44B8AC374DCCFF384DCBFF384DCCFF3145B4AC0000001E000000260000
0033000000330000003300000033000000330000003300000033000000333347
B4B73550DBFF385DF9FF375DFAFF385DF9FF3852D7FF3044B4ACAD7C17CCB67E
0EFFB47B09FFB47A07FFB47A07FFB47A07FFB47A07FFB67C06FFC38300FF2441
D8FF3F64FEFF3C60FAFF3A5DF8FF3C60FAFF4165FBFF344BCCFFB67E0EFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1E39
CCFFA6B7FFFFFFFFFFFFFFFFFFFFFFFFFFFFA9BAFFFF3148CAFFB47B09FFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1933
C6FF5674FEFF5675FEFF5473FDFF5776FEFF5C79FFFF334ACCFFB47A07FFFFFF
FFFFFBFCFDFFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFFFCFCFBFFFFFFFDFF8491
DEFF3650DAFF6A84FFFF7089FFFF6C87FFFF425CE2FF324BD194B47A07FFFFFF
FFFFF2F3F3FFF2F2F1FFF2F2F1FFF2F2F1FFF2F2F1FFF2F2F1FFF7F6F2FFFFFF
F4FF818FDAFF1C36C7FF1F39C9FF1F3BD0FF706474FF2747E300B47B08FFFFFF
FFFFEAEAEBFFEBEAE9FFEBEAE9FFEBEAE9FFEBEAE9FFEBEAE9FFECEBE9FFF0EE
EAFFF6F3EBFFFBF8EBFFFCFAEDFFFFFFFFFFC18300FFC78B0B00B47B08FFFFFF
FFFFE1E0E1FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE3E2
E1FFE4E3E1FFE5E3E0FFE3E3E1FFFFFFFFFFB67C07FFBC861900B47B08FFFFFF
FFFFD5D6D6FFD6D6D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7
D5FFD7D7D5FFD6D6D5FFD5D6D6FFFFFFFFFFB47B08FFBA851B00B57C0AFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB57C0AFFBA851C00B57E0FFFF7E0
BFFFE0A649FFE0A74CFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE0A8
4DFFE0A84DFFE0A74CFFE0A649FFF7E0BFFFB57E0FFFBA851C00B68013FFF2D8
AEFFD49222FFD49426FFD49427FFD49427FFD49427FFD49427FFD49427FFD494
27FFD49427FFD49426FFD49222FFF2D8AEFFB68013FFBA861D00B88217FFEED0
9BFFECCE98FFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE
9AFFECCE9AFFECCE9AFFECCE98FFEED09BFFB88217FFBB861E00BA851CC5B882
17FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB781
16FFB78116FFB78116FFB78116FFB88217FFBA851CBFBB871F00
}
OnClick = btnRemToolClick
TabOrder = 1
end
object btnRun: TBitBtn
Left = 379
Height = 28
Hint = 'execute selected tool'
Top = 0
Width = 28
Align = alRight
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00330000002F0000000000000000000000000000000000000000BB871F00BB87
1F00BB871F00BB871F00BB871F00BB871F00BD871D00C68711001D8EE9002A8D
D7FF2D8BCDF1000000330000000D8A8B6400C1871700BC871E00000000240000
0033000000330000003300000033000000330000003300000033000000334B7F
96C03A9BDCFF3A99DCFF445652670000003300000024BE871B00A8740DC1B67E
0EFFB47B09FFB47A07FFB47A07FFB47A07FFB47A07FFB57A06FFBA7A01FFBB7B
02FF4AA4D5FF92F4FFFF469DD4FF8F8655FFA8740DC1C7850D00B67E0EFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFA7CCEEFF6BCDF0FF83EBFFFF3B9EE5FF81886BFF00000022B47B09FFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2082
CDFF3E9ED9FF4FAFE0FF7DE9FDFF7FEFFFFF52B4EAFF3786C4BBB47A07FFFFFF
FFFFFBFCFDFFFAFAFAFFFAFAFAFFFAFAFAFFFAFAFAFFFDFCFBFFFFFFFEFF2984
CEFF8AEBFCFF6CE1F9FF5CC0E9FF3D8DD3FF3F93D9FF4395D7FFB47A07FFFFFF
FFFFF2F3F3FFF2F2F1FFF2F2F1FFF2F2F1FFF2F2F1FFF4F3F1FFFFF9F3FF65A5
D9FF88D3F1FF7CE0F8FF57CCF0FF4296DAFFA48741FF4096D900B47B08FFFFFF
FFFFEAEAEBFFEBEAE9FFEBEAE9FFEBEAE9FFEBEAE9FFEDEBE9FFF5EFEAFF8CB8
DDFF56B5E5FFD9F9FEFF4DD3F4FF49B5E8FF5A93BDFF00000012B47B08FFFFFF
FFFFE1E0E1FFE2E1E0FFE2E1E0FFE2E1E0FFE2E1E0FFE3E2E0FFEAE5E1FFACC6
DDFF3A9FDDFF8FE7F8FF91E7F8FF95E9FBFF4998DAFF3972A07BB47B08FFFFFF
FFFFD5D6D6FFD6D6D5FFD7D7D5FFD7D7D5FFD7D7D5FFD7D7D5FFDBD8D6FFC2CC
D5FF388FD9FF3C8FD8FF3D90D8FF4093DDFF489BE4FF4E9EE2FFB57C0AFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC67C00FF42A0F600B57E0FFFF7E0
BFFFE0A649FFE0A74CFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE0A84DFFE1A8
4DFFE2A84DFFE2A84CFFE2A649FFFAE1BEFFBA7E09FFC3840E00B68013FFF2D8
AEFFD49222FFD49426FFD49427FFD49427FFD49427FFD49427FFD49427FFD494
27FFD49427FFD49426FFD49222FFF2D8AEFFB78012FFBB851B00B88217FFEED0
9BFFECCE98FFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE9AFFECCE
9AFFECCE9AFFECCE9AFFECCE98FFEED09BFFB88217FFBB861E00B67E0EB2B882
17FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB78116FFB781
16FFB78116FFB78116FFB78116FFB88217FFB67E0EB2BB871F00
}
OnClick = btnRunClick
TabOrder = 2
end
end
object propsEd: TTIPropertyGrid[1]
Left = 169
Height = 358
Top = 36
Width = 242
Align = alClient
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
DefaultValueFont.Color = clWindowText
Filter = [tkInteger, tkChar, tkEnumeration, tkFloat, tkSet, tkMethod, tkSString, tkLString, tkAString, tkWString, tkVariant, tkArray, tkRecord, tkInterface, tkClass, tkObject, tkWChar, tkBool, tkInt64, tkQWord, tkDynArray, tkInterfaceRaw, tkProcVar, tkUString, tkUChar, tkHelper]
Indent = 16
NameFont.Color = clWindowText
OnModified = propsEdModified
ValueFont.Color = clMaroon
end
object Splitter1: TSplitter[2]
Left = 164
Height = 362
Top = 36
Width = 5
end
object lstTools: TListBox[3]
Left = 4
Height = 358
Top = 36
Width = 160
Align = alLeft
BorderSpacing.Left = 4
BorderSpacing.Bottom = 4
ItemHeight = 0
OnSelectionChange = lstToolsSelectionChange
TabOrder = 3
end
end
end
inherited contextMenu: TPopupMenu
left = 64
top = 8
end
end

110
src/ce_toolseditor.pas Normal file
View File

@ -0,0 +1,110 @@
unit ce_toolseditor;
{$I ce_defines.inc}
interface
uses
Classes, SysUtils, FileUtil, RTTIGrids, Forms, Controls, Graphics, Dialogs,
ExtCtrls, Menus, Buttons, StdCtrls, ce_widget;
type
{ TCEToolsEditorWidget }
TCEToolsEditorWidget = class(TCEWidget)
BtnAddTool: TBitBtn;
btnRemTool: TBitBtn;
btnRun: TBitBtn;
lstTools: TListBox;
Panel1: TPanel;
Splitter1: TSplitter;
propsEd: TTIPropertyGrid;
procedure BtnAddToolClick(Sender: TObject);
procedure btnRemToolClick(Sender: TObject);
procedure btnRunClick(Sender: TObject);
procedure lstToolsSelectionChange(Sender: TObject; User: boolean);
procedure propsEdModified(Sender: TObject);
private
procedure DataToGui;
procedure updateNames;
public
constructor create(aOwner: TComponent); override;
end;
implementation
{$R *.lfm}
uses
ce_main;
constructor TCEToolsEditorWidget.create(aOwner: TComponent);
begin
inherited;
DataToGui;
end;
procedure TCEToolsEditorWidget.updateNames;
var
i: Integer;
begin
with CEMainForm do for i := 0 to CustomTools.tools.Count-1 do
lstTools.Items.Strings[i] := CustomTools.tool[i].toolAlias;
end;
procedure TCEToolsEditorWidget.DataToGui;
var
i: integer;
begin
propsEd.TIObject := nil;
propsEd.ItemIndex := -1;
lstTools.Clear;
//
with CEMainForm 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;
end;
procedure TCEToolsEditorWidget.lstToolsSelectionChange(Sender: TObject;
User: boolean);
begin
if lstTools.ItemIndex = -1 then
exit;
propsEd.TIObject := CEMainForm.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;
DataToGui;
end;
procedure TCEToolsEditorWidget.btnRemToolClick(Sender: TObject);
begin
if lstTools.ItemIndex = -1 then
exit;
//
CEMainForm.CustomTools.tools.Delete(lstTools.ItemIndex);
DataToGui;
end;
procedure TCEToolsEditorWidget.btnRunClick(Sender: TObject);
begin
if lstTools.ItemIndex = -1 then
exit;
//
CEMainForm.CustomTools.tool[lstTools.ItemIndex].execute;
end;
end.