svn commit: r639358 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen: ModelScreen.java ModelScreenWidget.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r639358 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen: ModelScreen.java ModelScreenWidget.java

jacopoc
Author: jacopoc
Date: Thu Mar 20 10:01:13 2008
New Revision: 639358

URL: http://svn.apache.org/viewvc?rev=639358&view=rev
Log:
Improved methods to retrieve all the entities used by a screen.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=639358&r1=639357&r2=639358&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Thu Mar 20 10:01:13 2008
@@ -21,6 +21,7 @@
 import java.io.Serializable;
 import java.io.Writer;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -101,22 +102,65 @@
     }
     public Set<String> getAllEntityNamesUsed() {
         Set<String> allEntityNamesUsed = FastSet.newInstance();
-        findEntityNamesUsedInSection(this.section, allEntityNamesUsed);
+        findEntityNamesUsedInWidget(this.section, allEntityNamesUsed);
         return allEntityNamesUsed;
     }
-    protected static void findEntityNamesUsedInSection(ModelScreenWidget.Section currentSection, Set<String> allEntityNamesUsed) {
-        currentSection.findEntityNamesUsed(allEntityNamesUsed);
-        if (currentSection.subWidgets != null) {
-            for (ModelScreenWidget widget: currentSection.subWidgets) {
-                if (widget instanceof ModelScreenWidget.Section) {
-                    findEntityNamesUsedInSection((ModelScreenWidget.Section)widget, allEntityNamesUsed);
+    protected static void findEntityNamesUsedInWidget(ModelScreenWidget currentWidget, Set<String> allEntityNamesUsed) {
+        if (currentWidget instanceof ModelScreenWidget.Section) {
+            List<ModelScreenAction> actions = ((ModelScreenWidget.Section)currentWidget).actions;
+            List<ModelScreenWidget> subWidgets = ((ModelScreenWidget.Section)currentWidget).subWidgets;
+            List<ModelScreenWidget> failWidgets = ((ModelScreenWidget.Section)currentWidget).failWidgets;
+            if (actions != null) {
+                for (ModelScreenAction screenOperation: actions) {
+                    if (screenOperation instanceof ModelScreenAction.EntityOne) {
+                        String entName = ((ModelScreenAction.EntityOne) screenOperation).finder.getEntityName();
+                        if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
+                    } else if (screenOperation instanceof ModelScreenAction.EntityAnd) {
+                        String entName = ((ModelScreenAction.EntityAnd) screenOperation).finder.getEntityName();
+                        if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
+                    } else if (screenOperation instanceof ModelScreenAction.EntityCondition) {
+                        String entName = ((ModelScreenAction.EntityCondition) screenOperation).finder.getEntityName();
+                        if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
+                    }
                 }
             }
-        }
-        if (currentSection.failWidgets != null) {
-            for (ModelScreenWidget widget: currentSection.failWidgets) {
-                if (widget instanceof ModelScreenWidget.Section) {
-                    findEntityNamesUsedInSection((ModelScreenWidget.Section)widget, allEntityNamesUsed);
+            if (subWidgets != null) {
+                for (ModelScreenWidget widget: subWidgets) {
+                    findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
+                }
+            }
+            if (failWidgets != null) {
+                for (ModelScreenWidget widget: failWidgets) {
+                    findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
+            ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection)currentWidget;
+            if (decoratorSection.subWidgets != null) {
+                for (ModelScreenWidget widget: decoratorSection.subWidgets) {
+                    findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.DecoratorScreen) {
+            ModelScreenWidget.DecoratorScreen decoratorScreen = (ModelScreenWidget.DecoratorScreen)currentWidget;
+            if (decoratorScreen.sectionMap != null) {
+                Collection<ModelScreenWidget.DecoratorSection> sections = decoratorScreen.sectionMap.values();
+                for (ModelScreenWidget section: sections) {
+                    findEntityNamesUsedInWidget(section, allEntityNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.Container) {
+            ModelScreenWidget.Container container = (ModelScreenWidget.Container)currentWidget;
+            if (container.subWidgets != null) {
+                for (ModelScreenWidget widget: container.subWidgets) {
+                    findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
+            ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet)currentWidget;
+            if (screenlet.subWidgets != null) {
+                for (ModelScreenWidget widget: screenlet.subWidgets) {
+                    findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
                 }
             }
         }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=639358&r1=639357&r2=639358&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Thu Mar 20 10:01:13 2008
@@ -201,22 +201,6 @@
             }
         }
         
-        public void findEntityNamesUsed(Set<String> allEntityNames) {
-            if (this.actions != null) {
-                for (ModelScreenAction screenOperation: this.actions) {
-                    if (screenOperation instanceof ModelScreenAction.EntityOne) {
-                        String entName = ((ModelScreenAction.EntityOne) screenOperation).finder.getEntityName();
-                        if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
-                    } else if (screenOperation instanceof ModelScreenAction.EntityAnd) {
-                        String entName = ((ModelScreenAction.EntityAnd) screenOperation).finder.getEntityName();
-                        if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
-                    } else if (screenOperation instanceof ModelScreenAction.EntityCondition) {
-                        String entName = ((ModelScreenAction.EntityCondition) screenOperation).finder.getEntityName();
-                        if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
-                    }
-                }
-            }
-        }
         public void findServiceNamesUsed(Set<String> allServiceNames) {
             if (this.actions != null) {
                 for (ModelScreenAction screenOperation: this.actions) {