1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.contrib.inspector; |
16 | |
|
17 | |
import java.util.ArrayList; |
18 | |
import java.util.Collection; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import org.apache.hivemind.service.ClassFabUtils; |
22 | |
import org.apache.tapestry.BaseComponent; |
23 | |
import org.apache.tapestry.IPage; |
24 | |
import org.apache.tapestry.event.PageBeginRenderListener; |
25 | |
import org.apache.tapestry.event.PageEvent; |
26 | |
import org.apache.tapestry.record.PropertyChange; |
27 | |
import org.apache.tapestry.record.PropertyPersistenceStrategySource; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public abstract class ShowProperties extends BaseComponent implements PageBeginRenderListener |
36 | |
{ |
37 | |
|
38 | |
public abstract void setProperties(List properties); |
39 | |
|
40 | |
public abstract PropertyChange getChange(); |
41 | |
|
42 | |
|
43 | |
|
44 | |
public abstract PropertyPersistenceStrategySource getPropertySource(); |
45 | |
|
46 | |
public void pageBeginRender(PageEvent event) |
47 | |
{ |
48 | 0 | Inspector inspector = (Inspector) getPage(); |
49 | |
|
50 | 0 | IPage inspectedPage = inspector.getInspectedPage(); |
51 | |
|
52 | 0 | String pageName = inspectedPage.getPageName(); |
53 | |
|
54 | 0 | PropertyPersistenceStrategySource source = getPropertySource(); |
55 | |
|
56 | 0 | Collection properties = source.getAllStoredChanges(pageName); |
57 | |
|
58 | |
|
59 | |
|
60 | 0 | setProperties(new ArrayList(properties)); |
61 | 0 | } |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public String getValueClassName() |
68 | |
{ |
69 | 0 | Object value = getChange().getNewValue(); |
70 | |
|
71 | 0 | if (value == null) |
72 | 0 | return "<null>"; |
73 | |
|
74 | 0 | return ClassFabUtils.getJavaClassName(value.getClass()); |
75 | |
} |
76 | |
} |