[Tree Extension] Use classic tree if OBUIAPP_UseClassicTreeView property is set
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 05 Mar 2014 11:33:19 +0100
changeset 22630 a652f7e46643
parent 22629 ace05d1bc4cc
child 22631 22d0633c457c
[Tree Extension] Use classic tree if OBUIAPP_UseClassicTreeView property is set
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
src/org/openbravo/erpCommon/utility/WindowTree.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Wed Mar 05 10:20:50 2014 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Wed Mar 05 11:33:19 2014 +0100
@@ -50,7 +50,9 @@
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.Sqlc;
+import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.erpCommon.obps.ActivationKey;
+import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.datamodel.Column;
 import org.openbravo.model.ad.domain.ModelImplementation;
@@ -247,23 +249,34 @@
       iconButtons.add(auditBtn);
     }
 
-    // Old Tree button
-    if (tab.isTreeIncluded() && tab.getTableTree() == null) {
-      IconButton treeBtn = new IconButton();
-      treeBtn.type = "tree";
-      treeBtn.label = Utility.messageBD(new DalConnectionProvider(false), "Tree", OBContext
-          .getOBContext().getLanguage().getLanguage());
-      treeBtn.action = "OB.ToolbarUtils.showTree(this.view);";
-      iconButtons.add(treeBtn);
+    String useClassicPopupTreeStr = null;
+    try {
+      useClassicPopupTreeStr = Preferences.getPreferenceValue("OBUIAPP_UseClassicTreeView", true,
+          OBContext.getOBContext().getCurrentClient(), OBContext.getOBContext()
+              .getCurrentOrganization(), OBContext.getOBContext().getUser(), OBContext
+              .getOBContext().getRole(), tab.getWindow());
+    } catch (PropertyException e) {
+      // The property is not defined, so the classic popup tree should not be used
     }
+    boolean useClassicPopupTree = ("Y".equals(useClassicPopupTreeStr));
 
     if (tab.getTableTree() != null) {
-      IconButton treeBtn = new IconButton();
-      treeBtn.type = "treeGrid";
-      treeBtn.label = Utility.messageBD(new DalConnectionProvider(false),
-          "OBUIAPP_TOGGLE_TREE_BUTTON", OBContext.getOBContext().getLanguage().getLanguage());
-      treeBtn.action = "OB.ToolbarUtils.toggleTreeGridVisibility(this.view);";
-      iconButtons.add(treeBtn);
+      if (useClassicPopupTree) {
+        // Classic Tree button
+        IconButton treeBtn = new IconButton();
+        treeBtn.type = "tree";
+        treeBtn.label = Utility.messageBD(new DalConnectionProvider(false), "Tree", OBContext
+            .getOBContext().getLanguage().getLanguage());
+        treeBtn.action = "OB.ToolbarUtils.showTree(this.view);";
+        iconButtons.add(treeBtn);
+      } else {
+        IconButton treeBtn = new IconButton();
+        treeBtn.type = "treeGrid";
+        treeBtn.label = Utility.messageBD(new DalConnectionProvider(false),
+            "OBUIAPP_TOGGLE_TREE_BUTTON", OBContext.getOBContext().getLanguage().getLanguage());
+        treeBtn.action = "OB.ToolbarUtils.toggleTreeGridVisibility(this.view);";
+        iconButtons.add(treeBtn);
+      }
     }
 
     return iconButtons;
--- a/src/org/openbravo/erpCommon/utility/WindowTree.java	Wed Mar 05 10:20:50 2014 +0100
+++ b/src/org/openbravo/erpCommon/utility/WindowTree.java	Wed Mar 05 11:33:19 2014 +0100
@@ -469,7 +469,7 @@
 
       if (adTree != null) {
         TreeID = adTree.getId();
-        TreeType = "NEW";
+        TreeType = adTree.getTable().getTreeType();
       } else {
         WindowTreeData[] data = WindowTreeData.selectTreeID(this,
             Utility.getContext(this, vars, "#User_Client", ""), TreeType);