IDE: Update collection editor after adding item via OI. Issue #19091

git-svn-id: trunk@32702 -
This commit is contained in:
juha 2011-10-05 11:37:15 +00:00
parent 40f77bc7df
commit a8e589df12
3 changed files with 20 additions and 5 deletions

View File

@ -17898,7 +17898,7 @@ begin
ADesigner:=FindRootDesigner(AComponent) as TDesigner; ADesigner:=FindRootDesigner(AComponent) as TDesigner;
end; end;
if (RegComp<>nil) or (ClassUnitInfo<>nil) then begin if (ADesigner<>nil) and ((RegComp<>nil) or (ClassUnitInfo<>nil)) then begin
if not BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo, if not BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,
[ctfSwitchToFormSource]) [ctfSwitchToFormSource])
then exit; then exit;

View File

@ -37,6 +37,7 @@ type
protected protected
procedure UpdateCaption; procedure UpdateCaption;
procedure UpdateButtons; procedure UpdateButtons;
procedure PersistentAdded(APersistent: TPersistent; Select: boolean);
procedure ComponentRenamed(AComponent: TComponent); procedure ComponentRenamed(AComponent: TComponent);
procedure PersistentDeleting(APersistent: TPersistent); procedure PersistentDeleting(APersistent: TPersistent);
procedure RefreshPropertyValues; procedure RefreshPropertyValues;
@ -57,7 +58,8 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Controls, Dialogs, IDEImagesIntf, ObjInspStrConsts, PropEdits, PropEditUtils; Controls, Dialogs, LCLProc, IDEImagesIntf, ObjInspStrConsts, PropEdits,
PropEditUtils;
procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject); procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject);
begin begin
@ -225,9 +227,17 @@ begin
actMoveDown.Enabled := (I >= 0) and (I < Collection.Count - 1); actMoveDown.Enabled := (I >= 0) and (I < Collection.Count - 1);
end; end;
procedure TCollectionPropertyEditorForm.PersistentAdded(APersistent: TPersistent; Select: boolean);
begin
DebugLn('*** TCollectionPropertyEditorForm.PersistentAdded called ***');
FillCollectionListBox;
end;
procedure TCollectionPropertyEditorForm.ComponentRenamed(AComponent: TComponent); procedure TCollectionPropertyEditorForm.ComponentRenamed(AComponent: TComponent);
begin begin
if AComponent = OwnerPersistent then UpdateCaption; DebugLn('*** TCollectionPropertyEditorForm.ComponentRenamed called ***');
if AComponent = OwnerPersistent then
UpdateCaption;
end; end;
procedure TCollectionPropertyEditorForm.PersistentDeleting(APersistent: TPersistent); procedure TCollectionPropertyEditorForm.PersistentDeleting(APersistent: TPersistent);
@ -263,11 +273,13 @@ begin
end; end;
UpdateButtons; UpdateButtons;
UpdateCaption; UpdateCaption;
DebugLn('*** TCollectionPropertyEditorForm.PersistentDeleting called ***');
end; end;
procedure TCollectionPropertyEditorForm.RefreshPropertyValues; procedure TCollectionPropertyEditorForm.RefreshPropertyValues;
begin begin
FillCollectionListBox; FillCollectionListBox;
DebugLn('*** TCollectionPropertyEditorForm.RefreshPropertyValues called ***');
end; end;
procedure TCollectionPropertyEditorForm.FillCollectionListBox; procedure TCollectionPropertyEditorForm.FillCollectionListBox;
@ -342,11 +354,12 @@ begin
FCollection := NewCollection; FCollection := NewCollection;
FOwnerPersistent := NewOwnerPersistent; FOwnerPersistent := NewOwnerPersistent;
FPropertyName := NewPropName; FPropertyName := NewPropName;
//debugln('TCollectionPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName); debugln('TCollectionPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName);
if GlobalDesignHook <> nil then if GlobalDesignHook <> nil then
begin begin
if FOwnerPersistent <> nil then if FOwnerPersistent <> nil then
begin begin
GlobalDesignHook.AddHandlerPersistentAdded(@PersistentAdded);
GlobalDesignHook.AddHandlerComponentRenamed(@ComponentRenamed); GlobalDesignHook.AddHandlerComponentRenamed(@ComponentRenamed);
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting); GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
GlobalDesignHook.AddHandlerRefreshPropertyValues(@RefreshPropertyValues); GlobalDesignHook.AddHandlerRefreshPropertyValues(@RefreshPropertyValues);

View File

@ -5187,6 +5187,7 @@ procedure TObjectInspectorDlg.DoCollectionAddItem(Sender: TObject);
var var
Persistent: TPersistent; Persistent: TPersistent;
Collection: TCollection absolute Persistent; Collection: TCollection absolute Persistent;
ci: TCollectionItem;
begin begin
Persistent := GetSelectedPersistent; Persistent := GetSelectedPersistent;
if Persistent = nil then if Persistent = nil then
@ -5195,7 +5196,8 @@ begin
Persistent := TCollectionItem(Persistent).Collection; Persistent := TCollectionItem(Persistent).Collection;
if not (Persistent is TCollection) then if not (Persistent is TCollection) then
Exit; Exit;
Collection.Add; ci:=Collection.Add;
GlobalDesignHook.PersistentAdded(ci,false);
DoModified(Self); DoModified(Self);
Selection.ForceUpdate := True; Selection.ForceUpdate := True;
try try