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.ui.apps;
029
030import org.opencms.ui.CmsCssIcon;
031
032import java.util.LinkedHashMap;
033import java.util.List;
034import java.util.Locale;
035
036import com.vaadin.navigator.ViewChangeListener;
037import com.vaadin.server.Resource;
038import com.vaadin.ui.Component;
039
040/**
041 * Editor for the user quick launch configuration.<p>
042 */
043public class CmsQuickLaunchEditorConfiguration extends A_CmsWorkplaceAppConfiguration {
044
045    /**
046     * The quick launch editor app.<p>
047     */
048    protected static class QuickLaunchEditorApp extends A_CmsWorkplaceApp implements ViewChangeListener {
049
050        /** The serial version id. */
051        private static final long serialVersionUID = 5187855022780289047L;
052
053        /** The editor component. */
054        private CmsQuickLaunchEditor editor;
055
056        /**
057         * @see com.vaadin.navigator.ViewChangeListener#beforeViewChange(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)
058         */
059        public boolean beforeViewChange(ViewChangeEvent event) {
060
061            editor.saveToUser();
062            return true;
063        }
064
065        /**
066         * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getBreadCrumbForState(java.lang.String)
067         */
068        @Override
069        protected LinkedHashMap<String, String> getBreadCrumbForState(String state) {
070
071            return null;
072        }
073
074        /**
075         * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getComponentForState(java.lang.String)
076         */
077        @Override
078        protected Component getComponentForState(String state) {
079
080            if (editor == null) {
081                editor = new CmsQuickLaunchEditor();
082                editor.resetAppIcons();
083            }
084            return editor;
085        }
086
087        /**
088         * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String)
089         */
090        @Override
091        protected List<NavEntry> getSubNavEntries(String state) {
092
093            return null;
094        }
095    }
096
097    /** The app id. */
098    public static String APP_ID = "quicklaunch_editor";
099
100    /** The app icon resource (size 32x32). */
101    public static final CmsCssIcon ICON = new CmsCssIcon("oc-icon-32-quicklaunch-editor");
102
103    /**
104     * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppInstance()
105     */
106    public I_CmsWorkplaceApp getAppInstance() {
107
108        return new QuickLaunchEditorApp();
109    }
110
111    /**
112     * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getHelpText(java.util.Locale)
113     */
114    @Override
115    public String getHelpText(Locale locale) {
116
117        return Messages.get().getBundle(locale).key(Messages.GUI_QUICK_LAUNCH_EDITOR_HELP_0);
118    }
119
120    /**
121     * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
122     */
123    public Resource getIcon() {
124
125        return ICON;
126    }
127
128    /**
129     * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getId()
130     */
131    public String getId() {
132
133        return APP_ID;
134    }
135
136    /**
137     * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getName(java.util.Locale)
138     */
139    @Override
140    public String getName(Locale locale) {
141
142        return Messages.get().getBundle(locale).key(Messages.GUI_QUICK_LAUNCH_EDITOR_TITLE_0);
143    }
144
145    /**
146     * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getOrder()
147     */
148    @Override
149    public int getOrder() {
150
151        return 30;
152    }
153}