Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilterTools.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilterTools.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilterTools.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/EnhancedFilterTools.js Mon May 2 15:57:52 2016 @@ -28,333 +28,334 @@ define(["dojo/_base/declare", "qpid/common/grid/RowNumberLimitDialog", "qpid/common/grid/ColumnDefDialog", "qpid/common/grid/FilterSummary"], - function (declare, event, domConstruct, locale, Button, ToggleButton, RowNumberLimitDialog, ColumnDefDialog, FilterSummary) - { - - var _stopEvent = function (evt) - { - try - { - if (evt && evt.preventDefault) - { - event.stop(evt); - } - } - catch (e) - { - } - }; - - return declare("qpid.common.grid.EnhancedFilterTools", null, { - - grid: null, - filterBar: null, - filterStatusTip: null, - clearFilterDialog: null, - filterDefDialog: null, - - columnDefDialog: null, - columnDefButton: null, - filterDefButton: null, - clearFilterButton: null, - filterSummary: null, - setRowNumberLimitButton: null, - setRowNumberLimitDialog: null, - refreshButton: null, - autoRefreshButton: null, - - constructor: function (params) - { - this.inherited(arguments); - - this.userPreferences = params.userPreferences; - this.filterBar = params.toolbar; - this.grid = params.grid; - this.filterStatusTip = params.filterStatusTip; - this.clearFilterDialog = params.clearFilterDialog; - this.filterDefDialog = params.filterDefDialog; - this.ruleCountToConfirmClearFilter = params.ruleCountToConfirmClearFilter; - this.displayLastUpdateTime = - params.hasOwnProperty("displayLastUpdateTime") ? params.displayLastUpdateTime : true; - - this._addRefreshButtons(); - this._addRowLimitButton(params.defaulGridRowLimit); - this._addColumnsButton(); - - if (!params.disableFiltering) - { - this._addFilteringTools(params.nls); - } - }, - - toggleClearFilterBtn: function (clearFlag) - { - var filterLayer = this.grid.layer("filter"); - var filterSet = filterLayer && filterLayer.filterDef && filterLayer.filterDef(); - this.clearFilterButton.set("disabled", !filterSet); - }, - - destroy: function () - { - this.inherited(arguments); - - if (this.columnDefDialog) - { - this.columnDefDialog.destroy(); - this.columnDefDialog = null; - } - if (this.columnDefButton) - { - this.columnDefButton.destroy(); - this.columnDefButton = null; - } - if (this.filterDefButton) - { - this.filterDefButton.destroy(); - this.filterDefButton = null; - } - if (this.clearFilterButton) - { - this.clearFilterButton.destroy(); - this.clearFilterButton = null; - } - if (this.filterSummary) - { - this.filterSummary.destroy(); - this.filterSummary = null; - } - if (this.setRowNumberLimitButton) - { - this.setRowNumberLimitButton.destroy(); - this.setRowNumberLimitButton = null; - } - if (this.setRowNumberLimitDialog) - { - this.setRowNumberLimitDialog.destroy(); - this.setRowNumberLimitDialog = null; - } - if (this.refreshButton) - { - this.refreshButton.destroy(); - this.refreshButton = null; - } - if (this.autoRefreshButton) - { - this.autoRefreshButton.destroy(); - this.autoRefreshButton = null; - } - - this.grid = null; - this.filterBar = null; - this.filterStatusTip = null; - this.clearFilterDialog = null; - this.filterDefDialog = null; - }, - - _addRefreshButtons: function () - { - var self = this; - this.refreshButton = new dijit.form.Button({ - label: "Refresh", - type: "button", - iconClass: "gridRefreshIcon", - title: "Manual Refresh" - }); - - this.autoRefreshButton = new dijit.form.ToggleButton({ - label: "Auto Refresh", - type: "button", - iconClass: "gridAutoRefreshIcon", - title: "Auto Refresh" - }); - - this.autoRefreshButton.on("change", function (value) - { - self.grid.updater.updatable = value; - self.refreshButton.set("disabled", value); - }); - - this.refreshButton.on("click", function (value) - { - self.grid.updater.performUpdate(); - }); - - this.filterBar.addChild(this.autoRefreshButton); - this.filterBar.addChild(this.refreshButton); - - if (this.displayLastUpdateTime) - { - var updateStatusPanel = domConstruct.create("div"); - var updateTimeLabel = domConstruct.create("span", - { - innerHTML: "Update time: ", - "class": "formLabel-labelCell", - "style": "padding-right: 5px;padding-left: 5px" - }, - updateStatusPanel); - var updateTimeLabelPreferredTZ = domConstruct.create("span", - { - innerHTML: "Preferred timezone:", - "style": "padding-right: 5px" - }, - updateStatusPanel); - var updateTimePreferredTZ = domConstruct.create("span", - {"style": "padding-right: 5px"}, - updateStatusPanel); - var updateTimeLabelBrowserTZ = domConstruct.create("span", - { - innerHTML: "Browser timezone:", - "style": "padding-right: 5px" - }, - updateStatusPanel); - var updateTimeBrowserTZ = domConstruct.create("span", - {"style": "padding-right: 5px"}, - updateStatusPanel); - - var userPreferences = this.userPreferences; - var lastUpdateTimeUpdater = function (data) - { - var userTimeZone = userPreferences.timeZone; - var displayStyle = userTimeZone ? "inline" : "none"; - updateTimeLabelPreferredTZ.style.display = displayStyle; - updateTimePreferredTZ.style.display = displayStyle; - var formatOptions = { - selector: "time", - timePattern: "HH:mm:ss.SSS", - appendTimeZone: true, - addOffset: true - }; - var updateTime = new Date(); - updateTimePreferredTZ.innerHTML = - userPreferences.formatDateTime(updateTime.getTime(), formatOptions); - updateTimeBrowserTZ.innerHTML = locale.format(updateTime, formatOptions); - }; - - if (self.grid.updater.store) - { - // data have been already provided/or fetched - // set last update time to current time - lastUpdateTimeUpdater(); - } - - self.grid.updater.addOnUpdate(lastUpdateTimeUpdater); - domConstruct.place(updateStatusPanel, this.grid.viewsHeaderNode, "before"); - } - }, - - _addRowLimitButton: function (defaulGridRowLimit) - { - var self = this; - this.setRowNumberLimitButton = new dijit.form.Button({ - label: "Set Row Limit", - type: "button", - iconClass: "rowNumberLimitIcon", - title: "Set Row Number Limit" - }); - this.setRowNumberLimitButton.set("title", - "Set Row Number Limit (Current: " + defaulGridRowLimit + ")"); - - this.setRowNumberLimitDialog = new RowNumberLimitDialog(this.grid.domNode, function (newLimit) - { - if (newLimit > 0 && self.grid.updater.appendLimit != newLimit) - { - self.grid.updater.appendLimit = newLimit; - self.grid.updater.performRefresh([]); - self.setRowNumberLimitButton.set("title", - "Set Row Number Limit (Current: " + newLimit + ")"); - } - }); - - this.setRowNumberLimitButton.on("click", function (evt) - { - self.setRowNumberLimitDialog.showDialog(self.grid.updater.appendLimit); - }); - - this.filterBar.addChild(this.setRowNumberLimitButton); - }, - - _addColumnsButton: function () - { - var self = this; - this.columnDefDialog = new ColumnDefDialog({grid: this.grid}); - - this.columnDefButton = new dijit.form.Button({ - label: "Display Columns", - type: "button", - iconClass: "columnDefDialogButtonIcon", - title: "Show/Hide Columns" - }); - - this.columnDefButton.on("click", function (e) - { - _stopEvent(e); - self.columnDefDialog.showDialog(); - }); - - this.filterBar.addChild(this.columnDefButton); - }, - - _addFilteringTools: function (nls) - { - var self = this; - - this.filterDefButton = new dijit.form.Button({ - "class": "dojoxGridFBarBtn", - label: "Set Filter", - iconClass: "dojoxGridFBarDefFilterBtnIcon", - showLabel: "true", - title: "Define filter" - }); - - this.clearFilterButton = new dijit.form.Button({ - "class": "dojoxGridFBarBtn", - label: "Clear filter", - iconClass: "dojoxGridFBarClearFilterButtontnIcon", - showLabel: "true", - title: "Clear filter", - disabled: true - }); - - this.filterDefButton.on("click", function (e) - { - _stopEvent(e); - - // a bit of a hack to force dialog to rebuild the criteria controls in order to get rid from empty rule controls - self.filterDefDialog._criteriasChanged = true; - self.filterDefDialog.showDialog(); - }); - - this.clearFilterButton.on("click", function (e) - { - _stopEvent(e); - if (self.ruleCountToConfirmClearFilter && self.filterDefDialog.getCriteria() - >= self.ruleCountToConfirmClearFilter) - { - self.clearFilterDialog.show(); - } - else - { - self.grid.layer("filter").filterDef(null); - self.toggleClearFilterBtn(true) - } - }); - - this.filterSummary = new FilterSummary({ - grid: this.grid, - filterStatusTip: this.filterStatusTip, - nls: nls - }); - - this.filterBar.addChild(this.filterDefButton); - this.filterBar.addChild(this.clearFilterButton); - - this.filterBar.addChild(new dijit.ToolbarSeparator()); - this.filterBar.addChild(this.filterSummary, "last"); - this.filterBar.getColumnIdx = function (coordX) - { - return self.filterSummary._getColumnIdx(coordX); - }; - - } - }); - }); \ No newline at end of file + function (declare, + event, + domConstruct, + locale, + Button, + ToggleButton, + RowNumberLimitDialog, + ColumnDefDialog, + FilterSummary) + { + + var _stopEvent = function (evt) + { + try + { + if (evt && evt.preventDefault) + { + event.stop(evt); + } + } + catch (e) + { + } + }; + + return declare("qpid.common.grid.EnhancedFilterTools", null, { + + grid: null, + filterBar: null, + filterStatusTip: null, + clearFilterDialog: null, + filterDefDialog: null, + + columnDefDialog: null, + columnDefButton: null, + filterDefButton: null, + clearFilterButton: null, + filterSummary: null, + setRowNumberLimitButton: null, + setRowNumberLimitDialog: null, + refreshButton: null, + autoRefreshButton: null, + + constructor: function (params) + { + this.inherited(arguments); + + this.userPreferences = params.userPreferences; + this.filterBar = params.toolbar; + this.grid = params.grid; + this.filterStatusTip = params.filterStatusTip; + this.clearFilterDialog = params.clearFilterDialog; + this.filterDefDialog = params.filterDefDialog; + this.ruleCountToConfirmClearFilter = params.ruleCountToConfirmClearFilter; + this.displayLastUpdateTime = + params.hasOwnProperty("displayLastUpdateTime") ? params.displayLastUpdateTime : true; + + this._addRefreshButtons(); + this._addRowLimitButton(params.defaulGridRowLimit); + this._addColumnsButton(); + + if (!params.disableFiltering) + { + this._addFilteringTools(params.nls); + } + }, + + toggleClearFilterBtn: function (clearFlag) + { + var filterLayer = this.grid.layer("filter"); + var filterSet = filterLayer && filterLayer.filterDef && filterLayer.filterDef(); + this.clearFilterButton.set("disabled", !filterSet); + }, + + destroy: function () + { + this.inherited(arguments); + + if (this.columnDefDialog) + { + this.columnDefDialog.destroy(); + this.columnDefDialog = null; + } + if (this.columnDefButton) + { + this.columnDefButton.destroy(); + this.columnDefButton = null; + } + if (this.filterDefButton) + { + this.filterDefButton.destroy(); + this.filterDefButton = null; + } + if (this.clearFilterButton) + { + this.clearFilterButton.destroy(); + this.clearFilterButton = null; + } + if (this.filterSummary) + { + this.filterSummary.destroy(); + this.filterSummary = null; + } + if (this.setRowNumberLimitButton) + { + this.setRowNumberLimitButton.destroy(); + this.setRowNumberLimitButton = null; + } + if (this.setRowNumberLimitDialog) + { + this.setRowNumberLimitDialog.destroy(); + this.setRowNumberLimitDialog = null; + } + if (this.refreshButton) + { + this.refreshButton.destroy(); + this.refreshButton = null; + } + if (this.autoRefreshButton) + { + this.autoRefreshButton.destroy(); + this.autoRefreshButton = null; + } + + this.grid = null; + this.filterBar = null; + this.filterStatusTip = null; + this.clearFilterDialog = null; + this.filterDefDialog = null; + }, + + _addRefreshButtons: function () + { + var self = this; + this.refreshButton = new dijit.form.Button({ + label: "Refresh", + type: "button", + iconClass: "gridRefreshIcon", + title: "Manual Refresh" + }); + + this.autoRefreshButton = new dijit.form.ToggleButton({ + label: "Auto Refresh", + type: "button", + iconClass: "gridAutoRefreshIcon", + title: "Auto Refresh" + }); + + this.autoRefreshButton.on("change", function (value) + { + self.grid.updater.updatable = value; + self.refreshButton.set("disabled", value); + }); + + this.refreshButton.on("click", function (value) + { + self.grid.updater.performUpdate(); + }); + + this.filterBar.addChild(this.autoRefreshButton); + this.filterBar.addChild(this.refreshButton); + + if (this.displayLastUpdateTime) + { + var updateStatusPanel = domConstruct.create("div"); + var updateTimeLabel = domConstruct.create("span", { + innerHTML: "Update time: ", + "class": "formLabel-labelCell", + "style": "padding-right: 5px;padding-left: 5px" + }, updateStatusPanel); + var updateTimeLabelPreferredTZ = domConstruct.create("span", { + innerHTML: "Preferred timezone:", + "style": "padding-right: 5px" + }, updateStatusPanel); + var updateTimePreferredTZ = domConstruct.create("span", + {"style": "padding-right: 5px"}, + updateStatusPanel); + var updateTimeLabelBrowserTZ = domConstruct.create("span", { + innerHTML: "Browser timezone:", + "style": "padding-right: 5px" + }, updateStatusPanel); + var updateTimeBrowserTZ = domConstruct.create("span", + {"style": "padding-right: 5px"}, + updateStatusPanel); + + var userPreferences = this.userPreferences; + var lastUpdateTimeUpdater = function (data) + { + var userTimeZone = userPreferences.timeZone; + var displayStyle = userTimeZone ? "inline" : "none"; + updateTimeLabelPreferredTZ.style.display = displayStyle; + updateTimePreferredTZ.style.display = displayStyle; + var formatOptions = { + selector: "time", + timePattern: "HH:mm:ss.SSS", + appendTimeZone: true, + addOffset: true + }; + var updateTime = new Date(); + updateTimePreferredTZ.innerHTML = + userPreferences.formatDateTime(updateTime.getTime(), formatOptions); + updateTimeBrowserTZ.innerHTML = locale.format(updateTime, formatOptions); + }; + + if (self.grid.updater.store) + { + // data have been already provided/or fetched + // set last update time to current time + lastUpdateTimeUpdater(); + } + + self.grid.updater.addOnUpdate(lastUpdateTimeUpdater); + domConstruct.place(updateStatusPanel, this.grid.viewsHeaderNode, "before"); + } + }, + + _addRowLimitButton: function (defaulGridRowLimit) + { + var self = this; + this.setRowNumberLimitButton = new dijit.form.Button({ + label: "Set Row Limit", + type: "button", + iconClass: "rowNumberLimitIcon", + title: "Set Row Number Limit" + }); + this.setRowNumberLimitButton.set("title", "Set Row Number Limit (Current: " + defaulGridRowLimit + ")"); + + this.setRowNumberLimitDialog = new RowNumberLimitDialog(this.grid.domNode, function (newLimit) + { + if (newLimit > 0 && self.grid.updater.appendLimit != newLimit) + { + self.grid.updater.appendLimit = newLimit; + self.grid.updater.performRefresh([]); + self.setRowNumberLimitButton.set("title", "Set Row Number Limit (Current: " + newLimit + ")"); + } + }); + + this.setRowNumberLimitButton.on("click", function (evt) + { + self.setRowNumberLimitDialog.showDialog(self.grid.updater.appendLimit); + }); + + this.filterBar.addChild(this.setRowNumberLimitButton); + }, + + _addColumnsButton: function () + { + var self = this; + this.columnDefDialog = new ColumnDefDialog({grid: this.grid}); + + this.columnDefButton = new dijit.form.Button({ + label: "Display Columns", + type: "button", + iconClass: "columnDefDialogButtonIcon", + title: "Show/Hide Columns" + }); + + this.columnDefButton.on("click", function (e) + { + _stopEvent(e); + self.columnDefDialog.showDialog(); + }); + + this.filterBar.addChild(this.columnDefButton); + }, + + _addFilteringTools: function (nls) + { + var self = this; + + this.filterDefButton = new dijit.form.Button({ + "class": "dojoxGridFBarBtn", + label: "Set Filter", + iconClass: "dojoxGridFBarDefFilterBtnIcon", + showLabel: "true", + title: "Define filter" + }); + + this.clearFilterButton = new dijit.form.Button({ + "class": "dojoxGridFBarBtn", + label: "Clear filter", + iconClass: "dojoxGridFBarClearFilterButtontnIcon", + showLabel: "true", + title: "Clear filter", + disabled: true + }); + + this.filterDefButton.on("click", function (e) + { + _stopEvent(e); + + // a bit of a hack to force dialog to rebuild the criteria controls in order to get rid from empty rule controls + self.filterDefDialog._criteriasChanged = true; + self.filterDefDialog.showDialog(); + }); + + this.clearFilterButton.on("click", function (e) + { + _stopEvent(e); + if (self.ruleCountToConfirmClearFilter && self.filterDefDialog.getCriteria() + >= self.ruleCountToConfirmClearFilter) + { + self.clearFilterDialog.show(); + } + else + { + self.grid.layer("filter") + .filterDef(null); + self.toggleClearFilterBtn(true) + } + }); + + this.filterSummary = new FilterSummary({ + grid: this.grid, + filterStatusTip: this.filterStatusTip, + nls: nls + }); + + this.filterBar.addChild(this.filterDefButton); + this.filterBar.addChild(this.clearFilterButton); + + this.filterBar.addChild(new dijit.ToolbarSeparator()); + this.filterBar.addChild(this.filterSummary, "last"); + this.filterBar.getColumnIdx = function (coordX) + { + return self.filterSummary._getColumnIdx(coordX); + }; + + } + }); + }); \ No newline at end of file
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/FilterSummary.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/FilterSummary.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/FilterSummary.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/FilterSummary.js Mon May 2 15:57:52 2016 @@ -27,178 +27,175 @@ define(["dojo/_base/declare", "dojo/string", "dojo/on", "dijit/_WidgetBase"], function (declare, lang, html, query, domConstruct, string, on, _WidgetBase) - { +{ - return declare("qpid.common.grid.FilterSummary", [_WidgetBase], { + return declare("qpid.common.grid.FilterSummary", [_WidgetBase], { - domNode: null, - itemName: null, - filterStatusTip: null, - grid: null, - _handle_statusTooltip: null, - _timeout_statusTooltip: 300, - _nls: null, - - constructor: function (params) - { - this.inherited(arguments); - this.itemName = params.itemsName; - this.initialize(params.filterStatusTip, params.grid); - this._nls = params.nls; - }, - - buildRendering: function () - { - this.inherited(arguments); - var itemsName = this.itemName || this._nls["defaultItemsName"]; - var message = string.substitute(this._nls["filterBarMsgNoFilterTemplate"], [0, itemsName]); - this.domNode = domConstruct.create("span", - { - innerHTML: message, - "class": "dijit dijitReset dijitInline dijitButtonInline", - role: "presentation" - }); - }, - - postCreate: function () - { - this.inherited(arguments); - on(this.domNode, "mouseenter", lang.hitch(this, this._onMouseEnter)); - on(this.domNode, "mouseleave", lang.hitch(this, this._onMouseLeave)); - on(this.domNode, "mousemove", lang.hitch(this, this._onMouseMove)); - }, - - destroy: function () - { - this.inherited(arguments); - this.itemName = null; - this.filterStatusTip = null; - this.grid = null; - this._handle_statusTooltip = null; - this._filteredClass = null; - this._nls = null; - }, - - initialize: function (filterStatusTip, grid) - { - this.filterStatusTip = filterStatusTip; - this.grid = grid; - if (this.grid) - { - var filterLayer = grid.layer("filter"); - this.connect(filterLayer, "onFiltered", this.onFiltered); - } - }, - - onFiltered: function (filteredSize, originSize) - { - try - { - var itemsName = this.itemName - || this._nls["defaultItemsName"], msg = "", g = this.grid, filterLayer = g.layer( - "filter"); - if (filterLayer.filterDef()) - { - msg = string.substitute(this._nls["filterBarMsgHasFilterTemplate"], - [filteredSize, originSize, itemsName]); - } - else - { - msg = string.substitute(this._nls["filterBarMsgNoFilterTemplate"], [originSize, itemsName]); - } - this.domNode.innerHTML = msg; - } - catch (e) - { - // swallow and log exception - // otherwise grid rendering is screwed - console.error(e); - } - }, - - _getColumnIdx: function (coordX) - { - var headers = query("[role='columnheader']", this.grid.viewsHeaderNode); - var idx = -1; - for (var i = headers.length - 1; i >= 0; --i) - { - var coord = html.position(headers[i]); - if (coordX >= coord.x && coordX < coord.x + coord.w) - { - idx = i; - break; - } - } - if (idx >= 0 && this.grid.layout.cells[idx].filterable !== false) - { - return idx; - } - else - { - return -1; - } - }, - - _setStatusTipTimeout: function () - { - this._clearStatusTipTimeout(); - this._handle_statusTooltip = - setTimeout(lang.hitch(this, this._showStatusTooltip), this._timeout_statusTooltip); - }, - - _clearStatusTipTimeout: function () - { - if (this._handle_statusTooltip) - { - clearTimeout(this._handle_statusTooltip); - } - this._handle_statusTooltip = null; - }, - - _showStatusTooltip: function () - { - this._handle_statusTooltip = null; - if (this.filterStatusTip) - { - this.filterStatusTip.showDialog(this._tippos.x, - this._tippos.y, - this._getColumnIdx(this._tippos.x)); - } - }, - - _updateTipPosition: function (evt) - { - this._tippos = { - x: evt.pageX, - y: evt.pageY - }; - }, - - _onMouseEnter: function (e) - { - this._updateTipPosition(e); - if (this.filterStatusTip) - { - this._setStatusTipTimeout(); - } - }, - - _onMouseMove: function (e) - { - if (this.filterStatusTip) - { - this._setStatusTipTimeout(); - if (this._handle_statusTooltip) - { - this._updateTipPosition(e); - } - } - }, - - _onMouseLeave: function (e) - { - this._clearStatusTipTimeout(); - } - }); + domNode: null, + itemName: null, + filterStatusTip: null, + grid: null, + _handle_statusTooltip: null, + _timeout_statusTooltip: 300, + _nls: null, + + constructor: function (params) + { + this.inherited(arguments); + this.itemName = params.itemsName; + this.initialize(params.filterStatusTip, params.grid); + this._nls = params.nls; + }, + + buildRendering: function () + { + this.inherited(arguments); + var itemsName = this.itemName || this._nls["defaultItemsName"]; + var message = string.substitute(this._nls["filterBarMsgNoFilterTemplate"], [0, itemsName]); + this.domNode = domConstruct.create("span", { + innerHTML: message, + "class": "dijit dijitReset dijitInline dijitButtonInline", + role: "presentation" + }); + }, + + postCreate: function () + { + this.inherited(arguments); + on(this.domNode, "mouseenter", lang.hitch(this, this._onMouseEnter)); + on(this.domNode, "mouseleave", lang.hitch(this, this._onMouseLeave)); + on(this.domNode, "mousemove", lang.hitch(this, this._onMouseMove)); + }, + + destroy: function () + { + this.inherited(arguments); + this.itemName = null; + this.filterStatusTip = null; + this.grid = null; + this._handle_statusTooltip = null; + this._filteredClass = null; + this._nls = null; + }, + + initialize: function (filterStatusTip, grid) + { + this.filterStatusTip = filterStatusTip; + this.grid = grid; + if (this.grid) + { + var filterLayer = grid.layer("filter"); + this.connect(filterLayer, "onFiltered", this.onFiltered); + } + }, + + onFiltered: function (filteredSize, originSize) + { + try + { + var itemsName = this.itemName + || this._nls["defaultItemsName"], msg = "", g = this.grid, filterLayer = g.layer( + "filter"); + if (filterLayer.filterDef()) + { + msg = string.substitute(this._nls["filterBarMsgHasFilterTemplate"], + [filteredSize, originSize, itemsName]); + } + else + { + msg = string.substitute(this._nls["filterBarMsgNoFilterTemplate"], [originSize, itemsName]); + } + this.domNode.innerHTML = msg; + } + catch (e) + { + // swallow and log exception + // otherwise grid rendering is screwed + console.error(e); + } + }, + + _getColumnIdx: function (coordX) + { + var headers = query("[role='columnheader']", this.grid.viewsHeaderNode); + var idx = -1; + for (var i = headers.length - 1; i >= 0; --i) + { + var coord = html.position(headers[i]); + if (coordX >= coord.x && coordX < coord.x + coord.w) + { + idx = i; + break; + } + } + if (idx >= 0 && this.grid.layout.cells[idx].filterable !== false) + { + return idx; + } + else + { + return -1; + } + }, + + _setStatusTipTimeout: function () + { + this._clearStatusTipTimeout(); + this._handle_statusTooltip = + setTimeout(lang.hitch(this, this._showStatusTooltip), this._timeout_statusTooltip); + }, + + _clearStatusTipTimeout: function () + { + if (this._handle_statusTooltip) + { + clearTimeout(this._handle_statusTooltip); + } + this._handle_statusTooltip = null; + }, + + _showStatusTooltip: function () + { + this._handle_statusTooltip = null; + if (this.filterStatusTip) + { + this.filterStatusTip.showDialog(this._tippos.x, this._tippos.y, this._getColumnIdx(this._tippos.x)); + } + }, + + _updateTipPosition: function (evt) + { + this._tippos = { + x: evt.pageX, + y: evt.pageY + }; + }, + + _onMouseEnter: function (e) + { + this._updateTipPosition(e); + if (this.filterStatusTip) + { + this._setStatusTipTimeout(); + } + }, + + _onMouseMove: function (e) + { + if (this.filterStatusTip) + { + this._setStatusTipTimeout(); + if (this._handle_statusTooltip) + { + this._updateTipPosition(e); + } + } + }, + + _onMouseLeave: function (e) + { + this._clearStatusTipTimeout(); + } + }); - }); \ No newline at end of file +}); \ No newline at end of file Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/GridUpdater.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/GridUpdater.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/GridUpdater.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/GridUpdater.js Mon May 2 15:57:52 2016 @@ -32,288 +32,290 @@ define(["dojo/_base/xhr", "qpid/common/grid/EnhancedFilter", "dojox/grid/enhanced/plugins/NestedSorting", "dojo/domReady!"], - function (xhr, parser, array, lang, properties, updater, UpdatableStore, util, Memory, ObjectStore) - { + function (xhr, parser, array, lang, properties, updater, UpdatableStore, util, Memory, ObjectStore) + { - function GridUpdater(args, store) - { - this.updatable = args.hasOwnProperty("updatable") ? args.updatable : true; - this.serviceUrl = args.serviceUrl; - this.userPreferences = args.userPreferences; - this.onUpdate = []; - if (args.onUpdate) - { - this.onUpdate.push(args.onUpdate); - } - this.dataTransformer = args.dataTransformer; - - this.appendData = args.append; - this.appendLimit = args.appendLimit; - this.initialData = args.data; - this.initializeStore(store); - }; - - GridUpdater.prototype.buildUpdatableGridArguments = function (args) - { - var filterPluginFound = args && args.hasOwnProperty("plugins") && args.plugins.filter ? true : false; - - var gridProperties = { - autoHeight: true, - plugins: { - pagination: { - defaultPageSize: 25, - pageSizes: [10, 25, 50, 100], - description: true, - sizeSwitch: true, - pageStepper: true, - gotoButton: true, - maxPageStep: 4, - position: "bottom" - }, - enhancedFilter: { - disableFiltering: filterPluginFound, - userPreferences: this.userPreferences - } - } - }; - - if (args) - { - for (var argProperty in args) - { - if (args.hasOwnProperty(argProperty)) - { - if (argProperty == "plugins") - { - var argPlugins = args[argProperty]; - for (var argPlugin in argPlugins) - { - if (argPlugins.hasOwnProperty(argPlugin)) - { - var argPluginProperties = argPlugins[argPlugin]; - if (argPluginProperties && gridProperties.plugins.hasOwnProperty(argPlugin)) - { - var gridPlugin = gridProperties.plugins[argPlugin]; - for (var pluginProperty in argPluginProperties) - { - if (argPluginProperties.hasOwnProperty(pluginProperty)) - { - gridPlugin[pluginProperty] = argPluginProperties[pluginProperty]; - } - } - } - else - { - gridProperties.plugins[argPlugin] = argPlugins[argPlugin]; - } - } - } - } - else - { - gridProperties[argProperty] = args[argProperty]; - } - } - } - } - - gridProperties.updater = this; - gridProperties.store = this.dataStore; - - return gridProperties; - }; - - GridUpdater.prototype.initializeStore = function (store) - { - var self = this; - - function processData(data) - { - if (self.dataTransformer) - { - data = self.dataTransformer(data); - } - var dataSet = false; - if (!store) - { - store = new ObjectStore({ - objectStore: new Memory({ - data: data, - idProperty: "id" - }) - }); - dataSet = true; - } - self.dataStore = store - self.store = store; - if (store instanceof ObjectStore) - { - if (store.objectStore instanceof Memory) - { - self.memoryStore = store.objectStore; - } - self.store = store.objectStore - } - - if (data) - { - if ((dataSet || self.updateOrAppend(data)) && self.onUpdate.length > 0) - { - self.fireUpdate(data); - } - } - }; - - if (this.serviceUrl) - { - var requestUrl = lang.isFunction(this.serviceUrl) ? this.serviceUrl() : this.serviceUrl; - xhr.get({ - url: requestUrl, - sync: true, - handleAs: "json" - }).then(processData, util.xhrErrorHandler); - } - else - { - processData(this.initialData); - } - }; - - GridUpdater.prototype.start = function (grid) - { - this.grid = grid; - if (this.serviceUrl) - { - updater.add(this); - } - }; - - GridUpdater.prototype.destroy = function () - { - updater.remove(this); - if (this.dataStore) - { - this.dataStore.close(); - this.dataStore = null; - } - this.store = null; - this.memoryStore = null; - this.grid = null; - this.onUpdate = null; - }; - - GridUpdater.prototype.updateOrAppend = function (data) - { - return this.appendData - ? UpdatableStore.prototype.append.call(this, data, this.appendLimit) - : UpdatableStore.prototype.update.call(this, data); - }; - - GridUpdater.prototype.refresh = function (data) - { - if (this.dataTransformer && data) - { - data = this.dataTransformer(data); - } - this.updating = true; - try - { - if (this.updateOrAppend(data)) - { - // EnhancedGrid with Filter plugin has "filter" layer. - // The filter expression needs to be re-applied after the data update - var filterLayer = this.grid.layer("filter"); - if (filterLayer && filterLayer.filterDef) - { - var currentFilter = filterLayer.filterDef(); - - if (currentFilter) - { - // re-apply filter in the filter layer - filterLayer.filterDef(currentFilter); - } - } - - // refresh grid to render updates - this.grid._refresh(); - } - } - finally - { - this.updating = false; - this.fireUpdate(data); - } - } - - GridUpdater.prototype.update = function () - { - if (this.updatable) - { - this.performUpdate(); - } - }; - - GridUpdater.prototype.performUpdate = function () - { - var self = this; - var requestUrl = lang.isFunction(this.serviceUrl) ? this.serviceUrl() : this.serviceUrl; - var requestArguments = { - url: requestUrl, - sync: properties.useSyncGet, - handleAs: "json" - }; - xhr.get(requestArguments).then(function (data) - { - self.refresh(data); - }); - }; - - GridUpdater.prototype.performRefresh = function (data) - { - if (!this.updating) - { - this.refresh(data); - } - }; - - GridUpdater.prototype.fireUpdate = function (data) - { - if (this.onUpdate.length > 0) - { - for (var i = 0; i < this.onUpdate.length; i++) - { - var onUpdate = this.onUpdate[i]; - try - { - onUpdate(data); - } - catch (e) - { - if (console && console.error) - { - console.error(e); - } - } - } - } - }; - - GridUpdater.prototype.addOnUpdate = function (obj) - { - this.onUpdate.push(obj); - }; - - GridUpdater.prototype.removeOnUpdate = function (obj) - { - for (var i = 0; i < this.onUpdate.length; i++) - { - if (this.onUpdate[i] === obj) - { - this.onUpdate.splice(i, 1); - return; - } - } - }; + function GridUpdater(args, store) + { + this.updatable = args.hasOwnProperty("updatable") ? args.updatable : true; + this.serviceUrl = args.serviceUrl; + this.userPreferences = args.userPreferences; + this.onUpdate = []; + if (args.onUpdate) + { + this.onUpdate.push(args.onUpdate); + } + this.dataTransformer = args.dataTransformer; + + this.appendData = args.append; + this.appendLimit = args.appendLimit; + this.initialData = args.data; + this.initializeStore(store); + }; + + GridUpdater.prototype.buildUpdatableGridArguments = function (args) + { + var filterPluginFound = args && args.hasOwnProperty("plugins") && args.plugins.filter ? true : false; + + var gridProperties = { + autoHeight: true, + plugins: { + pagination: { + defaultPageSize: 25, + pageSizes: [10, 25, 50, 100], + description: true, + sizeSwitch: true, + pageStepper: true, + gotoButton: true, + maxPageStep: 4, + position: "bottom" + }, + enhancedFilter: { + disableFiltering: filterPluginFound, + userPreferences: this.userPreferences + } + } + }; + + if (args) + { + for (var argProperty in args) + { + if (args.hasOwnProperty(argProperty)) + { + if (argProperty == "plugins") + { + var argPlugins = args[argProperty]; + for (var argPlugin in argPlugins) + { + if (argPlugins.hasOwnProperty(argPlugin)) + { + var argPluginProperties = argPlugins[argPlugin]; + if (argPluginProperties && gridProperties.plugins.hasOwnProperty(argPlugin)) + { + var gridPlugin = gridProperties.plugins[argPlugin]; + for (var pluginProperty in argPluginProperties) + { + if (argPluginProperties.hasOwnProperty(pluginProperty)) + { + gridPlugin[pluginProperty] = argPluginProperties[pluginProperty]; + } + } + } + else + { + gridProperties.plugins[argPlugin] = argPlugins[argPlugin]; + } + } + } + } + else + { + gridProperties[argProperty] = args[argProperty]; + } + } + } + } + + gridProperties.updater = this; + gridProperties.store = this.dataStore; + + return gridProperties; + }; + + GridUpdater.prototype.initializeStore = function (store) + { + var self = this; + + function processData(data) + { + if (self.dataTransformer) + { + data = self.dataTransformer(data); + } + var dataSet = false; + if (!store) + { + store = new ObjectStore({ + objectStore: new Memory({ + data: data, + idProperty: "id" + }) + }); + dataSet = true; + } + self.dataStore = store + self.store = store; + if (store instanceof ObjectStore) + { + if (store.objectStore instanceof Memory) + { + self.memoryStore = store.objectStore; + } + self.store = store.objectStore + } + + if (data) + { + if ((dataSet || self.updateOrAppend(data)) && self.onUpdate.length > 0) + { + self.fireUpdate(data); + } + } + }; + + if (this.serviceUrl) + { + var requestUrl = lang.isFunction(this.serviceUrl) ? this.serviceUrl() : this.serviceUrl; + xhr.get({ + url: requestUrl, + sync: true, + handleAs: "json" + }) + .then(processData, util.xhrErrorHandler); + } + else + { + processData(this.initialData); + } + }; + + GridUpdater.prototype.start = function (grid) + { + this.grid = grid; + if (this.serviceUrl) + { + updater.add(this); + } + }; + + GridUpdater.prototype.destroy = function () + { + updater.remove(this); + if (this.dataStore) + { + this.dataStore.close(); + this.dataStore = null; + } + this.store = null; + this.memoryStore = null; + this.grid = null; + this.onUpdate = null; + }; + + GridUpdater.prototype.updateOrAppend = function (data) + { + return this.appendData + ? UpdatableStore.prototype.append.call(this, data, this.appendLimit) + : UpdatableStore.prototype.update.call(this, data); + }; + + GridUpdater.prototype.refresh = function (data) + { + if (this.dataTransformer && data) + { + data = this.dataTransformer(data); + } + this.updating = true; + try + { + if (this.updateOrAppend(data)) + { + // EnhancedGrid with Filter plugin has "filter" layer. + // The filter expression needs to be re-applied after the data update + var filterLayer = this.grid.layer("filter"); + if (filterLayer && filterLayer.filterDef) + { + var currentFilter = filterLayer.filterDef(); + + if (currentFilter) + { + // re-apply filter in the filter layer + filterLayer.filterDef(currentFilter); + } + } + + // refresh grid to render updates + this.grid._refresh(); + } + } + finally + { + this.updating = false; + this.fireUpdate(data); + } + } + + GridUpdater.prototype.update = function () + { + if (this.updatable) + { + this.performUpdate(); + } + }; + + GridUpdater.prototype.performUpdate = function () + { + var self = this; + var requestUrl = lang.isFunction(this.serviceUrl) ? this.serviceUrl() : this.serviceUrl; + var requestArguments = { + url: requestUrl, + sync: properties.useSyncGet, + handleAs: "json" + }; + xhr.get(requestArguments) + .then(function (data) + { + self.refresh(data); + }); + }; + + GridUpdater.prototype.performRefresh = function (data) + { + if (!this.updating) + { + this.refresh(data); + } + }; + + GridUpdater.prototype.fireUpdate = function (data) + { + if (this.onUpdate.length > 0) + { + for (var i = 0; i < this.onUpdate.length; i++) + { + var onUpdate = this.onUpdate[i]; + try + { + onUpdate(data); + } + catch (e) + { + if (console && console.error) + { + console.error(e); + } + } + } + } + }; + + GridUpdater.prototype.addOnUpdate = function (obj) + { + this.onUpdate.push(obj); + }; + + GridUpdater.prototype.removeOnUpdate = function (obj) + { + for (var i = 0; i < this.onUpdate.length; i++) + { + if (this.onUpdate[i] === obj) + { + this.onUpdate.splice(i, 1); + return; + } + } + }; - return GridUpdater; - }); + return GridUpdater; + }); Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js?rev=1741993&r1=1741992&r2=1741993&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js (original) +++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js Mon May 2 15:57:52 2016 @@ -32,76 +32,77 @@ define(["dojo/_base/declare", "dojox/grid/enhanced/plugins/Dialog", "dojo/text!../../../grid/showRowNumberLimitDialog.html", "dojo/domReady!"], - function (declare, event, array, lang, parser, dom, query, registry, Button, CheckBox, Dialog, template) - { + function (declare, event, array, lang, parser, dom, query, registry, Button, CheckBox, Dialog, template) + { - return declare("qpid.management.logs.RowNumberLimitDialog", null, { + return declare("qpid.management.logs.RowNumberLimitDialog", null, { - grid: null, - dialog: null, + grid: null, + dialog: null, - constructor: function (domNode, limitChangedCallback) - { - var that = this; - this.containerNode = dom.create("div", {innerHTML: template}); - parser.parse(this.containerNode).then(function (instances) - { - that._postParse(domNode, limitChangedCallback); - }); - }, - _postParse: function (domNode, limitChangedCallback) - { - this.rowNumberLimit = registry.byNode(query(".rowNumberLimit", this.containerNode)[0]) - this.submitButton = registry.byNode(query(".submitButton", this.containerNode)[0]); - this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); - - this.dialog = new Dialog({ - "refNode": domNode, - "title": "Grid Rows Number", - "content": this.containerNode - }); - - var self = this; - this.submitButton.on("click", function (e) - { - if (self.rowNumberLimit.value > 0) - { - try - { - limitChangedCallback(self.rowNumberLimit.value); - } - catch (e) - { - console.error(e); - } - finally - { - self.dialog.hide(); - } - } - }); - - this.closeButton.on("click", function (e) - { - self.dialog.hide(); - }); - this.dialog.startup(); - }, - - destroy: function () - { - this.submitButton.destroy(); - this.closeButton.destroy(); - this.dialog.destroy(); - this.dialog = null; - }, - - showDialog: function (currentLimit) - { - this.rowNumberLimit.set("value", currentLimit); - this.dialog.show(); - } + constructor: function (domNode, limitChangedCallback) + { + var that = this; + this.containerNode = dom.create("div", {innerHTML: template}); + parser.parse(this.containerNode) + .then(function (instances) + { + that._postParse(domNode, limitChangedCallback); + }); + }, + _postParse: function (domNode, limitChangedCallback) + { + this.rowNumberLimit = registry.byNode(query(".rowNumberLimit", this.containerNode)[0]) + this.submitButton = registry.byNode(query(".submitButton", this.containerNode)[0]); + this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); + + this.dialog = new Dialog({ + "refNode": domNode, + "title": "Grid Rows Number", + "content": this.containerNode + }); + + var self = this; + this.submitButton.on("click", function (e) + { + if (self.rowNumberLimit.value > 0) + { + try + { + limitChangedCallback(self.rowNumberLimit.value); + } + catch (e) + { + console.error(e); + } + finally + { + self.dialog.hide(); + } + } + }); + + this.closeButton.on("click", function (e) + { + self.dialog.hide(); + }); + this.dialog.startup(); + }, + + destroy: function () + { + this.submitButton.destroy(); + this.closeButton.destroy(); + this.dialog.destroy(); + this.dialog = null; + }, + + showDialog: function (currentLimit) + { + this.rowNumberLimit.set("value", currentLimit); + this.dialog.show(); + } - }); + }); - }); + }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
