details: /erp/devel/pi/rev/33b8779c6a76
changeset: 9097:33b8779c6a76
user: Iván Perdomo <ivan.perdomo <at> openbravo.com>
date: Mon Dec 13 14:11:43 2010 +0100
summary: Fixes issue 15399: Changed the way MyOB creates the widget instances
- The widget instances were preloaded as static resources in the call to
StaticResources. Now the widgets instances are not preloaded, they are
get using a call to reloadWidgets()
- The 'Get available widgets classes' now appends a definition
'isc.defineClass()' for all widget class definition to avoid requesting
again the same
- Removed tailing spaces from ob-myopenbravo.js
diffstat:
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java
| 28 +-
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoComponent.java
| 31 +-
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/templates/my_ob_js.ftl
| 13 +-
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
| 286 +++++----
4 files changed, 198 insertions(+), 160 deletions(-)
diffs (truncated from 973 to 300 lines):
diff -r f0e7e3fce561 -r 33b8779c6a76
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java
---
a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java
Mon Dec 13 13:00:09 2010 +0100
+++
b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java
Mon Dec 13 14:11:43 2010 +0100
@@ -88,18 +88,15 @@
availableAtLevelValue);
} else if (strEventType.equals(RELOAD_WIDGETS)) {
+ // Add available classes
+ addAvailableWidgetClasses(o);
+
+ // Add widget instances
widgets = new JSONArray();
reloadWidgets(isAdminMode, message, widgets, availableAtLevel,
availableAtLevelValue);
o.put("widgets", widgets);
} else if (strEventType.equals(GET_AVAILABLE_WIDGET_CLASSES)) {
- MyOpenbravoComponent component = new MyOpenbravoComponent();
- try {
- List<String> availableClasses =
component.getAvailableWidgetClasses();
- o.put("availableWidgetClasses", availableClasses);
- } catch (Exception e) {
- log.error("Error retreiving widget classes", e);
- o.put("availableWidgetClasses", Collections.EMPTY_LIST);
- }
+ addAvailableWidgetClasses(o);
} else {
message.setType("Error");
message.setMessage("@OBKMO_UnknownEventType@");
@@ -159,6 +156,21 @@
}
+ private void addAvailableWidgetClasses(JSONObject o) {
+ MyOpenbravoComponent component = new MyOpenbravoComponent();
+ try {
+ List<String> availableClasses = component.getAvailableWidgetClasses();
+ o.put("availableWidgetClasses", availableClasses);
+ } catch (Exception e) {
+ log.error("Error retreiving widget classes", e);
+ try {
+ o.put("availableWidgetClasses", Collections.EMPTY_LIST);
+ } catch (Exception ignore) {
+ // Give up
+ }
+ }
+ }
+
private void processWidgets(String strEventType, boolean isAdminMode,
OBError message,
JSONArray widgets, String availableAtLevel, String[]
availableAtLevelValue)
throws JSONException, OBException {
diff -r f0e7e3fce561 -r 33b8779c6a76
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoComponent.java
---
a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoComponent.java
Mon Dec 13 13:00:09 2010 +0100
+++
b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoComponent.java
Mon Dec 13 14:11:43 2010 +0100
@@ -87,12 +87,21 @@
}
final List<JSONObject> definitions = new ArrayList<JSONObject>();
+ final List<String> tmp = new ArrayList<String>();
+ String classDef = "";
final OBQuery<WidgetClass> widgetClassesQry =
OBDal.getInstance().createQuery(
WidgetClass.class, WidgetClass.PROPERTY_SUPERCLASS + " is false");
for (WidgetClass widgetClass : widgetClassesQry.list()) {
if (isAccessible(widgetClass)) {
final WidgetProvider widgetProvider =
MyOBUtils.getWidgetProvider(widgetClass);
definitions.add(widgetProvider.getWidgetClassDefinition());
+ try {
+ classDef = widgetProvider.generate();
+ classDef = classDef.substring(0, classDef.length() - 1);
+ tmp.add(classDef);
+ } catch (UnsupportedOperationException e) {
+ // Do nothing as the definition is already in a loaded js file
+ }
}
}
Collections.sort(definitions, new WidgetClassComparator());
@@ -101,7 +110,7 @@
for (JSONObject json : definitions) {
widgetClassDefinitions.add(json.toString());
}
-
+ widgetClassDefinitions.addAll(tmp);
log.debug("Available Widget Classes: " + widgetClassDefinitions.size());
return widgetClassDefinitions;
} finally {
@@ -211,8 +220,8 @@
copyWidgets();
widgets = new ArrayList<WidgetInstance>();
- final List<WidgetInstance> userWidgets = new ArrayList<WidgetInstance>(
- MyOBUtils.getUserWidgetInstances());
+ final List<WidgetInstance> userWidgets = new
ArrayList<WidgetInstance>(MyOBUtils
+ .getUserWidgetInstances());
log.debug("Defined User widgets:" + userWidgets.size());
// filter on the basis of role access
for (WidgetInstance widget : userWidgets) {
@@ -226,8 +235,8 @@
}
private void copyWidgets() {
- final List<WidgetInstance> userWidgets = new ArrayList<WidgetInstance>(
- MyOBUtils.getUserWidgetInstances());
+ final List<WidgetInstance> userWidgets = new
ArrayList<WidgetInstance>(MyOBUtils
+ .getUserWidgetInstances());
final User user = OBDal.getInstance().get(User.class,
OBContext.getOBContext().getUser().getId());
final Role role = OBDal.getInstance().get(Role.class,
@@ -239,12 +248,12 @@
final Set<WidgetInstance> defaultWidgets = new HashSet<WidgetInstance>();
defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("OB", null));
defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("SYSTEM", null));
- defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("CLIENT",
- new String[] { client.getId() }));
- defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("ORG",
- new String[] { organization.getId() }));
- defaultWidgets
- .addAll(MyOBUtils.getDefaultWidgetInstances("ROLE", new String[] {
role.getId() }));
+ defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("CLIENT", new
String[] { client
+ .getId() }));
+ defaultWidgets.addAll(MyOBUtils.getDefaultWidgetInstances("ORG", new
String[] { organization
+ .getId() }));
+ defaultWidgets.addAll(MyOBUtils
+ .getDefaultWidgetInstances("ROLE", new String[] { role.getId() }));
log.debug("Copying new widget instances on user: " + user.getId() + "
role: " + role.getId());
// remove the default widgets which are already defined on the user
diff -r f0e7e3fce561 -r 33b8779c6a76
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/templates/my_ob_js.ftl
---
a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/templates/my_ob_js.ftl
Mon Dec 13 13:00:09 2010 +0100
+++
b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/templates/my_ob_js.ftl
Mon Dec 13 14:11:43 2010 +0100
@@ -20,18 +20,7 @@
isc.OBMyOpenbravoImplementation.addProperties({
enableAdminMode: ${data.enableAdminMode},
- adminModeValueMap: ${data.adminModeValueMap},
-
- availableWidgetClasses: [
- <#list data.availableWidgetClasses as widgetClassDefinition>
- ${widgetClassDefinition}<#if widgetClassDefinition_has_next>,</#if>
- </#list>
- ],
- widgets: [
- <#list data.widgetInstanceDefinitions as widgetInstanceDefinition>
- ${widgetInstanceDefinition}<#if widgetInstanceDefinition_has_next>,</#if>
- </#list>
- ]
+ adminModeValueMap: ${data.adminModeValueMap}
});
//isc.Page.loadStyleSheet('[SKIN]../org.openbravo.client.myob/ob-widget-styles.css?'
+ OB.Application.moduleVersionParameters['2758CD25B2704AF6BBAD10365FC82C06']);
diff -r f0e7e3fce561 -r 33b8779c6a76
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
---
a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
Mon Dec 13 13:00:09 2010 +0100
+++
b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
Mon Dec 13 14:11:43 2010 +0100
@@ -48,7 +48,7 @@
// a non my ob tab
return false;
},
-
+
// ** {{{ OBMyOpenbravo.isSameTab() }}} **
//
// Returns true if the passed tab info corresponds to this instance,
@@ -60,25 +60,25 @@
isSameTab: function(viewId, params){
return this.isEqualParams(params);
},
-
+
// makes sure that only one MyOB tab is loaded, see equalParams
// implementation above
myOB: true,
-
+
// the widgetinstances already created for the user
widgets: [],
-
+
// the allowed widget types the user may/can create
availableWidgetClasses: [],
-
+
// reference back to the portalLayout creating the widget
portalLayout: null,
-
+
// reference to the left column layout
leftColumnLayout: null,
-
+
isReloading: false,
-
+
// Admin Mode
enableAdminMode: false,
adminModeValueMap: {},
@@ -86,7 +86,7 @@
adminMode: false,
adminLevel: '',
adminLevelValue: '',
-
+
initWidget: function(args){
var me = this, i, widgetInstance, recentViewsLayout, addWidgetLayout,
adminOtherMyOBLayout, refreshLayout;
@@ -102,20 +102,20 @@
baseStyle: 'OBMyOBRecentViews',
contents: OB.I18N.getLabel('OBKMO_RecentViews')
}));
-
+
recentViewsLinksLayout = isc.VLayout.create({
height: 1,
overflow: 'visible'
});
recentViewsLayout.addMember(recentViewsLinksLayout);
this.setRecentList(recentViewsLinksLayout);
-
+
OB.PropertyStore.addListener(function(propertyName, currentValue,
newValue){
if (propertyName === 'UINAVBA_RecentLaunchList') {
me.setRecentList(recentViewsLinksLayout);
}
});
-
+
var actionTitle = isc.VLayout.create({
height: 1,
overflow: 'visible'
@@ -126,7 +126,7 @@
baseStyle: 'OBMyOBRecentViews',
contents: OB.I18N.getLabel('OBKMO_Manage_MyOpenbravo')
}));
-
+
refreshLayout = isc.VLayout.create({
height: 1,
overflow: 'visible'
@@ -141,7 +141,7 @@
OB.MyOB.reloadWidgets();
}
}));
-
+
// the available widget classes the user may/can create
addWidgetLayout = isc.VLayout.create({
height: 1,
@@ -163,7 +163,7 @@
this.addWidgetLayout.addMember(addWidgetDialog);
}
}));
-
+
if (this.enableAdminMode) {
adminOtherMyOBLayout = isc.VLayout.create({});
adminOtherMyOBLayout.addMember(isc.Label.create({
@@ -187,7 +187,7 @@
}
}));
}
-
+
// the left layout containing the recent views and available widgets
this.leftColumnLayout = isc.VStack.create({
styleName: 'OBMyOBLeftColumn',
@@ -207,9 +207,9 @@
this.leftColumnLayout.addWidgetLayout = addWidgetLayout;
this.leftColumnLayout.adminOtherMyOBLayout = adminOtherMyOBLayout;
this.leftColumnLayout.refreshLayout = refreshLayout;
-
+
this.addMember(this.leftColumnLayout);
-
+
// the portallayout containing the widgets
this.portalLayout = isc.PortalLayout.create({
styleName: 'OBMyOBPortal',
@@ -223,7 +223,7 @@
overflow: 'auto',
height: '100%',
sendEvents: false,
-
+
// the PortalColumn is an autochild of the PortalLayout with the
// child name of 'column', the properties of the PortalColumn
// can be set like this using the AutoChild concept of SC
@@ -239,7 +239,7 @@
return false;
}
},
-
+
// after dropping create the widget here
getDropComponent: function(dragTarget, position){
if (dragTarget.createWidgetInstance) {
@@ -248,24 +248,24 @@
this.Super('getDropComponent', arguments);
}
},
-
+
// copied from PortalColumn to set fixed row heights based
// on the portlets height, see the NOTE line below
addPortlet: function(portlet, position){
------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages,
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits