mirror of https://gitlab.com/basile.b/dexed.git
DUB project editor, several fixes
- doesn't trow when a 'name is expected' - expand tree after property is added or set
This commit is contained in:
parent
057216db69
commit
2eca7e5e37
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils, fpjson, jsonparser, jsonscanner, process, strutils,
|
||||
ce_common, ce_interfaces, ce_observer;
|
||||
ce_common, ce_interfaces, ce_observer, ce_dialogs;
|
||||
|
||||
type
|
||||
|
||||
|
@ -339,6 +339,11 @@ var
|
|||
msgs: ICEMessagesDisplay;
|
||||
begin
|
||||
result := false;
|
||||
if not FileExists(fFilename) then
|
||||
begin
|
||||
dlgOkInfo('The DUB project must be saved before being compiled or run !');
|
||||
exit;
|
||||
end;
|
||||
msgs := getMessageDisplay;
|
||||
msgs.clearByData(Self as ICECommonProject);
|
||||
prjname := shortenPath(fFilename);
|
||||
|
@ -346,7 +351,10 @@ begin
|
|||
olddir := GetCurrentDir;
|
||||
try
|
||||
if not run then
|
||||
begin
|
||||
msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf);
|
||||
if modified then saveToFile(fFilename);
|
||||
end;
|
||||
chDir(extractFilePath(fFilename));
|
||||
dubproc.Executable := 'dub' + exeExt;
|
||||
dubproc.Options := dubproc.Options + [poStderrToOutPut, poUsePipes];
|
||||
|
@ -432,16 +440,16 @@ var
|
|||
begin
|
||||
fBuildTypes.Clear;
|
||||
fConfigs.Clear;
|
||||
|
||||
// the CE interface for dub doesn't make the difference between build type
|
||||
//and config, instead each possible combination type + build is generated.
|
||||
|
||||
if fJSON.Find('configurations') <> nil then
|
||||
begin
|
||||
arr := fJSON.Arrays['configurations'];
|
||||
for i:= 0 to arr.Count-1 do
|
||||
begin
|
||||
item := TJSONObject(arr.Items[i]);
|
||||
if item.Find('name') = nil then
|
||||
continue;
|
||||
fConfigs.Add(item.Strings['name']);
|
||||
end;
|
||||
end else
|
||||
|
@ -458,9 +466,12 @@ begin
|
|||
for i := 0 to arr.Count-1 do
|
||||
begin
|
||||
item := TJSONObject(arr.Items[i]);
|
||||
if item.Find('name') = nil then
|
||||
continue;
|
||||
itemname := item.Strings['name'];
|
||||
// defaults build types can be overridden
|
||||
if fBuildTypes.IndexOf(itemname) <> -1 then continue;
|
||||
if fBuildTypes.IndexOf(itemname) <> -1 then
|
||||
continue;
|
||||
fBuildTypes.Add(itemname);
|
||||
end;
|
||||
end;
|
||||
|
|
|
@ -21,10 +21,10 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
|||
Height = 416
|
||||
Top = 4
|
||||
Width = 403
|
||||
ActivePage = TabSheet1
|
||||
ActivePage = TabSheet2
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 4
|
||||
TabIndex = 0
|
||||
TabIndex = 1
|
||||
TabOrder = 0
|
||||
object TabSheet1: TTabSheet
|
||||
Caption = 'Inspector'
|
||||
|
|
|
@ -10,9 +10,6 @@ uses
|
|||
ce_widget, ce_common, ce_interfaces, ce_observer, ce_dubproject, ce_sharedres;
|
||||
|
||||
type
|
||||
|
||||
//TODO-cDUB: add new properties from UI
|
||||
|
||||
{ TCEDubProjectEditorWidget }
|
||||
|
||||
TDubPropAddEvent = procedure(const propName: string; tpe: TJSONtype) of object;
|
||||
|
@ -81,10 +78,12 @@ var
|
|||
layout: TPanel;
|
||||
begin
|
||||
inherited create(nil);
|
||||
width := 200;
|
||||
height := 120;
|
||||
width := 280;
|
||||
height := 130;
|
||||
fEvent := event;
|
||||
caption := 'add a DUB property';
|
||||
Position := poMainFormCenter;
|
||||
ShowHint:=true;
|
||||
//
|
||||
fSelType := TRadioGroup.Create(self);
|
||||
fSelType.Parent := self;
|
||||
|
@ -93,6 +92,7 @@ begin
|
|||
fSelType.BorderSpacing.Around:=2;
|
||||
fSelType.Caption:= 'type';
|
||||
fSelType.ItemIndex:=2;
|
||||
fSelType.Hint:= 'type of the property to add';
|
||||
//
|
||||
layout := TPanel.Create(self);
|
||||
layout.Parent := self;
|
||||
|
@ -105,6 +105,7 @@ begin
|
|||
fEdName.Align:=alClient;
|
||||
fEdName.BorderSpacing.Around:=4;
|
||||
fEdName.Width:=80;
|
||||
fEdName.Hint:='name of the property to add';
|
||||
//
|
||||
fBtnValidate := TBitBtn.Create(self);
|
||||
fBtnValidate.Parent := layout;
|
||||
|
@ -112,6 +113,7 @@ begin
|
|||
fBtnValidate.BorderSpacing.Around:=4;
|
||||
fBtnValidate.Width:= 26;
|
||||
fBtnValidate.OnClick:=@doValidate;
|
||||
fBtnValidate.Hint:='accept and add a property';
|
||||
AssignPng(fBtnValidate, 'accept');
|
||||
end;
|
||||
|
||||
|
@ -119,7 +121,7 @@ procedure TCEDubProjectPropAddPanel.doValidate(sender: TObject);
|
|||
var
|
||||
tpe: TJSONtype;
|
||||
begin
|
||||
if assigned(fEvent) and (fEdName.Text <> '') then
|
||||
if assigned(fEvent) then
|
||||
begin
|
||||
case fSelType.ItemIndex of
|
||||
0: tpe := TJSONtype.jtArray;
|
||||
|
@ -231,6 +233,7 @@ begin
|
|||
if fSelectedNode = nil then exit;
|
||||
//
|
||||
setJsonValueFromEditor;
|
||||
propTree.FullExpand;
|
||||
end;
|
||||
|
||||
procedure TCEDubProjectEditorWidget.btnAddPropClick(Sender: TObject);
|
||||
|
@ -273,11 +276,15 @@ begin
|
|||
end;
|
||||
end;
|
||||
fProj.endModification;
|
||||
propTree.FullExpand;
|
||||
nod := propTree.Items.FindNodeWithText('<value>');
|
||||
if nod <> nil then propTree.Selected := nod
|
||||
else nod := propTree.Items.FindNodeWithText(propName);
|
||||
if nod <> nil then propTree.Selected := nod;
|
||||
propTree.MakeSelectionVisible;
|
||||
if nod = nil then
|
||||
nod := propTree.Items.FindNodeWithText(propName);
|
||||
if nod <> nil then
|
||||
begin
|
||||
propTree.Selected := nod;
|
||||
propTree.MakeSelectionVisible;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEDubProjectEditorWidget.btnDelPropClick(Sender: TObject);
|
||||
|
|
Loading…
Reference in New Issue