1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.html; |
16 | |
|
17 | |
import org.apache.tapestry.BaseComponent; |
18 | |
import org.apache.tapestry.IMarkupWriter; |
19 | |
import org.apache.tapestry.IRequestCycle; |
20 | |
import org.apache.tapestry.bean.EvenOdd; |
21 | |
import org.apache.tapestry.util.exception.ExceptionDescription; |
22 | |
|
23 | |
import java.util.List; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public abstract class ExceptionDisplay extends BaseComponent |
34 | |
{ |
35 | |
private ExceptionDescription _exception; |
36 | |
|
37 | |
private EvenOdd _evenOdd; |
38 | |
|
39 | |
public abstract int getIndex(); |
40 | |
|
41 | |
public abstract int getCount(); |
42 | |
|
43 | |
public abstract void setCount(int count); |
44 | |
|
45 | |
public abstract ExceptionDescription[] getExceptions(); |
46 | |
|
47 | |
|
48 | |
public abstract List getPackages(); |
49 | |
|
50 | |
public abstract String getTrace(); |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public void setException(ExceptionDescription value) |
58 | |
{ |
59 | 0 | _exception = value; |
60 | |
|
61 | 0 | _evenOdd.setEven(true); |
62 | 0 | } |
63 | |
|
64 | |
public ExceptionDescription getException() |
65 | |
{ |
66 | 0 | return _exception; |
67 | |
} |
68 | |
|
69 | |
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
70 | |
{ |
71 | 0 | ExceptionDescription[] exceptions = getExceptions(); |
72 | |
|
73 | 0 | setCount(exceptions.length); |
74 | |
|
75 | |
try |
76 | |
{ |
77 | 0 | _evenOdd = (EvenOdd) getBeans().getBean("evenOdd"); |
78 | |
|
79 | 0 | super.renderComponent(writer, cycle); |
80 | |
} |
81 | |
finally |
82 | |
{ |
83 | 0 | _exception = null; |
84 | 0 | _evenOdd = null; |
85 | 0 | } |
86 | 0 | } |
87 | |
|
88 | |
public boolean isLast() |
89 | |
{ |
90 | 0 | return getIndex() == (getCount() - 1); |
91 | |
} |
92 | |
|
93 | |
public boolean isInPackage() { |
94 | 0 | List packages = getPackages(); |
95 | 0 | if (packages == null) |
96 | 0 | return false; |
97 | |
|
98 | 0 | String trace = getTrace(); |
99 | 0 | for (int i=0; i<packages.size(); i++) |
100 | |
{ |
101 | 0 | if (trace.startsWith((String)packages.get(i))) |
102 | 0 | return true; |
103 | |
} |
104 | |
|
105 | 0 | return false; |
106 | |
} |
107 | |
|
108 | |
public String getStackClass() |
109 | |
{ |
110 | 0 | return isInPackage() ? "stackSelected" : null; |
111 | |
} |
112 | |
} |