details: /erp/devel/pi/rev/9fcf528ba721
changeset: 10160:9fcf528ba721
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Jan 27 13:10:07 2011 +0100
summary: Solved wrong parent tab/property computation
details: /erp/devel/pi/rev/fdbff2dc951b
changeset: 10161:fdbff2dc951b
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Jan 27 13:10:28 2011 +0100
summary: Added logos to testregistry
details: /erp/devel/pi/rev/c287d1f2a912
changeset: 10162:c287d1f2a912
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Jan 27 13:10:58 2011 +0100
summary: Solved issue with spaces in filename
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
| 40 +++
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
| 32 +-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
| 111 ++++++++-
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseTemplateProcessor.java
| 2 +-
4 files changed, 152 insertions(+), 33 deletions(-)
diffs (289 lines):
diff -r cd86af3f3207 -r c287d1f2a912
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
Thu Jan 27 10:28:26 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
Thu Jan 27 13:10:58 2011 +0100
@@ -23,6 +23,10 @@
import org.apache.log4j.Logger;
import org.hibernate.criterion.Expression;
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.base.model.Property;
+import org.openbravo.dal.core.DalUtil;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
@@ -61,6 +65,42 @@
return false;
}
+ /**
+ * Computes the parent property for a certain tab and its parent tab. The
parentProperty is the
+ * property in the entity of the tab pointing to the parent tab.
+ *
+ * @param tab
+ * the child tab
+ * @param parentTab
+ * the parent tab
+ * @return the parentproperty in the source entity pointing to the parent
+ */
+ public static String getParentProperty(Tab tab, Tab parentTab) {
+ String parentProperty = "";
+ final Entity thisEntity =
ModelProvider.getInstance().getEntity(tab.getTable().getName());
+ final Entity parentEntity = ModelProvider.getInstance().getEntity(
+ parentTab.getTable().getName());
+ if (tab.getColumn() != null) {
+ final String columnId = (String) DalUtil.getId(tab.getColumn());
+ for (Property property : thisEntity.getProperties()) {
+ if (property.getColumnId() != null &&
property.getColumnId().equals(columnId)) {
+ parentProperty = property.getName();
+ }
+ }
+ } else {
+ for (Property property : thisEntity.getProperties()) {
+ if (property.isPrimitive() || property.isOneToMany()) {
+ continue;
+ }
+ if (property.getTargetEntity() == parentEntity) {
+ parentProperty = property.getName();
+ break;
+ }
+ }
+ }
+ return parentProperty;
+ }
+
public static boolean isClientAdmin() {
return OBContext.getOBContext().getRole().isClientAdmin();
}
diff -r cd86af3f3207 -r c287d1f2a912
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
Thu Jan 27 10:28:26 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/layout.js.ftl
Thu Jan 27 13:10:58 2011 +0100
@@ -40,8 +40,6 @@
}
isc.Canvas.addClassProperties({neverUsePNGWorkaround:true});
-isc.Canvas.loadingImageSrc =
'[SKINIMG]../../org.openbravo.client.application/images/system/windowLoading.gif';
-isc.Canvas.loadingImageSize = 70;
OB.KeyboardManager.KS.readRegisteredKSList('OBUIAPP_KeyboardShortcuts');
OB.KeyboardManager.KS.readRegisteredKSList('UINAVBA_KeyboardShortcuts');
@@ -87,7 +85,22 @@
OB.TopLayout.CompanyImageLogo = isc.Img.create({
imageType: 'normal'
}, OB.MainLayoutStylingProperties.CompanyImageLogo);
-
+OB.TestRegistry.register('org.openbravo.client.application.companylogo',
OB.TopLayout.CompanyImageLogo);
+
+OB.TopLayout.OpenbravoLogo = isc.Img.create({
+ imageType: 'normal',
+ src: OB.Application.contextUrl + 'utility/GetOpenbravoLogo.png',
+ getInnerHTML: function() {
+ var html = this.Super('getInnerHTML', arguments);
+ <#if data.addProfessionalLink>
+ return '<a href="http://www.openbravo.com/product/erp/professional/"
target="_new">' + html + '</a>';
+ <#else>
+ return html;
+ </#if>
+ }
+});
+OB.TestRegistry.register('org.openbravo.client.application.companylogo',
OB.TopLayout.OpenbravoLogo);
+
OB.TopLayout.addMember(OB.Toolbar);
OB.TopLayout.addMember(
isc.HLayout.create({
@@ -96,18 +109,7 @@
layoutRightMargin: 10,
membersMargin: 10,
defaultLayoutAlign: 'center',
- members: [OB.TopLayout.CompanyImageLogo, isc.Img.create({
- imageType: 'normal',
- src: OB.Application.contextUrl +
'utility/GetOpenbravoLogo.png',
- getInnerHTML: function() {
- var html = this.Super('getInnerHTML', arguments);
- <#if data.addProfessionalLink>
- return '<a
href="http://www.openbravo.com/product/erp/professional/" target="_new">' +
html + '</a>';
- <#else>
- return html;
- </#if>
- }
- })]
+ members: [OB.TopLayout.CompanyImageLogo,
OB.TopLayout.OpenbravoLogo]
})
);
diff -r cd86af3f3207 -r c287d1f2a912
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
Thu Jan 27 10:28:26 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
Thu Jan 27 13:10:58 2011 +0100
@@ -30,8 +30,8 @@
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.openbravo.base.exception.OBException;
-import org.openbravo.base.model.Property;
import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.client.application.ApplicationUtils;
import org.openbravo.client.application.MenuManager;
import org.openbravo.client.application.MenuManager.MenuOption;
import org.openbravo.client.kernel.BaseActionHandler;
@@ -128,6 +128,7 @@
throw new OBException("No root tab found in window " + window);
}
+ System.err.println("Computing tab info");
final Tab tab = getTab(window, entityName);
final TabInfo tabInfo = new TabInfo();
tabInfo.setRecord(bob);
@@ -135,31 +136,33 @@
final List<JSONObject> resultList = new ArrayList<JSONObject>();
resultList.add(tabInfo.getJSONObject());
TabInfo currentTabInfo = tabInfo;
- while (currentTabInfo != null) {
- currentTabInfo = getParentTabInfo(currentTabInfo.getRecord(), window);
+ TabTreeNode tabTreeNode = computeTabTreeStructure(window, tab);
+ // skip the first node
+ tabTreeNode = tabTreeNode.getParentTabTreeNode();
+ while (tabTreeNode != null) {
+ currentTabInfo = createTabInfo(currentTabInfo.getRecord(), tabTreeNode);
if (currentTabInfo != null) {
resultList.add(0, currentTabInfo.getJSONObject());
}
+ tabTreeNode = tabTreeNode.getParentTabTreeNode();
}
final JSONObject result = new JSONObject();
result.put(RESULT, new JSONArray(resultList));
+ System.err.println("Computing tab info done");
return result;
}
- private TabInfo getParentTabInfo(BaseOBObject childEntity, Window window) {
- for (Property property : childEntity.getEntity().getProperties()) {
- if (property.isParent()) {
- final Tab tab = getTab(window, property.getTargetEntity().getName());
- if (tab != null && childEntity.get(property.getName()) != null) {
- final BaseOBObject parent = (BaseOBObject)
childEntity.get(property.getName());
- final TabInfo tabInfo = new TabInfo();
- tabInfo.setRecord(parent);
- tabInfo.setTab(tab);
- return tabInfo;
- }
- }
+ private TabInfo createTabInfo(BaseOBObject childObject, TabTreeNode
tabTreeNode) {
+ if (tabTreeNode.getParentTabTreeNode() == null) {
+ return null;
}
- return null;
+ final String parentProperty =
ApplicationUtils.getParentProperty(tabTreeNode.getTab(),
+ tabTreeNode.getParentTabTreeNode().getTab());
+ final BaseOBObject parent = (BaseOBObject) childObject.get(parentProperty);
+ final TabInfo tabInfo = new TabInfo();
+ tabInfo.setRecord(parent);
+ tabInfo.setTab(tabTreeNode.getTab());
+ return tabInfo;
}
private Tab getTab(Window window, String entityName) {
@@ -169,13 +172,55 @@
return tab;
}
}
- throw new OBException("No tab found using entity " + entityName + "
window: " + window);
+ return null;
}
protected JSONObject execute(Map<String, Object> parameters, String data) {
throw new UnsupportedOperationException();
}
+ private TabTreeNode computeTabTreeStructure(Window window, Tab targetTab) {
+ final List<Tab> tempTabs = new ArrayList<Tab>(window.getADTabList());
+ for (Tab tab : window.getADTabList()) {
+ if (!tab.isActive() || !tab.getModule().isEnabled()) {
+ tempTabs.remove(tab);
+ }
+ }
+ final List<TabTreeNode> treeNodes = new ArrayList<TabTreeNode>();
+ for (Tab tab : window.getADTabList()) {
+
+ final TabTreeNode treeNode = new TabTreeNode();
+ treeNode.setTab(tab);
+ treeNodes.add(treeNode);
+
+ TabTreeNode parentTabNode = null;
+ for (TabTreeNode tabTreeNode : treeNodes) {
+ if (tabTreeNode.getTab().getTabLevel() ==
(treeNode.getTab().getTabLevel() - 1)
+ && tabTreeNode.getTab().getSequenceNumber() <
treeNode.getTab().getSequenceNumber()) {
+ if (parentTabNode != null) {
+ // if the new potential parent has a higher sequence number then
that one is the correct
+ // one
+ if (parentTabNode.getTab().getSequenceNumber() <
tabTreeNode.getTab()
+ .getSequenceNumber()) {
+ parentTabNode = tabTreeNode;
+ }
+ } else {
+ parentTabNode = tabTreeNode;
+ }
+ }
+ }
+ if (parentTabNode != null) {
+ parentTabNode.addChildTabTreeNode(treeNode);
+ }
+ }
+ for (TabTreeNode treeNode : treeNodes) {
+ if (treeNode.getTab() == targetTab) {
+ return treeNode;
+ }
+ }
+ throw new OBException("Target tab not present in resulting tab tree " +
targetTab);
+ }
+
private class TabInfo {
private BaseOBObject record;
private Tab tab;
@@ -205,4 +250,36 @@
return result;
}
}
+
+ private class TabTreeNode {
+ private Tab tab;
+ final private List<TabTreeNode> children = new ArrayList<TabTreeNode>();
+ private TabTreeNode parentTabTreeNode;
+
+ public void addChildTabTreeNode(TabTreeNode childTreeNode) {
+ getChildren().add(childTreeNode);
+ childTreeNode.setParentTabTreeNode(this);
+ }
+
+ public Tab getTab() {
+ return tab;
+ }
+
+ public void setTab(Tab tab) {
+ this.tab = tab;
+ }
+
+ public List<TabTreeNode> getChildren() {
+ return children;
+ }
+
+ public TabTreeNode getParentTabTreeNode() {
+ return parentTabTreeNode;
+ }
+
+ public void setParentTabTreeNode(TabTreeNode parentTab) {
+ this.parentTabTreeNode = parentTab;
+ }
+
+ }
}
diff -r cd86af3f3207 -r c287d1f2a912
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseTemplateProcessor.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseTemplateProcessor.java
Thu Jan 27 10:28:26 2011 +0100
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseTemplateProcessor.java
Thu Jan 27 13:10:58 2011 +0100
@@ -155,7 +155,7 @@
*/
protected String readTemplateSourceFromClasspath(String path) {
try {
- final URL url = this.getClass().getResource(path.trim());
+ final URL url = this.getClass().getResource(path.trim().replace(" ",
"+"));
final File file = new File(url.toURI());
return readFileAsString(file);
} catch (Exception e) {
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits