1 | |
---|
2 | package eu.clarin.cmdi.vlo.pages; |
---|
3 | |
---|
4 | import org.apache.wicket.behavior.SimpleAttributeModifier; |
---|
5 | import org.apache.wicket.markup.html.basic.Label; |
---|
6 | import org.apache.wicket.markup.html.image.Image; |
---|
7 | import org.apache.wicket.markup.html.link.ExternalLink; |
---|
8 | import org.apache.wicket.resource.ContextRelativeResource; |
---|
9 | |
---|
10 | /** |
---|
11 | * Panel showing a search link. |
---|
12 | * |
---|
13 | * In the extension of the link panel class, this class adds a label text and |
---|
14 | * an icon that is specific for search page links. |
---|
15 | * |
---|
16 | * @author keeloo |
---|
17 | */ |
---|
18 | public class SearchPageLinkPanel extends LinkPanel { |
---|
19 | |
---|
20 | private final static ImageResource SEARCHPAGE_ICON = |
---|
21 | new ImageResource(new ContextRelativeResource("Images/Crystal_Clear_action_filefind.png"), |
---|
22 | "Search page"); |
---|
23 | |
---|
24 | /** |
---|
25 | * Panel constructor. |
---|
26 | * |
---|
27 | * @param id Wicket mark up identifier |
---|
28 | * @param resourceLink URL to pointing to the resource |
---|
29 | */ |
---|
30 | public SearchPageLinkPanel(String id, String resourceLink) { |
---|
31 | // ... |
---|
32 | super(id); |
---|
33 | |
---|
34 | // add the icon image |
---|
35 | ImageResource imageResource = SEARCHPAGE_ICON; |
---|
36 | Image resourceImg = new Image("searchPageImage", imageResource.getResource()); |
---|
37 | |
---|
38 | // add the image's title |
---|
39 | String title; |
---|
40 | title = imageResource.getTitle(); |
---|
41 | resourceImg.add(new SimpleAttributeModifier("title", title)); |
---|
42 | resourceImg.add(new SimpleAttributeModifier("alt", title)); |
---|
43 | |
---|
44 | // ... |
---|
45 | String href = getHref(resourceLink); |
---|
46 | |
---|
47 | // get the name associated with the link |
---|
48 | String name = getNameFromLink(resourceLink); |
---|
49 | |
---|
50 | // ... and add the link itself |
---|
51 | ExternalLink link = new ExternalLink("searchPageLink", href); |
---|
52 | link.add(resourceImg); |
---|
53 | link.add(new Label("searchPageLabel", name)); |
---|
54 | add(link); |
---|
55 | } |
---|
56 | } |
---|