[pw] P&E accepts simple reference parameters
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 11 Dec 2012 10:50:02 +0100
changeset 19261 54cfb4fd773f
parent 19260 e0f70fa098c5
child 19262 39072df94fc1
[pw] P&E accepts simple reference parameters
modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE_DEPENDENCY.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-param-window-parameter.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewParameterHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java
src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml	Tue Dec 11 10:50:02 2012 +0100
@@ -1,5 +1,17 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--05E5CD50EDE14457BCAC218A77837D1E--><OBCLKER_TEMPLATE>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <OBCLKER_TEMPLATE_ID><![CDATA[05E5CD50EDE14457BCAC218A77837D1E]]></OBCLKER_TEMPLATE_ID>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <NAME><![CDATA[Param window parameter]]></NAME>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <TEMPLATECLASSPATHLOCATION><![CDATA[/org/openbravo/client/application/templates/ob-param-window-parameter.ftl]]></TEMPLATECLASSPATHLOCATION>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <TEMPLATE_LANGUAGE><![CDATA[OBCLFRE_Freemarker]]></TEMPLATE_LANGUAGE>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <COMPONENT_TYPE><![CDATA[OBUIAPP_ViewImplementation]]></COMPONENT_TYPE>
+<!--05E5CD50EDE14457BCAC218A77837D1E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--05E5CD50EDE14457BCAC218A77837D1E--></OBCLKER_TEMPLATE>
+
 <!--08074180655340F0B67E2BA3BA087062--><OBCLKER_TEMPLATE>
 <!--08074180655340F0B67E2BA3BA087062-->  <OBCLKER_TEMPLATE_ID><![CDATA[08074180655340F0B67E2BA3BA087062]]></OBCLKER_TEMPLATE_ID>
 <!--08074180655340F0B67E2BA3BA087062-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE_DEPENDENCY.xml	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE_DEPENDENCY.xml	Tue Dec 11 10:50:02 2012 +0100
@@ -1,5 +1,14 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--F62202D72A8A4C5FABECAF2ED640609E--><OBCLKER_TEMPLATE_DEPENDENCY>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <OBCLKER_TEMPLATE_DEPENDENCY_ID><![CDATA[F62202D72A8A4C5FABECAF2ED640609E]]></OBCLKER_TEMPLATE_DEPENDENCY_ID>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <OBCLKER_TEMPLATE_ID><![CDATA[FF80818132F916130132F9357DE10016]]></OBCLKER_TEMPLATE_ID>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <DEPENDSON_TEMPLATE_ID><![CDATA[05E5CD50EDE14457BCAC218A77837D1E]]></DEPENDSON_TEMPLATE_ID>
+<!--F62202D72A8A4C5FABECAF2ED640609E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F62202D72A8A4C5FABECAF2ED640609E--></OBCLKER_TEMPLATE_DEPENDENCY>
+
 <!--FF808181324E2FEC01324E3F2E620015--><OBCLKER_TEMPLATE_DEPENDENCY>
 <!--FF808181324E2FEC01324E3F2E620015-->  <OBCLKER_TEMPLATE_DEPENDENCY_ID><![CDATA[FF808181324E2FEC01324E3F2E620015]]></OBCLKER_TEMPLATE_DEPENDENCY_ID>
 <!--FF808181324E2FEC01324E3F2E620015-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Tue Dec 11 10:50:02 2012 +0100
