1 15 package org.apache.tapestry.contrib.inspector; 16 17 import java.util.Collections ; 18 import java.util.List ; 19 20 import org.apache.hivemind.service.ClassFabUtils; 21 import org.apache.tapestry.BaseComponent; 22 import org.apache.tapestry.IPage; 23 import org.apache.tapestry.engine.IPageRecorder; 24 import org.apache.tapestry.event.PageEvent; 25 import org.apache.tapestry.event.PageRenderListener; 26 import org.apache.tapestry.record.PropertyChange; 27 28 33 34 public abstract class ShowProperties extends BaseComponent implements PageRenderListener 35 { 36 private List _properties; 37 38 private PropertyChange _change; 39 40 private IPage _inspectedPage; 41 42 47 48 public void pageBeginRender(PageEvent event) 49 { 50 } 51 52 55 56 public void pageEndRender(PageEvent event) 57 { 58 _properties = null; 59 _change = null; 60 _inspectedPage = null; 61 } 62 63 private void buildProperties() 64 { 65 Inspector inspector = (Inspector) getPage(); 66 67 _inspectedPage = inspector.getInspectedPage(); 68 69 IPageRecorder recorder = null; 71 72 75 77 if (recorder == null) 78 { 79 _properties = Collections.EMPTY_LIST; 80 return; 81 } 82 83 _properties = Collections.EMPTY_LIST; 84 85 } 89 90 95 96 public List getProperties() 97 { 98 if (_properties == null) 99 buildProperties(); 100 101 return _properties; 102 } 103 104 public void setChange(PropertyChange value) 105 { 106 _change = value; 107 } 108 109 public PropertyChange getChange() 110 { 111 return _change; 112 } 113 114 117 118 public String getValueClassName() 119 { 120 Object value; 121 122 value = _change.getNewValue(); 123 124 if (value == null) 125 return "<null>"; 126 127 return ClassFabUtils.getJavaClassName(value.getClass()); 128 } 129 } | Popular Tags |