diff options
Diffstat (limited to 'web-gui/live/source/class/live/Application.js')
-rw-r--r-- | web-gui/live/source/class/live/Application.js | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/web-gui/live/source/class/live/Application.js b/web-gui/live/source/class/live/Application.js new file mode 100644 index 0000000..193e506 --- /dev/null +++ b/web-gui/live/source/class/live/Application.js @@ -0,0 +1,128 @@ +/* ************************************************************************ + + Copyright: + + License: + + Authors: + +************************************************************************ */ + +/* ************************************************************************ + +#asset(live/*) + +************************************************************************ */ + +/** + * This is the main application class of your custom application "live" + */ +qx.Class.define("live.Application", +{ +extend : qx.application.Standalone, + +properties: { + online: { + init: false, + apply: "__applyOnline", + check: "Boolean" + } +}, + + +/* +***************************************************************************** + MEMBERS +***************************************************************************** +*/ + +members : +{ + __rpc: null, + __call: null, + __statusImageOn: null, + __statusImageOff: null, + __statusStack: null, + __label: null, + /** + * This method contains the initial application code and gets called + * during startup of the application + * + * @lint ignoreDeprecated(alert) + */ + main : function() + { + // Call super class + this.base(arguments); + + // Enable logging in debug variant + if (qx.core.Variant.isSet("qx.debug", "on")) + { + // support native logging capabilities, e.g. Firebug for Firefox + qx.log.appender.Native; + // support additional cross-browser console. Press F7 to toggle visibility + qx.log.appender.Console; + } + + /* + ------------------------------------------------------------------------- + Below is your actual application code... + ------------------------------------------------------------------------- + */ + + // Document is the application root + var doc = this.getRoot(); + doc.setBackgroundColor("#ffffff"); + + var back = new qx.ui.basic.Image("live/back.png"); + back.setScale(true); + doc.add(back, {left:0, top: 0}); + + this.__label = new qx.ui.basic.Label("The Server is"); + doc.add(this.__label, {left:50, top: 50}); + this.__statusStack = new qx.ui.container.Stack(); + this.__statusStack.setAllowGrowX(false); + this.__statusStack.setAllowGrowY(false); + doc.add(this.__statusStack, {left:100, top: 100}); + this.__statusImageOn = new qx.ui.basic.Image("live/network-online.png"); + this.__statusStack.add(this.__statusImageOn); + this.__statusImageOff = new qx.ui.basic.Image("live/network-offline.png"); + this.__statusStack.add(this.__statusImageOff); + this.__statusStack.setSelection([this.__statusImageOff]); + + this.__rpc = new qx.io.remote.Rpc("http://localhost:8080/rpc", "com.pengutronix.jdb.Hello|/"); + + var timer = new qx.event.Timer(1000); + timer.addListener("interval", this.__tick, this); + timer.start(); + }, + __applyOnline: function(online) { + if (online) { + this.__statusStack.setSelection([this.__statusImageOn]); + this.__label.setValue("The Server is online."); + } + else { + this.__statusStack.setSelection([this.__statusImageOff]); + this.__label.setValue("The Server is offline."); + } + }, + __tick : function() + { + if (this.__call != null) { + this.__rpc.abort(this.__call); + this.setOnline(false); + } + this.__call = this.__rpc.callAsync( + qx.lang.Function.bind(this.__callback, this), + "com.pengutronix.jdb.Hello.HelloWorld"); + }, + __callback: function(ret, err, id) { + this.__call = null; + if (err != null) { + this.setOnline(false); + return; + } + this.setOnline(true); + } +} +}); |