All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.ui.CmsCssIcon Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

The newest version!
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.ui;

import org.opencms.ui.components.OpenCmsTheme;
import org.opencms.util.CmsStringUtil;

import com.vaadin.server.FontIcon;

/**
 * An icon resource. Will be rendered as <span class="v-icon styleName">&bnsp;</span>.

*/ public class CmsCssIcon implements FontIcon { /** The serial version id. */ private static final long serialVersionUID = -1013502165062622197L; /** The additional style to apply to buttons generated with this icon. */ private String m_additionalButtonStyle; /** The unicode codepoint (character location) for this icon. */ private int m_codePoint = 0x00A0; /** The icon css class. */ private String m_styleName; /**The icon overlay css class.*/ private String m_styleNameOverlay; /** * Cloning constructor.

* * @param icon the icon to clone */ public CmsCssIcon(FontIcon icon) { m_styleName = icon.getFontFamily(); m_codePoint = icon.getCodepoint(); if (icon instanceof CmsCssIcon) { m_styleNameOverlay = ((CmsCssIcon)icon).m_styleNameOverlay; m_additionalButtonStyle = ((CmsCssIcon)icon).m_additionalButtonStyle; } } /** * Constructor.

* * @param styleName the style name to assign to the icon.

*/ public CmsCssIcon(String styleName) { m_styleName = styleName; } /** * Constructor.

* * @param styleName the style name to assign to the icon.

* @param additionalStyle the additional style to apply to buttons generated with this icon */ public CmsCssIcon(String styleName, String additionalStyle) { m_styleName = styleName; m_additionalButtonStyle = additionalStyle; } /** * Returns the additional style name to use with OpenCms app buttons.

* * @return the additional style name */ public String getAdditionalButtonStyle() { return m_additionalButtonStyle; } /** * @see com.vaadin.server.FontIcon#getCodepoint() */ public int getCodepoint() { // this is the encoding for   return m_codePoint; } /** * @see com.vaadin.server.FontIcon#getFontFamily() */ public String getFontFamily() { return m_styleName; } /** * @see com.vaadin.server.FontIcon#getHtml() */ @Override public String getHtml() { return "&#x" + Integer.toHexString(getCodepoint()) + ";"; } /** * Returns the icon HTML with the title attribute set.

* * @param title the title to set * * @return the icon HTML */ public String getHtml(String title) { return "&#x" + Integer.toHexString(getCodepoint()) + ";"; } /** * Gets the html for the icon.

* If overlay is set, it will be shown.

* * @return html */ public String getHtmlWithOverlay() { if (m_styleNameOverlay == null) { return getHtml(); } return "

" + getHtml() + "" + "
"; } /** * @see com.vaadin.server.Resource#getMIMEType() */ public String getMIMEType() { throw new UnsupportedOperationException( FontIcon.class.getSimpleName() + " should not be used where a MIME type is needed."); } /** * Returns the style name of this icon.

* * @return the style name */ public String getStyleName() { return m_styleName; } /** * Returns whether this icon has the additional button style set.

* * @return true in case the additional style is set */ public boolean hasAdditionalButtonStyle() { return CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_additionalButtonStyle); } /** * Sets the additional style to apply to buttons generated with this icon.

* * @param additionalStyle the additional style to apply to buttons generated with this icon */ public void setAdditionalButtonStyle(String additionalStyle) { m_additionalButtonStyle = additionalStyle; } /** * Adds an overlay to icon. Overlay is only returned by getHtmlWithOverlay().

* * @param overlayStyle style to be added */ public void setOverlay(String overlayStyle) { m_styleNameOverlay = overlayStyle; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy