mirror of https://gitlab.com/basile.b/dexed.git
added basic TCEActionProviderSubject implementation
This commit is contained in:
parent
10aa04e96a
commit
a1d0d600f2
|
@ -178,6 +178,7 @@ type
|
||||||
private
|
private
|
||||||
|
|
||||||
fDoc: TCESynMemo;
|
fDoc: TCESynMemo;
|
||||||
|
fActionHandler: TCEActionProviderSubject;
|
||||||
fMultidoc: ICEMultiDocHandler;
|
fMultidoc: ICEMultiDocHandler;
|
||||||
fScCollectCount: Integer;
|
fScCollectCount: Integer;
|
||||||
fUpdateCount: NativeInt;
|
fUpdateCount: NativeInt;
|
||||||
|
@ -209,6 +210,10 @@ type
|
||||||
fMainMenuSubj: TCEMainMenuSubject;
|
fMainMenuSubj: TCEMainMenuSubject;
|
||||||
procedure updateMainMenuProviders;
|
procedure updateMainMenuProviders;
|
||||||
|
|
||||||
|
// action provider handling;
|
||||||
|
procedure clearActProviderEntries;
|
||||||
|
procedure collectedActProviderEntries;
|
||||||
|
|
||||||
// ICEMultiDocObserver
|
// ICEMultiDocObserver
|
||||||
procedure docNew(aDoc: TCESynMemo);
|
procedure docNew(aDoc: TCESynMemo);
|
||||||
procedure docClosing(aDoc: TCESynMemo);
|
procedure docClosing(aDoc: TCESynMemo);
|
||||||
|
@ -301,6 +306,7 @@ constructor TCEMainForm.create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited create(aOwner);
|
inherited create(aOwner);
|
||||||
fMainMenuSubj := TCEMainMenuSubject.create;
|
fMainMenuSubj := TCEMainMenuSubject.create;
|
||||||
|
fActionHandler := TCEActionProviderSubject.create;
|
||||||
//
|
//
|
||||||
EntitiesConnector.addObserver(self);
|
EntitiesConnector.addObserver(self);
|
||||||
//
|
//
|
||||||
|
@ -648,6 +654,7 @@ begin
|
||||||
FreeRunnableProc;
|
FreeRunnableProc;
|
||||||
//
|
//
|
||||||
fMainMenuSubj.Free;
|
fMainMenuSubj.Free;
|
||||||
|
fActionHandler.Free;
|
||||||
EntitiesConnector.removeObserver(self);
|
EntitiesConnector.removeObserver(self);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
@ -696,6 +703,11 @@ begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if fUpdateCount > 0 then exit;
|
if fUpdateCount > 0 then exit;
|
||||||
Inc(fUpdateCount);
|
Inc(fUpdateCount);
|
||||||
|
|
||||||
|
|
||||||
|
clearActProviderEntries;
|
||||||
|
collectedActProviderEntries;
|
||||||
|
|
||||||
try
|
try
|
||||||
HasEd := fDoc <> nil;
|
HasEd := fDoc <> nil;
|
||||||
if hasEd then
|
if hasEd then
|
||||||
|
@ -905,7 +917,7 @@ begin
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION ICEEditableShortCut}
|
{$REGION ICEEditableShortCut ---------------------------------------------------}
|
||||||
function TCEMainForm.scedWantFirst: boolean;
|
function TCEMainForm.scedWantFirst: boolean;
|
||||||
begin
|
begin
|
||||||
fScCollectCount := 0;
|
fScCollectCount := 0;
|
||||||
|
@ -931,6 +943,60 @@ begin
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
{$REGION TCEActionProviderHandler ----------------------------------------------}
|
||||||
|
procedure TCEMainForm.clearActProviderEntries;
|
||||||
|
var
|
||||||
|
prov: ICEActionProvider;
|
||||||
|
act: TContainedAction;
|
||||||
|
i, j: Integer;
|
||||||
|
begin
|
||||||
|
for i:= 0 to fActionHandler.observersCount-1 do
|
||||||
|
begin
|
||||||
|
prov := fActionHandler[i] as ICEActionProvider;
|
||||||
|
if not prov.actHandlerWantRecollect then continue;
|
||||||
|
//
|
||||||
|
for j := Actions.ActionCount-1 downto 0 do
|
||||||
|
begin
|
||||||
|
act := Actions.Actions[j];
|
||||||
|
if act.Owner = Self then continue;
|
||||||
|
if act.Tag <> PtrInt(prov) then continue;
|
||||||
|
//
|
||||||
|
act.ActionList := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.collectedActProviderEntries;
|
||||||
|
var
|
||||||
|
prov: ICEActionProvider;
|
||||||
|
act: TCustomAction;
|
||||||
|
cat: string;
|
||||||
|
i: Integer;
|
||||||
|
procedure addAction;
|
||||||
|
begin
|
||||||
|
act.ActionList := Actions;
|
||||||
|
act.Tag := ptrInt(prov);
|
||||||
|
act.Category := cat;
|
||||||
|
//
|
||||||
|
act := nil;
|
||||||
|
cat := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for i:= 0 to fActionHandler.observersCount-1 do
|
||||||
|
begin
|
||||||
|
prov := fActionHandler[i] as ICEActionProvider;
|
||||||
|
if not prov.actHandlerWantFirst then continue;
|
||||||
|
//
|
||||||
|
act := nil;
|
||||||
|
cat := '';
|
||||||
|
while prov.actHandlerWantNext(cat, act) do
|
||||||
|
addAction;
|
||||||
|
addAction;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION file ------------------------------------------------------------------}
|
{$REGION file ------------------------------------------------------------------}
|
||||||
procedure TCEMainForm.actFileHtmlExportExecute(Sender: TObject);
|
procedure TCEMainForm.actFileHtmlExportExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
|
|
Loading…
Reference in New Issue