PublishModule
module increments or decrements a value cyclicallyEventModule
module allows to click on a toggle to set if the first module should increment or decrement the value, and shows the valueEventModule
was developed in Java. We will create a XUL file to implement this interface and all the wiring to the framework. The scripting will use a XUL Javascript script.
services.xml
XML file:event
service carries the state of the toggle button. It is an event Service because the service should only be invoked when the state of the toggle button changespublished
service carries the value. It is a publish Service because the service should be invoked cyclically<services> <event name="event" id="1" > <data name="event" type="bool" /> </event> <publish name="published" id="2" > <data name="value" type="int" /> </publish> </services>
bool
type is a booleanint
type is an inttypes.xml
XML file:<types> <simpleType name="bool" baseType="boolean" /> <simpleType name="int" baseType="int" /> </types>
applications.xml
XML file:eventAppli
will be implemented by a xulInterface script and will:event
servicepublished
servicepublishAppli
only contains the PublishModule
. This Module is identical to the one defined in the first tutorial:published
serviceevent
service<applications> <application name="eventAppli"> <deployment> <lib url="xulInterface.jar" /> </deployment> <modules> <module name="xulInterface"> <interfaces> <eventSend service="event" attach="attach"/> <subscribe service="published" /> </interfaces> </module> </modules> </application> <application name="publishAppli"> <deployment> <lib url="samples1Publish.jar" /> </deployment> <modules> <module name="PublishModule"> <implementation path="org.da.samples.protoframework.publish.PublishModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </module> </modules> </application> </applications>
<properties> <application name="xulInterface" > <module name="xulInterface" > <moduleProperty key="xul" value="event.xul" /> <moduleProperty key="validate" value="true" /> </module> </application> </properties>The
event.xul
file will contain all our XUL definition.
event.xul
file.
<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="vboxExample" title="Example" width="200" height ="200" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <hbox> <button id="button" label="Positive Step" /> <label id="label" value="0" /> </hbox> </window>
published
serviceevent
service about the click on the button<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="vboxExample" title="Example" width="200" height ="200" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> var positive = true; function toggle() { positive = !positive; if (!positive) { document.getElementById("button").label = "Positive Step"; } else { document.getElementById("button").label = "Negative Step"; } var service = context.getService("event"); service.getData("event").setBooleanValue(positive); service.invoke(); } function subscribe(service) { var value = service.getData("value").getValueAsInt(); document.getElementById("label").value = value; } </script> <hbox> <button id="button" label="Positive Step" oncommand="toggle()" /> <label id="label" value="0" /> </hbox> </window>
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence