Author: orudyy
Date: Sat Sep 14 11:30:18 2013
New Revision: 1523222

URL: http://svn.apache.org/r1523222
Log:
QPID-5138: Add preferences UI into web management console

Added:
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/gear.png
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/help.png
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html
Modified:
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html
    
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js

Modified: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1523222&r1=1523221&r2=1523222&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
 Sat Sep 14 11:30:18 2013
@@ -330,6 +330,13 @@ public class HttpManagement extends Abst
         root.addServlet(new ServletHolder(new LogFileListingServlet()), 
"/rest/logfiles");
         root.addServlet(new ServletHolder(new LogFileServlet()), 
"/rest/logfile");
 
+        String[] timeZoneFiles = {"africa", "antarctica", "asia", 
"australasia", "backward",
+                "etcetera", "europe", "northamerica", "pacificnew",  
"southamerica"};
+        for (String timeZoneFile : timeZoneFiles)
+        {
+            root.addServlet(new ServletHolder(FileServlet.INSTANCE), 
"/dojo/dojox/date/zoneinfo/" + timeZoneFile);
+        }
+
         final SessionManager sessionManager = 
root.getSessionHandler().getSessionManager();
         sessionManager.setSessionCookie(JSESSIONID_COOKIE_PREFIX + lastPort);
         sessionManager.setMaxInactiveInterval((Integer)getAttribute(TIME_OUT));

Modified: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java?rev=1523222&r1=1523221&r2=1523222&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
 Sat Sep 14 11:30:18 2013
@@ -41,6 +41,8 @@ import org.codehaus.jackson.map.Serializ
 
 public class HelperServlet extends AbstractServlet
 {
+    private static final long serialVersionUID = 1L;
+
     private static final String PARAM_ACTION = "action";
 
     private Map<String, Action> _actions;
@@ -56,6 +58,7 @@ public class HelperServlet extends Abstr
                 new 
ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, 
"ListMessageStoreTypes"),
                 new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_TYPES, 
"ListVirtualHostTypes"),
                 new 
ListBrokerAttribute(Broker.SUPPORTED_PREFERENCES_PROVIDERS_TYPES, 
"ListPreferencesProvidersTypes"),
+                new ListBrokerAttribute(Broker.PRODUCT_VERSION, "version"),
                 new ListGroupProviderAttributes(),
                 new ListAccessControlProviderAttributes(),
                 new PluginClassProviderAction()

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html?rev=1523222&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html
 (added)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/common/TimeZoneSelector.html
 Sat Sep 14 11:30:18 2013
@@ -0,0 +1,35 @@
+<table cellpadding="0" cellspacing="2">
+    <tr>
+        <td>Region</td>
+        <td>
+          <select class='timezoneRegion' name="region" 
data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="
+                placeholder: 'Select region',
+                required: true,
+                missingMessage: 'A region must be supplied',
+                title: 'Select region',
+                autoComplete: true,
+                value:'undefined'">
+            <option value="undefined">Undefined</option>
+            <option value="Africa">Africa</option>
+            <option value="America">America</option>
+            <option value="Antarctica">Antarctica</option>
+            <option value="Arctic">Arctic</option>
+            <option value="Asia">Asia</option>
+            <option value="Atlantic">Atlantic</option>
+            <option value="Australia">Australia</option>
+            <option value="Europe">Europe</option>
+            <option value="Indian">Indian</option>
+            <option value="Pacific">Pacific</option>
+          </select>
+        </td>
+        <td>City</td>
+        <td>
+          <select class='timezoneCity' name="city" 
data-dojo-type="dijit/form/FilteringSelect" data-dojo-props="
+                placeholder: 'Select city',
+                required: true,
+                missingMessage: 'A city must be supplied',
+                title: 'Select city'">
+          </select>
+        </td>
+    </tr>
+</table>
\ No newline at end of file

Modified: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css?rev=1523222&r1=1523221&r2=1523222&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
 Sat Sep 14 11:30:18 2013
