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.util;
029
030import org.opencms.db.CmsResourceState;
031import org.opencms.gwt.client.Messages;
032import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle;
033import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.I_CmsResourceStateCss;
034
035/**
036 * Utility class for the publish dialog.<p>
037 *
038 * @since 8.0.0
039 */
040public final class CmsResourceStateUtil {
041
042    /** The CSS bundle for the publish dialog. <p> */
043    private static final I_CmsResourceStateCss CSS = I_CmsLayoutBundle.INSTANCE.resourceStateCss();
044
045    /**
046     * Hide constructor.<p>
047     */
048    private CmsResourceStateUtil() {
049
050        // empty
051    }
052
053    /**
054     * Returns the human-readable name of a resource state.<p>
055     *
056     * @param state the resource state
057     *
058     * @return the human-readable name of the code
059     */
060    public static String getStateName(CmsResourceState state) {
061
062        if (state.equals(CmsResourceState.STATE_NEW)) {
063            return Messages.get().key(Messages.GUI_RESOURCE_STATE_NEW_0);
064        } else if (state.equals(CmsResourceState.STATE_DELETED)) {
065            return Messages.get().key(Messages.GUI_RESOURCE_STATE_DELETED_0);
066        } else if (state.equals(CmsResourceState.STATE_CHANGED)) {
067            return Messages.get().key(Messages.GUI_RESOURCE_STATE_CHANGED_0);
068        } else if (state.equals(CmsResourceState.STATE_UNCHANGED)) {
069            return Messages.get().key(Messages.GUI_RESOURCE_STATE_UNCHANGED_0);
070        }
071        return "";
072    }
073
074    /**
075     * Returns the text style for a given resource state.<p>
076     *
077     * @param state the resource state
078     *
079     * @return the style name for the resource's state
080     */
081    public static String getStateStyle(CmsResourceState state) {
082
083        if (state.equals(CmsResourceState.STATE_NEW)) {
084            return CSS.stateNew();
085        } else if (state.equals(CmsResourceState.STATE_DELETED)) {
086            return CSS.stateDeleted();
087        } else if (state.equals(CmsResourceState.STATE_CHANGED)) {
088            return CSS.stateChanged();
089        }
090        return CSS.noState();
091    }
092}