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