001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/tools/CmsHtmlIconButtonStyleEnum.java,v $
003: * Date : $Date: 2008-02-27 12:05:31 $
004: * Version: $Revision: 1.11 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools;
033:
034: import org.opencms.main.CmsIllegalArgumentException;
035: import org.opencms.workplace.list.Messages;
036:
037: import java.util.Arrays;
038: import java.util.Collections;
039: import java.util.Iterator;
040: import java.util.List;
041:
042: /**
043: * Wrapper class for
044: * the different style of icon buttons.<p>
045: *
046: * The possibles values are:<br>
047: * <ul>
048: * <li>BigIconText</li>
049: * <li>SmallIconText</li>
050: * <li>SmallIconOnly</li>
051: * </ul>
052: * <p>
053: *
054: * @author Michael Moossen
055: *
056: * @version $Revision: 1.11 $
057: *
058: * @since 6.0.0
059: */
060: public final class CmsHtmlIconButtonStyleEnum {
061:
062: /** Constant for ascending ordering. */
063: public static final CmsHtmlIconButtonStyleEnum BIG_ICON_TEXT = new CmsHtmlIconButtonStyleEnum(
064: "bigicontext");
065:
066: /** Constant for none ordering. */
067: public static final CmsHtmlIconButtonStyleEnum SMALL_ICON_ONLY = new CmsHtmlIconButtonStyleEnum(
068: "smallicononly");
069:
070: /** Constant for descending ordering. */
071: public static final CmsHtmlIconButtonStyleEnum SMALL_ICON_TEXT = new CmsHtmlIconButtonStyleEnum(
072: "smallicontext");
073:
074: /** Array constant for column sorting. */
075: private static final CmsHtmlIconButtonStyleEnum[] VALUE_ARRAY = {
076: BIG_ICON_TEXT, SMALL_ICON_TEXT, SMALL_ICON_ONLY };
077:
078: /** List of ordering constants. */
079: public static final List VALUES = Collections
080: .unmodifiableList(Arrays.asList(VALUE_ARRAY));
081:
082: /** Internal representation. */
083: private final String m_style;
084:
085: /**
086: * Private constructor.<p>
087: *
088: * @param style internal representation
089: */
090: private CmsHtmlIconButtonStyleEnum(String style) {
091:
092: m_style = style;
093: }
094:
095: /**
096: * Parses an string into an element of this enumeration.<p>
097: *
098: * @param value the style to parse
099: *
100: * @return the enumeration element
101: *
102: * @throws CmsIllegalArgumentException if the given instance for the argument is not found
103: */
104: public static CmsHtmlIconButtonStyleEnum valueOf(String value)
105: throws CmsIllegalArgumentException {
106:
107: Iterator iter = VALUES.iterator();
108: while (iter.hasNext()) {
109: CmsHtmlIconButtonStyleEnum target = (CmsHtmlIconButtonStyleEnum) iter
110: .next();
111: if (value.equals(target.getStyle())) {
112: return target;
113: }
114: }
115: throw new CmsIllegalArgumentException(Messages.get().container(
116: Messages.ERR_LIST_ENUM_PARSE_2, new Integer(value),
117: CmsHtmlIconButtonStyleEnum.class.getName()));
118: }
119:
120: /**
121: * Returns the style string.<p>
122: *
123: * @return the style string
124: */
125: public String getStyle() {
126:
127: return m_style;
128: }
129:
130: /**
131: * @see java.lang.Object#toString()
132: */
133: public String toString() {
134:
135: return m_style;
136: }
137:
138: }
|