1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package br.com.arsmachina.tapestrycrud.components;
16
17 import org.apache.tapestry5.Asset;
18 import org.apache.tapestry5.BindingConstants;
19 import org.apache.tapestry5.annotations.IncludeStylesheet;
20 import org.apache.tapestry5.annotations.Parameter;
21 import org.apache.tapestry5.annotations.Property;
22 import org.apache.tapestry5.corelib.components.Grid;
23
24 import br.com.arsmachina.tapestrycrud.Constants;
25
26
27
28
29
30
31
32
33
34
35
36 @IncludeStylesheet(Constants.TAPESTRY_CRUD_CSS_ASSET)
37 public class ActionLinks {
38
39 private static final String IMAGES_ASSET_ROOT = "asset:classpath:/br/com/arsmachina/tapestrycrud/components/images/";
40
41 private static final String DEFAULT_EDIT_ICON_ASSET = IMAGES_ASSET_ROOT + "edit.png";
42
43 private static final String DEFAULT_DELETE_ICON_ASSET = IMAGES_ASSET_ROOT + "delete.png";
44
45 private static final String DEFAULT_VIEW_ICON_ASSET = IMAGES_ASSET_ROOT + "view.png";
46
47
48
49
50 @Parameter(defaultPrefix = BindingConstants.LITERAL)
51 @SuppressWarnings("unused")
52 private String editPage;
53
54
55
56
57 @Parameter(defaultPrefix = BindingConstants.LITERAL)
58 @SuppressWarnings("unused")
59 private String viewPage;
60
61
62
63
64 @Parameter(value = "true")
65 @Property
66 @SuppressWarnings("unused")
67 private boolean edit;
68
69
70
71
72 @Parameter(value = "true")
73 @Property
74 @SuppressWarnings("unused")
75 private boolean remove;
76
77
78
79
80 @Parameter(value = "false")
81 @Property
82 @SuppressWarnings("unused")
83 private boolean view;
84
85
86
87
88 @Parameter(required = true)
89 @Property
90 @SuppressWarnings("unused")
91 private Object object;
92
93 @Parameter(defaultPrefix = BindingConstants.ASSET, value = DEFAULT_EDIT_ICON_ASSET)
94 @Property
95 @SuppressWarnings("unused")
96 private Asset editIcon;
97
98 @Parameter(defaultPrefix = BindingConstants.ASSET, value = DEFAULT_VIEW_ICON_ASSET)
99 @Property
100 @SuppressWarnings("unused")
101 private Asset viewIcon;
102
103 @Parameter(defaultPrefix = BindingConstants.ASSET, value = DEFAULT_DELETE_ICON_ASSET)
104 @Property
105 @SuppressWarnings("unused")
106 private Asset deleteIcon;
107
108
109
110
111
112
113 public String getEditPage() {
114
115 if (edit && (editPage == null || editPage.trim().length() == 0)) {
116
117 throw new IllegalArgumentException(
118 "When parameter edit is true, parameter editPage must have a non-empty value");
119
120 }
121
122 return editPage;
123 }
124
125
126
127
128
129
130 public String getViewPage() {
131
132 if (view && viewPage == null || viewPage.trim().length() == 0) {
133
134 throw new IllegalArgumentException(
135 "When parameter view is true, parameter viewPage must have a non-empty value");
136
137 }
138
139 return viewPage;
140
141 }
142
143 }