Changeset 4881


Ignore:
Timestamp:
04/02/14 14:36:46 (11 years ago)
Author:
Twan Goosen
Message:

resource type names (singular and plural) are now read from properties file (shared with css class)

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/VloWicketApplication.java

    r4878 r4881  
    5858        // register the resource of field names (used by eu.clarin.cmdi.vlo.wicket.componentsSolrFieldNameLabel)
    5959        getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("fieldNames"));
    60         // register the resource of resource type class properties
    61         getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("resourceTypeClasses"));
     60        // register the resource of resource type names and class properties
     61        getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("resourceTypes"));
    6262        // register the resource of application properties (version information filtered at build time)
    6363        getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("application"));
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/ResourceTypeCssBehaviour.java

    r4878 r4881  
    3535                // to one of the properties in resourceTypeClass.properties file
    3636                // (defaults to "")
    37                 new StringResourceModel("class.${resourceType}", resourceInfoModel, "", new Object[0]));
     37                new StringResourceModel("resourcetype.${resourceType}.class", resourceInfoModel, "", new Object[0]));
    3838        // separate CSS classes with a space
    3939        setSeparator(" ");
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemCollapsedPanel.java

    r4880 r4881  
    1717package eu.clarin.cmdi.vlo.wicket.panels.search;
    1818
    19 import eu.clarin.cmdi.vlo.wicket.provider.ResouceTypeCountDataProvider;
    2019import eu.clarin.cmdi.vlo.FacetConstants;
    2120import eu.clarin.cmdi.vlo.pojo.ResourceTypeCount;
     
    2524import eu.clarin.cmdi.vlo.wicket.components.SolrFieldLabel;
    2625import eu.clarin.cmdi.vlo.wicket.model.SolrFieldModel;
     26import eu.clarin.cmdi.vlo.wicket.provider.ResouceTypeCountDataProvider;
    2727import java.util.Locale;
    2828import org.apache.solr.common.SolrDocument;
     
    3535import org.apache.wicket.markup.repeater.data.IDataProvider;
    3636import org.apache.wicket.model.IModel;
     37import org.apache.wicket.model.Model;
     38import org.apache.wicket.model.StringResourceModel;
    3739import org.apache.wicket.spring.injection.annot.SpringBean;
    3840import org.apache.wicket.util.convert.ConversionException;
     
    4547public class SearchResultItemCollapsedPanel extends Panel {
    4648
    47     private final static ResourceTypeCountConverter resourceTypeCountConverter = new ResourceTypeCountConverter();
     49    private final ResourceTypeCountConverter resourceTypeCountConverter = new ResourceTypeCountConverter();
    4850    private static final int MAX_DESCRIPTION_LENGTH = 350;
    4951    private static final int LONG_DESCRIPTION_TRUNCATE_POINT = 320;
     
    133135        @Override
    134136        public String convertToString(ResourceTypeCount value, Locale locale) {
    135             final String resourceTypeString;
    136             if (value.getCount() == 1) {
    137                 resourceTypeString = getSingularResourceTypeString(value);
    138             } else {
    139                 resourceTypeString = getPluralResourceTypeString(value);
    140             }
     137            final String resourceTypeString = getResourceTypeString(value);
    141138            return String.format("%d %s", value.getCount(), resourceTypeString);
    142139        }
    143140
    144         private String getSingularResourceTypeString(ResourceTypeCount value) {
    145             //TODO: read from resource bundle
    146             switch (value.getResourceType()) {
    147                 case ANNOTATION:
    148                     return "annotation file";
    149                 case AUDIO:
    150                     return "audio file";
    151                 case VIDEO:
    152                     return "video file";
    153                 case IMAGE:
    154                     return "image";
    155                 case TEXT:
    156                     return "text document";
    157                 case OTHER:
    158                     return "other";
    159                 default:
    160                     return "unknown";
    161             }
    162         }
    163 
    164         private String getPluralResourceTypeString(ResourceTypeCount value) {
    165             //TODO: read from resource bundle
    166             switch (value.getResourceType()) {
    167                 case ANNOTATION:
    168                     return "annotation files";
    169                 case AUDIO:
    170                     return "audio files";
    171                 case VIDEO:
    172                     return "video files";
    173                 case IMAGE:
    174                     return "images";
    175                 case TEXT:
    176                     return "text documents";
    177                 case OTHER:
    178                     return "other";
    179                 default:
    180                     return "unknown";
    181             }
     141        private String getResourceTypeString(ResourceTypeCount value) {
     142            final String count = value.getCount() == 1 ? "singular" : "plural";
     143            final StringResourceModel resourceModel = new StringResourceModel("resourcetype.${resourceType}." + count, Model.of(value), "?");
     144            return resourceModel.getObject();
    182145        }
    183146
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.java

    r4880 r4881  
    102102                        = new StringResourceModel("resource.tooltip", SearchResultItemExpandedPanel.this, null,
    103103                                new Object[]{
    104                                     new PropertyModel(resourceInfoModel, "resourceType"),
     104                                    new StringResourceModel("resourcetype.${resourceType}.singular", resourceInfoModel, "?"),
    105105                                    new PropertyModel(resourceInfoModel, "mimeType")});
    106106                resourceLink.add(new AttributeAppender("title", tooltipModel));
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.properties

    r4879 r4881  
    1414# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1515
    16 resource.tooltip={0}. Mime type: {1}
     16# {0} = resource type, {1} = mime type
     17resource.tooltip={0} ({1})
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/resources/resourceTypes.properties

    r4878 r4881  
    1414# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1515
    16 # This maps values of ResourceType to CSS classes
     16# This maps values of ResourceType to plural and singular names and CSS classes
    1717
    18 class.TEXT=writtenresource
    19 class.AUDIO=audioresource
    20 class.VIDEO=videoresource
    21 class.IMAGE=imageresource
    22 class.ANNOTATION=annotationresource
     18resourcetype.ANNOTATION.class=annotationresource
     19resourcetype.ANNOTATION.singular=annotation file
     20resourcetype.ANNOTATION.plural=annotation files
     21
     22resourcetype.AUDIO.class=audioresource
     23resourcetype.AUDIO.singular=audio file
     24resourcetype.AUDIO.plural=audio files
     25
     26resourcetype.IMAGE.class=imageresource
     27resourcetype.IMAGE.singular=image
     28resourcetype.IMAGE.plural=images
     29
    2330#make separate class for 'other'
    24 class.OTHER=writtenresource
     31resourcetype.OTHER.class=writtenresource
     32resourcetype.OTHER.singular=other
     33resourcetype.OTHER.plural=other
     34
     35resourcetype.TEXT.class=writtenresource
     36resourcetype.TEXT.singular=text document
     37resourcetype.TEXT.plural=text documents
     38
     39resourcetype.VIDEO.class=videoresource
     40resourcetype.VIDEO.singular=video file
     41resourcetype.VIDEO.plural=video files
Note: See TracChangeset for help on using the changeset viewer.