Using a simulation for inspecting objects

A simulation provides an environment for developing and testing remote object inspection within a single image by converting the views to their specification in the inspector, like it happens when inspecting a proxy.

The main simulation class is GtRemoteInspectionSimulation Object subclass: #GtRemoteInspectionSimulation uses: TGtRemoteProxySpecificViews + TGtRemoteProxySpecificActions + TGtRemoteProxyInspectorWrappedObjectAttachment + TGtRemoteProxyActionsAttachment + TGtRemoteProxyViewsAttachment instanceVariableNames: 'object localProxyInspector remoteInspectorProxy' classVariableNames: '' package: 'GToolkit-RemoteGt-Development' . Another version is GtRemotePlainInspectionSimulation GtRemoteInspectionSimulation subclass: #GtRemotePlainInspectionSimulation instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-RemoteGt-Development' that should be used to simulate creating views using the API provided by GtRemotePhlowProtoView Object subclass: #GtRemotePhlowProtoView instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-RemotePhlow-PhlowViews' . This API is used from GemStone and plain Pharo.

From the perspective of the inspector a simulation acts as a proxy to a remote object with inspection support. This is the same support for inspection provided by GtRsrProxyServiceClient GtRsrProxyService subclass: #GtRsrProxyServiceClient uses: TGtRemoteProxySpecificViews + TGtRemoteProxySpecificActions + TGtRemoteProxyInspectorWrappedObjectAttachment + TGtRemoteProxyViewsAttachment + TGtRemoteProxyActionsAttachment instanceVariableNames: 'gtSession' classVariableNames: 'ObjectMap' package: 'GToolkit-GemStone-Pharo-Client' or LanguageLinkProxyObject Object subclass: #LanguageLinkProxyObject uses: TGtPharoLinkPlayground instanceVariableNames: 'application remoteClass name' classVariableNames: '' package: 'PharoLink-Core' .

Internally the simulation uses a proxy to an inspector wrapper (GtRemotePhlowViewedObject Object subclass: #GtRemotePhlowViewedObject instanceVariableNames: 'object actionSpecificationsBySelector viewSpecificationsBySelector' classVariableNames: '' package: 'GToolkit-RemotePhlow-InspectorCore' when the remote side is Glamorous Toolkit, GemStone or Pharo) and attaches views to the inspector in the same way that provy objects do.

simulation := GtRemoteInspectionSimulation 
	openOn: GtRemotePhlowDeclarativeTestInspectable new.
  
simulation := GtRemotePlainInspectionSimulation 
	openOn: GtRemotePhlowDeclarativeTestInspectable new.
  

As in the case of a proxy object we can ask the simulation for the view specifications of the object.

simulation declarativeViews 
  

We can also just get the raw data from for the view specifications.

simulation getViewsDeclarations
  

Interacting with a proxy for the view specification

From the simulation we can get directly a view speficiation. In remote contexts this will be a proxy to the remote view specification.

viewSpecificationProxy := simulation getDeclarativeViewFor: #gtListFor:
  

We can then use this view specification to retrieve the items in the list view.

viewSpecificationProxy 
	retrieveItems: 2 
	fromIndex: 2
  
viewSpecification retriveSentItemAt: 1
  

Interacting with a local view specification

We can also use the simulation to create a new local view specification and link it with the remote data source.

We can do that first manually step by step. We start by getting the data of the view specification.

viewSpecificationData := simulation getViewDeclaration: #gtListFor:
  

Then from the data we instantiate and initialize a local view specification object.

viewSpecification := GtPhlowViewSpecification 
	fromDictionary: viewSpecificationData.
viewSpecification initializeFromInspector: simulation.
  

Instead of the steps above we can directly ask the simulation to give us a new local instance for the view specification. In remote contexts, this will still be a local instance and not a proxy.

viewSpecification := simulation 
	buildLocalViewSpecificationFor: #gtListFor:
  

We can then use this view specification to retrieve the items in the list view.

viewSpecification 
	retrieveItems: 2 
	fromIndex: 2
  
viewSpecification retriveSentItemAt: 1