source: vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/LandingPageLinkPanel.java @ 2829

Last change on this file since 2829 was 2829, checked in by keeloo, 11 years ago

Added support for search page type of resources.

File size: 1.8 KB
Line 
1
2package eu.clarin.cmdi.vlo.pages;
3
4import org.apache.wicket.behavior.SimpleAttributeModifier;
5import org.apache.wicket.markup.html.basic.Label;
6import org.apache.wicket.markup.html.image.Image;
7import org.apache.wicket.markup.html.link.ExternalLink;
8import org.apache.wicket.resource.ContextRelativeResource;
9
10/**
11 * Panel showing a landing page 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 */
18public class LandingPageLinkPanel extends LinkPanel {
19
20    private final static ImageResource LANDINGPAGE_ICON =
21            new ImageResource(new ContextRelativeResource(
22            "Images/Crystal_Clear_mimetype_readme.png"),
23            "Landing page");
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 LandingPageLinkPanel(String id, String resourceLink) {
32        // ...
33        super(id);
34       
35        // add the icon image
36        ImageResource imageResouce = LANDINGPAGE_ICON;
37        Image resourceImg = new Image("landingPageImage", imageResouce.getResource());
38       
39        // add the image's title
40        String title;
41        title = imageResouce.getTitle();
42        resourceImg.add(new SimpleAttributeModifier("title", title));
43        resourceImg.add(new SimpleAttributeModifier("alt", title));
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("landingPageLink", href);
53        link.add(resourceImg);
54        link.add(new Label("landingPageLabel", name));
55        add(link);
56    }
57}
Note: See TracBrowser for help on using the repository browser.