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.configuration.preferences;
029
030import org.opencms.file.CmsObject;
031import org.opencms.main.OpenCms;
032import org.opencms.xml.content.CmsXmlContentProperty;
033
034/**
035 * Workplace mode preference configuration.<p>
036 */
037public class CmsWorkplaceModePreference extends CmsBuiltinPreference {
038
039    /** The preference name. */
040    public static final String PREFERENCE_NAME = "workplaceMode";
041
042    /** The nice name. */
043    private static final String NICE_NAME = "%(key." + org.opencms.ui.Messages.GUI_PREF_WORKPLACE_MODE_0 + ")";
044
045    /** Widget configuration. */
046    public static final String WIDGET_CONFIG = "old:%(key.GUI_PREF_WORKPLACE_MODE_OLD_0)|new:%(key.GUI_PREF_WORKPLACE_MODE_NEW_0)";
047
048    /**
049     * Constructor.<p>
050     *
051     * @param propName the name of the bean property used to access this preference
052     */
053    public CmsWorkplaceModePreference(String propName) {
054
055        super(propName);
056        m_basic = false;
057    }
058
059    /**
060     * @see org.opencms.configuration.preferences.CmsBuiltinPreference#getDefaultValue()
061     */
062    @Override
063    public String getDefaultValue() {
064
065        return "new";
066    }
067
068    /**
069     * Gets the nice name key.<p>
070     *
071     * @return the nice name key
072     */
073    public String getNiceName() {
074
075        return NICE_NAME;
076    }
077
078    /**
079     * @see org.opencms.configuration.preferences.CmsBuiltinPreference#getPropertyDefinition()
080     */
081    @Override
082    public CmsXmlContentProperty getPropertyDefinition() {
083
084        CmsXmlContentProperty prop = new CmsXmlContentProperty(
085            getName(), //name
086            "string", //type
087            "select_notnull", //widget
088            WIDGET_CONFIG, //widgetconfig
089            null, //regex
090            null, //ruletype
091            getDefaultValue(), //default
092            getNiceName(), //nicename
093            null, //description
094            null, //error
095            null //preferfolder
096        );
097        return prop;
098    }
099
100    /**
101     * @see org.opencms.configuration.preferences.A_CmsPreference#getPropertyDefinition(org.opencms.file.CmsObject)
102     */
103    @Override
104    public CmsXmlContentProperty getPropertyDefinition(CmsObject cms) {
105
106        return getPropertyDefinition();
107    }
108
109    /**
110     * @see org.opencms.configuration.preferences.A_CmsPreference#isDisabled(CmsObject)
111     */
112    @Override
113    public boolean isDisabled(CmsObject cms) {
114
115        return !OpenCms.getModuleManager().hasModule("org.opencms.workplace.traditional");
116    }
117}