Within the parent exemplar there will be an action called "start_child." This action will call the start_child() method. The start_child_method will actually create and show the child GUI.
parent.define_shared_constant(
:databus_consumer_data_types,
{ :child_data },
:public )
$
_method parent.init_actions()
....
_self.add_action(
sw_action.new(:start_child,
:engine,_self,
:action_message,:start_child|()|,
:toolbar_control, :button_item,
:enabled?,_true
))
....
_endmethod
_method parent.start_child()
....
_if .dialogs[:child] _is _unset #DEBUG _orif _true
_then
# The following creates a child_plugin with parent as the framework
.dialogs[:child] << child_plugin.new(:child,_self)
# Need to assign the databus of the child to this so we can be notified that
# the child sent me something
.dialogs[:child].databus << _self.databus
_endif
# show the GUI
.dialogs[:child].activate_dialog(_self)
....
_endmethod
The either one of the following methods can be used. The sw_databus_data_available() method is the method that is called when data is passed thru using the databus
_method parent.handle_child_ok(child)
## Do something with the child information when the child calls this directly.
## May not be the 100% component solution and you may want to use the other
## method for databus usage.
_endmethod
_method.sw_databus_data_available(what,data,who)
## Do something thru the databus
_endmethod
Now in the child_plugin exemplar, you need to subclass the activate_dialog to use the parent.
_method child_plugin.activate_plugin(parent)
_local d
# create a framework if needed
_if (d << _self.get_dialog(:child)) _is _unset #DEBUG _orif _true
_then
d << child_framework.new("Child",parent)
# Set the databus if using databus communications
d.databus << _self.databus
_self.cache_dialog(:child,d)
_endif
d.maximizable? << _true
d.minimizable? << _true
d.resizable? << _true
# get the top frame if parent is set
_local tf << _if parent _isnt _unset
_then
>> parent.top_frame
_endif
# activate the framework using the top frame was the parent frame
d.activate(tf,_self.message(name))
>> d
_endmethod
To support databus communications, you need to add the following to the framework of the child
child_framework.define_shared_constant(
:databus_producer_data_types,
{ :child_data },
:public )
$
Now from the child GUI code, you need to inform the parent that the child has done something if you want to update the parent. In this example it is assumed that there is an action defined on the child exemplar called :ok which calls the ok() method.
_method child.ok()
# 1st get the parent using self framework (child_framework) and the
# child_framework had parent as it's framework
_local parent << self.framework.framework
# now notify the parent
parent.handle_child_ok(child)
# close the child GUI
_self.quit()
_endmethod
$
_method child.init_actions()
...
# Use this for databus communications
_self.databus << _self.framework.databus
...
_endmethod
$
_method child.ok_using_databus()
_self.databus_make_data_available(:child_data,{:test})
_self.quit()
_endmethod
$