@@ -148,4 +148,18 @@ div .messages {
 .grayBackground tr{background-color:#eeeeee !important; background-image: none 
!important;}
 .dojoxGridRowOdd.grayBackground tr{ background-color:#e9e9e9 !important; 
background-image: none !important;}
 .dojoxGridRowOdd.yellowBackground tr{background-color:#fafdd5 !important; 
background-image: none !important;}
-.dojoxGridRowOdd.redBackground tr{background-color:#f4c1c1 !important; 
background-image: none !important;}
\ No newline at end of file
+.dojoxGridRowOdd.redBackground tr{background-color:#f4c1c1 !important; 
background-image: none !important;}
+
+.preferencesIcon
+{
+    background: url("../images/gear.png") no-repeat;
+    width: 16px;
+    height: 16px;
+}
+
+.helpIcon
+{
+    background: url("../images/help.png") no-repeat;
+    width: 16px;
+    height: 16px;
+}
\ No newline at end of file

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/gear.png
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/gear.png?rev=1523222&view=auto
==============================================================================
Files 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/gear.png
 (added) and 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/gear.png
 Sat Sep 14 11:30:18 2013 differ

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/help.png
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/help.png?rev=1523222&view=auto
==============================================================================
Files 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/help.png
 (added) and 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/images/help.png
 Sat Sep 14 11:30:18 2013 differ

Modified: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html?rev=1523222&r1=1523221&r2=1523222&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html
 Sat Sep 14 11:30:18 2013
@@ -42,7 +42,6 @@
 
         var dojoConfig = {
             tlmSiblingOfDojo:false,
-            parseOnLoad:true,
             async:true,
             baseUrl: getContextPath(),
             packages:[
@@ -58,7 +57,14 @@
     </script>
 
     <script>
-        require(["dijit/layout/BorderContainer",
+        var qpidHelpLocation = "http://qpid.apache.org/releases/qpid-";;
+        var qpidHelpURL = null;
+        var qpidPreferences = null;
+        require([
+                    "dojo/_base/xhr",
+                    "dojo/parser",
+                    "qpid/management/Preferences",
+                    "dijit/layout/BorderContainer",
                     "dijit/layout/TabContainer",
                     "dijit/layout/ContentPane",
                     "dijit/TitlePane",
@@ -66,7 +72,18 @@
                     "qpid/management/treeView",
                     "qpid/management/controller",
                     "qpid/common/footer",
-                    "qpid/authorization/checkUser"]);
+                    "qpid/authorization/checkUser"], function(xhr, parser, 
Preferences){
+                        parser.parse();
+                        qpidPreferences = new Preferences();
+                         xhr.get({
+                                sync: true,
+                                url: "rest/helper?action=version",
+                                handleAs: "json"
+                         }).then(function(qpidVersion) {
+                            qpidHelpURL = qpidHelpLocation + qpidVersion + 
"/java-broker/book/index.html";
+                         });
+
+                    });
     </script>
 
 </head>
@@ -75,7 +92,27 @@
 <div id="pageLayout" data-dojo-type="dijit.layout.BorderContainer" 
data-dojo-props="design: 'headline', gutters: false">
     <div data-dojo-type="dijit.layout.ContentPane" 
data-dojo-props="region:'top'">
         <div id="header" class="header" style="float: left; width: 
300px"></div>
-        <div id="login" style="float: right; display:none"><strong>User: 
</strong> <span id="authenticatedUser"></span><a 
href="logout">[logout]</a></div>
+        <div style="float: right;">
+          <div id="login" style="display:none"><strong>User: </strong> <span 
id="authenticatedUser"></span><a href="logout">[logout]</a></div>
+          <div id="preferencesButton" style="float: right; margin-top: 0px;" 
data-dojo-type="dijit.form.DropDownButton" data-dojo-props="iconClass: 
'preferencesIcon', title: 'Preferences', showLabel:false">
+            <div data-dojo-type="dijit.Menu">
+                <div data-dojo-type="dijit.MenuItem" data-dojo-props="
+                        iconClass: 'dijitIconFunction',
+                        onClick: function(){ qpidPreferences.showDialog(); } ">
+                    Preferences
+                </div>
+                <!--
+                <div data-dojo-type="dijit.MenuItem" 
data-dojo-props="iconClass: 'dijitIconMail', onClick: function(){ 
console.log('TODO'); }">
+                    Contacts
+                </div>
+                 -->
+                <div data-dojo-type="dijit.MenuItem" 
data-dojo-props="iconClass: 'helpIcon', onClick: function(){
+                     var newWindow = 
window.open(qpidHelpURL,'QpidHelp','height=600,width=600,scrollbars=1,location=1,resizable=1,status=0,toolbar=0,titlebar=1,menubar=0',true);
 newWindow.focus(); } ">
+                    Help
+                </div>
+            </div>
+         </div>
+       </div>
     </div>
     <div data-dojo-type="dijit.layout.ContentPane" 
data-dojo-props="region:'leading', splitter: true" style="width:20%">
         <div qpid-type="treeView" qpid-props="query: 'rest/structure'" ></div>
@@ -104,4 +141,4 @@
 </div>
 
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js?rev=1523222&r1=1523221&r2=1523222&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js
 (original)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/authorization/checkUser.js
 Sat Sep 14 11:30:18 2013
@@ -29,7 +29,7 @@ var updateUI = function updateUI(data)
     if(data.user)
     {
         dom.byId("authenticatedUser").innerHTML = 
entities.encode(String(data.user));
-        dom.byId("login").style.display = "block";
+        dom.byId("login").style.display = "inline";
     }
 };
 

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js?rev=1523222&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js
 (added)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/TimeZoneSelector.js
 Sat Sep 14 11:30:18 2013
