Display.(a)syncExec() execution problem [message #662384] |
Wed, 30 March 2011 13:32 |
Dimitri Jeske Messages: 4 Registered: March 2011 |
Junior Member |
|
|
Hi RAP developers and community,
I am relatively new to this topic, but nevertheless I am trying to implement an application consisting of several bundles in RAP. One of them acts as a GUI (GUI bundle) and another one (monitoring bundle) is meant for collecting data from sensors attached to a platform running OSGi.
Among others the GUI consits of several views and one of them is used for displaying the informaiton received from the monitoring bundle in tabular mode (using org.eclipse.jface.viewers.TableViewer). For this purpose the GUI bundle registers a service which is used by the monitoring bundle for transmitting the collected data in an appropriate way. This is done periodically by implementing a java.util.Timer. Upon receiving new data, the data model of the GUI bundle gets updated and Display.asyncExec(runnable) is called. But the execution of the runnable occurs only after a user interaction with the browser window (e.g. resizing it, scrolling up/down or reordering the collumns of a table).
The corresponding pieces of code are listed below:
GUI bundle
public void updateRegularData(final String sensorclassID, final Node[] nodes) {
//create a list for the sensor data
List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
//traverse all nodes of the sensorclass
for(Node node : nodes) {
//and every sensor of a node
for(Sensor sensor : node.getSensors()) {
//create new simplesensor with its properties
SimpleSensor newSensor = new SimpleSensor();
newSensor.setId(sensor.getID());
newSensor.setName(sensor.getName());
newSensor.setValue(sensor.getSensorValue().getValue());
newSensor.setMax(sensor.getSensorValue().getMax());
newSensor.setMin(sensor.getSensorValue().getMin());
newSensor.setUnit(sensor.getSensorValue().getUnit());
newSensor.setOnline(!sensor.isOffline());
newSensor.setParent(node.getID());
//and put it into the list
sensorList.add(newSensor);
}
}
//update the data of the model with the newly created list
SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
}
private class MyRunnable implements Runnable {
private final String sensorclassID;
MyRunnable(String sensorclassID) {
this.sensorclassID = sensorclassID;
}
@Override
public void run() {
//this call does not affect anything
UICallBack.activate(sensorclassID);
//check whether there is already a view for displaying the data
if(!manager.containsViewer(sensorclassID)) {
//if not, create a new one
manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
}
else {
//otherwise just update the view
manager.updateViewer(sensorclassID);
}
//this call does not affect anything
UICallBack.deactivate(sensorclassID);
}
}
As stated above, the execution of run()s occurs only after a user interaction with the GUI, meaning that the corresponding threads are waiting for an event, which is not intended.
Is there any possibility to force the execution, so that the GUI gets updated immediately after receiving new data?
Every helpful suggestion for solving this behavior is greatly appreciated.
Greetings,
Dimitri
[Updated on: Wed, 30 March 2011 13:32] Report message to a moderator
|
|
|
Re: Display.(a)syncExec() execution problem [message #662613 is a reply to message #662384] |
Thu, 31 March 2011 09:45 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Dimitri,
activate the UICallBack outside the runnable... something like this:
SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
UICallBack.activate(sensorclassID);
MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
HTH,
Ivan
On 3/30/2011 4:32 PM, Dimitri Jeske wrote:
> Hi RAP developers and community,
>
> I am relatively new to this topic, but nevertheless I am trying to
> implement an application consisting of several bundles in RAP. One of
> them acts as a GUI (GUI bundle) and another one (monitoring bundle) is
> meant for collecting data from sensors attached to a platform running
> OSGi.
> Among others the GUI consits of several views and one of them is used
> for displaying the informaiton received from the monitoring bundle in
> tabular mode (using org.eclipse.jface.viewers.TableViewer). For this
> purpose the GUI bundle registers a service which is used by the
> monitoring bundle for transmitting the collected data in an
> appropriate way. This is done periodically by implementing a
> java.util.Timer. Upon receiving new data, the data model of the GUI
> bundle gets updated and Display.asyncExec(runnable) is called. But the
> execution of the runnable occurs only after a user interaction with
> the browser window (e.g. resizing it, scrolling up/down or reordering
> the collumns of a table).
>
> The corresponding pieces of code are listed below:
>
> GUI bundle
> public void updateRegularData(final String sensorclassID, final Node[]
> nodes) {
> //create a list for the sensor data
> List<SimpleSensor> sensorList = new ArrayList<SimpleSensor>();
> //traverse all nodes of the sensorclass
> for(Node node : nodes) {
> //and every sensor of a node
> for(Sensor sensor : node.getSensors()) {
> //create new simplesensor with its properties
> SimpleSensor newSensor = new SimpleSensor();
> newSensor.setId(sensor.getID());
> newSensor.setName(sensor.getName());
> newSensor.setValue(sensor.getSensorValue().getValue());
> newSensor.setMax(sensor.getSensorValue().getMax());
> newSensor.setMin(sensor.getSensorValue().getMin());
> newSensor.setUnit(sensor.getSensorValue().getUnit());
> newSensor.setOnline(!sensor.isOffline());
> newSensor.setParent(node.getID());
> //and put it into the list
> sensorList.add(newSensor);
> }
> }
> //update the data of the model with the newly created list
> SensorModelProvider.INSTANCE.updateData(sensorclassID, sensorList);
> MonitoringView.defaultDisplay.asyncExec(new MyRunnable(sensorclassID));
> }
>
> private class MyRunnable implements Runnable {
> private final String sensorclassID;
> MyRunnable(String sensorclassID) {
> this.sensorclassID = sensorclassID;
> }
> @Override
> public void run() {
> //this call does not affect anything
> UICallBack.activate(sensorclassID);
> //check whether there is already a view for displaying the data
> if(!manager.containsViewer(sensorclassID)) {
> //if not, create a new one
> manager.createViewer(MonitoringView.TOP_CONTAINER, sensorclassID);
> }
> else {
> //otherwise just update the view
> manager.updateViewer(sensorclassID);
> }
> //this call does not affect anything
> UICallBack.deactivate(sensorclassID);
> }
> }
> As stated above, the execution of run()s occurs only after a user
> interaction with the GUI, meaning that the corresponding threads are
> waiting for an event, which is not intended.
> Is there any possibility to force the execution, so that the GUI gets
> updated immediately after receiving new data?
> Every helpful suggestion for solving this behavior is greatly
> appreciated.
>
> Greetings,
> Dimitri
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03766 seconds