work on #10, dub support

- configs and built types are combined
- widget split in two pages: editor and inspector
- inspector displays the combined configs
This commit is contained in:
Basile Burg 2015-09-08 00:13:40 +02:00
parent 0b03b51a19
commit fa4e2b3cf8
3 changed files with 271 additions and 78 deletions

View File

@ -10,13 +10,23 @@ uses
type type
TUpdaterTarget = (configs, files);
TCEDubProject = class(TComponent, ICECommonProject) TCEDubProject = class(TComponent, ICECommonProject)
private private
fFilename: string; fFilename: string;
fModified: boolean; fModified: boolean;
fJson: TJSONObject; fJson: TJSONObject;
fProjectSubject: TCEProjectSubject; fProjectSubject: TCEProjectSubject;
fConfigsCount: integer;
fBuildTypes: TStringList;
fConfigs: TStringList;
fBuiltTypeIx: integer;
fConfigIx: integer;
// //
procedure updateFields;
procedure udpateConfigsFromJson;
procedure updateSourcesFromJson;
procedure dubProcOutput(proc: TProcess); procedure dubProcOutput(proc: TProcess);
// //
function getFormat: TCEProjectFormat; function getFormat: TCEProjectFormat;
@ -45,12 +55,23 @@ type
property json: TJSONObject read fJson; property json: TJSONObject read fJson;
end; end;
// these 9 built types alway exist
TDubBuildType = (plain, debug, release, unittest, docs, ddox, profile, cov, unittestcov);
const
DubBuiltTypeName: array[TDubBuildType] of string = ('plain', 'debug', 'release',
'unittest', 'docs', 'ddox', 'profile', 'cov', 'unittest-cov'
);
implementation implementation
constructor TCEDubProject.create(aOwner: TComponent); constructor TCEDubProject.create(aOwner: TComponent);
begin begin
inherited; inherited;
fProjectSubject := TCEProjectSubject.Create; fProjectSubject := TCEProjectSubject.Create;
fBuildTypes := TStringList.Create;
fConfigs := TStringList.Create;
// //
subjProjNew(fProjectSubject, self); subjProjNew(fProjectSubject, self);
subjProjChanged(fProjectSubject, self); subjProjChanged(fProjectSubject, self);
@ -62,6 +83,8 @@ begin
fProjectSubject.free; fProjectSubject.free;
// //
fJSon.Free; fJSon.Free;
fBuildTypes.Free;
fConfigs.Free;
inherited; inherited;
end; end;
@ -97,6 +120,52 @@ begin
exit(fFilename); exit(fFilename);
end; end;
procedure TCEDubProject.udpateConfigsFromJson;
var
i: integer;
builtTypes: TJSONArray = nil;
configs: TJSONArray = nil;
item: TJSONObject = nil;
begin
fBuildTypes.Clear;
fConfigs.Clear;
// configs: builtype0 - config0, builtype0 - config1, ... , builtype0 - configN
// builtype1 - config0, builtype1 - config1, ... , builtype1 - configN, etc
fConfigs.Add('(dub default)'); // default
if fJson.Find('configurations') <> nil then
begin
configs := fJson.Arrays['configurations'];
for i:= 0 to configs.Count-1 do
begin
item := TJSONObject(configs.Items[i]);
fConfigs.Add(item.Strings['name']);
end;
end;
fBuildTypes.AddStrings(DubBuiltTypeName);
if fJson.Find('buildTypes') <> nil then
begin
builtTypes := fJson.Arrays['buildTypes'];
for i := 0 to builtTypes.Count-1 do
begin
item := TJSONObject(builtTypes.Items[i]);
fBuildTypes.Add(item.Strings['name']);
end;
end;
fConfigsCount := fConfigs.Count * fBuildTypes.Count;
end;
procedure TCEDubProject.updateSourcesFromJson;
begin
//TODO-cDUB: update the source files for the current configuration
end;
procedure TCEDubProject.updateFields;
begin
udpateConfigsFromJson;
updateSourcesFromJson;
end;
function TCEDubProject.getBinaryKind: TProjectBinaryKind; function TCEDubProject.getBinaryKind: TProjectBinaryKind;
begin begin
//TODO-cDUB: implement //TODO-cDUB: implement
@ -121,6 +190,7 @@ begin
end; end;
finally finally
loader.Free; loader.Free;
updateFields;
subjProjChanged(fProjectSubject, self); subjProjChanged(fProjectSubject, self);
fModified := false; fModified := false;
end; end;
@ -150,31 +220,32 @@ end;
function TCEDubProject.getIfIsSource(const aFilename: string): boolean; function TCEDubProject.getIfIsSource(const aFilename: string): boolean;
begin begin
//TODO-cDUB: implement //TODO-cDUB: implement getIfIsSource
exit(false); exit(false);
end; end;
function TCEDubProject.getOutputFilename: string; function TCEDubProject.getOutputFilename: string;
begin begin
//TODO-cDUB: implement //TODO-cDUB: implement getOutputFilename
exit(''); exit('');
end; end;
function TCEDubProject.getConfigurationCount: integer; function TCEDubProject.getConfigurationCount: integer;
begin begin
//TODO-cDUB: implement exit(fConfigsCount);
exit(0);
end; end;
procedure TCEDubProject.setActiveConfiguration(index: integer); procedure TCEDubProject.setActiveConfiguration(index: integer);
begin begin
//TODO-cDUB: implement fBuiltTypeIx := index div fConfigs.Count;
fConfigIx := index mod fConfigs.Count;
updateSourcesFromJson;
end; end;
function TCEDubProject.getConfigurationName(index: integer): string; function TCEDubProject.getConfigurationName(index: integer): string;
begin begin
//TODO-cDUB: implement result := fBuildTypes.Strings[index div fConfigs.Count] + ' - ' +
exit(''); fConfigs.Strings[index mod fConfigs.Count];
end; end;
function TCEDubProject.compile: boolean; function TCEDubProject.compile: boolean;

