details:   /erp/devel/pi/rev/85209bf81395
changeset: 12300:85209bf81395
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Mon May 23 01:44:45 2011 +0200
summary:   [KS] Added StatusBar keyboard shortcuts

diffstat:

 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
                 |   15 +
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
                   |   11 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
 |    1 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
  |    4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
      |  190 +++++++--
 5 files changed, 170 insertions(+), 51 deletions(-)

diffs (truncated from 338 to 300 lines):

diff -r 613824a3f1a0 -r 85209bf81395 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
     Fri May 20 17:09:50 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
     Mon May 23 01:44:45 2011 +0200
@@ -65,6 +65,21 @@
 <!--7EE6D055A7FE4C4DA7EB557F6C61D0EC-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--7EE6D055A7FE4C4DA7EB557F6C61D0EC--></AD_PREFERENCE>
 
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED--><AD_PREFERENCE>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  
<AD_PREFERENCE_ID><![CDATA[8EE6D055A7FE4C4DA7EB557F6C61D0ED]]></AD_PREFERENCE_ID>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  <VALUE><![CDATA[[
+  {"id": "StatusBar_Previous", "keyComb": {"alt": true, "shift": true, "key": 
"Page_Up"}},
+  {"id": "StatusBar_Next", "keyComb": {"alt": true, "shift": true, "key": 
"Page_Down"}},
+  {"id": "StatusBar_Maximize-Restore", "keyComb": {"ctrl": true, "alt": true, 
"key": "Enter"}}
+]]]></VALUE>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  
<PROPERTY><![CDATA[UISTATB_KeyboardShortcuts]]></PROPERTY>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  
<ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--8EE6D055A7FE4C4DA7EB557F6C61D0ED--></AD_PREFERENCE>
+
 <!--C085B29F345B423F9E7DE5677359E02B--><AD_PREFERENCE>
 <!--C085B29F345B423F9E7DE5677359E02B-->  
<AD_PREFERENCE_ID><![CDATA[C085B29F345B423F9E7DE5677359E02B]]></AD_PREFERENCE_ID>
 <!--C085B29F345B423F9E7DE5677359E02B-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 613824a3f1a0 -r 85209bf81395 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
       Fri May 20 17:09:50 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
       Mon May 23 01:44:45 2011 +0200
@@ -139,6 +139,17 @@
 <!--CF6EAC4255D0484399EF03DB23376CD5-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--CF6EAC4255D0484399EF03DB23376CD5--></AD_REF_LIST>
 
+<!--DF6EAC4255D0484399EF03DB23376CD6--><AD_REF_LIST>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  
<AD_REF_LIST_ID><![CDATA[DF6EAC4255D0484399EF03DB23376CD6]]></AD_REF_LIST_ID>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  
<VALUE><![CDATA[UISTATB_KeyboardShortcuts]]></VALUE>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  <NAME><![CDATA[Keyboard Shortcuts 
(UISTATB)]]></NAME>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  
<AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--DF6EAC4255D0484399EF03DB23376CD6-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--DF6EAC4255D0484399EF03DB23376CD6--></AD_REF_LIST>
+
 <!--FF8080812DE1CD58012DE1FC1FB9002F--><AD_REF_LIST>
 <!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_REF_LIST_ID><![CDATA[FF8080812DE1CD58012DE1FC1FB9002F]]></AD_REF_LIST_ID>
 <!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 613824a3f1a0 -r 85209bf81395 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
     Fri May 20 17:09:50 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
     Mon May 23 01:44:45 2011 +0200
@@ -44,6 +44,7 @@
 OB.KeyboardManager.KS.setPredefinedKSList('OBUIAPP_KeyboardShortcuts');
 OB.KeyboardManager.KS.setPredefinedKSList('UINAVBA_KeyboardShortcuts');
 OB.KeyboardManager.KS.setPredefinedKSList('UITOOLB_KeyboardShortcuts');
+OB.KeyboardManager.KS.setPredefinedKSList('UISTATB_KeyboardShortcuts');
 
 // should be moved to client.kernel component
 // placed here to prevent dependencies of client.kernel on Preferences