@@ -0,0 +1,176 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define([
+        "dojo/_base/declare",
+        "dojo/_base/array",
+        "dojo/dom-construct",
+        "dojo/parser",
+        "dojo/query",
+        "dojo/store/Memory",
+        "dijit/_WidgetBase",
+        "dijit/registry",
+        "dojo/text!common/TimeZoneSelector.html",
+        "dijit/form/ComboBox",
+        "dijit/form/FilteringSelect",
+        "dojox/date/timezone",
+        "dojox/validate/us",
+        "dojox/validate/web",
+        "dojo/domReady!"],
+function (declare, array, domConstruct, parser, query, Memory, _WidgetBase, 
registry, template) {
+
+  var preferencesRegions = 
["Africa","America","Antarctica","Arctic","Asia","Atlantic","Australia","Europe","Indian","Pacific"];
+
+  function initSupportedTimeZones()
+  {
+    var supportedTimeZones = [];
+    var allTimeZones = dojox.date.timezone.getAllZones();
+    for(var i = 0; i < allTimeZones.length; i++)
+    {
+      var timeZone = allTimeZones[i];
+      var elements = timeZone.split("/");
+      if (elements.length > 1)
+      {
+        for(var j = 0; j<preferencesRegions.length; j++)
+        {
+          if (elements[0] == preferencesRegions[j])
+          {
+            supportedTimeZones.push({id: timeZone, region: elements[0], city: 
elements.slice(1).join("/").replace("_", " ") })
+            break;
+          }
+        }
+      }
+    }
+    return supportedTimeZones;
+  }
+
+  function initSupportedRegions()
+  {
+    var supportedRegions = [{"id": "undefined", "name": "Undefined"}];
+    for(var j = 0; j<preferencesRegions.length; j++)
+    {
+      supportedRegions.push({id: preferencesRegions[j], name: 
preferencesRegions[j] });
+    }
+    return supportedRegions;
+  }
+
+  return declare("qpid.common.TimeZoneSelector", [_WidgetBase], {
+
+    value: null,
+    domNode: null,
+    _regionSelector: null,
+    _citySelector: null,
+
+    constructor: function(args)
+    {
+      this._args = args;
+    },
+
+    buildRendering: function(){
+      this.domNode = domConstruct.create("div", {innerHTML: template});
+      parser.parse(this.domNode);
+    },
+
+    postCreate: function(){
+      this.inherited(arguments);
+
+      var supportedTimeZones = initSupportedTimeZones();
+
+      this._citySelector = registry.byNode(query(".timezoneCity", 
this.domNode)[0]);
+      this._citySelector.set("searchAttr", "city");
+      this._citySelector.set("query", {region: /.*/});
+      this._citySelector.set("labelAttr", "city");
+      this._citySelector.set("store", new Memory({ data: supportedTimeZones 
}));
+      if (this._args.name)
+      {
+        this._citySelector.set("name", this._args.name);
+      }
+      this._regionSelector = registry.byNode(query(".timezoneRegion", 
this.domNode)[0]);
+      var supportedRegions = initSupportedRegions();
+      this._regionSelector.set("store", new Memory({ data: supportedRegions 
}));
+      var self = this;
+
+      this._regionSelector.on("change", function(value){
+        if (value=="undefined")
+        {
+          self._citySelector.set("disabled", true);
+          self._citySelector.query.region = /.*/;
+          self.value = null;
+          self._citySelector.set("value", null);
+        }
+        else
+        {
+          self._citySelector.set("disabled", false);
+          self._citySelector.query.region = value || /.*/;
+          if (this.timeZone)
+          {
+            self._citySelector.set("value", this.timeZone);
+            this.timeZone = null;
+          }
+          else
+          {
+            self._citySelector.set("value", null);
+          }
+        }
+      });
+
+      this._citySelector.on("change", function(value){
+        self.value = value;
+      });
+
+      this._setValueAttr(this._args.value);
+    },
+
+    _setValueAttr: function(value)
+    {
+      if (value)
+      {
+        var elements = value.split("/");
+        if (elements.length > 1)
+        {
+          this._regionSelector.timeZone = value;
+          this._regionSelector.set("value", elements[0]);
+          this._citySelector.set("value", value);
+        }
+        else
+        {
+          this._regionSelector.set("value", "undefined");
+        }
+      }
+      else
+      {
+        this._regionSelector.set("value", "undefined");
+      }
+      this.value = value;
+    },
+
+    destroy: function()
+    {
+      if (this.domNode)
+      {
+        this.domNode.destroy();
+        this.domNode = null;
+      }
+      _regionSelector: null;
+      _citySelector: null;
+    }
+
+  });
+});
\ No newline at end of file

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js?rev=1523222&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js
 (added)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js
 Sat Sep 14 11:30:18 2013