View File

@ -1,78 +1,153 @@
inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
Left = 816 Left = 816
Height = 417 Height = 557
Top = 191 Top = 191
Width = 411 Width = 411
ClientHeight = 417 Caption = 'Dub project editor'
ClientHeight = 557
ClientWidth = 411 ClientWidth = 411
inherited Back: TPanel inherited Back: TPanel
Height = 417 Height = 557
Width = 411 Width = 411
ClientHeight = 417 ClientHeight = 557
ClientWidth = 411 ClientWidth = 411
inherited Content: TPanel inherited Content: TPanel
Height = 417 Height = 557
Width = 411 Width = 411
ClientHeight = 417 ClientHeight = 557
ClientWidth = 411 ClientWidth = 411
object pnlToolBar: TPanel[0] object PageControl1: TPageControl[0]
Left = 4 Left = 4
Height = 26 Height = 549
Top = 2 Top = 4
Width = 403
Align = alTop
BorderSpacing.Left = 2
BorderSpacing.Right = 2
BorderSpacing.Around = 2
BevelOuter = bvNone
ClientHeight = 26
ClientWidth = 403
TabOrder = 0
object btnAddProp: TSpeedButton
Left = 0
Height = 26
Hint = 'add an empty configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
object btnDelProp: TSpeedButton
Left = 28
Height = 26
Hint = 'remove selected configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
end
object propTree: TTreeView[1]
Left = 4
Height = 284
Top = 32
Width = 403 Width = 403
ActivePage = TabSheet1
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
DefaultItemHeight = 18 TabIndex = 0
HideSelection = False TabOrder = 0
ReadOnly = True object TabSheet1: TTabSheet
ScrollBars = ssAutoBoth Caption = 'Inspector'
TabOrder = 1 ClientHeight = 521
OnSelectionChanged = propTreeSelectionChanged ClientWidth = 395
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] object pnlToolBar1: TPanel
end Left = 4
object edValue: TMemo[2] Height = 26
Left = 4 Top = 2
Height = 93 Width = 387
Top = 320 Align = alTop
Width = 403 BorderSpacing.Left = 2
Align = alBottom BorderSpacing.Right = 2
BorderSpacing.Around = 4 BorderSpacing.Around = 2
ScrollBars = ssAutoVertical BevelOuter = bvNone
TabOrder = 2 ClientHeight = 26
ClientWidth = 387
TabOrder = 0
object btnAddProp1: TSpeedButton
Left = 0
Height = 26
Hint = 'add an empty configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
object btnDelProp1: TSpeedButton
Left = 28
Height = 26
Hint = 'remove selected configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
end
object treeInspect: TTreeView
Left = 4
Height = 485
Top = 32
Width = 387
Align = alClient
BorderSpacing.Around = 4
DefaultItemHeight = 18
HideSelection = False
ReadOnly = True
ScrollBars = ssAutoBoth
TabOrder = 1
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
Items.Data = {
F9FFFFFF020002000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000
0000000C000000536F757263652066696C6573FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFF0000000000000000000E000000436F6E66696775726174696F6E73
}
end
end
object TabSheet2: TTabSheet
Caption = 'Editor'
ClientHeight = 521
ClientWidth = 395
object edValue: TMemo
Left = 4
Height = 93
Top = 424
Width = 387
Align = alBottom
BorderSpacing.Around = 4
ScrollBars = ssAutoVertical
TabOrder = 0
end
object propTree: TTreeView
Left = 4
Height = 388
Top = 32
Width = 387
Align = alClient
BorderSpacing.Around = 4
DefaultItemHeight = 18
HideSelection = False
ReadOnly = True
ScrollBars = ssAutoBoth
TabOrder = 1
OnSelectionChanged = propTreeSelectionChanged
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end
object pnlToolBar: TPanel
Left = 4
Height = 26
Top = 2
Width = 387
Align = alTop
BorderSpacing.Left = 2
BorderSpacing.Right = 2
BorderSpacing.Around = 2
BevelOuter = bvNone
ClientHeight = 26
ClientWidth = 387
TabOrder = 2
object btnAddProp: TSpeedButton
Left = 0
Height = 26
Hint = 'add an empty configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
object btnDelProp: TSpeedButton
Left = 28
Height = 26
Hint = 'remove selected configuration'
Top = 0
Width = 28
Align = alLeft
Layout = blGlyphBottom
ShowCaption = False
end
end
end
end end
end end
end end

