1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.contrib.inspector; |
16 | |
|
17 | |
import org.apache.tapestry.BaseComponent; |
18 | |
import org.apache.tapestry.IAsset; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | 0 | public abstract class ViewTabs extends BaseComponent |
27 | |
{ |
28 | 0 | private static String[] _views = |
29 | |
{ View.SPECIFICATION, View.TEMPLATE, View.PROPERTIES, View.ENGINE }; |
30 | |
|
31 | |
public String[] getViews() |
32 | |
{ |
33 | 0 | return _views; |
34 | |
} |
35 | |
|
36 | |
public abstract void setView(String value); |
37 | |
|
38 | |
public abstract String getView(); |
39 | |
|
40 | |
private IAsset getImageForView(boolean focus) |
41 | |
{ |
42 | 0 | Inspector inspector = (Inspector) getPage(); |
43 | |
|
44 | 0 | String view = getView(); |
45 | |
|
46 | 0 | boolean selected = view.equals(inspector.getView()); |
47 | |
|
48 | 0 | StringBuffer buffer = new StringBuffer(view); |
49 | |
|
50 | 0 | if (selected) |
51 | 0 | buffer.append("_selected"); |
52 | |
|
53 | 0 | if (focus) |
54 | 0 | buffer.append("_focus"); |
55 | |
|
56 | 0 | String key = buffer.toString(); |
57 | |
|
58 | 0 | return (IAsset) getAssets().get(key); |
59 | |
} |
60 | |
|
61 | |
public IAsset getViewImage() |
62 | |
{ |
63 | 0 | return getImageForView(false); |
64 | |
} |
65 | |
|
66 | |
public IAsset getFocusImage() |
67 | |
{ |
68 | 0 | return getImageForView(true); |
69 | |
} |
70 | |
|
71 | |
public IAsset getBannerImage() |
72 | |
{ |
73 | 0 | Inspector inspector = (Inspector) getPage(); |
74 | 0 | String selectedView = inspector.getView(); |
75 | |
|
76 | 0 | String key = selectedView + "_banner"; |
77 | |
|
78 | 0 | return (IAsset) getAssets().get(key); |
79 | |
} |
80 | |
|
81 | |
public void selectTab(String view) |
82 | |
{ |
83 | 0 | Inspector inspector = (Inspector) getPage(); |
84 | 0 | inspector.setView(view); |
85 | 0 | } |
86 | |
} |