@@ -0,0 +1,149 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define([
+        "dojo/_base/declare",
+        "dojo/_base/xhr",
+        "dojo/_base/event",
+        "dojo/dom",
+        "dojo/dom-construct",
+        "dojo/parser",
+        "dojo/query",
+        "dojo/json",
+        "dojox/html/entities",
+        "dijit/registry",
+        "qpid/common/TimeZoneSelector",
+        "dojo/text!../../showPreferences.html",
+        "dijit/Dialog",
+        "dijit/form/NumberSpinner",
+        "dijit/form/CheckBox",
+        "dijit/form/Textarea",
+        "dijit/form/FilteringSelect",
+        "dijit/form/TextBox",
+        "dijit/form/DropDownButton",
+        "dijit/form/Button",
+        "dijit/form/Form",
+        "dojox/validate/us",
+        "dojox/validate/web",
+        "dojo/domReady!"],
+function (declare, xhr, event, dom, domConstruct, parser, query, json, 
entities, registry, TimeZoneSelector, markup) {
+
+  var preferenceNames = ["timeZone", "updatePeriod", "saveTabs"];
+
+  return declare("qpid.management.Preferences", null, {
+
+    preferencesDialog: null,
+    saveButton: null,
+    cancelButton: null,
+
+    constructor: function()
+    {
+      var that = this;
+
+      this.domNode = domConstruct.create("div", {innerHTML: markup});
+      parser.parse(this.domNode);
+
+      for(var i=0; i<preferenceNames.length; i++)
+      {
+        var name = preferenceNames[i];
+        this[name] = registry.byNode(query("." + name, this.domNode)[0]);
+      }
+
+      this.saveButton = registry.byNode(query(".saveButton", this.domNode)[0]);
+      this.cancelButton = registry.byNode(query(".cancelButton", 
this.domNode)[0]);
+      this.theForm = registry.byId("preferencesForm");
+
+      this.preferencesDialog = new dijit.Dialog({
+        title:"Preferences",
+        style: "width: 600px",
+        content: this.domNode
+      });
+
+      this.cancelButton.on("click", 
function(){that.preferencesDialog.hide();});
+      this.theForm.on("submit", function(e){
+        event.stop(e);
+        if(that.theForm.validate()){
+          var preferences = {};
+          for(var i=0; i<preferenceNames.length; i++)
+          {
+            var name = preferenceNames[i];
+            var preferenceWidget = that[name];
+            if (preferenceWidget)
+            {
+              preferences[name] = preferenceWidget.get("value");
+            }
+          }
+          xhr.post({
+                url: "rest/preferences",
+                sync: true,
+                handleAs: "json",
+                headers: { "Content-Type": "application/json"},
+                postData: json.stringify(preferences),
+                load: function(x) {that.success = true; },
+                error: function(error) {that.success = false; 
that.failureReason = error;}
+          });
+          if(that.success === true)
+          {
+            that.preferencesDialog.hide();
+          }
+          else
+          {
+            alert("Error:" + that.failureReason);
+          }
+        }
+        return false;
+      });
+      this.preferencesDialog.startup();
+    },
+
+    showDialog: function(){
+      var that = this;
+      xhr.get({
+        url: "rest/preferences",
+        sync: true,
+        handleAs: "json"
+      }).then(
+       function(data) {
+         for(var preference in data)
+         {
+           if (that.hasOwnProperty(preference))
+           {
+             var value = data[preference];
+             if (typeof data[preference] == "string")
+             {
+               value = entities.encode(String(value))
+             }
+             that[preference].set("value", value);
+           }
+         }
+         that.preferencesDialog.show();
+      });
+    },
+
+    destroy: function()
+    {
+      if (this.preferencesDialog)
+      {
+        this.preferencesDialog.destroyRecursevly();
+        this.preferencesDialog = null;
+      }
+    }
+  });
+});
\ No newline at end of file

