add the ICEOptionsEditor service

This commit is contained in:
Basile Burg 2016-09-22 10:46:12 +02:00
parent 0c634cce91
commit bd94792cce
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 54 additions and 11 deletions

View File

@ -373,6 +373,17 @@ type
end;
// TODO-cOptions: widgets that expose options can use ICEOptionsEditor in their ctxt menu
(**
* Single service provided by the options editor.
*)
ICEOptionsEditor = interface(ICESingleService)
// Shows the editor. When observer is not nil, its category is selected.
procedure showOptionEditor(observer: ICEEditableOptions = nil);
end;
TDCDCompletionKind = (
dckClass,
dckInterface,
@ -431,6 +442,7 @@ type
function getSymStringExpander: ICESymStringExpander;
function getProjectGroup: ICEProjectGroup;
function getExplorer: ICEExplorer;
function getOptionsEditor: ICEOptionsEditor;
implementation
@ -571,6 +583,10 @@ begin
exit(EntitiesConnector.getSingleService('ICEExplorer') as ICEExplorer);
end;
function getOptionsEditor: ICEOptionsEditor;
begin
exit(EntitiesConnector.getSingleService('ICEOptionsEditor') as ICEOptionsEditor);
end;
{$ENDREGION}
end.

View File

@ -14,24 +14,24 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
ClientHeight = 493
ClientWidth = 559
inherited Content: TPanel
Height = 493
Height = 457
Width = 559
ClientHeight = 493
ClientHeight = 457
ClientWidth = 559
object pnlBody: TPanel[0]
Left = 4
Height = 451
Height = 415
Top = 4
Width = 551
Align = alClient
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 451
ClientHeight = 415
ClientWidth = 551
TabOrder = 0
object selCat: TTreeView
Left = 0
Height = 451
Height = 415
Top = 0
Width = 150
Align = alLeft
@ -49,17 +49,17 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
end
object pnlEd: TPanel
Left = 156
Height = 451
Height = 415
Top = 0
Width = 395
Align = alClient
BevelOuter = bvNone
ClientHeight = 451
ClientHeight = 415
ClientWidth = 395
TabOrder = 1
object inspector: TTIPropertyGrid
Left = 0
Height = 451
Height = 415
Top = 0
Width = 395
Align = alClient
@ -77,7 +77,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
end
object Splitter1: TSplitter
Left = 150
Height = 451
Height = 415
Top = 0
Width = 6
end
@ -85,7 +85,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
object pnlFooter: TPanel[1]
Left = 4
Height = 30
Top = 459
Top = 423
Width = 551
Align = alBottom
BorderSpacing.Around = 4
@ -117,6 +117,9 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
end
end
end
inherited toolbar: TCEToolBar
Width = 551
end
end
inherited contextMenu: TPopupMenu
left = 144

View File

@ -22,7 +22,7 @@ type
{ TCEOptionEditorWidget }
TCEOptionEditorWidget = class(TCEWidget)
TCEOptionEditorWidget = class(TCEWidget, ICEOptionsEditor)
btnCancel: TSpeedButton;
btnAccept: TSpeedButton;
pnlEd: TPanel;
@ -50,6 +50,8 @@ type
procedure updateCategories;
function allowCategoryChange: boolean;
function sortCategories(Cat1, Cat2: TTreeNode): integer;
procedure showOptionEditor(observer: ICEEditableOptions = nil);
function singleServiceName: string;
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
@ -74,6 +76,8 @@ begin
//
AssignPng(btnCancel, 'CANCEL');
AssignPng(btnAccept, 'ACCEPT');
//
EntitiesConnector.addSingleService(self);
end;
destructor TCEOptionEditorWidget.destroy;
@ -91,6 +95,26 @@ end;
{$ENDREGION}
{$REGION Option editor things --------------------------------------------------}
procedure TCEOptionEditorWidget.showOptionEditor(observer: ICEEditableOptions = nil);
var
n: TTreeNode;
begin
if assigned(observer) then
begin
if selCat.Items.Count = 0 then
updateCategories;
n := selCat.Items.FindNodeWithText(observer.optionedWantCategory());
if n.isNotNil then
selCat.Selected := n;
end;
showWidget;
end;
function TCEOptionEditorWidget.singleServiceName: string;
begin
exit('ICEOptionsEditor');
end;
procedure TCEOptionEditorWidget.updateCategories;
var
i: Integer;