set the mini explorer as a single service

This commit is contained in:
Basile Burg 2016-06-22 05:44:44 +02:00
parent baee2e6207
commit 495fb610b0
3 changed files with 45 additions and 5 deletions

View File

@ -342,6 +342,15 @@ type
end;
(**
* Single service related to build-in file explorer.
*)
ICEExplorer = interface(ICESingleService)
procedure browse(const location: string);
function currentLocation: string;
end;
{
subject primitives:
@ -378,6 +387,7 @@ type
function getMultiDocHandler: ICEMultiDocHandler;
function getSymStringExpander: ICESymStringExpander;
function getProjectGroup: ICEProjectGroup;
function getExplorer: ICEExplorer;
implementation
@ -513,6 +523,11 @@ begin
exit(EntitiesConnector.getSingleService('ICEProjectGroup') as ICEProjectGroup);
end;
function getExplorer: ICEExplorer;
begin
exit(EntitiesConnector.getSingleService('ICEExplorer') as ICEExplorer);
end;
{$ENDREGION}
end.

View File

@ -1820,7 +1820,7 @@ begin
if not fProject.filename.fileExists then exit;
//
DockMaster.GetAnchorSite(fExplWidg).Show;
fExplWidg.expandPath(fProject.filename.extractFilePath);
getExplorer.browse(fProject.filename.extractFilePath);
end;
procedure TCEMainForm.actFileNewExecute(Sender: TObject);
@ -2465,7 +2465,7 @@ begin
if not fDoc.fileName.fileExists then exit;
//
DockMaster.GetAnchorSite(fExplWidg).Show;
fExplWidg.expandPath(fDoc.fileName.extractFilePath);
getExplorer.browse(fDoc.fileName.extractFilePath);
end;
procedure TCEMainForm.actProjCompileExecute(Sender: TObject);

View File

@ -60,7 +60,7 @@ type
{ TCEMiniExplorerWidget }
TCEMiniExplorerWidget = class(TCEWidget, ICEProjectObserver, ICEMultiDocObserver)
TCEMiniExplorerWidget = class(TCEWidget, ICEProjectObserver, ICEMultiDocObserver, ICEExplorer)
btnAddFav: TBitBtn;
btnEdit: TBitBtn;
btnShellOpen: TBitBtn;
@ -120,8 +120,12 @@ type
procedure docFocused(aDoc: TCESynMemo);
procedure docChanged(aDoc: TCESynMemo);
procedure docClosing(aDoc: TCESynMemo);
//
function singleServiceName: string;
procedure browse(const location: string);
function currentLocation: string;
public
constructor create(aIwner: TComponent); override;
constructor create(aOwner: TComponent); override;
destructor destroy; override;
//
procedure expandPath(aPath: string);
@ -238,7 +242,7 @@ end;
{$ENDREGION}
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEMiniExplorerWidget.create(aIwner: TComponent);
constructor TCEMiniExplorerWidget.create(aOwner: TComponent);
var
fname: string;
begin
@ -279,6 +283,7 @@ begin
end;
//
EntitiesConnector.addObserver(self);
EntitiesConnector.addSingleService(self);
end;
destructor TCEMiniExplorerWidget.destroy;
@ -693,6 +698,26 @@ begin
end;
{$ENDREGION}
{$REGION ICEEXplorer -----------------------------------------------------------}
function TCEMiniExplorerWidget.singleServiceName: string;
begin
exit('ICEExplorer');
end;
procedure TCEMiniExplorerWidget.browse(const location: string);
begin
expandPath(location);
end;
function TCEMiniExplorerWidget.currentLocation: string;
begin
if Tree.Selected.isNil then
result := ''
else
result := PString(tree.Selected.Data)^;
end;
{$ENDREGION}
initialization
RegisterClasses([TCEMiniExplorerOptions]);
end.