001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (C) Alkacon Software (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; 029 030import org.opencms.acacia.client.widgets.I_CmsEditWidget; 031import org.opencms.acacia.client.widgets.I_CmsFormEditWidget; 032import org.opencms.acacia.shared.CmsAttributeConfiguration; 033import org.opencms.acacia.shared.CmsType; 034 035import java.util.Map; 036 037import com.google.gwt.dom.client.Element; 038 039/** 040 * Provides widget renderer for entity attributes.<p> 041 */ 042public interface I_CmsWidgetService { 043 044 /** 045 * Adds the given path to the list of paths where child attributes have change their order.<p> 046 * 047 * @param attributePath the attribute path 048 */ 049 void addChangedOrderPath(String attributePath); 050 051 /** 052 * Adds all configurations.<p> 053 * 054 * @param configurations the configurations to add 055 */ 056 void addConfigurations(Map<String, CmsAttributeConfiguration> configurations); 057 058 /** 059 * Adds a renderer.<p> 060 * 061 * @param renderer the renderer to add 062 */ 063 void addRenderer(I_CmsEntityRenderer renderer); 064 065 /** 066 * Registers the given widget factory with the service.<p> 067 * 068 * @param widgetName the widget name 069 * @param widgetFactory the widget factory 070 */ 071 void addWidgetFactory(String widgetName, I_CmsWidgetFactory widgetFactory); 072 073 /** 074 * Returns the attribute form editing widget.<p> 075 * 076 * @param attributeName the attribute name 077 * 078 * @return the attribute widget 079 */ 080 I_CmsFormEditWidget getAttributeFormWidget(String attributeName); 081 082 /** 083 * Returns the attribute help information.<p> 084 * 085 * @param attributeName the attribute name 086 * 087 * @return the attribute help information 088 */ 089 String getAttributeHelp(String attributeName); 090 091 /** 092 * Returns the attribute inline editing widget wrapping the given DOM element.<p> 093 * 094 * @param attributeName the attribute name 095 * @param element the DOM element to wrap 096 * 097 * @return the attribute widget 098 */ 099 I_CmsEditWidget getAttributeInlineWidget(String attributeName, Element element); 100 101 /** 102 * Returns the label for the given attribute.<p> 103 * 104 * @param attributeName the attribute name 105 * 106 * @return the attribute label 107 */ 108 String getAttributeLabel(String attributeName); 109 110 /** 111 * Returns the default attribute value.<p> 112 * 113 * @param attributeName the attribute name 114 * @param simpleValuePath the value path 115 * 116 * @return the default value 117 */ 118 String getDefaultAttributeValue(String attributeName, String simpleValuePath); 119 120 /** 121 * Returns the renderer for the given attribute.<p> 122 * 123 * @param attributeName the name of the attribute 124 * @param attributeType the type of the attribute 125 * 126 * @return the renderer 127 */ 128 I_CmsEntityRenderer getRendererForAttribute(String attributeName, CmsType attributeType); 129 130 /** 131 * Returns the renderer for the given entity type.<p> 132 * 133 * @param entityType the type 134 * 135 * @return the renderer 136 */ 137 I_CmsEntityRenderer getRendererForType(CmsType entityType); 138 139 /** 140 * Returns the if the attribute widget should be displayed in compact view.<p> 141 * 142 * @param attributeName the attribute name 143 * 144 * @return <code>true</code> if the attribute widget should be displayed in compact view 145 */ 146 boolean isDisplayCompact(String attributeName); 147 148 /** 149 * Returns if the attribute widget should be displayed in single line view.<p> 150 * 151 * @param attributeName the attribute name 152 * 153 * @return <code>true</code> if the attribute widget should be displayed in single line view 154 */ 155 boolean isDisplaySingleLine(String attributeName); 156 157 /** 158 * Returns if the given attribute should be visible in the editor.<p> 159 * 160 * @param attributeName the attribute name 161 * 162 * @return <code>true</code> if the given attribute should be visible in the editor 163 */ 164 boolean isVisible(String attributeName); 165 166 /** 167 * Registers a complex widget attribute which should be handled by a special renderer.<p> 168 * 169 * @param attrName the attribute name 170 * @param renderer the renderer to register for the attribute 171 * @param configuration the renderer configuration 172 */ 173 void registerComplexWidgetAttribute(String attrName, String renderer, String configuration); 174 175 /** 176 * Sets the default renderer.<p> 177 * 178 * @param renderer the default renderer 179 */ 180 void setDefaultRenderer(I_CmsEntityRenderer renderer); 181 182 /** 183 * Sets the widget factories.<p> 184 * 185 * @param widgetFactories the widget factories 186 */ 187 void setWidgetFactories(Map<String, I_CmsWidgetFactory> widgetFactories); 188 189 /** 190 * Returns true if the value which this widget is being used for should be disabled if it is unfocused and the last remaining attribute value for a given attribute.<p> 191 * 192 * The main use case is disabling empty text input fields.<p> 193 * 194 * @param widget the widget to check 195 * 196 * @return true if the value should be disabled 197 */ 198 boolean shouldRemoveLastValueAfterUnfocus(I_CmsEditWidget widget); 199}