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