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 * troger 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.annotations.gwt.client; 021 022import java.util.MissingResourceException; 023 024import com.allen_sauer.gwt.log.client.Log; 025import com.google.gwt.i18n.client.Dictionary; 026 027/** 028 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 029 */ 030public class PreviewSettings { 031 032 private static final String PREVIEW_SETTINGS = "previewSettings"; 033 034 private static final String IMAGE_ONLY = "imageOnly"; 035 036 private static final String MULTI_IMAGE_ANNOTATION = "multiImageAnnotation"; 037 038 private static final String XPOINTER_FILTER_PATH = "xPointerFilterPath"; 039 040 private static final String POINTER_ADAPTER = "pointerAdapter"; 041 042 private static final String ANNOTATION_DECORATOR_FUNCTION = "annotationDecoratorFunction"; 043 044 private static PreviewSettings INSTANCE; 045 046 private Dictionary dictionary; 047 048 public static PreviewSettings getInstance() { 049 if (INSTANCE == null) { 050 try { 051 INSTANCE = new PreviewSettings(); 052 } catch (MissingResourceException e) { 053 Log.debug("Preview Settings dictionary not found"); 054 INSTANCE = null; 055 } 056 } 057 return INSTANCE; 058 } 059 060 public PreviewSettings() { 061 dictionary = Dictionary.getDictionary(PREVIEW_SETTINGS); 062 } 063 064 private String get(String key) { 065 try { 066 return dictionary.get(key); 067 } catch (MissingResourceException e) { 068 return null; 069 } 070 } 071 072 public boolean isImageOnly() { 073 String imageOnly = get(IMAGE_ONLY); 074 return imageOnly != null ? Boolean.parseBoolean(imageOnly) : false; 075 } 076 077 public boolean isMultiImageAnnotation() { 078 String multiImageAnnotation = get(MULTI_IMAGE_ANNOTATION); 079 return multiImageAnnotation != null ? Boolean.parseBoolean(multiImageAnnotation) : false; 080 } 081 082 public String getXPointerFilterPath() { 083 return get(XPOINTER_FILTER_PATH); 084 } 085 086 public String getPointerAdapter() { 087 return get(POINTER_ADAPTER); 088 } 089 090 public String getAnnotationDecoratorFunction() { 091 return get(ANNOTATION_DECORATOR_FUNCTION); 092 } 093 094}