001/* 002 * (C) Copyright 2007-2011 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 * Stephane Lacoin 016 * 017 */ 018package org.nuxeo.ecm.platform.ui.web.util.beans; 019 020import java.beans.PropertyEditor; 021import java.beans.PropertyEditorManager; 022 023public class PropertiesEditorsInstaller { 024 025 public PropertiesEditorsInstaller() { 026 027 } 028 029 public void installEditors() { 030 installEditor(String[].class, StringArrayEditor.class); 031 } 032 033 public void uninstallEditors() { 034 uninstallEditor(String[].class, StringArrayEditor.class); 035 } 036 037 protected void installEditor(Class<?> targetType, Class<?> editorClass) { 038 if (PropertyEditorManager.findEditor(targetType) != null) {; 039 return; 040 } 041 PropertyEditorManager.registerEditor(targetType, editorClass); 042 } 043 044 protected void uninstallEditor(Class<?> targetType, Class<?> editorClass) { 045 PropertyEditor editor = PropertyEditorManager.findEditor(targetType); 046 if (!editorClass.equals(editor.getClass())) { 047 return; 048 } 049 PropertyEditorManager.registerEditor(targetType, null); 050 } 051 052}