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