IdeIntf: Add "Change Class" feature also to popup menu of Object Inspector.

git-svn-id: trunk@48551 -
This commit is contained in:
juha 2015-03-31 17:10:25 +00:00
parent d28b3af044
commit f51604367b
4 changed files with 47 additions and 26 deletions

View File

@ -77,6 +77,7 @@ type
function InvokeComponentEditor(AComponent: TComponent;
{%H-}MenuIndex: integer): boolean; deprecated;
function InvokeComponentEditor(AComponent: TComponent): boolean; virtual; abstract;
function ChangeClass: boolean; virtual; abstract;
function CanUndo: Boolean; virtual; abstract;
function CanRedo: Boolean; virtual; abstract;

View File

@ -587,11 +587,13 @@ type
ViewRestrictedPropertiesPopupMenuItem: TMenuItem;
CopyPopupmenuItem: TMenuItem;
CutPopupmenuItem: TMenuItem;
PastePopupmenuItem: TMenuItem;
DeletePopupmenuItem: TMenuItem;
ChangeClassPopupmenuItem: TMenuItem;
FindDeclarationPopupmenuItem: TMenuItem;
OptionsSeparatorMenuItem: TMenuItem;
OptionsSeparatorMenuItem2: TMenuItem;
PastePopupmenuItem: TMenuItem;
OptionsSeparatorMenuItem3: TMenuItem;
RemoveFromFavoritesPopupMenuItem: TMenuItem;
ShowComponentTreePopupMenuItem: TMenuItem;
ShowHintsPopupMenuItem: TMenuItem;
@ -634,6 +636,7 @@ type
procedure OnCopyPopupmenuItemClick(Sender: TObject);
procedure OnPastePopupmenuItemClick(Sender: TObject);
procedure OnDeletePopupmenuItemClick(Sender: TObject);
procedure OnChangeClassPopupmenuItemClick(Sender: TObject);
procedure OnShowComponentTreePopupMenuItemClick(Sender: TObject);
procedure OnShowHintPopupMenuItemClick(Sender: TObject);
procedure OnShowInfoBoxPopupMenuItemClick(Sender: TObject);
@ -3965,6 +3968,12 @@ begin
@OnDeletePopupmenuItemClick,false,true,true);
OptionsSeparatorMenuItem2 := AddSeparatorMenuItem(nil, 'OptionsSeparatorMenuItem2', true);
// Change class of the component. ToDo: create a 'change_class' icon resource
AddPopupMenuItem(ChangeClassPopupMenuItem,nil,'ChangeClassPopupMenuItem',
oisChangeClass,'Change Class of component', '',
@OnChangeClassPopupmenuItemClick,false,true,true);
OptionsSeparatorMenuItem3 := AddSeparatorMenuItem(nil, 'OptionsSeparatorMenuItem3', true);
AddPopupMenuItem(ShowComponentTreePopupMenuItem,nil
,'ShowComponentTreePopupMenuItem',oisShowComponentTree, '', ''
,@OnShowComponentTreePopupMenuItemClick,FShowComponentTree,true,true);
@ -4648,6 +4657,18 @@ begin
end;
end;
procedure TObjectInspectorDlg.OnChangeClassPopupmenuItemClick(Sender: TObject);
var
ADesigner: TIDesigner;
begin
if (Selection.Count = 1) then
begin
ADesigner := FindRootDesigner(Selection[0]);
if ADesigner is TComponentEditorDesigner then
TComponentEditorDesigner(ADesigner).ChangeClass;
end;
end;
procedure TObjectInspectorDlg.OnGridModified(Sender: TObject);
begin
DoModified(Self);
@ -5196,7 +5217,7 @@ var
end;
var
b, AtLeastOneComponent, CanBeDeleted: Boolean;
b, ExactlyOneComp, AtLeastOneComp: Boolean;
CurRow: TOIPropertyGridRow;
Persistent: TPersistent;
begin
@ -5204,6 +5225,8 @@ begin
RemoveComponentEditorMenuItems;
ShowHintsPopupMenuItem.Checked := PropertyGrid.ShowHint;
Persistent := GetSelectedPersistent;
ExactlyOneComp := False;
AtLeastOneComp := False;
// show component editors only for component treeview
if MainPopupMenu.PopupComponent = ComponentTree then
begin
@ -5218,26 +5241,19 @@ begin
else if Persistent is TCollectionItem then
AddCollectionEditorMenuItems(TCollectionItem(Persistent).Collection);
end;
ExactlyOneComp := (Selection.Count = 1) and (Selection[0] is TComponent);
AtLeastOneComp := (Selection.Count > 0) and (Selection[0] is TComponent);
// add Z-Order menu
if (Selection.Count = 1) and (Selection[0] is TControl) then
AddZOrderMenuItems;
AtLeastOneComponent:=(Selection.Count > 0) and (Selection[0] is TComponent);
CanBeDeleted:=AtLeastOneComponent;
CutPopupMenuItem.Visible := CanBeDeleted;
CopyPopupMenuItem.Visible := AtLeastOneComponent;
PastePopupMenuItem.Visible := AtLeastOneComponent;
DeletePopupMenuItem.Visible := CanBeDeleted;
OptionsSeparatorMenuItem2.Visible := AtLeastOneComponent;
end
else
begin
CutPopupMenuItem.Visible := False;
CopyPopupMenuItem.Visible := False;
PastePopupMenuItem.Visible := False;
DeletePopupMenuItem.Visible := False;
OptionsSeparatorMenuItem2.Visible := False;
end;
CutPopupMenuItem.Visible := AtLeastOneComp;
CopyPopupMenuItem.Visible := AtLeastOneComp;
PastePopupMenuItem.Visible := AtLeastOneComp;
DeletePopupMenuItem.Visible := AtLeastOneComp;
OptionsSeparatorMenuItem2.Visible := AtLeastOneComp;
ChangeClassPopupmenuItem.Visible := ExactlyOneComp;
OptionsSeparatorMenuItem3.Visible := ExactlyOneComp;
// The editors can do menu actions, for example set defaults and constraints
CurRow := GetActivePropertyRow;