Added: 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html?rev=1523222&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html
 (added)
+++ 
qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html
 Sat Sep 14 11:30:18 2013
@@ -0,0 +1,51 @@
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing,
+ - software distributed under the License is distributed on an
+ - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ - KIND, either express or implied.  See the License for the
+ - specific language governing permissions and limitations
+ - under the License.
+ -
+ -->
+<div>
+    <form method="post" data-dojo-type="dijit/form/Form" id="preferencesForm">
+        <table cellpadding="0" cellspacing="2">
+            <tr>
+                <td><strong>Time zone: </strong></td>
+                <td>
+                    <span class="timeZone" 
data-dojo-type="qpid/common/TimeZoneSelector" data-dojo-props="name: 
'timeZone'"></span>
+                </td>
+            </tr>
+            <tr>
+                <td><strong>Update period:</strong></td>
+                <td><input class="updatePeriod" name="updatePeriod" 
data-dojo-type="dijit/form/NumberSpinner" data-dojo-props="
+                                  invalidMessage: 'Invalid value',
+                                  required: false,
+                                  smallDelta: 1,
+                                  value: 5,
+                                  constraints: {min:1,max:65535,places:0, 
pattern: '#####'},
+                              "/>
+                </td>
+            </tr>
+            <tr>
+                <td><strong>Save tabs:</strong></td>
+                <td><input class="saveTabs" type="checkbox" 
data-dojo-type="dijit/form/CheckBox" name="saveTabs"/></td>
+            </tr>
+        </table>
+        <div class="dijitDialogPaneActionBar">
+          <input type="submit" value="Save Preferences" 
data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Save Preferences'" 
class="saveButton"/>
+          <button value="Cancel" data-dojo-type="dijit/form/Button" 
data-dojo-props="label: 'Cancel'" class="cancelButton"></button>
+        </div>
+    </form>
+</div>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to