@@ -269,6 +269,8 @@
         "web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js", false));
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js", false));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/process/ob-parameter-window-view.js", false));
 
     // Return Material
     globalResources.add(createStaticResource(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-param-window-parameter.ftl	Tue Dec 11 10:50:02 2012 +0100
@@ -0,0 +1,30 @@
+<#--
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+*/
+
+-->
+
+<#macro createParameter param>
+{
+    type: '${param.type}',
+    title: '${param.title?js_string}',
+    name: '${param.name?js_string}',
+    width: '*'
+}
+</#macro>
\ No newline at end of file
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl	Tue Dec 11 10:50:02 2012 +0100
@@ -21,11 +21,25 @@
 
 /*jslint*/
 
-isc.ClassFactory.defineClass('${data.windowClientClassName?js_string}', isc.OBPickAndExecuteView).addProperties({
+isc.ClassFactory.defineClass('${data.windowClientClassName?js_string}', isc.OBParameterWindowView).addProperties({
     windowId: '${data.windowId?js_string}',
     viewProperties: {
       windowId: '${data.windowId?js_string}', 
-      ${data.tabView}
+      fields: [
+    <#list data.paramHandler.parameters as param>
+      <#if param.grid>
+      {
+        isGrid: true,
+        viewProperties: {
+          ${param.tabView}
+        }
+      }
+      <#if param_has_next>,</#if>
+      <#else>
+      <@createParameter param/><#if param_has_next>,</#if>
+      </#if>
+    </#list>    
+    ],
     }
 });
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewParameterHandler.java	Tue Dec 11 10:50:02 2012 +0100
@@ -0,0 +1,91 @@
+package org.openbravo.client.application.window;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.openbravo.client.application.Parameter;
+import org.openbravo.client.application.Process;
+import org.openbravo.client.kernel.reference.UIDefinition;
+import org.openbravo.client.kernel.reference.UIDefinitionController;
+import org.openbravo.model.ad.ui.Tab;
+import org.openbravo.model.ad.ui.Window;
+
+public class OBViewParameterHandler {
+  private static final Logger log = Logger.getLogger(OBViewParameterHandler.class);
+  private Process process;
+  private ParameterWindowComponent paramWindow;
+
+  public void setProcess(Process process) {
+    this.process = process;
+  }
+
+  public List<OBViewParameter> getParameters() {
+    List<OBViewParameter> params = new ArrayList<OBViewParameterHandler.OBViewParameter>();
+    for (Parameter param : process.getOBUIAPPParameterList()) {
+      if (param.isActive()) {
+        params.add(new OBViewParameter(param));
+      }
+    }
+    return params;
+  }
+
+  public class OBViewParameter {
+    UIDefinition uiDefinition;
+    Parameter parameter;
+
+    public OBViewParameter(Parameter param) {
+      // TODO Auto-generated constructor stub
+      uiDefinition = UIDefinitionController.getInstance().getUIDefinition(param.getReference());
+      parameter = param;
+    }
+
+    public String getType() {
+      return uiDefinition != null ? uiDefinition.getName() : "--";
+    }
+
+    public String getTitle() {
+      // TODO: trl
+      return parameter.getName();
+    }
+
+    public String getName() {
+      // TODO: camelcase??
+      return parameter.getDBColumnName();
+    }
+
+    public boolean isGrid() {
+      return parameter.getReferenceSearchKey() != null
+          && parameter.getReferenceSearchKey().getOBUIAPPRefWindowList().size() > 0;
+    }
+
+    public String getTabView() {
+      Window window;
+
+      if (parameter.getReferenceSearchKey().getOBUIAPPRefWindowList().size() == 0
+          || parameter.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow() == null) {
+        // log.error(String.format(AD_DEF_ERROR, p.getId(), "Window", "window"));
+        System.out.println("oooo");
+        return null;
+      } else {
+        window = parameter.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow();
+      }
+
+      if (window.getADTabList().isEmpty()) {
+        log.error("Window definition " + window.getName() + " has no tabs");
+        return null;
+      }
+
+      Tab tab = window.getADTabList().get(0);
+
+      final OBViewTab tabComponent = paramWindow.createComponent(OBViewTab.class);
+      tabComponent.setTab(tab);
+      // tabComponent.setUniqueString(uniqueString); //XXX: ???
+      return tabComponent.generate();
+    }
+  }
+
+  public void setParamWindow(ParameterWindowComponent parameterWindowComponent) {
+    this.paramWindow = parameterWindowComponent;
+  }
+}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Tue Dec 11 10:50:02 2012 +0100
@@ -54,7 +54,6 @@
 import org.openbravo.model.ad.ui.Process;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.TabTrl;
-import org.openbravo.model.ad.ui.Window;
 import org.openbravo.service.datasource.DataSourceConstants;
 import org.openbravo.service.db.DalConnectionProvider;
 import org.openbravo.service.json.JsonConstants;
@@ -467,13 +466,16 @@
   public String getProcessViews() {
     StringBuilder views = new StringBuilder();
     for (ButtonField f : getButtonFields()) {
-      if ("".equals(f.getWindowId())) {
+      if (f.column.getOBUIAPPProcess() == null
+          || !"OBUIAPP_PickAndExecute".equals(f.column.getOBUIAPPProcess().getUIPattern())) {
         continue;
       }
-      final StandardWindowComponent processWindow = createComponent(StandardWindowComponent.class);
+
+      final ParameterWindowComponent processWindow = createComponent(ParameterWindowComponent.class);
       processWindow.setParameters(getParameters());
       processWindow.setUniqueString(uniqueString);
-      processWindow.setWindow(OBDal.getInstance().get(Window.class, f.getWindowId()));
+      processWindow.setProcess(f.column.getOBUIAPPProcess());
+      // processWindow.setWindow(OBDal.getInstance().get(Window.class, f.getWindowId()));
       views.append(processWindow.generate()).append("\n");
     }
     return views.toString();
@@ -532,11 +534,14 @@
     private boolean newDefinition = false;
     private String uiPattern = "";
     private boolean multiRecord = false;
+    private Column column;
 
     public ButtonField(Field fld) {
       id = fld.getId();
       label = OBViewUtil.getLabel(fld);
-      Column column = fld.getColumn();
+
+      // TODO: column might be null when model doesn't require it!!
+      column = fld.getColumn();
 
       propertyName = KernelUtils.getInstance().getPropertyFromColumn(column).getName();
       autosave = column.isAutosave();
@@ -554,6 +559,7 @@
         uiPattern = newProcess.getUIPattern();
         multiRecord = newProcess.isMultiRecord();
 
+        setWindowId(processId);
         if ("OBUIAPP_PickAndExecute".equals(uiPattern)) {
           // TODO: modal should be a parameter in the process definition?
           modal = false;
@@ -629,18 +635,7 @@
     }
 
     private void processParameter(org.openbravo.client.application.Parameter p) {
-
-      if (p.getReference().getId().equals(ApplicationConstants.WINDOW_REFERENCE_ID)) {
-        if (p.getReferenceSearchKey().getOBUIAPPRefWindowList().size() == 0
-            || p.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow() == null) {
-          log.error(String.format(AD_DEF_ERROR, p.getId(), "Window", "window"));
-        } else {
-          setWindowId(p.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow()
-              .getId());
-          setWindowTitle(p.getName());
-        }
-        return;
-      } else if (p.getReference().getId().equals(ApplicationConstants.BUTTON_LIST_REFERENCE_ID)) {
+      if (p.getReference().getId().equals(ApplicationConstants.BUTTON_LIST_REFERENCE_ID)) {
         labelValues = new ArrayList<Value>();
         for (org.openbravo.model.ad.domain.List valueList : p.getReferenceSearchKey()
             .getADListList()) {
@@ -651,7 +646,6 @@
         }
         return;
       }
-      log.error("Trying to use a yet not implemented reference: " + p.getReference());
     }
 
     public boolean isAutosave() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java	Tue Dec 11 10:50:02 2012 +0100
@@ -0,0 +1,222 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.client.application.window;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.openbravo.client.application.ApplicationConstants;
+import org.openbravo.client.application.Process;
+import org.openbravo.client.kernel.BaseTemplateComponent;
+import org.openbravo.client.kernel.KernelConstants;
+import org.openbravo.client.kernel.Template;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.obps.ActivationKey;
+import org.openbravo.erpCommon.obps.ActivationKey.FeatureRestriction;
+import org.openbravo.model.ad.ui.Tab;
+import org.openbravo.model.ad.ui.Window;
+
+/**
+ * The component which takes care of creating a class for a specific paramter window.
+ * 
+ * @author alostale
+ */
+public class ParameterWindowComponent extends BaseTemplateComponent {
+  private static final Logger log = Logger.getLogger(ParameterWindowComponent.class);
+  private static final String DEFAULT_TEMPLATE_ID = "FF80818132F916130132F9357DE10016";
+
+  protected static final Map<String, String> TEMPLATE_MAP = new HashMap<String, String>();
+
+  private Window window;
+  private OBViewTab rootTabComponent = null;
+  private Boolean inDevelopment = null;
+  private String uniqueString = "" + System.currentTimeMillis();
+  private List<String> processViews = new ArrayList<String>();
+  private Process process;
+
+  @Inject
+  private OBViewParameterHandler paramHandler;
+
+  protected Template getComponentTemplate() {
+    return OBDal.getInstance().get(Template.class, DEFAULT_TEMPLATE_ID);
+  }
+
+  public String getWindowClientClassName() {
+    // see the ViewComponent#correctViewId
+    // changes made in this if statement should also be done in that method
+    if (isIndevelopment()) {
+      return KernelConstants.ID_PREFIX + process.getId() + KernelConstants.ID_PREFIX + uniqueString;
+    }
+    return KernelConstants.ID_PREFIX + process.getId();
+  }
+
+  public void setUniqueString(String uniqueString) {
+    this.uniqueString = uniqueString;
+  }
+
+  public boolean isIndevelopment() {
+    if (inDevelopment != null) {
+      return inDevelopment;
+    }
+
+    // check window, tabs and fields
+    inDevelopment = Boolean.FALSE;
+    if (process.getModule().isInDevelopment() && process.getModule().isEnabled()) {
+      inDevelopment = Boolean.TRUE;
+    }
+    // TODO: remove this
+    inDevelopment = Boolean.TRUE;
+
+    return inDevelopment;
+  }
+
+  public String generate() {
+    final String jsCode = super.generate();
+    // System.err.println(jsCode);
+    return jsCode;
+  }
+
+  public String getTabView() {
+    return getRootTabComponent().generate();
+  }
+
+  public String getWindowId() {
+    return process.getId();
+  }
+
+  public String getThreadSafe() {
+    // final Boolean value = getWindow().isThreadsafe();
+    // if (value != null) {
+    // return value.toString();
+    // }
+    return "true";
+  }
+
+  // public Window getWindow() {
+  // return window;
+  // }
+  //
+  // public void setWindow(Window window) {
+  // this.window = window;
+  // }
+
+  public OBViewTab getRootTabComponent() {
+    if (rootTabComponent != null) {
+      return rootTabComponent;
+    }
+    processParameter();
+
+    final List<OBViewTab> tempTabs = new ArrayList<OBViewTab>();
+    for (Tab tab : window.getADTabList()) {
+      // NOTE: grid sequence and field sequence tabs do not have any fields defined!
+      if (!tab.isActive()
+          || tab.getADFieldList().isEmpty()
+          || ActivationKey.getInstance().hasLicencesTabAccess(tab.getId()) != FeatureRestriction.NO_RESTRICTION) {
+        continue;
+      }
+      final OBViewTab tabComponent = createComponent(OBViewTab.class);
+      tabComponent.setTab(tab);
+      tabComponent.setUniqueString(uniqueString);
+      tempTabs.add(tabComponent);
+      final String processView = tabComponent.getProcessViews();
+      if (!"".equals(processView)) {
+        processViews.add(tabComponent.getProcessViews());
+      }
+    }
+
+    // compute the correct hierarchical structure of the tabs
+    for (OBViewTab tabComponent : tempTabs) {
+      OBViewTab parentTabComponent = null;
+      for (OBViewTab testTabComponent : tempTabs) {
+        if (testTabComponent.getTab().getTabLevel() == (tabComponent.getTab().getTabLevel() - 1)
+            && testTabComponent.getTab().getSequenceNumber() < tabComponent.getTab()
+                .getSequenceNumber()) {
+          if (parentTabComponent != null) {
+            // if the new potential parent has a higher sequence number then that one is the correct
+            // one
+            if (parentTabComponent.getTab().getSequenceNumber() < testTabComponent.getTab()
+                .getSequenceNumber()) {
+              parentTabComponent = testTabComponent;
+            }
+          } else {
+            parentTabComponent = testTabComponent;
+          }
+        }
+      }
+      if (parentTabComponent != null) {
+        parentTabComponent.addChildTabComponent(tabComponent);
+      }
+    }
+
+    // handle a special case, multiple root tab components
+    // now get the root tabs
+    for (OBViewTab tabComponent : tempTabs) {
+      if (tabComponent.getParentTabComponent() == null) {
+        if (rootTabComponent != null) {
+          // warn for a special case, multiple root tab components
+          // log.warn("Window " + window.getName() + " " + window.getId()
+          // + " has more than on tab on level 0, choosing an arbitrary root tab");
+          rootTabComponent.addChildTabComponent(tabComponent);
+        } else {
+          rootTabComponent = tabComponent;
+        }
+      }
+    }
+    if (rootTabComponent != null) {
+      rootTabComponent.setRootTab(true);
+    }
+    return rootTabComponent;
+  }
+
+  public List<String> getProcessViews() {
+    return processViews;
+  }
+
+  public void setProcess(org.openbravo.client.application.Process process) {
+    this.process = process;
+    paramHandler.setProcess(process);
+    paramHandler.setParamWindow(this);
+  }
+
+  private void processParameter() {
+    System.out.println("pp");
+    for (org.openbravo.client.application.Parameter p : process.getOBUIAPPParameterList()) {
+      if (p.getReference().getId().equals(ApplicationConstants.WINDOW_REFERENCE_ID)) {
+        if (p.getReferenceSearchKey().getOBUIAPPRefWindowList().size() == 0
+            || p.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow() == null) {
+          // log.error(String.format(AD_DEF_ERROR, p.getId(), "Window", "window"));
+          System.out.println("oooo");
+        } else {
+          this.window = p.getReferenceSearchKey().getOBUIAPPRefWindowList().get(0).getWindow();
+        }
+        return;
+      }
+    }
+
+  }
+
+  public OBViewParameterHandler getParamHandler() {
+    return paramHandler;
+  }
+}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Tue Dec 11 10:50:02 2012 +0100
@@ -44,10 +44,6 @@
   private static final String DEFAULT_TEMPLATE_ID = "ADD5EF45333C458098286D0E639B3290";
 
   protected static final Map<String, String> TEMPLATE_MAP = new HashMap<String, String>();
-  static {
-    // WindowType - Template
-    TEMPLATE_MAP.put("OBUIAPP_PickAndExecute", "FF80818132F916130132F9357DE10016");
-  }
 
   private Window window;
   private OBViewTab rootTabComponent = null;
@@ -56,9 +52,7 @@
   private List<String> processViews = new ArrayList<String>();
 
   protected Template getComponentTemplate() {
-    if (TEMPLATE_MAP.containsKey(window.getWindowType())) {
-      return OBDal.getInstance().get(Template.class, TEMPLATE_MAP.get(window.getWindowType()));
-    }
+
     return OBDal.getInstance().get(Template.class, DEFAULT_TEMPLATE_ID);
   }
 
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java	Mon Dec 10 15:23:43 2012 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java	Tue Dec 11 10:50:02 2012 +0100
@@ -172,7 +172,7 @@
    *          an instance of this class will be returned
    * @return an instance of clz
    */
-  protected <U extends Component> U createComponent(Class<U> clz) {
+  public <U extends Component> U createComponent(Class<U> clz) {
     return (U) components.select(clz).get();
   }
 
--- a/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon Dec 10 15:23:43 2012 +0100
+++ b/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Tue Dec 11 10:50:02 2012 +0100
@@ -21,6 +21,43 @@
 <!--19B6A6E74EC8497E956F2EBE96096226-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[7EE694CFF8B94B4C9B9CE69C9D292CC4]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--19B6A6E74EC8497E956F2EBE96096226--></OBUIAPP_PARAMETER>
 
+<!--31530341FA404BFCB3393D5A47C7E05C--><OBUIAPP_PARAMETER>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <OBUIAPP_PARAMETER_ID><![CDATA[31530341FA404BFCB3393D5A47C7E05C]]></OBUIAPP_PARAMETER_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <NAME><![CDATA[when]]></NAME>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <COLUMNNAME><![CDATA[when]]></COLUMNNAME>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--31530341FA404BFCB3393D5A47C7E05C-->  <OBUIAPP_PROCESS_ID><![CDATA[C79A2D191BBD48AC8456DBD1AAF89E04]]></OBUIAPP_PROCESS_ID>
+<!--31530341FA404BFCB3393D5A47C7E05C--></OBUIAPP_PARAMETER>
+
+<!--56208A218E1C4233B500A857D26D0226--><OBUIAPP_PARAMETER>
+<!--56208A218E1C4233B500A857D26D0226-->  <OBUIAPP_PARAMETER_ID><![CDATA[56208A218E1C4233B500A857D26D0226]]></OBUIAPP_PARAMETER_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--56208A218E1C4233B500A857D26D0226-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <NAME><![CDATA[search]]></NAME>
+<!--56208A218E1C4233B500A857D26D0226-->  <SEQNO><![CDATA[0]]></SEQNO>
+<!--56208A218E1C4233B500A857D26D0226-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <AD_REFERENCE_VALUE_ID><![CDATA[56DEFF37A33F46D1AC918C97C4447EAF]]></AD_REFERENCE_VALUE_ID>
+<!--56208A218E1C4233B500A857D26D0226-->  <COLUMNNAME><![CDATA[search]]></COLUMNNAME>
+<!--56208A218E1C4233B500A857D26D0226-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--56208A218E1C4233B500A857D26D0226-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--56208A218E1C4233B500A857D26D0226-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--56208A218E1C4233B500A857D26D0226-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--56208A218E1C4233B500A857D26D0226-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--56208A218E1C4233B500A857D26D0226-->  <OBUIAPP_PROCESS_ID><![CDATA[C79A2D191BBD48AC8456DBD1AAF89E04]]></OBUIAPP_PROCESS_ID>
+<!--56208A218E1C4233B500A857D26D0226--></OBUIAPP_PARAMETER>
+
 <!--5936B9348BFF4A78A84F2A735BFEB949--><OBUIAPP_PARAMETER>
 <!--5936B9348BFF4A78A84F2A735BFEB949-->  <OBUIAPP_PARAMETER_ID><![CDATA[5936B9348BFF4A78A84F2A735BFEB949]]></OBUIAPP_PARAMETER_ID>
 <!--5936B9348BFF4A78A84F2A735BFEB949-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -82,6 +119,24 @@
 <!--608B149396C04375B78B0B28681AA53E-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[7EE694CFF8B94B4C9B9CE69C9D292CC4]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--608B149396C04375B78B0B28681AA53E--></OBUIAPP_PARAMETER>
 
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD--><OBUIAPP_PARAMETER>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <OBUIAPP_PARAMETER_ID><![CDATA[81CDCE857F7B4EB1A4DA48B58898FCAD]]></OBUIAPP_PARAMETER_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <NAME><![CDATA[test]]></NAME>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <SEQNO><![CDATA[1]]></SEQNO>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <AD_REFERENCE_ID><![CDATA[14]]></AD_REFERENCE_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <COLUMNNAME><![CDATA[test]]></COLUMNNAME>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <FIELDLENGTH><![CDATA[5]]></FIELDLENGTH>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD-->  <OBUIAPP_PROCESS_ID><![CDATA[C79A2D191BBD48AC8456DBD1AAF89E04]]></OBUIAPP_PROCESS_ID>
+<!--81CDCE857F7B4EB1A4DA48B58898FCAD--></OBUIAPP_PARAMETER>
+
 <!--9CECCCE5B5664F5D9EEA37A573BC4D77--><OBUIAPP_PARAMETER>
 <!--9CECCCE5B5664F5D9EEA37A573BC4D77-->  <OBUIAPP_PARAMETER_ID><![CDATA[9CECCCE5B5664F5D9EEA37A573BC4D77]]></OBUIAPP_PARAMETER_ID>
 <!--9CECCCE5B5664F5D9EEA37A573BC4D77-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -123,6 +178,24 @@
 <!--A079FC63513445C1BBD1FAE0B92C59DD-->  <OBUIAPP_PROCESS_ID><![CDATA[5E9F9D7EECC24E4FBB2C60840FF613BE]]></OBUIAPP_PROCESS_ID>
 <!--A079FC63513445C1BBD1FAE0B92C59DD--></OBUIAPP_PARAMETER>
 
+<!--C801D0DFF10047B297F9687BA3EA25FC--><OBUIAPP_PARAMETER>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <OBUIAPP_PARAMETER_ID><![CDATA[C801D0DFF10047B297F9687BA3EA25FC]]></OBUIAPP_PARAMETER_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <NAME><![CDATA[how much]]></NAME>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <AD_REFERENCE_ID><![CDATA[12]]></AD_REFERENCE_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <COLUMNNAME><![CDATA[value]]></COLUMNNAME>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--C801D0DFF10047B297F9687BA3EA25FC-->  <OBUIAPP_PROCESS_ID><![CDATA[C79A2D191BBD48AC8456DBD1AAF89E04]]></OBUIAPP_PROCESS_ID>
+<!--C801D0DFF10047B297F9687BA3EA25FC--></OBUIAPP_PARAMETER>
+
 <!--EBAC5A44ECF3491A9B4281C8902A3B02--><OBUIAPP_PARAMETER>
 <!--EBAC5A44ECF3491A9B4281C8902A3B02-->  <OBUIAPP_PARAMETER_ID><![CDATA[EBAC5A44ECF3491A9B4281C8902A3B02]]></OBUIAPP_PARAMETER_ID>
 <!--EBAC5A44ECF3491A9B4281C8902A3B02-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>