From 55490b1bfb539386b63e25a8fd90e56c0200c1e8 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Tue, 23 Aug 2011 13:59:15 +0000 Subject: clean out smoketrace --- qx08/source/class/tr/ui/Cellrenderer.js | 51 ------ qx08/source/class/tr/ui/Config.js | 206 --------------------- qx08/source/class/tr/ui/CopyBuffer.js | 45 ----- qx08/source/class/tr/ui/Footer.js | 24 --- qx08/source/class/tr/ui/Link.js | 54 ------ qx08/source/class/tr/ui/TraceTable.js | 314 -------------------------------- 6 files changed, 694 deletions(-) delete mode 100644 qx08/source/class/tr/ui/Cellrenderer.js delete mode 100644 qx08/source/class/tr/ui/Config.js delete mode 100644 qx08/source/class/tr/ui/CopyBuffer.js delete mode 100644 qx08/source/class/tr/ui/Footer.js delete mode 100644 qx08/source/class/tr/ui/Link.js delete mode 100644 qx08/source/class/tr/ui/TraceTable.js (limited to 'qx08/source/class/tr/ui') diff --git a/qx08/source/class/tr/ui/Cellrenderer.js b/qx08/source/class/tr/ui/Cellrenderer.js deleted file mode 100644 index 79edf4d..0000000 --- a/qx08/source/class/tr/ui/Cellrenderer.js +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************ - - Tr Frontend - - Author: - * Tobias Oetiker - -************************************************************************ */ - -/* ************************************************************************ -#module(Tr) -************************************************************************ */ - -/** - * A configurable cell renderre - */ -qx.Class.define('tr.ui.Cellrenderer', { - extend : qx.ui.table.cellrenderer.Number, - - - /** - * Format a number with a configurable number of fraction digits - * and add optional pre and postfix. - * @param digits {Integer} how many digits should there be. Default is 0. - * @param prefix {String} optional prefix. - * @param postfix {String} optional postfix. - */ - construct : function(digits, postfix, prefix) { - if (digits == undefined) { - digits = 0; - } - - this.base(arguments); - var format = new qx.util.format.NumberFormat(); - - format.set({ - maximumFractionDigits : digits, - minimumFractionDigits : digits - }); - - if (postfix != undefined) { - format.setPostfix(postfix); - } - - if (prefix != undefined) { - format.setPrefix(prefix); - } - - this.setNumberFormat(format); - } -}); \ No newline at end of file diff --git a/qx08/source/class/tr/ui/Config.js b/qx08/source/class/tr/ui/Config.js deleted file mode 100644 index 3310bee..0000000 --- a/qx08/source/class/tr/ui/Config.js +++ /dev/null @@ -1,206 +0,0 @@ -/* ************************************************************************ -#module(Tr) -#asset(qx/icon/${qx.icontheme}/22/actions/dialog-apply.png) -#asset(qx/icon/${qx.icontheme}/22/actions/dialog-close.png) - -************************************************************************ */ - -/** - * show the config options for traceroute as defined by the server - */ -qx.Class.define('tr.ui.Config', { - extend : qx.ui.window.Window, - - construct : function() { - this.base(arguments, this.tr("Traceroute Configuration")); - var layout = new qx.ui.layout.Grid(3, 5); - layout.setColumnAlign(0, 'right', 'middle'); - layout.setColumnAlign(1, 'left', 'middle'); - layout.setColumnWidth(0, 140); - layout.setColumnWidth(1, 140); - - this.setLayout(layout); - - this.set({ - allowMaximize : false, - allowMinimize : false, - modal : true, - resizable : false, - showMaximize : false, - showMinimize : false - }); - - var that = this; - - var create_config = function(retval, exc, id) { - if (exc == null) { - that.__create_config(retval); - } else { - qx.event.message.Bus.dispatch('error', [ that.tr("Server Error"), '' + exc ]); - } - }; - - tr.Server.getInstance().callAsync(create_config, 'get_config'); - - qx.event.message.Bus.subscribe('config', function(e) { - this.__task = e.getData(); - this.__seed(); - this.center(); - this.open(); - }, - this); - }, - - members : { - __task : null, - __setters : null, - - - /** - * Load configuration values into dialog. If no values are provided, - * the default values get loaded. - * - * @type member - * @return {void} - */ - __seed : function() { - for (var key in this.__setters) { - this.info(key+': '+this.__task[key]) - this.__setters[key](this.__task[key]); - } - }, - - - /** - * TODOC - * - * @type member - * @param data {var} TODOC - * @return {void} - */ - __create_config : function(data) { - var entries = data.length; - var status = {}; - var setters = {}; - this.__setters = setters; - - var r = 0; - var that = this; - - for (var k=0; k 0 : value > 0); - }; - - break; - } - - that.add(widget, { - row : r, - column : 1 - }); - - r++; - })(); - } - - var ok = new qx.ui.form.Button(this.tr("Apply")).set({ - marginTop : 10, - marginLeft : 40 - }); - - ok.addListener('execute', function(e) { - for (var key in status) { - that.__task[key] = status[key](); - } - - that.close(); - }); - - this.add(ok, { - row : r, - column : 0 - }); - - var cancel = new qx.ui.form.Button(this.tr("Reset")).set({ - marginTop : 10, - marginRight : 30 - }); - - cancel.addListener('execute', function(e) { - for (var key in setters) { - setters[key](); - } - }); - - this.add(cancel, { - row : r, - column : 1 - }); - } - } -}); diff --git a/qx08/source/class/tr/ui/CopyBuffer.js b/qx08/source/class/tr/ui/CopyBuffer.js deleted file mode 100644 index a48fee2..0000000 --- a/qx08/source/class/tr/ui/CopyBuffer.js +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************ - Copyright: 2008, OETIKER+PARTNER AG - License: GPL - Authors: Tobias Oetiker - $Id: $ -* ************************************************************************ */ - -/** - * Place an instance of this widget into the application root. It will remain - * invisible. I will listen on the 'copy' bus for data to get ready for copying with - * [ctrl]+[c] - */ -qx.Class.define('tr.ui.CopyBuffer', { - extend : qx.ui.form.TextArea, - - construct : function() { - this.base(arguments); - - this.set({ - width : 0, - height : 0, - allowGrowX : false, - allowGrowY : false, - decorator : null - }); - - qx.event.message.Bus.subscribe('copy', this.__copy, this); - }, - - members : { - /** - * TODOC - * - * @type member - * @param m {var} TODOC - * @return {void} - */ - __copy : function(m) { - var data = m.getData(); - this.info('set: ' + data); - this.setValue(data); - this.selectAll(); - } - } -}); \ No newline at end of file diff --git a/qx08/source/class/tr/ui/Footer.js b/qx08/source/class/tr/ui/Footer.js deleted file mode 100644 index 4e2a2d2..0000000 --- a/qx08/source/class/tr/ui/Footer.js +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************ -#module(Tr) -************************************************************************ */ - -/** - * a widget showing the footer - */ -qx.Class.define('tr.ui.Footer', { - extend : qx.ui.container.Composite, - - - - - /* - ***************************************************************************** - CONSTRUCTOR - ***************************************************************************** - */ - - construct : function(text, url) { - this.base(arguments, new qx.ui.layout.HBox().set({ alignX : 'right' })); - this.add(new tr.ui.Link(text, url, '#888', '10px sans-serif')); - } -}); \ No newline at end of file diff --git a/qx08/source/class/tr/ui/Link.js b/qx08/source/class/tr/ui/Link.js deleted file mode 100644 index d7bd28b..0000000 --- a/qx08/source/class/tr/ui/Link.js +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************ -#module(Tr) -************************************************************************ */ - -/** - * A label with the ability to link out. Based on Label. - */ -qx.Class.define('tr.ui.Link', { - extend : qx.ui.basic.Label, - - - - - /* - ***************************************************************************** - CONSTRUCTOR - ***************************************************************************** - */ - - /** - * @param text {String} Initial label - * @param url {String} Where to link to - * @param color {String} Hex Color for the text - * @param font {String} Font from string representation - */ - construct : function(text, url, color, font) { - this.base(arguments, text); - - if (color) { - this.setTextColor(color); - } - - if (font) { - this.setFont(qx.bom.Font.fromString(font)); - } - - this.set({ - cursor : 'pointer', - opacity : 0.9 - }); - - this.addListener('click', function(e) { - window.open(url, '__new'); - }); - - this.addListener('mouseover', function(e) { - this.setOpacity(1); - }, this); - - this.addListener('mouseout', function(e) { - this.setOpacity(0.7); - }, this); - } -}); \ No newline at end of file diff --git a/qx08/source/class/tr/ui/TraceTable.js b/qx08/source/class/tr/ui/TraceTable.js deleted file mode 100644 index 42ed8cc..0000000 --- a/qx08/source/class/tr/ui/TraceTable.js +++ /dev/null @@ -1,314 +0,0 @@ -/* ************************************************************************ - Copyright: 2008, OETIKER+PARTNER AG - License: GPL - Authors: Tobias Oetiker - $Id: $ -* ************************************************************************ */ - -/** - * a widget showing the Tr target tree - */ -qx.Class.define('tr.ui.TraceTable', { - extend : qx.ui.table.Table, - - construct : function() { - var tableModel = new qx.ui.table.model.Simple(); - this.__tableModel = tableModel; - - tableModel.setColumns([ this.tr("Hop"), this.tr("Host"), this.tr("Ip"), this.tr("Loss [%]"), this.tr("Sent"), this.tr("Last [ms]"), this.tr("Avg [ms]"), this.tr("Best [ms]"), this.tr("Worst [ms]"), this.tr("StDev [ms]") ]); - - var custom = { - tableColumnModel : function(obj) { - return new qx.ui.table.columnmodel.Resize(obj); - } - }; - - this.base(arguments, tableModel, custom); - - this.set({ - decorator : 'main', - showCellFocusIndicator : false, - statusBarVisible : false - }); - - var tcm = this.getTableColumnModel(); - this.__tcm = tcm; - - tcm.setDataCellRenderer(0, new tr.ui.Cellrenderer(1)); - tcm.setDataCellRenderer(3, new tr.ui.Cellrenderer(0, ' %')); - tcm.setDataCellRenderer(4, new tr.ui.Cellrenderer(0)); - - var render_ms = new tr.ui.Cellrenderer(1); - - for (var i=5; i<10; i++) { - tcm.setDataCellRenderer(i, render_ms); - } - - // Obtain the behavior object to manipulate - var resizeBehavior = tcm.getBehavior(); - - // This uses the set() method to set all attriutes at once; uses flex - resizeBehavior.set(0, { width : '2*' }); - resizeBehavior.set(1, { width : '9*' }); - resizeBehavior.set(2, { width : '5*' }); - - for (var i=3; i<10; i++) { - resizeBehavior.set(i, { width : '3*' }); - } - - }, - - members : { - __handle : null, - __data : null, - __delay : null, - __tableModel : null, - __tcm : null, - - - /** - * TODOC - * - * @type member - * @return {var} TODOC - */ - __make_empty_row : function() { - return ([ undefined, undefined, undefined, 0, 0, undefined, undefined, undefined, undefined, undefined, 0, 0, 0 ]); - }, - - - /** - * TODOC - * - * @type member - * @return {void} - */ - __stop_table : function() { - var tableModel = this.__tableModel; - - for (var i=0; i<10; i++) { - tableModel.setColumnSortable(i, true); - } - - qx.event.message.Bus.dispatch('tr.status', 'stopped'); - this.__handle = undefined; - }, - - - /** - * TODOC - * - * @type member - * @param retval {var} TODOC - * @param exc {Exception} TODOC - * @param id {var} TODOC - * @return {void} - */ - __fill_table : function(retval, exc, id) { - var f_host = 1; - var f_ip = 2; - var f_loss = 3; - var f_snt = 4; - var f_last = 5; - var f_avg = 6; - var f_best = 7; - var f_worst = 8; - var f_stdev = 9; - var f_cnt = 10; - var f_sum = 11; - var f_sqsum = 12; - var that = this; - - if (exc == null) { - if (this.__handle == undefined) { - qx.event.message.Bus.dispatch('tr.status', 'started'); - } - - this.__handle = retval['handle']; - var tableModel = this.__tableModel; - var lines = retval['output'].length; - var data = this.__data; - var sleep = 0; - - for (var i=0; i hop) { - break; - } - - if (Math.floor(data[ii][0]) == hop) { - if (ip == undefined) { - break; - } - - if (ip == data[ii][2]) { - break; - } - } - - ii++; - } - - if (ii == max || Math.floor(data[ii][0]) > hop) { - if (ii > 0 && Math.floor(data[ii - 1][0]) == hop) { - hop = data[ii - 1][0] + 0.1; - } - - data.splice(ii, 0, this.__make_empty_row()); - data[ii][0] = hop; - } - - var drow = data[ii]; - - if (drow[f_host] == undefined && host != undefined) { - drow[f_host] = host; - } - - if (drow[f_ip] == undefined && ip != undefined) { - drow[f_ip] = ip; - } - - drow[f_snt]++; - drow[f_last] = value; - - if (value != undefined) { - var best = drow[f_best]; - - if (best == undefined || best > value) { - drow[f_best] = value; - } - - var worst = drow[f_worst]; - - if (worst == undefined || worst < value) { - drow[f_worst] = value; - } - - drow[f_sum] += value; - var sum = drow[f_sum]; - drow[f_cnt]++; - var cnt = drow[f_cnt]; - var sqsum = drow[f_sqsum] + value * value; - drow[f_sqsum] = sqsum; - drow[f_avg] = drow[f_sum] / drow[f_cnt]; - drow[f_stdev] = Math.sqrt((cnt * sqsum - sum * sum) / (cnt * (cnt - 1))); - } - - drow[f_loss] = ((drow[f_snt] - drow[f_cnt]) / drow[f_snt]) * 100; - } - - tableModel.setData(data); - - if (retval['again']) { - var next_round = function() { - tr.Server.getInstance().callAsync(function(ret, exc, id) { - that.__fill_table(ret, exc, id); - }, 'run_tr', { - handle : retval['handle'], - point : retval['point'] - }); - }; - - qx.event.Timer.once(next_round, this, sleep * 1000); - } - else { - this.__stop_table(); - } - } - else { - this.__stop_table(); - } - }, - - - /** - * TODOC - * - * @type member - * @param data {var} TODOC - * @param exc {Exception} TODOC - * @param id {var} TODOC - * @return {void} - */ - __stop_handler : function(data, exc, id) { - if (exc == null) { - qx.event.message.Bus.dispatch('tr.status', 'stopped'); - } else { - this.error(exc); - } - }, - - subscribe: function(handle){ - qx.event.message.Bus.subscribe(handle+'::data', this.__handle_tr, this); - }, - - - /** - * TODOC - * - * @type member - * @param m {var} TODOC - * @return {void} - */ - __handle_tr : function(m) { - var that = this; - var cmd = m.getData(); - - switch(cmd['action']) - { - case 'stop': - qx.event.message.Bus.dispatch('tr.status', 'stopping'); - tr.Server.getInstance().callAsync(function(ret, exc, id) { - that.__stop_handler(ret, exc, id); - }, 'stop_tr', this.__handle); - - break; - - case 'go': - this.__data = []; - this.__tableModel.setData(this.__data); - this.__delay = cmd['delay']; - - for (var i=0; i<10; i++) { - this.__tableModel.setColumnSortable(i, false); - } - - qx.event.message.Bus.dispatch('tr.status', 'starting'); - tr.Server.getInstance().callAsync(function(ret, exc, id) { - that.__fill_table(ret, exc, id); - }, 'run_tr', { - host : cmd['host'], - rounds : cmd['rounds'], - delay : cmd['delay'] - }); - - break; - - default: - this.error('Unknown Command ' + cmd['action']); - } - } - } -}); -- cgit v1.2.3-24-g4f1b