001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.acacia.client.widgets; 029 030import org.opencms.acacia.client.I_CmsWidgetFactory; 031import org.opencms.acacia.client.css.I_CmsWidgetsLayoutBundle; 032import org.opencms.ade.contenteditor.widgetregistry.client.WidgetRegistry; 033import org.opencms.gwt.client.I_CmsHasInit; 034import org.opencms.gwt.client.util.CmsDomUtil; 035 036import com.google.gwt.dom.client.Element; 037 038/** 039 * Factory to generate basic input widget.<p> 040 */ 041public class CmsCheckBoxWidgetFactory implements I_CmsWidgetFactory, I_CmsHasInit { 042 043 /** 044 * Wrapper class for checkboxes, which is needed because the help text needs to be set on the check box widgets themselves. 045 */ 046 class CheckboxWrapper extends CmsFormWidgetWrapper { 047 048 /** The wrapped widget. */ 049 private CmsCheckboxWidget m_checkBoxWidget; 050 051 /** 052 * Creates a new instance.<p> 053 */ 054 public CheckboxWrapper() { 055 056 super(new CmsCheckboxWidget()); 057 m_checkBoxWidget = (CmsCheckboxWidget)getEditWidget(); 058 } 059 060 /** 061 * @see org.opencms.acacia.client.widgets.CmsFormWidgetWrapper#setWidgetInfo(java.lang.String, java.lang.String) 062 */ 063 @Override 064 public void setWidgetInfo(String label, String help) { 065 066 super.setWidgetInfo(label, help); 067 m_checkBoxWidget.setTitle(CmsDomUtil.stripHtml(help)); 068 } 069 } 070 071 /** The widget name. */ 072 private static final String WIDGET_NAME = "org.opencms.widgets.CmsCheckboxWidget"; 073 074 /** 075 * Initializes this class.<p> 076 */ 077 public static void initClass() { 078 079 WidgetRegistry.getInstance().registerWidgetFactory(WIDGET_NAME, new CmsCheckBoxWidgetFactory()); 080 } 081 082 /** 083 * @see org.opencms.acacia.client.I_CmsWidgetFactory#createFormWidget(java.lang.String) 084 */ 085 public I_CmsFormEditWidget createFormWidget(String configuration) { 086 087 CmsFormWidgetWrapper wrapper = new CheckboxWrapper(); 088 wrapper.addStyleName(I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().checkBoxStyle()); 089 return wrapper; 090 091 } 092 093 /** 094 * @see org.opencms.acacia.client.I_CmsWidgetFactory#createInlineWidget(java.lang.String, com.google.gwt.dom.client.Element) 095 */ 096 public I_CmsEditWidget createInlineWidget(String configuration, Element element) { 097 098 return null; 099 } 100 101}