unit uROIDEEditors; {----------------------------------------------------------------------------} { RemObjects SDK Library - IDE Integration } { } { compiler: Delphi 6 and up } { platform: Win32, Linux } { } { (c)opyright RemObjects Software. all rights reserved. } { } { Using this code requires a valid license of the RemObjects SDK } { which can be obtained at http://www.remobjects.com. } {----------------------------------------------------------------------------} {$IFNDEF MSWINDOWS} {$I ../RemObjects.inc} {$ELSE} {$I ..\RemObjects.inc} {$ENDIF} interface uses {$IFDEF FPC} PropEdits,ComponentEditors, {$ELSE} {$IFDEF VER140UP}DesignEditors, DesignIntf, {$ELSE} DsgnIntf,{$ENDIF} {$ENDIF} Forms,Classes; const prop_ServiceName = 'ServiceName'; prop_OperationName = 'OperationName'; prop_Dispatchers = 'Dispatchers'; capt_TestConnection = 'Test Connection...'; type {$IFDEF FPC} IDesigner = TIDesigner; {$ENDIF} { TROServiceNameProperty } TROServiceNameProperty = class(TStringProperty) protected public function GetAttributes: TPropertyAttributes; override; procedure GetValues(Proc: TGetStrProc); override; end; { TDispatchersProperty } TDispatchersProperty = class(TClassProperty) public procedure Edit; override; function GetAttributes: TPropertyAttributes; override; end; {$IFDEF VER140UP} { TROServerEditor } TROServerEditor = class(TComponentEditor) public procedure Edit; override; end; { TRORemoteServiceEditor } TRORemoteServiceEditor = class(TComponentEditor) protected public procedure ExecuteVerb(Index: Integer); override; function GetVerb(Index: Integer): string; override; function GetVerbCount: Integer; override; end; {$ENDIF VER140UP} implementation uses Controls, Dialogs, uRORemoteService, uROServer, uROClasses, {$IFDEF FPC} fDispatchersEditorForm, {$ELSE} {$IFDEF MSWINDOWS} fDispatchersEditorForm, {$ELSE} fDispatchersEditorFormKylix, {$ENDIF} {$ENDIF} uROEventRepository; function FindDesigner(Container: TComponent): IDesigner; begin Result := nil; if Container <> nil then begin if Container is TCustomForm then begin Result := TCustomForm(Container).Designer as IDesigner; end else if (Container is TDataModule) and (Container.Owner <> nil) then begin Result := (Container.Owner as TForm).Designer as IDesigner; end else if (Container is TWinControl) and (Container.Owner <> nil) then begin Result := (Container.Owner as TForm).Designer as IDesigner; end; end; end; { TROServiceNameProperty } function TROServiceNameProperty.GetAttributes: TPropertyAttributes; begin result := [paValueList, paSortList] end; procedure TROServiceNameProperty.GetValues(Proc: TGetStrProc); var i : integer; ss : IROStrings; begin if GetComponent(0) is TRORemoteService then begin ss := TRORemoteService(GetComponent(0)).GetServiceNames; end else if GetComponent(0) is TROEventReceiver then begin TROEventReceiver(GetComponent(0)).CheckProperties(False); with TRORemoteService.Create(nil) do try Message:=TROEventReceiver(GetComponent(0)).Message; Channel:=TROEventReceiver(GetComponent(0)).Channel; ss := GetServiceNames; finally free; end; end; if assigned(ss) then for i := 0 to (ss.Count-1) do Proc(ss[i]); end; { TDispatchersProperty } procedure TDispatchersProperty.Edit; begin with TDispatchersEditorForm.Create(TROServer(GetComponent(0))) do try ShowModal; Modified(); finally Free; end; end; function TDispatchersProperty.GetAttributes: TPropertyAttributes; begin result := [paDialog] end; { TROServerEditor } {$IFDEF VER140UP} procedure TROServerEditor.Edit; var lDesigner:IDesigner; begin with TDispatchersEditorForm.Create(TROServer(GetComponent())) do try ShowModal; lDesigner := FindDesigner(GetComponent().Owner); if Assigned(lDesigner) then lDesigner.Modified() //else ShowMessage('No designer'); finally Free; end; end; {$ENDIF VER140UP} { TRORemoteServiceEditor } {$IFDEF VER140UP} procedure TRORemoteServiceEditor.ExecuteVerb(Index: Integer); var conn : TRORemoteService; i : integer; s : string; ss : IROStrings; begin conn := TRORemoteService(GetComponent); case Index of 0 : begin ss := conn.GetServiceNames; if assigned(ss) then begin s := 'The server exposes the following service(s):'+#13#13; for i := 0 to (ss.Count-1) do s := s+ss[i]+#13; MessageDlg(s, mtInformation, [mbOK], 0); end else begin MessageDlg('The server exposes no services.', mtInformation, [mbOK], 0); end; end; end; end; function TRORemoteServiceEditor.GetVerb(Index: Integer): string; begin case Index of 0 : result := capt_TestConnection; end; end; function TRORemoteServiceEditor.GetVerbCount: Integer; begin result := 1; end; {$ENDIF VER140UP} end.