View File

@ -15,15 +15,25 @@ type
TCEDubProjectEditorWidget = class(TCEWidget, ICEProjectObserver) TCEDubProjectEditorWidget = class(TCEWidget, ICEProjectObserver)
btnAddProp: TSpeedButton; btnAddProp: TSpeedButton;
btnAddProp1: TSpeedButton;
btnDelProp: TSpeedButton; btnDelProp: TSpeedButton;
btnDelProp1: TSpeedButton;
edValue: TMemo; edValue: TMemo;
PageControl1: TPageControl;
pnlToolBar: TPanel; pnlToolBar: TPanel;
pnlToolBar1: TPanel;
propTree: TTreeView; propTree: TTreeView;
treeInspect: TTreeView;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure propTreeSelectionChanged(Sender: TObject); procedure propTreeSelectionChanged(Sender: TObject);
private private
fSelectedNode: TTreeNode; fSelectedNode: TTreeNode;
fProj: TCEDubProject; fProj: TCEDubProject;
procedure updateGui; fNodeSources: TTreeNode;
fNodeConfig: TTreeNode;
procedure updateEditor;
procedure updateInspector;
procedure updateValueEditor; procedure updateValueEditor;
procedure setJsonValueFromEditor; procedure setJsonValueFromEditor;
// //
@ -36,18 +46,26 @@ type
protected protected
procedure SetVisible(Value: boolean); override; procedure SetVisible(Value: boolean); override;
public public
constructor create(aOwner: TComponent); override;
end; end;
implementation implementation
{$R *.lfm} {$R *.lfm}
{$REGION Standard Comp/Obj ----------------------------------------------------} {$REGION Standard Comp/Obj ----------------------------------------------------}
constructor TCEDubProjectEditorWidget.create(aOwner: TComponent);
begin
inherited;
fNodeSources := treeInspect.Items[0];
fNodeConfig := treeInspect.Items[1];
end;
procedure TCEDubProjectEditorWidget.SetVisible(Value: boolean); procedure TCEDubProjectEditorWidget.SetVisible(Value: boolean);
begin begin
inherited; inherited;
if not Value then exit; if not Value then exit;
// //
updateGui; updateEditor;
end; end;
{$ENDREGION} {$ENDREGION}
@ -55,8 +73,10 @@ end;
procedure TCEDubProjectEditorWidget.projNew(aProject: ICECommonProject); procedure TCEDubProjectEditorWidget.projNew(aProject: ICECommonProject);
begin begin
fProj := nil; fProj := nil;
enabled := false;
if aProject.getFormat <> pfDub then if aProject.getFormat <> pfDub then
exit; exit;
enabled := true;
fProj := TCEDubProject(aProject.getProject); fProj := TCEDubProject(aProject.getProject);
// //
end; end;
@ -67,9 +87,11 @@ begin
exit; exit;
if aProject.getProject <> fProj then if aProject.getProject <> fProj then
exit; exit;
// if not Visible then
if Visible then exit;
updateGui;
updateEditor;
updateInspector;
end; end;
procedure TCEDubProjectEditorWidget.projClosing(aProject: ICECommonProject); procedure TCEDubProjectEditorWidget.projClosing(aProject: ICECommonProject);
@ -80,18 +102,24 @@ begin
exit; exit;
fProj := nil; fProj := nil;
// //
updateGui; updateEditor;
updateInspector;
enabled := false;
end; end;
procedure TCEDubProjectEditorWidget.projFocused(aProject: ICECommonProject); procedure TCEDubProjectEditorWidget.projFocused(aProject: ICECommonProject);
begin begin
fProj := nil; fProj := nil;
enabled := false;
if aProject.getFormat <> pfDub then if aProject.getFormat <> pfDub then
exit; exit;
fProj := TCEDubProject(aProject.getProject); fProj := TCEDubProject(aProject.getProject);
// enabled := true;
if Visible then if not Visible then
updateGui; exit;
updateEditor;
updateInspector;
end; end;
procedure TCEDubProjectEditorWidget.projCompiling(aProject: ICECommonProject); procedure TCEDubProjectEditorWidget.projCompiling(aProject: ICECommonProject);
@ -99,7 +127,7 @@ begin
end; end;
{$ENDREGION} {$ENDREGION}
{$REGION GUI -------------------------------------------------------------------} {$REGION Editor ----------------------------------------------------------------}
procedure TCEDubProjectEditorWidget.propTreeSelectionChanged(Sender: TObject); procedure TCEDubProjectEditorWidget.propTreeSelectionChanged(Sender: TObject);
begin begin
fSelectedNode := nil; fSelectedNode := nil;
@ -168,7 +196,7 @@ begin
end; end;
end; end;
procedure TCEDubProjectEditorWidget.updateGui; procedure TCEDubProjectEditorWidget.updateEditor;
procedure addPropsFrom(node: TTreeNode; data: TJSONData); procedure addPropsFrom(node: TTreeNode; data: TJSONData);
var var
@ -205,5 +233,24 @@ begin
end; end;
{$ENDREGION} {$ENDREGION}
{$REGION Inspector -------------------------------------------------------------}
procedure TCEDubProjectEditorWidget.updateInspector;
var
i: integer;
begin
if (fNodeConfig = nil) or (fNodeSources = nil) then
exit;
//
fNodeConfig.DeleteChildren;
fNodeSources.DeleteChildren;
//
if (fProj = nil) then
exit;
//
for i:= 0 to fProj.getConfigurationCount -1 do
treeInspect.Items.AddChild(fNodeConfig, fProj.getConfigurationName(i));
end;
{$ENDREGION}
end. end.