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; 029 030import org.opencms.gwt.client.Messages; 031import org.opencms.util.CmsStringUtil; 032 033import com.google.gwt.core.client.GWT; 034import com.google.gwt.dom.client.DivElement; 035import com.google.gwt.dom.client.Element; 036import com.google.gwt.dom.client.HeadingElement; 037import com.google.gwt.dom.client.ParagraphElement; 038import com.google.gwt.dom.client.SpanElement; 039import com.google.gwt.dom.client.Style.Unit; 040import com.google.gwt.uibinder.client.UiBinder; 041import com.google.gwt.uibinder.client.UiField; 042import com.google.gwt.user.client.ui.Composite; 043import com.google.gwt.user.client.ui.HTMLPanel; 044import com.google.gwt.user.client.ui.Widget; 045 046/** 047 * Header info widget.<p> 048 */ 049public class CmsInfoHeader extends Composite { 050 051 /** 052 * @see com.google.gwt.uibinder.client.UiBinder 053 */ 054 protected interface I_CmsInfoHeaderUiBinder extends UiBinder<HTMLPanel, CmsInfoHeader> { 055 // GWT interface, nothing to do here 056 } 057 058 /** The ui-binder instance for this class. */ 059 private static I_CmsInfoHeaderUiBinder uiBinder = GWT.create(I_CmsInfoHeaderUiBinder.class); 060 061 /** The description element. */ 062 @UiField 063 protected ParagraphElement m_description; 064 065 /** The locale cell. */ 066 @UiField 067 protected SpanElement m_locale; 068 069 /** The site host element. */ 070 @UiField 071 protected SpanElement m_siteHost; 072 073 /** The title element. */ 074 @UiField 075 protected HeadingElement m_title; 076 077 /** The type icon element. */ 078 @UiField 079 protected DivElement m_typeIcon; 080 081 /** The button bar. */ 082 @UiField 083 protected Element m_buttonBar; 084 085 /** The main panel. */ 086 private HTMLPanel m_main; 087 088 /** 089 * Constructor.<p> 090 * 091 * @param title the title 092 * @param description the description 093 * @param path the path 094 * @param locale the locale 095 * @param typeIcon the type icon CSS class 096 */ 097 public CmsInfoHeader(String title, String description, String path, String locale, String typeIcon) { 098 099 m_main = uiBinder.createAndBindUi(this); 100 initWidget(m_main); 101 if (CmsStringUtil.isEmptyOrWhitespaceOnly(title)) { 102 title = Messages.get().key(Messages.GUI_NO_TITLE_0); 103 } 104 m_title.setInnerText(title); 105 m_description.setInnerText(description); 106 m_siteHost.setInnerText(path); 107 m_locale.setInnerText("[" + locale + "]"); 108 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(typeIcon)) { 109 m_typeIcon.addClassName(typeIcon); 110 m_typeIcon.getStyle().setWidth(24, Unit.PX); 111 m_typeIcon.getStyle().setHeight(24, Unit.PX); 112 } else { 113 m_typeIcon.removeFromParent(); 114 } 115 } 116 117 /** 118 * Adds a button to the top right of the info header.<p> 119 * 120 * @param button the button to add 121 */ 122 public void addButtonTopRight(Widget button) { 123 124 m_main.add(button, m_buttonBar); 125 } 126}