svn commit: r1636137 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: ModelActionVisitor.java artifact/ArtifactInfoGatherer.java tree/ModelTree.java tree/ModelTreeAction.java

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

svn commit: r1636137 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: ModelActionVisitor.java artifact/ArtifactInfoGatherer.java tree/ModelTree.java tree/ModelTreeAction.java

adrianc
Author: adrianc
Date: Sun Nov  2 14:03:02 2014
New Revision: 1636137

URL: http://svn.apache.org/r1636137
Log:
Delegate most tree widget actions to ModelWidgetAction. Tree nodes will support an <actions> element like other widgets, but that is still a WIP.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java?rev=1636137&r1=1636136&r2=1636137&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java Sun Nov  2 14:03:02 2014
@@ -20,6 +20,7 @@ package org.ofbiz.widget;
 
 import org.ofbiz.widget.form.ModelFormAction;
 import org.ofbiz.widget.menu.ModelMenuAction;
+import org.ofbiz.widget.tree.ModelTreeAction;
 
 /**
  *  A <code>ModelWidgetAction</code> visitor.
@@ -55,4 +56,12 @@ public interface ModelActionVisitor {
     void visit(ModelFormAction.EntityCondition entityCondition);
 
     void visit(ModelMenuAction.SetField setField);
+
+    void visit(ModelTreeAction.Script script);
+
+    void visit(ModelTreeAction.Service service);
+
+    void visit(ModelTreeAction.EntityAnd entityAnd);
+
+    void visit(ModelTreeAction.EntityCondition entityCondition);
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java?rev=1636137&r1=1636136&r2=1636137&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java Sun Nov  2 14:03:02 2014
@@ -96,6 +96,7 @@ import org.ofbiz.widget.screen.ModelScre
 import org.ofbiz.widget.screen.ModelScreenWidget.Section;
 import org.ofbiz.widget.screen.ModelScreenWidget.Tree;
 import org.ofbiz.widget.tree.ModelTree;
+import org.ofbiz.widget.tree.ModelTreeAction;
 
 /**
  * An object that gathers artifact information from screen widgets.
@@ -293,7 +294,6 @@ public final class ArtifactInfoGatherer
         String screenLocation = modelScreen.getSourceLocation().concat("#").concat(modelScreen.getName());
         infoContext.addScreenLocation(screenLocation);
         modelScreen.getSection().accept(this);
-        ;
     }
 
     @Override
@@ -416,6 +416,22 @@ public final class ArtifactInfoGatherer
     public void visit(ModelTree modelTree) {
     }
 
+    @Override
+    public void visit(ModelTreeAction.EntityAnd entityAnd) {
+    }
+
+    @Override
+    public void visit(ModelTreeAction.EntityCondition entityCondition) {
+    }
+
+    @Override
+    public void visit(ModelTreeAction.Script script) {
+    }
+
+    @Override
+    public void visit(ModelTreeAction.Service service) {
+    }
+
     private class FieldInfoGatherer implements ModelFieldVisitor {
 
         private void addRequestLocations(String target, String urlMode) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=1636137&r1=1636136&r2=1636137&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Sun Nov  2 14:03:02 2014
@@ -21,6 +21,7 @@ package org.ofbiz.widget.tree;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -50,6 +51,7 @@ import org.ofbiz.entity.model.ModelField
 import org.ofbiz.entity.util.EntityListIterator;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.ModelWidgetAction;
 import org.ofbiz.widget.ModelWidgetVisitor;
 import org.ofbiz.widget.WidgetWorker;
 import org.ofbiz.widget.screen.ModelScreen;
@@ -67,21 +69,21 @@ public class ModelTree extends ModelWidg
 
     public static final String module = ModelTree.class.getName();
 
-    protected String treeLocation;
-    protected String rootNodeName;
+    protected String defaultEntityName;
+    protected String defaultPkName;
     protected String defaultRenderStyle;
     protected FlexibleStringExpander defaultWrapStyleExdr;
-    protected List<ModelNode> nodeList = new ArrayList<ModelNode>();
-    protected Map<String, ModelNode> nodeMap = new HashMap<String, ModelNode>();
     protected Delegator delegator;
     protected LocalDispatcher dispatcher;
     protected FlexibleStringExpander expandCollapseRequestExdr;
-    protected FlexibleStringExpander trailNameExdr;
+    protected boolean forceChildCheck;
+    protected List<ModelNode> nodeList = new ArrayList<ModelNode>();
+    protected Map<String, ModelNode> nodeMap = new HashMap<String, ModelNode>();
     protected int openDepth;
     protected int postTrailOpenDepth;
-    protected String defaultEntityName;
-    protected String defaultPkName;
-    protected boolean forceChildCheck;
+    protected String rootNodeName;
+    protected FlexibleStringExpander trailNameExdr;
+    protected String treeLocation;
 
 // ===== CONSTRUCTORS =====
     /** Default Constructor */
