From f31baf8b4e6afd08516d043f0cf254501ae2c634 Mon Sep 17 00:00:00 2001 From: dmitry Date: Mon, 24 May 2010 15:45:40 +0000 Subject: [PATCH] fix ActionListEditor showing, to work with r25457 #811e84764c changes git-svn-id: trunk@25612 - --- ideintf/actionseditor.pas | 84 ++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/ideintf/actionseditor.pas b/ideintf/actionseditor.pas index e4217cb5e4..acbbd85016 100644 --- a/ideintf/actionseditor.pas +++ b/ideintf/actionseditor.pas @@ -150,7 +150,6 @@ type private FActionList: TActionList; FDesigner: TComponentEditorDesigner; - FComponentEditor: TActionListComponentEditor; procedure ResultStdActProc(const Category: string; ActionClass: TBasicActionClass; ActionProperty: TActStdPropItem; LastItem: Boolean); public @@ -160,7 +159,6 @@ type procedure FillCategories; procedure FillActionByCategory(iIndex: Integer); property Designer:TComponentEditorDesigner read FDesigner write FDesigner; - property ComponentEditor: TActionListComponentEditor write FComponentEditor; end; { TActionListComponentEditor } @@ -169,8 +167,6 @@ type private FActionList: TActionList; FDesigner: TComponentEditorDesigner; - FActionListEditorForm: TActionListEditor; - fWindowClosed: Boolean; protected public constructor Create(AComponent: TComponent; @@ -181,7 +177,6 @@ type function GetVerbCount: Integer; override; function GetVerb(Index: Integer): string; override; procedure ExecuteVerb(Index: Integer); override; - procedure EditorWindowClose; end; { Action Registration } @@ -260,6 +255,49 @@ function CreateAction(TheOwner: TComponent; implementation +var + EditorForms : TList = nil; + +procedure InitFormsList; +begin + EditorForms:=TList.Create; +end; + +procedure ReleaseFormsList; +begin + EditorForms.Free; + EditorForms:=nil; +end; + +procedure AddActionEditor(Editor: TActionListEditor); +begin + if Assigned(EditorForms) and (EditorForms.IndexOf(Editor)<0) then + EditorForms.Add(Editor); +end; + +procedure ReleaseActionEditor(Editor: TActionListEditor); +var + i : Integer; +begin + if not Assigned(EditorForms) then Exit; + i:=EditorForms.IndexOf(Editor); + if i>=0 then EditorForms.Delete(i); +end; + +function FindActionEditor(AList: TActionList): TActionListEditor; +var + i : Integer; +begin + for i:=0 to EditorForms.Count-1 do begin + if TActionListEditor(EditorForms[i]).FActionList=AList then begin + Result:=TActionListEditor(EditorForms[i]); + Exit; + end; + end; + Result:=nil +end; + + {$R *.lfm} procedure RegisterActions(const ACategory: string; @@ -853,13 +891,17 @@ begin GlobalDesignHook.AddHandlerComponentRenamed(@OnComponentRenamed); GlobalDesignHook.AddHandlerSetSelection(@OnComponentSelection); GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues); + + AddActionEditor(Self); end; destructor TActionListEditor.Destroy; begin if Assigned(GlobalDesignHook) then GlobalDesignHook.RemoveAllHandlersForObject(Self); - FComponentEditor.EditorWindowClose; + + ReleaseActionEditor(Self); + inherited Destroy; end; @@ -982,44 +1024,36 @@ end; { TActionListComponentEditor } -procedure TActionListComponentEditor.EditorWindowClose; -begin - fWindowClosed := True; -end; - constructor TActionListComponentEditor.Create(AComponent: TComponent; ADesigner: TComponentEditorDesigner); begin inherited Create(AComponent, ADesigner); FDesigner := ADesigner; - fWindowClosed := True; end; destructor TActionListComponentEditor.Destroy; begin - if not fWindowClosed - then FreeThenNil(FActionListEditorForm); inherited Destroy; end; procedure TActionListComponentEditor.Edit; var AActionList: TActionList; + AEditor: TActionListEditor; begin AActionList := GetComponent as TActionList; if AActionList = nil then raise Exception.Create('TActionListComponentEditor.Edit AActionList=nil'); - if fWindowClosed then begin - FActionListEditorForm := TActionListEditor.Create(Application); - fWindowClosed := False; - end; - with FActionListEditorForm do begin - lstActionName.ItemIndex := -1; - Designer := Self.FDesigner; - SetActionList(AActionList); - ComponentEditor := Self; - ShowOnTop; + AEditor:=FindActionEditor(AActionList); + if not Assigned(AEditor) then begin + AEditor:=TActionListEditor.Create(Application); + with AEditor do begin + lstActionName.ItemIndex := -1; + Designer := Self.FDesigner; + SetActionList(AActionList); + end; end; + AEditor.ShowOnTop; end; function TActionListComponentEditor.GetVerbCount: Integer; @@ -1334,8 +1368,10 @@ initialization RegisterComponentEditor(TActionList,TActionListComponentEditor); RegisterStandardActions; RegisterPropertyEditor(TypeInfo(string), TContainedAction, 'Category', TActionCategoryProperty); + InitFormsList; finalization + ReleaseFormsList; RegisteredActions.Free; RegisteredActions := nil; end.