xworker.swt.object.ObjectTree Maven / Gradle / Ivy
package xworker.swt.object;
import ognl.Ognl;
import ognl.OgnlException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import org.xmeta.util.UtilMap;
import xworker.swt.ActionContainer;
import xworker.swt.util.ResourceManager;
import xworker.util.UtilData;
public class ObjectTree {
public static Object create(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
//创建树对象
ActionContext ac = new ActionContext();
ac.put("parent", actionContext.get("parent"));
ac.put("thing", self);
Thing treeThing = World.getInstance().getThing("xworker.swt.object.ObjectTree/@tree");
Tree tree = (Tree) treeThing.doAction("create", ac);
ActionContainer actions = (ActionContainer) ac.get("actions");
//创建子节点
actionContext.peek().put("parent", tree);
for(Thing child : self.getChilds()){
child.doAction("create", actionContext);
}
//如果有对象,那么显示
Object object = self.doAction("getObject", actionContext);
if(object != null){
actions.doAction("setObject", actionContext, UtilMap.toMap("object", object, "context", actionContext));
}
tree.setData(object);
tree.setData("thing", self);
actionContext.g().put(self.getMetadata().getName(), actions);
return tree;
}
public static void setObject(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
Tree tree = (Tree) actionContext.get("tree");
Object object = actionContext.get("object");
//先移除已有的所有节点
tree.removeAll();
ActionContext context = (ActionContext) actionContext.get("context");
context.peek().put("_object", object);
context.peek().put("_rootObject", object);
context.peek().put("treeItem", tree);
actionContext.peek().put("_object", object);
actionContext.peek().put("_rootObject", object);
actionContext.peek().put("treeItem", tree);
actionContext.peek().put("parent", tree);
for(Thing node : self.getChilds("Node")){
node.doAction("createTreeItem", actionContext);
}
}
public static void createTreeItem(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
if(self.getStringBlankAsNull("refNode") != null){
Thing refNode = World.getInstance().getThing(self.getString("refNode"));
if(refNode != null){
refNode.doAction("createTreeItem", actionContext);
return;
}
}
Object object = self.doAction("getObject", actionContext);
if(object == null){
return;
}
ActionContext context = (ActionContext) actionContext.get("context");
//按照列表的方式创建
Iterable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy