svn commit: r639374 - in /ofbiz/trunk/framework: webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java widget/src/org/ofbiz/widget/screen/ModelScreen.java widget/src/org/ofbiz/widget/screen/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: r639374 - in /ofbiz/trunk/framework: webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java widget/src/org/ofbiz/widget/screen/ModelScreen.java widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java

jacopoc
Author: jacopoc
Date: Thu Mar 20 10:22:55 2008
New Revision: 639374

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

Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    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/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=639374&r1=639373&r2=639374&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Thu Mar 20 10:22:55 2008
@@ -244,7 +244,7 @@
     }
     
     public ModelForm getModelForm(String formNameAndLocation) throws ParserConfigurationException, SAXException, IOException {
-        return getModelForm(formNameAndLocation.substring(0, formNameAndLocation.indexOf("#")), formNameAndLocation.substring(formNameAndLocation.indexOf("#")));
+        return getModelForm(formNameAndLocation.substring(formNameAndLocation.indexOf("#") + 1), formNameAndLocation.substring(0, formNameAndLocation.indexOf("#")));
     }
     public ModelForm getModelForm(String formName, String formLocation) throws ParserConfigurationException, SAXException, IOException {
         return FormFactory.getFormFromLocation(formLocation, formName, this.entityModelReader, this.dispatchContext);
@@ -294,7 +294,7 @@
     }
     
     public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formNameAndLocation) throws GeneralException {
-        return getFormWidgetArtifactInfo(formNameAndLocation.substring(0, formNameAndLocation.indexOf("#")), formNameAndLocation.substring(formNameAndLocation.indexOf("#")));
+        return getFormWidgetArtifactInfo(formNameAndLocation.substring(formNameAndLocation.indexOf("#") + 1), formNameAndLocation.substring(0, formNameAndLocation.indexOf("#")));
     }
     public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formName, String formLocation) throws GeneralException {
         FormWidgetArtifactInfo curInfo = this.allFormInfos.get(formLocation + "#" + formName);

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=639374&r1=639373&r2=639374&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:22:55 2008
@@ -80,22 +80,60 @@
 
     public Set<String> getAllServiceNamesUsed() {
         Set<String> allServiceNamesUsed = FastSet.newInstance();
-        findServiceNamesUsedInSection(this.section, allServiceNamesUsed);
+        findServiceNamesUsedInWidget(this.section, allServiceNamesUsed);
         return allServiceNamesUsed;
     }
-    protected static void findServiceNamesUsedInSection(ModelScreenWidget.Section currentSection, Set<String> allServiceNamesUsed) {
-        currentSection.findServiceNamesUsed(allServiceNamesUsed);
-        if (currentSection.subWidgets != null) {
-            for (ModelScreenWidget widget: currentSection.subWidgets) {
-                if (widget instanceof ModelScreenWidget.Section) {
-                    findServiceNamesUsedInSection((ModelScreenWidget.Section)widget, allServiceNamesUsed);
+
+    protected static void findServiceNamesUsedInWidget(ModelScreenWidget currentWidget, Set<String> allServiceNamesUsed) {
+        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.Service) {
+                        String serviceName = ((ModelScreenAction.Service) screenOperation).serviceNameExdr.getOriginal();
+                        if (UtilValidate.isNotEmpty(serviceName)) allServiceNamesUsed.add(serviceName);
+                    }
                 }
             }
-        }
-        if (currentSection.failWidgets != null) {
-            for (ModelScreenWidget widget: currentSection.failWidgets) {
-                if (widget instanceof ModelScreenWidget.Section) {
-                    findServiceNamesUsedInSection((ModelScreenWidget.Section)widget, allServiceNamesUsed);
+            if (subWidgets != null) {
+                for (ModelScreenWidget widget: subWidgets) {
+                    findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
+                }
+            }
+            if (failWidgets != null) {
+                for (ModelScreenWidget widget: failWidgets) {
+                    findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
+            ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection)currentWidget;
+            if (decoratorSection.subWidgets != null) {
+                for (ModelScreenWidget widget: decoratorSection.subWidgets) {
+                    findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
+                }
+            }
+        } 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) {
+                    findServiceNamesUsedInWidget(section, allServiceNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.Container) {
+            ModelScreenWidget.Container container = (ModelScreenWidget.Container)currentWidget;
+            if (container.subWidgets != null) {
+                for (ModelScreenWidget widget: container.subWidgets) {
+                    findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
+                }
+            }
+        } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
+            ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet)currentWidget;
+            if (screenlet.subWidgets != null) {
+                for (ModelScreenWidget widget: screenlet.subWidgets) {
+                    findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
                 }
             }
         }

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=639374&r1=639373&r2=639374&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:22:55 2008
@@ -200,17 +200,6 @@
                 this.failWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, failElementList);
             }
         }
-        
-        public void findServiceNamesUsed(Set<String> allServiceNames) {
-            if (this.actions != null) {
-                for (ModelScreenAction screenOperation: this.actions) {
-                    if (screenOperation instanceof ModelScreenAction.Service) {
-                        String serviceName = ((ModelScreenAction.Service) screenOperation).serviceNameExdr.toString();
-                        if (UtilValidate.isNotEmpty(serviceName)) allServiceNames.add(serviceName);
-                    }
-                }
-            }
-        }
 
         public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
             // check the condition, if there is one