1 15 package org.apache.tapestry.workbench.tree.examples.fsmodel; 16 17 import java.io.File ; 18 19 import org.apache.tapestry.contrib.tree.model.ITreeDataModel; 20 import org.apache.tapestry.contrib.tree.model.ITreeModel; 21 import org.apache.tapestry.contrib.tree.model.ITreeNode; 22 import org.apache.tapestry.contrib.tree.model.ITreeSessionStateManager; 23 import org.apache.tapestry.contrib.tree.model.ITreeStateModel; 24 import org.apache.tapestry.contrib.tree.simple.SimpleTreeModel; 25 26 29 public class FileSystemStateManager implements ITreeSessionStateManager { 30 private String m_strRootDir; 31 32 35 public FileSystemStateManager(String strRootDir) { 36 super(); 37 m_strRootDir = strRootDir; 38 } 39 40 43 public Object getSessionState(ITreeModel objModel) { 44 return objModel.getTreeStateModel(); 45 } 46 47 50 public ITreeModel getModel(Object objSessionState) { 51 ITreeStateModel objStateModel = (ITreeStateModel) objSessionState; 52 53 ITreeNode objParent; 54 55 if (m_strRootDir == null || "".equals(m_strRootDir)) { 56 objParent = new FileSystem(); 57 } else { 58 FolderObject objFolder = new FolderObject(null, new File (m_strRootDir), true); 59 objFolder.reload(); 60 objParent = objFolder; 61 } 62 63 ITreeDataModel objDataModel = new FileSystemDataModel(objParent); 64 ITreeModel objModel = new SimpleTreeModel(objDataModel, 65 objStateModel); 66 67 return objModel; 68 } 69 } 70 | Popular Tags |