1 | |
---|
2 | package eu.clarin.cmdi.vlo.pages; |
---|
3 | |
---|
4 | import org.apache.wicket.AttributeModifier; |
---|
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 | |
---|
9 | /** |
---|
10 | * Panel showing a landing page link. |
---|
11 | * |
---|
12 | * In the extension of the link panel class, this class adds a label text and |
---|
13 | * an icon that is specific for search page links |
---|
14 | * |
---|
15 | * @author keeloo |
---|
16 | */ |
---|
17 | public class LandingPageLinkPanel extends LinkPanel { |
---|
18 | |
---|
19 | private final static ImageResource LANDINGPAGE_ICON = |
---|
20 | new ImageResource( |
---|
21 | "Crystal_Clear_mimetype_readme.png", |
---|
22 | "Landing 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 LandingPageLinkPanel(String id, String resourceLink) { |
---|
31 | // ... |
---|
32 | super(id); |
---|
33 | |
---|
34 | // add the icon image |
---|
35 | ImageResource imageResource = LANDINGPAGE_ICON; |
---|
36 | Image resourceImg = new Image("landingPageImage", imageResource.getResource()); |
---|
37 | |
---|
38 | // add the image's title |
---|
39 | String title; |
---|
40 | title = imageResource.getTitle(); |
---|
41 | resourceImg.add(new AttributeModifier("title", title)); |
---|
42 | resourceImg.add(new AttributeModifier("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("landingPageLink", href); |
---|
52 | link.add(resourceImg); |
---|
53 | link.add(new Label("landingPageLabel", name)); |
---|
54 | add(link); |
---|
55 | } |
---|
56 | } |
---|