001/* 002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Alexandre Russel 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.annotations.gwt.client; 021 022import com.google.gwt.i18n.client.Dictionary; 023 024import java.util.MissingResourceException; 025 026/** 027 * @author Alexandre Russel 028 */ 029public class AnnotationConfiguration { 030 private static final String ANNOTATION_CSS_URL = "annotationCssUrl"; 031 032 private static final String ANNOTEA_SERVER_URL = "annoteaServerUrl"; 033 034 private static final String PREVIEW_URL = "previewUrl"; 035 036 private static final String DOCUMENT_URL = "documentUrl"; 037 038 /** 039 * @since 5.7 040 */ 041 private static final String DATE_FORMAT_PATTERN = "dateFormatPattern"; 042 043 private static final String ANNOTATION_CONFIGURATION = "annotationConfiguration"; 044 045 private static final AnnotationConfiguration INSTANCE; 046 047 private String annoteaServerUrl; 048 049 private String annotationCssUrl; 050 051 private String previewUrl; 052 053 private String documentUrl; 054 055 /** 056 * @since 5.7 057 */ 058 private String dateFormatPattern; 059 060 static { 061 INSTANCE = new AnnotationConfiguration(); 062 INSTANCE.loadConfiguration(); 063 } 064 065 public static AnnotationConfiguration getInstance() { 066 return INSTANCE; 067 } 068 069 public String getAnnotationCssUrl() { 070 return annotationCssUrl; 071 } 072 073 public void setAnnotationCssUrl(String annotationCssUrl) { 074 this.annotationCssUrl = annotationCssUrl; 075 } 076 077 public String getAnnoteaServerUrl() { 078 return annoteaServerUrl; 079 } 080 081 public void setAnnoteaServerUrl(String annoteaServerUrl) { 082 this.annoteaServerUrl = annoteaServerUrl; 083 } 084 085 public String getPreviewUrl() { 086 return previewUrl; 087 } 088 089 public String getDocumentUrl() { 090 return documentUrl; 091 } 092 093 /** 094 * Returns the configured date format, if any. 095 * 096 * @since 5.7 097 */ 098 public String getDateFormatPattern() { 099 return dateFormatPattern; 100 } 101 102 private void loadConfiguration() { 103 Dictionary dictionary = Dictionary.getDictionary(ANNOTATION_CONFIGURATION); 104 annoteaServerUrl = dictionary.get(ANNOTEA_SERVER_URL); 105 annotationCssUrl = dictionary.get(ANNOTATION_CSS_URL); 106 previewUrl = dictionary.get(PREVIEW_URL); 107 documentUrl = dictionary.get(DOCUMENT_URL); 108 try { 109 // this one is optional 110 dateFormatPattern = dictionary.get(DATE_FORMAT_PATTERN); 111 } catch (MissingResourceException e) { 112 dateFormatPattern = null; 113 } 114 } 115}