added a tool buton to open the proj matching to a library item, when possible

This commit is contained in:
Basile Burg 2015-11-05 02:28:40 +01:00
parent 6c90ec9a6c
commit de04bd5ecf
2 changed files with 70 additions and 12 deletions

View File

@ -125,7 +125,7 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 8
end
object btnDubFetch: TBitBtn
Left = 140
Left = 168
Height = 26
Hint = 'register an online dub package'
Top = 0
@ -146,6 +146,17 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
Spacing = 0
TabOrder = 10
end
object btnOpenProj: TBitBtn
Left = 140
Height = 26
Hint = 'open the matching project'
Top = 0
Width = 28
Align = alLeft
OnClick = btnOpenProjClick
Spacing = 0
TabOrder = 11
end
end
object List: TListView[1]
Left = 4
@ -158,22 +169,22 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
item
AutoSize = True
Caption = 'Alias'
Width = 629
Width = 39
end
item
AutoSize = True
Caption = 'Library file'
Width = 67
Width = 76
end
item
AutoSize = True
Caption = 'Sources root'
Width = 78
Width = 88
end
item
AutoSize = True
Caption = 'project'
Width = 49
Width = 409
end>
GridLines = True
HideSelection = False
@ -183,11 +194,12 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 1
ViewStyle = vsReport
OnEdited = ListEdited
OnSelectItem = ListSelectItem
end
end
end
inherited contextMenu: TPopupMenu
left = 184
top = 8
left = 304
top = 16
end
end

View File

@ -14,6 +14,7 @@ type
{ TCELibManEditorWidget }
TCELibManEditorWidget = class(TCEWidget, ICEProjectObserver)
btnOpenProj: TBitBtn;
btnMoveDown: TBitBtn;
btnMoveUp: TBitBtn;
btnReg: TBitBtn;
@ -30,6 +31,7 @@ type
procedure btnAddLibClick(Sender: TObject);
procedure btnDubFetchClick(Sender: TObject);
procedure btnEditAliasClick(Sender: TObject);
procedure btnOpenProjClick(Sender: TObject);
procedure btnRegClick(Sender: TObject);
procedure btnRemLibClick(Sender: TObject);
procedure btnSelFileClick(Sender: TObject);
@ -39,9 +41,11 @@ type
procedure btnMoveUpClick(Sender: TObject);
procedure btnMoveDownClick(Sender: TObject);
procedure ListEdited(Sender: TObject; Item: TListItem; var AValue: string);
procedure ListSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean
);
private
fProj: ICECommonProject;
procedure updateRegistrable;
procedure updateButtonsState;
procedure projNew(aProject: ICECommonProject);
procedure projChanged(aProject: ICECommonProject);
procedure projClosing(aProject: ICECommonProject);
@ -80,12 +84,15 @@ begin
AssignPng(btnReg, 'book_link');
AssignPng(btnDubFetch, 'dub_small');
AssignPng(btnSelProj, 'script_bricks');
AssignPng(btnOpenProj, 'book_open');
end;
procedure TCELibManEditorWidget.updateRegistrable;
procedure TCELibManEditorWidget.updateButtonsState;
begin
btnReg.Enabled := (fProj <> nil) and (fProj.binaryKind = staticlib) and
FileExists(fProj.Filename);
btnOpenProj.Enabled := (List.Selected <> nil) and
(fileExists(List.Selected.SubItems[2]));
end;
procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject);
@ -99,7 +106,7 @@ begin
if fProj <> aProject then
exit;
//
updateRegistrable;
updateButtonsState;
end;
procedure TCELibManEditorWidget.projClosing(aProject: ICECommonProject);
@ -107,13 +114,13 @@ begin
if fProj <> aProject then
exit;
fProj := nil;
updateRegistrable;
updateButtonsState;
end;
procedure TCELibManEditorWidget.projFocused(aProject: ICECommonProject);
begin
fProj := aProject;
updateRegistrable;
updateButtonsState;
end;
procedure TCELibManEditorWidget.projCompiling(aProject: ICECommonProject);
@ -125,6 +132,12 @@ begin
gridToData;
end;
procedure TCELibManEditorWidget.ListSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
updateButtonsState;
end;
procedure TCELibManEditorWidget.btnAddLibClick(Sender: TObject);
var
itm: TListItem;
@ -289,6 +302,39 @@ begin
gridToData;
end;
procedure TCELibManEditorWidget.btnOpenProjClick(Sender: TObject);
var
fname: string;
begin
if List.Selected = nil then exit;
fname := List.Selected.SubItems[2];
if not FileExists(fname) then exit;
//
if isValidNativeProject(fname) then
begin
if assigned(fProj) then
begin
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
exit;
fProj.getProject.Free;
end;
TCENativeProject.create(nil);
fProj.loadFromFile(fname);
end
else if isValidDubProject(fname) then
begin
if assigned(fProj) then
begin
if fProj.modified and (dlgFileChangeClose(fname) = mrCancel) then
exit;
fProj.getProject.Free;
end;
TCEDubProject.create(nil);
fProj.loadFromFile(fname);
end
else dlgOkInfo('the project file for this library seems to be invalid');
end;
procedure TCELibManEditorWidget.btnRegClick(Sender: TObject);
var
str: TStringList;