1 26 27 package org.objectweb.util.browser.gui.lib; 28 29 import org.objectweb.util.browser.api.Context; 30 import org.objectweb.util.browser.api.Entry; 31 import org.objectweb.util.browser.api.TreeView; 32 import org.objectweb.util.browser.core.api.ExtendedTreeView; 33 import org.objectweb.util.browser.core.api.TreeConfiguration; 34 import org.objectweb.util.browser.core.common.DynamicTree; 35 import org.objectweb.util.browser.gui.api.TreeProvider; 36 37 44 public class DefaultTreeProvider implements TreeProvider { 45 46 52 58 64 70 73 public DynamicTree createDynamicTree(TreeView treeView) { 74 return createDynamicTree(treeView,true); 75 } 76 77 80 public DynamicTree createDynamicTree(TreeView treeView, boolean withData) { 81 DynamicTree tree = null; 82 if(treeView!=null){ 83 tree = new DynamicTree(); 84 TreeConfiguration treeConfiguration = ((ExtendedTreeView)treeView).getTreeConfiguration(); 85 tree.setNewBrowserProperty(treeConfiguration.getBrowserProperty()); 86 tree.setNewContextProperty(treeConfiguration.getContextProperty()); 87 if(withData){ 88 Context c = treeConfiguration.getInitialContext(); 89 Entry[] entries = c.getEntries(); 90 for (int i = 0; i < entries.length; i++) { 91 Entry entry = entries[i]; 92 tree.addEntry(entry.getName().toString(),entry.getValue(),1); 93 } 94 } 95 } 96 return tree; 97 } 98 99 } | Popular Tags |