@@ -125,7 +127,6 @@ public class ModelTree extends ModelWidg
         if (nodeList.size() == 0) {
             throw new IllegalArgumentException("No node elements found for the tree definition with name: " + getName());
         }
-
     }
 
     public void setDefaultEntityName(String name) {
@@ -272,31 +273,29 @@ public class ModelTree extends ModelWidg
     }
 
 
-    public static class ModelNode {
+    public static class ModelNode extends ModelWidget {
 
-        protected FlexibleStringExpander screenNameExdr;
-        protected FlexibleStringExpander screenLocationExdr;
-        protected String shareScope;
+        private final List<ModelWidgetAction> actions;
+        protected ModelTreeCondition condition;
+        protected String entityName;
+        protected String entryName;
+        protected String expandCollapseStyle;
+        protected Image image;
         protected Label label;
         protected Link link;
-        protected Image image;
-        protected List<ModelSubNode> subNodeList = new ArrayList<ModelSubNode>();
-        protected List<ModelTreeAction> actions = new ArrayList<ModelTreeAction>();
-        protected String name;
         protected ModelTree modelTree;
+        protected String name;
+        protected String pkName;
+        protected String renderStyle;
+        protected FlexibleStringExpander screenLocationExdr;
+        protected FlexibleStringExpander screenNameExdr;
+        protected String shareScope;
+        protected List<ModelSubNode> subNodeList = new ArrayList<ModelSubNode>();
         protected List<Object []> subNodeValues;
-        protected String expandCollapseStyle;
         protected FlexibleStringExpander wrapStyleExdr;
-        protected ModelTreeCondition condition;
-        protected String renderStyle;
-        protected String entryName;
-        protected String entityName;
-        protected String pkName;
-
-        public ModelNode() {}
 
         public ModelNode(Element nodeElement, ModelTree modelTree) {
-
+            super(nodeElement);
             this.modelTree = modelTree;
             this.name = nodeElement.getAttribute("name");
             this.expandCollapseStyle = nodeElement.getAttribute("expand-collapse-style");
@@ -306,21 +305,25 @@ public class ModelTree extends ModelWidg
             setEntityName(nodeElement.getAttribute("entity-name"));
             if (this.pkName == null || nodeElement.hasAttribute("join-field-name"))
                 this.pkName = nodeElement.getAttribute("join-field-name");
-
+            ArrayList<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>();
+            Element actionsElement = UtilXml.firstChildElement(nodeElement, "actions");
+            if (actionsElement != null) {
+                actions.addAll(ModelTreeAction.readNodeActions(this, actionsElement));
+            }
             Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-one");
             if (actionElement != null) {
-               actions.add(new ModelTreeAction.EntityOne(this, actionElement));
+               actions.add(new ModelWidgetAction.EntityOne(this, actionElement));
             }
-
             actionElement = UtilXml.firstChildElement(nodeElement, "service");
             if (actionElement != null) {
                 actions.add(new ModelTreeAction.Service(this, actionElement));
             }
-
             actionElement = UtilXml.firstChildElement(nodeElement, "script");
             if (actionElement != null) {
                 actions.add(new ModelTreeAction.Script(this, actionElement));
             }
+            actions.trimToSize();
+            this.actions = Collections.unmodifiableList(actions);
 
             Element screenElement = UtilXml.firstChildElement(nodeElement, "include-screen");
             if (screenElement != null) {
@@ -547,9 +550,9 @@ public class ModelTree extends ModelWidg
              for (ModelSubNode subNode: subNodeList) {
                  String nodeName = subNode.getNodeName(context);
                  ModelNode node = modelTree.nodeMap.get(nodeName);
-                 List<ModelTreeAction> subNodeActions = subNode.getActions();
+                 List<ModelWidgetAction> subNodeActions = subNode.getActions();
                  //if (Debug.infoOn()) Debug.logInfo(" context.currentValue:" + context.get("currentValue"), module);
-                 ModelTreeAction.runSubActions(subNodeActions, context);
+                 ModelWidgetAction.runSubActions(subNodeActions, context);
                  // List dataFound = (List)context.get("dataFound");
                  Iterator<? extends Map<String, ? extends Object>> dataIter =  subNode.getListIterator();
                  if (dataIter instanceof EntityListIterator) {
@@ -693,40 +696,40 @@ public class ModelTree extends ModelWidg
             this.pkName = pkName;
         }
 
-        public static class ModelSubNode {
+        public static class ModelSubNode extends ModelWidget {
 
+            private final List<ModelWidgetAction> actions;
             protected ModelNode rootNode;
             protected FlexibleStringExpander nodeNameExdr;
-            protected List<ModelTreeAction> actions = new ArrayList<ModelTreeAction>();
             protected ListIterator<? extends Map<String, ? extends Object>> listIterator;
 
-            public ModelSubNode() {}
-
-            public ModelSubNode(Element nodeElement, ModelNode modelNode) {
-
+            public ModelSubNode(Element subNodeElement, ModelNode modelNode) {
+                super(subNodeElement);
                 this.rootNode = modelNode;
-                this.nodeNameExdr = FlexibleStringExpander.getInstance(nodeElement.getAttribute("node-name"));
-
-                Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-and");
+                this.nodeNameExdr = FlexibleStringExpander.getInstance(subNodeElement.getAttribute("node-name"));
+                ArrayList<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>();
+                Element actionsElement = UtilXml.firstChildElement(subNodeElement, "actions");
+                if (actionsElement != null) {
+                    actions.addAll(ModelTreeAction.readNodeActions(this, actionsElement));
+                }
+                Element actionElement = UtilXml.firstChildElement(subNodeElement, "entity-and");
                 if (actionElement != null) {
                    actions.add(new ModelTreeAction.EntityAnd(this, actionElement));
                 }
-
-                actionElement = UtilXml.firstChildElement(nodeElement, "service");
+                actionElement = UtilXml.firstChildElement(subNodeElement, "service");
                 if (actionElement != null) {
                     actions.add(new ModelTreeAction.Service(this, actionElement));
                 }
-
-                actionElement = UtilXml.firstChildElement(nodeElement, "entity-condition");
+                actionElement = UtilXml.firstChildElement(subNodeElement, "entity-condition");
                 if (actionElement != null) {
                     actions.add(new ModelTreeAction.EntityCondition(this, actionElement));
                 }
-
-                actionElement = UtilXml.firstChildElement(nodeElement, "script");
+                actionElement = UtilXml.firstChildElement(subNodeElement, "script");
                 if (actionElement != null) {
                     actions.add(new ModelTreeAction.Script(this, actionElement));
                 }
-
+                actions.trimToSize();
+                this.actions = Collections.unmodifiableList(actions);
             }
 
             public ModelTree.ModelNode getNode() {
@@ -737,7 +740,7 @@ public class ModelTree extends ModelWidg
                 return this.nodeNameExdr.expandString(context);
             }
 
-            public List<ModelTreeAction> getActions() {
+            public List<ModelWidgetAction> getActions() {
                 return actions;
             }
 
@@ -748,6 +751,12 @@ public class ModelTree extends ModelWidg
             public ListIterator<? extends Map<String, ? extends Object>> getListIterator() {
                 return listIterator;
             }
+
+            @Override
+            public void accept(ModelWidgetVisitor visitor) {
+                // TODO Auto-generated method stub
+                
+            }
         }
 
         public static class Label {
@@ -1106,6 +1115,12 @@ public class ModelTree extends ModelWidg
                 }
             }
         }
+
+        @Override
+        public void accept(ModelWidgetVisitor visitor) {
+            // TODO Auto-generated method stub
+            
+        }
     }
 
     @Override

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=1636137&r1=1636136&r2=1636137&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Sun Nov  2 14:03:02 2014
@@ -18,19 +18,16 @@
  *******************************************************************************/
 package org.ofbiz.widget.tree;
 
+import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
-import java.util.Locale;
 import java.util.Map;
-import java.util.TimeZone;
 import java.util.regex.PatternSyntaxException;
 
-import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.ScriptUtil;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilValidate;
@@ -40,177 +37,104 @@ import org.ofbiz.base.util.string.Flexib
 import org.ofbiz.entity.finder.ByAndFinder;
 import org.ofbiz.entity.finder.ByConditionFinder;
 import org.ofbiz.entity.finder.EntityFinderUtil;
-import org.ofbiz.entity.finder.PrimaryKeyFinder;
 import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
+import org.ofbiz.widget.ModelActionVisitor;
+import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.ModelWidgetAction;
+import org.ofbiz.widget.WidgetWorker;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
  * Widget Library - Tree model class
  */
-public abstract class ModelTreeAction {
+@SuppressWarnings("serial")
+public abstract class ModelTreeAction extends ModelWidgetAction {
+
     public static final String module = ModelTreeAction.class.getName();
 
     protected ModelTree modelTree;
-    protected ModelTree.ModelNode modelNode;
     protected ModelTree.ModelNode.ModelSubNode modelSubNode;
 
     public ModelTreeAction(ModelTree.ModelNode modelNode, Element actionElement) {
         if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module);
-        this.modelNode = modelNode;
         this.modelTree = modelNode.getModelTree();
     }
 
     public ModelTreeAction(ModelTree.ModelNode.ModelSubNode modelSubNode, Element actionElement) {
         if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module);
         this.modelSubNode = modelSubNode;
-        this.modelNode = this.modelSubNode.getNode();
-        this.modelTree = this.modelNode.getModelTree();
+        this.modelTree = modelSubNode.getNode().getModelTree();
     }
 
-    public abstract void runAction(Map<String, Object> context);
-
-/*
-    public static List readSubActions(ModelTree.ModelNode modelNode, Element parentElement) {
-        List actions = new LinkedList();
-
-        List actionElementList = UtilXml.childElementList(parentElement);
-        Iterator actionElementIter = actionElementList.iterator();
-        while (actionElementIter.hasNext()) {
-            Element actionElement = (Element) actionElementIter.next();
-            if ("set".equals(actionElement.getNodeName())) {
-                actions.add(new SetField(modelTree, actionElement));
-            } else if ("script".equals(actionElement.getNodeName())) {
-                actions.add(new Script(modelTree, actionElement));
-            } else if ("service".equals(actionElement.getNodeName())) {
-                actions.add(new Service(modelTree, actionElement));
-            } else if ("entity-one".equals(actionElement.getNodeName())) {
-                actions.add(new EntityOne(modelTree, actionElement));
-            } else if ("entity-and".equals(actionElement.getNodeName())) {
-                actions.add(new EntityAnd(modelTree, actionElement));
-            } else if ("entity-condition".equals(actionElement.getNodeName())) {
-                actions.add(new EntityCondition(modelTree, actionElement));
-            } else {
-                throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName());
-            }
+    public static List<ModelWidgetAction> readNodeActions(ModelWidget modelNode, Element actionsElement) {
+        List<? extends Element> actionElementList = UtilXml.childElementList(actionsElement);
+        List<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>(actionElementList.size());
+        for (Element actionElement : actionElementList) {
+            // TODO: Check for tree-specific actions
+            actions.add(ModelWidgetAction.toModelWidgetAction(modelNode, actionElement));
         }
-
         return actions;
     }
-    */
-
-    public static void runSubActions(List<? extends ModelTreeAction> actions, Map<String, Object> context) {
-        for (ModelTreeAction action: actions) {
-            if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module);
-            action.runAction(context);
-        }
-    }
-
-    public static class SetField extends ModelTreeAction {
-        protected FlexibleMapAccessor<Object> field;
-        protected FlexibleMapAccessor<Object> fromField;
-        protected FlexibleStringExpander valueExdr;
-        protected FlexibleStringExpander globalExdr;
-        protected String type;
-
-        public SetField(ModelTree.ModelNode modelNode, Element setElement) {
-            super (modelNode, setElement);
-            this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field"));
-            this.fromField = FlexibleMapAccessor.getInstance(setElement.getAttribute("from-field"));
-            this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value"));
-            this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
-            this.type = setElement.getAttribute("type");
-            if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
-                throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a tree widget");
-            }
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        public void runAction(Map<String, Object> context) {
-            String globalStr = this.globalExdr.expandString(context);
-            // default to false
-            boolean global = "true".equals(globalStr);
-
-            Object newValue = null;
-            if (!this.fromField.isEmpty()) {
-                newValue = this.fromField.get(context);
-            } else if (!this.valueExdr.isEmpty()) {
-                newValue = this.valueExdr.expandString(context);
-            }
-            if (UtilValidate.isNotEmpty(this.type)) {
-                if ("NewMap".equals(this.type)) {
-                    newValue = new HashMap();
-                } else if ("NewList".equals(this.type)) {
-                    newValue = new LinkedList();
-                } else {
-                    try {
-                        newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
-                    } catch (GeneralException e) {
-                        String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString();
-                        Debug.logError(e, errMsg, module);
-                        throw new IllegalArgumentException(errMsg);
-                    }
-                }
-            }
-            this.field.put(context, newValue);
-
-            if (global) {
-                Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
-                if (globalCtx != null) {
-                    this.field.put(globalCtx, newValue);
-                }
-            }
-
-            // this is a hack for backward compatibility with the JPublish page object
-            Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
-            if (page != null) {
-                this.field.put(page, newValue);
-            }
-        }
-    }
 
     public static class Script extends ModelTreeAction {
         protected String location;
+        protected String method;
 
         public Script(ModelTree.ModelNode modelNode, Element scriptElement) {
             super (modelNode, scriptElement);
-            this.location = scriptElement.getAttribute("location");
+            String scriptLocation = scriptElement.getAttribute("location");
+            this.location = WidgetWorker.getScriptLocation(scriptLocation);
+            this.method = WidgetWorker.getScriptMethodName(scriptLocation);
         }
 
         public Script(ModelTree.ModelNode.ModelSubNode modelSubNode, Element scriptElement) {
             super (modelSubNode, scriptElement);
-            this.location = scriptElement.getAttribute("location");
+            String scriptLocation = scriptElement.getAttribute("location");
+            this.location = WidgetWorker.getScriptLocation(scriptLocation);
+            this.method = WidgetWorker.getScriptMethodName(scriptLocation);
         }
 
         @Override
         public void runAction(Map<String, Object> context) {
-            if (location.endsWith(".bsh")) {
+            context.put("_LIST_ITERATOR_", null);
+            if (location.endsWith(".xml")) {
+                Map<String, Object> localContext = new HashMap<String, Object>();
+                localContext.putAll(context);
+                DispatchContext ctx = WidgetWorker.getDispatcher(context).getDispatchContext();
+                MethodContext methodContext = new MethodContext(ctx, localContext, null);
                 try {
-                    context.put("_LIST_ITERATOR_", null);
-                    BshUtil.runBshAtLocation(location, context);
-                    Object obj = context.get("_LIST_ITERATOR_");
-                    if (this.modelSubNode != null) {
-                        if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
-                            ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
-                            this.modelSubNode.setListIterator(listIt);
-                        } else {
-                            if (obj instanceof List<?>) {
-                                List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
-                                this.modelSubNode.setListIterator(list.listIterator());
-                            }
-                        }
-                    }
-                } catch (GeneralException e) {
-                    String errMsg = "Error running BSH script at location [" + location + "]: " + e.toString();
-                    Debug.logError(e, errMsg, module);
-                    throw new IllegalArgumentException(errMsg);
+                    SimpleMethod.runSimpleMethod(location, method, methodContext);
+                    context.putAll(methodContext.getResults());
+                } catch (MiniLangException e) {
+                    throw new RuntimeException("Error running simple method at location [" + location + "]", e);
                 }
             } else {
-                throw new IllegalArgumentException("For tree script actions the script type is not yet support for location:" + location);
+                ScriptUtil.executeScript(this.location, this.method, context);
             }
+            Object obj = context.get("_LIST_ITERATOR_");
+            if (this.modelSubNode != null) {
+                if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
+                    ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
+                    this.modelSubNode.setListIterator(listIt);
+                } else {
+                    if (obj instanceof List<?>) {
+                        List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
+                        this.modelSubNode.setListIterator(list.listIterator());
+                    }
+                }
+            }
+        }
+
+        @Override
+        public void accept(ModelActionVisitor visitor) {
+            visitor.visit(this);
         }
     }
 
@@ -323,31 +247,10 @@ public abstract class ModelTreeAction {
                 throw new IllegalArgumentException(errMsg);
             }
         }
-    }
-
-    public static class EntityOne extends ModelTreeAction {
-        protected PrimaryKeyFinder finder;
-        String valueName;
-
-        public EntityOne(ModelTree.ModelNode modelNode, Element entityOneElement) {
-            super (modelNode, entityOneElement);
-
-            this.valueName = UtilFormatOut.checkEmpty(entityOneElement.getAttribute("value"), entityOneElement.getAttribute("value-name"));
-            if (UtilValidate.isEmpty(this.valueName)) this.valueName = null;
-            entityOneElement.setAttribute("value", this.valueName);
-
-            finder = new PrimaryKeyFinder(entityOneElement);
-        }
 
         @Override
-        public void runAction(Map<String, Object> context) {
-            try {
-                finder.runFind(context, this.modelTree.getDelegator());
-            } catch (GeneralException e) {
-                String errMsg = "Error doing entity query by condition: " + e.toString();
-                Debug.logError(e, errMsg, module);
-                throw new IllegalArgumentException(errMsg);
-            }
+        public void accept(ModelActionVisitor visitor) {
+            visitor.visit(this);
         }
     }
 
@@ -389,6 +292,11 @@ public abstract class ModelTreeAction {
                 throw new IllegalArgumentException(errMsg);
             }
         }
+
+        @Override
+        public void accept(ModelActionVisitor visitor) {
+            visitor.visit(this);
+        }
     }
 
     public static class EntityCondition extends ModelTreeAction {
@@ -429,5 +337,10 @@ public abstract class ModelTreeAction {
                 throw new IllegalArgumentException(errMsg);
             }
         }
+
+        @Override
+        public void accept(ModelActionVisitor visitor) {
+            visitor.visit(this);
+        }
     }
 }