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

View File

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

View File

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