Changeset 4879


Ignore:
Timestamp:
04/02/14 13:05:57 (10 years ago)
Author:
Twan Goosen
Message:

added resources to expanded search result item view

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.html

    r4875 r4879  
    3131                <p class="moredocumentproperties"><a wicket:id="recordLink">More</a></p>
    3232                <h3>Resources</h3>
    33                 <ul>
    34                     <li class="writtenresource"><a href="">http://dspace.library.uu.nl/bitstream/1874/235456/1/Bachelorscriptie+Rene+Witteveen+3375005.docx</a></li>
    35                     <li class="audioresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Media/002-djawu_klluu-2011-09-01.wav</a></li>
    36                     <li class="annotationresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Annotations/002-djawu_klluu-2011-09-01.eaf</a></li>
     33                <ul class="searchresultresources">
     34                    <li wicket:id="resource">
     35                        <a wicket:id="resourceLink" href="">
     36                            <wicket:container wicket:id="resourceName"></wicket:container>
     37                        </a>
     38                    </li>
    3739                </ul>
    3840            </div>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.java

    r4875 r4879  
    2020import eu.clarin.cmdi.vlo.pojo.SearchContext;
    2121import eu.clarin.cmdi.vlo.service.FieldFilter;
     22import eu.clarin.cmdi.vlo.service.ResourceStringConverter;
     23import eu.clarin.cmdi.vlo.wicket.ResourceTypeCssBehaviour;
    2224import eu.clarin.cmdi.vlo.wicket.components.RecordPageLink;
    2325import eu.clarin.cmdi.vlo.wicket.components.SolrFieldLabel;
     26import eu.clarin.cmdi.vlo.wicket.model.CollectionListModel;
     27import eu.clarin.cmdi.vlo.wicket.model.ResourceInfoModel;
     28import eu.clarin.cmdi.vlo.wicket.model.SolrFieldModel;
    2429import eu.clarin.cmdi.vlo.wicket.panels.record.FieldsTablePanel;
    2530import eu.clarin.cmdi.vlo.wicket.provider.DocumentFieldsProvider;
     31import java.util.List;
    2632import org.apache.solr.common.SolrDocument;
     33import org.apache.wicket.behavior.AttributeAppender;
     34import org.apache.wicket.markup.html.basic.Label;
     35import org.apache.wicket.markup.html.link.ExternalLink;
     36import org.apache.wicket.markup.html.list.ListItem;
     37import org.apache.wicket.markup.html.list.ListView;
    2738import org.apache.wicket.markup.html.panel.GenericPanel;
    2839import org.apache.wicket.model.IModel;
     40import org.apache.wicket.model.PropertyModel;
     41import org.apache.wicket.model.StringResourceModel;
    2942import org.apache.wicket.spring.injection.annot.SpringBean;
    3043
     
    3750    @SpringBean(name = "basicPropertiesFilter") //TODO: make separate filter for properties in search result items
    3851    private FieldFilter basicPropertiesFilter;
    39     private final IModel<SearchContext> selectionModel;
     52    @SpringBean
     53    ResourceStringConverter resourceStringConverter;
    4054
    4155    public SearchResultItemExpandedPanel(String id, IModel<SolrDocument> documentModel, IModel<SearchContext> selectionModel) {
    4256        super(id, documentModel);
    43         this.selectionModel = selectionModel;
    4457
    4558        // add untruncated description
     
    4760        add(new RecordPageLink("recordLink", documentModel, selectionModel));
    4861
     62        // table with some basic properties
    4963        add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(documentModel, basicPropertiesFilter)));
    50        
    51         //TODO: Add resource list
     64
     65        createResourcesList("resource");
     66    }
     67
     68    private void createResourcesList(String id) {
     69        // list of resources in this record
     70        // TODO: limit number of resources shown here?
     71        final SolrFieldModel<String> resourceModel = new SolrFieldModel<String>(getModel(), FacetConstants.FIELD_RESOURCE);
     72        final IModel<List<String>> resourceListModel = new CollectionListModel<String>(resourceModel);
     73        add(new ListView<String>(id, resourceListModel) {
     74
     75            @Override
     76            protected void populateItem(ListItem<String> item) {
     77                // get resource string converted into a ResourceInfo model
     78                final ResourceInfoModel resourceInfoModel = new ResourceInfoModel(resourceStringConverter, item.getModel());
     79
     80                // add a link to the resource with the file name as its label
     81                final ExternalLink resourceLink = new ExternalLink("resourceLink", new PropertyModel(resourceInfoModel, "href"));
     82                resourceLink.add(new Label("resourceName", new PropertyModel(resourceInfoModel, "fileName")));
     83
     84                // add a tooltip showing resource type and mime type
     85                final StringResourceModel tooltipModel
     86                        = new StringResourceModel("resource.tooltip", SearchResultItemExpandedPanel.this, resourceModel,
     87                                new Object[]{
     88                                    new PropertyModel(resourceInfoModel, "resourceType"),
     89                                    new PropertyModel(resourceInfoModel, "mimeType")});
     90                resourceLink.add(new AttributeAppender("title", tooltipModel));
     91
     92                // sets the css class depending on the resource type
     93                item.add(new ResourceTypeCssBehaviour(resourceInfoModel));
     94
     95                // add to list
     96                item.add(resourceLink);
     97            }
     98        });
    5299    }
    53100
     
    55102    public void detachModels() {
    56103        super.detachModels();
    57         // not passed to super
    58         selectionModel.detach();
    59104    }
    60105
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/webapp/style/vlo-search.css

    r4618 r4879  
    154154    font-weight: bold;
    155155}
     156
     157.searchresultresources li {
     158    list-style: none;
     159    background-repeat: no-repeat;
     160    background-size: 1em;
     161    padding-left: 1.5em;
     162}
     163
     164.searchresultresources li.writtenresource {
     165    background-image: url('document-256.png'); /* icon from icons8.com */
     166}
     167
     168.searchresultresources li.audioresource {
     169    background-image: url('audio-file-3-256.png'); /* icon from icons8.com */
     170}
     171
     172.searchresultresources li.videoresource {
     173    background-image: url('video-file-3-256.png'); /* icon from icons8.com */
     174}
     175
     176.searchresultresources li.imageresource {
     177    background-image: url('image-file-256.png'); /* icon from icons8.com */
     178}
     179
     180.searchresultresources li.annotationresource {
     181    background-image: url('document-256.png'); /* icon from icons8.com */
     182}
Note: See TracChangeset for help on using the changeset viewer.