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.HashMap; |
18 |
| import java.util.Map; |
19 |
| |
20 |
| import org.apache.tapestry.IComponent; |
21 |
| import org.apache.tapestry.IPage; |
22 |
| import org.apache.tapestry.IRequestCycle; |
23 |
| import org.apache.tapestry.components.Block; |
24 |
| import org.apache.tapestry.html.BasePage; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public abstract class Inspector extends BasePage |
33 |
| { |
34 |
| private Map _blocks = new HashMap(); |
35 |
| |
36 |
0
| protected void finishLoad()
|
37 |
| { |
38 |
0
| _blocks.put(View.TEMPLATE, getComponent("templateBlock"));
|
39 |
0
| _blocks.put(View.SPECIFICATION, getComponent("specificationBlock"));
|
40 |
0
| _blocks.put(View.ENGINE, getComponent("engineBlock"));
|
41 |
0
| _blocks.put(View.PROPERTIES, getComponent("propertiesBlock"));
|
42 |
| } |
43 |
| |
44 |
| public abstract String getView(); |
45 |
| |
46 |
| public abstract void setView(String value); |
47 |
| |
48 |
| public abstract String getInspectedPageName(); |
49 |
| |
50 |
| public abstract void setInspectedPageName(String value); |
51 |
| |
52 |
| public abstract String getInspectedIdPath(); |
53 |
| |
54 |
| public abstract void setInspectedIdPath(String value); |
55 |
| |
56 |
| |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
0
| public void selectComponent(String idPath)
|
64 |
| { |
65 |
0
| setInspectedIdPath(idPath);
|
66 |
| } |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
0
| public void inspect(String pageName, IRequestCycle cycle)
|
75 |
| { |
76 |
0
| setInspectedPageName(pageName);
|
77 |
0
| selectComponent((String) null);
|
78 |
| |
79 |
0
| cycle.activate(this);
|
80 |
| } |
81 |
| |
82 |
| |
83 |
| |
84 |
| |
85 |
| |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
| |
91 |
| |
92 |
0
| public void selectComponent(IRequestCycle cycle)
|
93 |
| { |
94 |
0
| Object[] parameters = cycle.getListenerParameters();
|
95 |
| |
96 |
0
| String newIdPath;
|
97 |
| |
98 |
| |
99 |
| |
100 |
0
| if (parameters == null || parameters.length == 0)
|
101 |
0
| newIdPath = null;
|
102 |
| else |
103 |
0
| newIdPath = (String) parameters[0];
|
104 |
| |
105 |
0
| selectComponent(newIdPath);
|
106 |
| } |
107 |
| |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
0
| public IPage getInspectedPage()
|
115 |
| { |
116 |
0
| return getRequestCycle().getPage(getInspectedPageName());
|
117 |
| } |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
0
| public IComponent getInspectedComponent()
|
126 |
| { |
127 |
0
| return getInspectedPage().getNestedComponent(getInspectedIdPath());
|
128 |
| } |
129 |
| |
130 |
0
| public String getInspectorTitle()
|
131 |
| { |
132 |
0
| return "Tapestry Inspector: " + getEngine().getSpecification().getName();
|
133 |
| } |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
0
| public Block getBlockForView()
|
141 |
| { |
142 |
0
| return (Block) _blocks.get(getView());
|
143 |
| } |
144 |
| } |