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 GmbH & Co. KG, 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.workplace.tools; 029 030import org.opencms.main.CmsIllegalArgumentException; 031import org.opencms.workplace.list.Messages; 032 033import java.util.Arrays; 034import java.util.Collections; 035import java.util.Iterator; 036import java.util.List; 037 038/** 039 * Wrapper class for 040 * the different style of icon buttons.<p> 041 * 042 * The possibles values are:<br> 043 * <ul> 044 * <li>BigIconText</li> 045 * <li>SmallIconText</li> 046 * <li>SmallIconOnly</li> 047 * </ul> 048 * <p> 049 * 050 * @since 6.0.0 051 */ 052public final class CmsHtmlIconButtonStyleEnum { 053 054 /** Constant for ascending ordering. */ 055 public static final CmsHtmlIconButtonStyleEnum BIG_ICON_TEXT = new CmsHtmlIconButtonStyleEnum("bigicontext"); 056 057 /** Constant for none ordering. */ 058 public static final CmsHtmlIconButtonStyleEnum SMALL_ICON_ONLY = new CmsHtmlIconButtonStyleEnum("smallicononly"); 059 060 /** Constant for descending ordering. */ 061 public static final CmsHtmlIconButtonStyleEnum SMALL_ICON_TEXT = new CmsHtmlIconButtonStyleEnum("smallicontext"); 062 063 /** Array constant for column sorting. */ 064 private static final CmsHtmlIconButtonStyleEnum[] VALUE_ARRAY = {BIG_ICON_TEXT, SMALL_ICON_TEXT, SMALL_ICON_ONLY}; 065 066 /** List of ordering constants. */ 067 public static final List<CmsHtmlIconButtonStyleEnum> VALUES = Collections.unmodifiableList( 068 Arrays.asList(VALUE_ARRAY)); 069 070 /** Internal representation. */ 071 private final String m_style; 072 073 /** 074 * Private constructor.<p> 075 * 076 * @param style internal representation 077 */ 078 private CmsHtmlIconButtonStyleEnum(String style) { 079 080 m_style = style; 081 } 082 083 /** 084 * Parses an string into an element of this enumeration.<p> 085 * 086 * @param value the style to parse 087 * 088 * @return the enumeration element 089 * 090 * @throws CmsIllegalArgumentException if the given instance for the argument is not found 091 */ 092 public static CmsHtmlIconButtonStyleEnum valueOf(String value) throws CmsIllegalArgumentException { 093 094 Iterator<CmsHtmlIconButtonStyleEnum> iter = VALUES.iterator(); 095 while (iter.hasNext()) { 096 CmsHtmlIconButtonStyleEnum target = iter.next(); 097 if (value.equals(target.getStyle())) { 098 return target; 099 } 100 } 101 throw new CmsIllegalArgumentException( 102 Messages.get().container( 103 Messages.ERR_LIST_ENUM_PARSE_2, 104 Integer.valueOf(value), 105 CmsHtmlIconButtonStyleEnum.class.getName())); 106 } 107 108 /** 109 * Returns the style string.<p> 110 * 111 * @return the style string 112 */ 113 public String getStyle() { 114 115 return m_style; 116 } 117 118 /** 119 * @see java.lang.Object#toString() 120 */ 121 @Override 122 public String toString() { 123 124 return m_style; 125 } 126 127}