All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.gwt.CmsQuickLaunchProvider Maven / Gradle / Ivy

/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.gwt;

import org.opencms.ade.configuration.CmsADEManager;
import org.opencms.db.CmsUserSettings;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.gwt.shared.CmsQuickLaunchData;
import org.opencms.gwt.shared.CmsQuickLaunchParams;
import org.opencms.gwt.shared.CmsReturnLinkInfo;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.ui.apps.CmsFileExplorerConfiguration;
import org.opencms.ui.apps.CmsLegacyAppConfiguration;
import org.opencms.ui.apps.CmsPageEditorConfiguration;
import org.opencms.ui.apps.CmsSitemapEditorConfiguration;
import org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration;

import java.util.List;
import java.util.Locale;

import org.apache.commons.logging.Log;

import com.google.common.collect.Lists;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.Resource;

/**
 * Provides the data for the buttons in the quick launch menu.

*/ public class CmsQuickLaunchProvider { /** Log instance for this class. */ private static final Log LOG = CmsLog.getLog(CmsQuickLaunchProvider.class); /** Current CMS context. */ private CmsObject m_cms; /** * Creates a new instance.

* * @param cms the current CMS context */ public CmsQuickLaunchProvider(CmsObject cms) { m_cms = cms; } /** * Gets the quick launch data for the current user and context.

* * The context is a string which identifies where the quick launch menu is located * * @param params the quick launch parameters * * @return the list of available quick launch items */ public List getQuickLaunchData(CmsQuickLaunchParams params) { List result = Lists.newArrayList(); Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms); CmsUserSettings userSettings = new CmsUserSettings(m_cms); boolean usesNewWorkplace = userSettings.usesNewWorkplace(); for (I_CmsWorkplaceAppConfiguration config : OpenCms.getWorkplaceAppManager().getQuickLaunchConfigurations( m_cms)) { try { boolean reload = false; String link = null; String errorTitle = null; String errorMessage = null; if (CmsFileExplorerConfiguration.APP_ID.equals(config.getId())) { if (!usesNewWorkplace) { continue; } link = CmsCoreService.getVaadinWorkplaceLink(m_cms, params.getPageId()); } else if (CmsPageEditorConfiguration.APP_ID.equals(config.getId())) { if (params.isPageContext()) { reload = true; } else if (params.isSitemapContext()) { if (params.getReturnCode() != null) { CmsReturnLinkInfo linkInfo = CmsCoreService.internalGetLinkForReturnCode( m_cms, params.getReturnCode()); link = linkInfo.getLink(); if (link == null) { errorTitle = Messages.get().getBundle(locale).key( Messages.GUI_QUICKLAUNCH_PAGE_NOT_FOUND_TITLE_0); errorMessage = Messages.get().getBundle(locale).key( Messages.GUI_QUICKLAUNCH_PAGE_NOT_FOUND_0); } } else { CmsResource resource = m_cms.readDefaultFile("/"); CmsReturnLinkInfo linkInfo = CmsCoreService.internalGetLinkForReturnCode( m_cms, "" + resource.getStructureId()); link = linkInfo.getLink(); } } } else if (CmsSitemapEditorConfiguration.APP_ID.equals(config.getId())) { if (params.isSitemapContext()) { reload = true; } else if (params.isPageContext()) { String sitemapLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget( m_cms, CmsADEManager.PATH_SITEMAP_EDITOR_JSP); String returnCode = params.getDetailId() != null ? "" + params.getPageId() + ":" + params.getDetailId() : "" + params.getPageId(); link = sitemapLink + "?path=" + params.getPath() + "&returncode=" + returnCode; } } else { if (!usesNewWorkplace) { continue; } link = OpenCms.getSystemInfo().getWorkplaceContext() + "#!" + config.getId(); } Resource icon = config.getIcon(); String imageLink = ""; if (icon instanceof ExternalResource) { imageLink = ((ExternalResource)icon).getURL(); // no icon if not an external resource } String name = config.getName(OpenCms.getWorkplaceManager().getWorkplaceLocale(m_cms)); CmsQuickLaunchData data = new CmsQuickLaunchData( link, name, imageLink, errorTitle, errorMessage, config instanceof CmsLegacyAppConfiguration, reload); result.add(data); } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); } } return result; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy