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.gwt.client.ui.input.form; 029 030import org.opencms.gwt.client.ui.CmsListItemWidget; 031import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle; 032import org.opencms.gwt.client.ui.input.I_CmsFormField; 033import org.opencms.gwt.shared.CmsListInfoBean; 034import org.opencms.gwt.shared.CmsListInfoBean.StateIcon; 035 036import java.util.Collection; 037import java.util.List; 038 039import com.google.gwt.user.client.ui.FlowPanel; 040import com.google.gwt.user.client.ui.Widget; 041 042/** 043 * Form field panel for the sitemap entry editor in the navigation mode.<p> 044 * 045 * @since 8.0.0 046 */ 047public class CmsInfoBoxFormFieldPanel extends A_CmsFormFieldPanel { 048 049 /** Text metrics key for the info box. */ 050 public static String TM_INFOBOX = "infobox_"; 051 052 /** The list of form fields. */ 053 protected List<I_CmsFormField> m_fields; 054 055 /** The inner panel containing the form fields. */ 056 private FlowPanel m_innerPanel; 057 058 /** The main panel .*/ 059 private FlowPanel m_panel; 060 061 /** 062 * Creates a new instance.<p> 063 * 064 * @param info the bean used to display the info item 065 */ 066 public CmsInfoBoxFormFieldPanel(CmsListInfoBean info) { 067 068 m_panel = new FlowPanel(); 069 m_innerPanel = new FlowPanel(); 070 m_infoWidget = new CmsListItemWidget(info); 071 m_infoWidget.truncate(TM_INFOBOX, CmsFormDialog.STANDARD_DIALOG_WIDTH - 50); 072 m_infoWidget.setStateIcon(StateIcon.standard); 073 m_panel.add(m_infoWidget); 074 m_panel.add(m_innerPanel); 075 m_innerPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll()); 076 m_innerPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.propertiesCss().navModePropertiesBox()); 077 //setBorder(m_panel); 078 initWidget(m_panel); 079 } 080 081 /** 082 * Adds another widget after the list info widget. 083 * 084 * @param widget the widget to add 085 */ 086 public void addWidgetAfterListInfo(Widget widget) { 087 088 int index = m_panel.getWidgetIndex(m_infoWidget); 089 m_panel.insert(widget, index + 1); 090 } 091 092 /** 093 * @see org.opencms.gwt.client.ui.input.form.A_CmsFormFieldPanel#getDefaultGroup() 094 */ 095 @Override 096 public String getDefaultGroup() { 097 098 return ""; 099 } 100 101 /** 102 * @see org.opencms.gwt.client.ui.input.form.A_CmsFormFieldPanel#renderFields(java.util.Collection) 103 */ 104 @Override 105 public void renderFields(Collection<I_CmsFormField> fields) { 106 107 m_innerPanel.clear(); 108 for (I_CmsFormField field : fields) { 109 CmsFormRow row = createRow(field); 110 m_innerPanel.add(row); 111 } 112 } 113 114 /** 115 * @see org.opencms.gwt.client.ui.I_CmsTruncable#truncate(java.lang.String, int) 116 */ 117 public void truncate(String textMetricsKey, int clientWidth) { 118 119 clientWidth -= 12; 120 storeTruncation(textMetricsKey, clientWidth); 121 truncatePanel(m_panel, textMetricsKey, clientWidth); 122 truncatePanel(m_innerPanel, textMetricsKey, clientWidth); 123 } 124 125}