001/* 002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Alexandre Russel 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.annotations.gwt.client; 023 024import java.util.MissingResourceException; 025 026import com.google.gwt.i18n.client.Dictionary; 027 028/** 029 * @author Alexandre Russel 030 */ 031public class AnnotationConfiguration { 032 private static final String ANNOTATION_CSS_URL = "annotationCssUrl"; 033 034 private static final String ANNOTEA_SERVER_URL = "annoteaServerUrl"; 035 036 private static final String PREVIEW_URL = "previewUrl"; 037 038 private static final String DOCUMENT_URL = "documentUrl"; 039 040 /** 041 * @since 5.7 042 */ 043 private static final String DATE_FORMAT_PATTERN = "dateFormatPattern"; 044 045 private static final String ANNOTATION_CONFIGURATION = "annotationConfiguration"; 046 047 private static final AnnotationConfiguration INSTANCE; 048 049 private String annoteaServerUrl; 050 051 private String annotationCssUrl; 052 053 private String previewUrl; 054 055 private String documentUrl; 056 057 /** 058 * @since 5.7 059 */ 060 private String dateFormatPattern; 061 062 static { 063 INSTANCE = new AnnotationConfiguration(); 064 INSTANCE.loadConfiguration(); 065 } 066 067 public static AnnotationConfiguration getInstance() { 068 return INSTANCE; 069 } 070 071 public String getAnnotationCssUrl() { 072 return annotationCssUrl; 073 } 074 075 public void setAnnotationCssUrl(String annotationCssUrl) { 076 this.annotationCssUrl = annotationCssUrl; 077 } 078 079 public String getAnnoteaServerUrl() { 080 return annoteaServerUrl; 081 } 082 083 public void setAnnoteaServerUrl(String annoteaServerUrl) { 084 this.annoteaServerUrl = annoteaServerUrl; 085 } 086 087 public String getPreviewUrl() { 088 return previewUrl; 089 } 090 091 public String getDocumentUrl() { 092 return documentUrl; 093 } 094 095 /** 096 * Returns the configured date format, if any. 097 * 098 * @since 5.7 099 */ 100 public String getDateFormatPattern() { 101 return dateFormatPattern; 102 } 103 104 private void loadConfiguration() { 105 Dictionary dictionary = Dictionary.getDictionary(ANNOTATION_CONFIGURATION); 106 annoteaServerUrl = dictionary.get(ANNOTEA_SERVER_URL); 107 annotationCssUrl = dictionary.get(ANNOTATION_CSS_URL); 108 previewUrl = dictionary.get(PREVIEW_URL); 109 documentUrl = dictionary.get(DOCUMENT_URL); 110 try { 111 // this one is optional 112 dateFormatPattern = dictionary.get(DATE_FORMAT_PATTERN); 113 } catch (MissingResourceException e) { 114 dateFormatPattern = null; 115 } 116 } 117}