diff -r 613824a3f1a0 -r 85209bf81395 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Fri May 20 17:09:50 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Mon May 23 01:44:45 2011 +0200
@@ -666,6 +666,7 @@
   setActiveViewProps: function(state){
     if (state) {
       this.toolBar.show();
+      this.statusBar.setActive(true);
       this.activeBar.setActive(true);
       this.setViewFocus();
       this.viewGrid.setActive(true);
@@ -679,8 +680,9 @@
       this.viewGrid.closeAnyOpenEditor();
       
       this.toolBar.hide();
+      this.statusBar.setActive(false);
+      this.activeBar.setActive(false);
       this.viewGrid.setActive(false);
-      this.activeBar.setActive(false);
       // note we can not check on viewForm visibility as 
       // the grid and form can both be hidden when changing
       // to another tab, this handles the case that the grid
diff -r 613824a3f1a0 -r 85209bf81395 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
  Fri May 20 17:09:50 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
  Mon May 23 01:44:45 2011 +0200
@@ -44,6 +44,7 @@
   view : null,
   // to allow setting the active view when clicking in the statusbar
   canFocus : true,
+  keyboardShortcutId : null,
 
   // always go through the autosave of the window
   action : function() {
@@ -67,7 +68,7 @@
   },
 
   doAction : function() {
-    var rowNum, newRowNum, newRecord;
+    var rowNum, newRowNum, newRecord, theButtonVar, i;
     if (this.buttonType === 'previous') {
       this.view.editNextPreviousRecord(false);
     } else if (this.buttonType === 'maximize') {
@@ -79,6 +80,40 @@
     } else if (this.buttonType === 'close') {
       this.view.switchFormGridVisibility();
       this.view.messageBar.hide();
+    } else if (this.buttonType === 'maximizeRestore') {
+      theButtonVar = this.view.statusBar.buttonBar;
+      if (theButtonVar.members) {
+        for (i = 0; i < theButtonVar.members.length; i++) {
+          if (theButtonVar.members[i].buttonType === 'maximize' && 
!theButtonVar.members[i].isDisabled() && theButtonVar.members[i].isVisible()) {
+            theButtonVar.members[i].action();
+            break;
+          } else if (theButtonVar.members[i].buttonType === 'restore' && 
!theButtonVar.members[i].isDisabled() && theButtonVar.members[i].isVisible()) {
+            theButtonVar.members[i].action();
+            break;
+          }
+        }
+      }
+    }
+  },
+
+  enableShortcut: function() {
+    if (this.keyboardShortcutId) {
+      var me = this;
+      var ksAction = function(){
+        if ((!me.isDisabled() && me.isVisible()) || me.buttonType === 
'maximizeRestore') {
+          me.action();
+        }
+        return false; //To avoid keyboard shortcut propagation
+      };
+      OB.KeyboardManager.KS.set(this.keyboardShortcutId, ksAction);
+    }
+  },
+
+  disableShortcut: function() {
+    if (this.keyboardShortcutId) {
+      OB.KeyboardManager.KS.set(this.keyboardShortcutId, function(){
+        return true;
+      });
     }
   },
 
@@ -101,7 +136,9 @@
   previousButton : null,
   newIcon : null,
   showingIcon : false,
-  mode : "",
+  mode : '',
+  isActive : true,
+  buttonBar : null,
 
   initWidget : function() {
     this.contentLabel = isc.OBStatusBarTextLabel.create( {
@@ -116,11 +153,13 @@
     this.previousButton = isc.OBStatusBarIconButton.create( {
       view : this.view,
       buttonType : 'previous',
+      keyboardShortcutId : 'StatusBar_Previous',
       prompt : OB.I18N.getLabel('OBUIAPP_PREVIOUSBUTTON')
     });
     this.nextButton = isc.OBStatusBarIconButton.create( {
       view : this.view,
       buttonType : 'next',
+      keyboardShortcutId : 'StatusBar_Next',
       prompt : OB.I18N.getLabel('OBUIAPP_NEXTBUTTON')
     });
     this.closeButton = isc.OBStatusBarIconButton.create( {
@@ -139,18 +178,25 @@
       buttonType : 'restore',
       prompt : OB.I18N.getLabel('OBUIAPP_RESTOREBUTTON')
     });
+    this.maximizeRestoreButton = isc.OBStatusBarIconButton.create( { // Only 
for implement 'StatusBar_Maximize-Restore' keyboard shortcut
+      visibility : 'hidden',
+      view : this.view,
+      buttonType : 'maximizeRestore',
+      keyboardShortcutId : 'StatusBar_Maximize-Restore'
+    });
+    this.buttonBar = isc.OBStatusBarIconButtonBar.create( {});
+
     var buttonSpacer = isc.HLayout.create( {
       width : this.iconButtonGroupSpacerWidth
-    }),
-    buttonBar = isc.OBStatusBarIconButtonBar.create( {}), i;
+    }), i;
 
-    buttonBar.addMembers( [ this.previousButton, this.nextButton, buttonSpacer,
-        this.maximizeButton, this.restoreButton, this.closeButton ]);
-    for (i = 0; i < buttonBar.members.length; i++) {
-      if (buttonBar.members[i].buttonType) {
+    this.buttonBar.addMembers( [ this.previousButton, this.nextButton, 
buttonSpacer,
+        this.maximizeButton, this.restoreButton, this.closeButton, 
this.maximizeRestoreButton ]);
+    for (i = 0; i < this.buttonBar.members.length; i++) {
+      if (this.buttonBar.members[i].buttonType) {
         OB.TestRegistry.register(
-            'org.openbravo.client.application.statusbar.button.' + 
buttonBar.members[i].buttonType + '.' + this.view.tabId,
-            buttonBar.members[i]);
+            'org.openbravo.client.application.statusbar.button.' + 
this.buttonBar.members[i].buttonType + '.' + this.view.tabId,
+            this.buttonBar.members[i]);
       }
     }
 
@@ -161,54 +207,98 @@
     });
     this.leftStatusBar.addMember(this.spacer, 0);
 
-    this.addMembers( [ this.leftStatusBar, buttonBar ]);
+    this.addMembers( [ this.leftStatusBar, this.buttonBar ]);
     this.Super('initWidget', arguments);
   },
 
-addIcon : function(icon) {
+  draw: function(){
+    this.Super('draw', arguments);
+  },
+
+  visibilityChanged: function(state){
+    if (this.isActive) {
+      if (state) {
+        this.enableShortcuts();
+      } else {
+        this.disableShortcuts();
+      }
+    }
+  },
+
+  setActive: function(value){
+    if (value) {
+      this.isActive = true;
+      this.enableShortcuts();
+    } else {
+      this.isActive = false;
+      this.disableShortcuts();
+    }
+  },
+
+  enableShortcuts: function(){
+    if (this.buttonBar.members) {
+      for (i = 0; i < this.buttonBar.members.length; i++) {
+        if (this.buttonBar.members[i].enableShortcut) {
+          this.buttonBar.members[i].enableShortcut();
+        }
+      }
+    }
+  },
+
+  disableShortcuts: function(){
+    if (this.buttonBar.members) {
+      for (i = 0; i < this.buttonBar.members.length; i++) {
+        if (this.buttonBar.members[i].disableShortcut) {
+          this.buttonBar.members[i].disableShortcut();
+        }
+      }
+    }
+  },
+
+  addIcon : function(icon) {
+      // remove any existing icon or spacer
+    this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
+    this.leftStatusBar.addMember(icon, 0);
+  },
+
+  removeIcon : function() {
     // remove any existing icon or spacer
-  this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
-  this.leftStatusBar.addMember(icon, 0);
-},
+    this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
+    this.leftStatusBar.addMember(this.spacer, 0);
+  },
 
-removeIcon : function() {
-  // remove any existing icon or spacer
-  this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
-  this.leftStatusBar.addMember(this.spacer, 0);
-},
+  setNewState : function(isNew) {
+    this.previousButton.setDisabled(isNew);
+    this.nextButton.setDisabled(isNew);
+    if (isNew) {
+      this.mode = 'NEW';
+      this.setContentLabel(this.newIcon, 'OBUIAPP_New');
+    }
+  },
 
-setNewState : function(isNew) {
-  this.previousButton.setDisabled(isNew);
-  this.nextButton.setDisabled(isNew);
-  if (isNew) {
-    this.mode = 'NEW';
-    this.setContentLabel(this.newIcon, 'OBUIAPP_New');
-  }
-},
-
-setContentLabel : function(icon, statusCode, arrayTitleField) {
-  var msg = '', i;
-  if (statusCode) {
-    msg += '<span class="' + (this.statusLabelStyle?this.statusLabelStyle:'') 
+ '">' + OB.I18N.getLabel(statusCode) + '</span>';
-  }
-  if (arrayTitleField) {
-    for (i = 0; i < arrayTitleField[0].length; i++) {
-      if (i !== 0 || statusCode) {
-        msg += '<span class="' + 
(this.separatorLabelStyle?this.separatorLabelStyle:'') + '">' + 
'&nbsp;&nbsp;|&nbsp;&nbsp;' + '</span>';

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to