View File

@ -432,6 +432,7 @@ resourcestring
oisUnableToChangeParentOfControlToNewParent = 'Unable to change parent of '
+'control "%s" to new parent "%s".%s%s';
oisAddCollectionItem = '&Add Item';
oisChangeClass = 'Change Class ...';
lisUnableToFindParserForTool = 'Unable to find parser for tool "%s"';
// Dbgrid Columns editor

View File

@ -214,7 +214,6 @@ type
procedure DoShowAnchorEditor;
procedure DoShowTabOrderEditor;
procedure DoShowChangeClassDialog;
procedure DoShowObjectInspector;
procedure DoChangeZOrder(TheAction: Integer);
@ -282,6 +281,8 @@ type
function InsertFromStream(s: TStream; Parent: TWinControl;
PasteFlags: TComponentPasteSelectionFlags): Boolean; override;
function InvokeComponentEditor(AComponent: TComponent): boolean; override;
function ChangeClass: boolean; override;
procedure DoProcessCommand(Sender: TObject; var Command: word;
var Handled: boolean);
@ -1404,12 +1405,6 @@ begin
FOnShowTabOrderEditor(Self);
end;
procedure TDesigner.DoShowChangeClassDialog;
begin
if (ControlSelection.Count=1) and (not ControlSelection.LookupRootSelected) then
ShowChangeClassDialog(Self,ControlSelection[0].Persistent);
end;
procedure TDesigner.DoShowObjectInspector;
begin
if Assigned(FOnShowObjectInspector) then
@ -1548,6 +1543,14 @@ begin
end;
end;
function TDesigner.ChangeClass: boolean;
begin
if (ControlSelection.Count=1) and (not ControlSelection.LookupRootSelected) then
Result:=ShowChangeClassDialog(Self,ControlSelection[0].Persistent)=mrOK
else
Result:=false;
end;
procedure TDesigner.DoProcessCommand(Sender: TObject; var Command: word;
var Handled: boolean);
begin
@ -3183,7 +3186,7 @@ end;
procedure TDesigner.OnChangeClassMenuClick(Sender: TObject);
begin
DoShowChangeClassDialog;
ChangeClass;
end;
procedure TDesigner.OnChangeParentMenuClick(Sender: TObject);